:root {
  color-scheme: light;
  --page: #f8f7f4;
  --paper: #fff;
  --ink: #252622;
  --muted: #6a6e64;
  --line: #e5e6de;
  --brand: #d8f783;
  --brand-dark: #293125;
  --green: #36633f;
  --red: #92392e;
  --radius: 20px;
  font: 15px/1.45 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, select, input[type='checkbox'] { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
input:focus-visible + .track { outline: 3px solid #788f48; outline-offset: 3px; }
a { color: #355938; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.75rem); line-height: 1.02; letter-spacing: -.06em; }
h2 { font-size: 1.35rem; letter-spacing: -.025em; }
h3 { font-size: 1.12rem; line-height: 1.25; letter-spacing: -.015em; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.28rem; font-weight: 760; letter-spacing: -.045em; }
.brand-icon { display: inline-grid; place-items: center; width: 35px; height: 35px; background: var(--brand); color: #293125; border-radius: 11px; font: 800 25px/1 system-ui; }
.opening { min-height: 100dvh; display: grid; place-items: center; }
.login-page { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr); }
.login-brand { background: #282f25; color: #fff; padding: clamp(30px, 6vw, 90px); display: flex; flex-direction: column; justify-content: space-between; gap: 48px; position: relative; overflow: hidden; }
.login-brand::before, .login-brand::after { content: ''; pointer-events: none; position: absolute; width: min(48vw, 670px); aspect-ratio: 1; right: -16%; bottom: -22%; border: 1px solid #515e41; border-radius: 32%; transform: rotate(-32deg); }
.login-brand::after { right: -4%; bottom: -35%; border-color: #738259; }
.login-brand h1 { position: relative; z-index: 1; max-width: 8ch; font-size: clamp(3.4rem, 8vw, 8.5rem); color: var(--brand); }
.login-main { display: grid; place-items: center; padding: 32px; }
.login-form { width: min(100%, 390px); display: grid; gap: 22px; }
.login-form h2 { font-size: 2rem; line-height: 1.1; }
.app-layout { min-height: 100dvh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar { background: #282f25; color: #fcfdf8; min-height: 100dvh; position: sticky; top: 0; height: 100dvh; padding: 28px 16px; display: flex; flex-direction: column; gap: 48px; }
.sidebar .brand { padding-left: 9px; }
.nav { display: grid; gap: 5px; }
.nav button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 13px; background: transparent; color: #e5e8dd; border: 1px solid transparent; border-radius: 10px; text-align: left; font-weight: 600; }
.nav button:hover { background: #353e30; }
.nav button[aria-current='page'] { color: var(--brand); background: #3e4836; border-color: #46513f; }
.nav-icon { width: 22px; display: inline-grid; place-items: center; font-size: 1.28rem; line-height: 1; }
.sidebar-account { margin-top: auto; border-top: 1px solid #424b3a; padding: 19px 9px 0; overflow-wrap: anywhere; }
.sidebar-account .small { color: #b8c2ad; }
.workspace { min-width: 0; }
.topbar { height: 72px; padding: 0 clamp(20px, 4vw, 58px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.topbar .brand { display: none; }
.topbar > span { color: var(--muted); }
.profile-chip { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 100px; padding: 4px 12px 4px 4px; font-weight: 650; background: var(--paper); color: var(--ink); min-width: 0; }
.profile-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: inline-grid; flex: none; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #edf0e6; color: #445441; font-size: .83rem; font-weight: 750; }
.main { max-width: 1290px; padding: 35px clamp(20px, 4vw, 58px) 60px; margin-inline: auto; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 23px; }
.heading .muted { margin-top: 8px; }
.heading > button { flex: none; }
.button { min-height: 43px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #dae0d4; border-radius: 9px; background: var(--paper); color: var(--ink); font-weight: 690; text-decoration: none; text-align: center; }
.button:hover:not(:disabled) { background: #f3f5ee; }
.button.primary { background: var(--brand); border-color: var(--brand); color: #293125; }
.button.primary:hover:not(:disabled) { background: #cbe973; }
.button.dark { background: #30392d; border-color: #30392d; color: #fff; }
.button.dark:hover:not(:disabled) { background: #455140; }
.button.danger { color: var(--red); }
.button.compact { min-height: 37px; font-size: .87rem; padding: 6px 11px; }
.button.full { width: 100%; }
.grid { display: grid; gap: 13px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 23px; }
.stat { min-width: 0; padding: 15px 17px; display: grid; align-content: center; justify-items: start; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.stat.highlight { background: #eef3e3; border-color: #e0e7d7; }
.stat strong { font-size: clamp(1.25rem, 3.3vw, 1.95rem); line-height: 1.05; letter-spacing: -.04em; overflow-wrap: anywhere; }
.stat span { font-size: .86rem; color: var(--muted); }
.panel, .order, .empty { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 18px; }
.panel h2 { margin-bottom: 10px; }
.panel + .panel { margin-top: 12px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 11px; margin-bottom: 17px; }
.switch-label { display: flex; align-items: center; gap: 9px; font-weight: 620; cursor: pointer; }
.switch { display: inline-flex; flex: none; position: relative; }
.switch input { position: absolute; margin: 0; width: 100%; height: 100%; opacity: 0; }
.track { pointer-events: none; position: relative; display: block; width: 39px; height: 23px; background: #d9dcd3; border-radius: 40px; transition: background .15s; }
.track::before { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: white; transition: transform .15s; }
.switch input:checked + .track { background: #567047; }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .55; }
.tabs { display: flex; gap: 4px; padding: 4px; background: #edeee8; border-radius: 10px; max-width: 100%; }
.tabs button { min-height: 36px; padding: 5px 12px; border: 0; background: transparent; color: #53584d; border-radius: 7px; white-space: nowrap; font-size: .89rem; font-weight: 700; }
.tabs button[aria-pressed='true'] { color: var(--ink); background: var(--paper); box-shadow: 0 1px 3px #36382b15; }
.empty { padding: 47px 18px; text-align: center; border-style: dashed; }
.empty .muted { margin: 7px auto 0; max-width: 41ch; }
.order { overflow: hidden; }
.order-head { display: flex; gap: 10px; justify-content: space-between; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.order-ident, .order-actions, .tag-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order-id { font-weight: 750; }
.order-price { align-self: center; font-size: 1.18rem; font-weight: 750; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; gap: 5px; border-radius: 100px; padding: 3px 8px; background: #edeee8; font-size: .78rem; font-weight: 680; color: #51584c; }
.tag.open { background: #ebefd7; color: #425821; }
.tag.heading { background: #f7edda; color: #755719; }
.tag.picked_up { background: #e6eefa; color: #365577; }
.tag.delivered, .tag.online { background: #e6f2e5; color: #365e3c; }
.tag.returning { background: #f7edda; color: #755719; }
.tag.returned { background: #e8eddf; color: #4a5a40; }
.tag.cancelled { background: #f8e9e7; color: var(--red); }
.tag.blocked { background: #f8e9e7; color: var(--red); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.order-body { display: grid; gap: 13px; padding: 15px 17px; }
.route { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.route-stop { padding-left: 17px; position: relative; min-width: 0; overflow-wrap: anywhere; }
.route-stop::before { content: ''; width: 8px; height: 8px; border: 2px solid #839277; position: absolute; left: 0; top: .4rem; border-radius: 50%; }
.route-stop.drop::before { background: #839277; }
.route-stop .small { display: block; margin-bottom: 3px; }
.delivery-detail { margin-top: 4px; }
.order-note { padding: 9px 11px; background: #f3f4ee; border-radius: 8px; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.order-actions { border-top: 1px solid var(--line); padding: 12px 17px; }
.line-status { padding: 15px 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #edf3e5; border: 1px solid #dce7d4; border-radius: 14px; margin-bottom: 16px; }
.line-status p { margin-top: 3px; }
.directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.directory .panel + .panel { margin-top: 0; }
.directory .panel { padding: 15px; display: grid; align-content: start; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.directory-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rating { color: #665222; font-weight: 700; }
.review .muted { margin: 5px 0 9px; }
.review p:last-child { white-space: pre-wrap; overflow-wrap: anywhere; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting-row p { margin-top: 4px; }
.settings { max-width: 710px; }
.timeline { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; }
.timeline li { padding-left: 13px; border-left: 3px solid #cbd7bb; overflow-wrap: anywhere; }
.timeline .order-note { margin-top: 6px; }
.report-form { display: grid; gap: 10px; justify-items: start; margin-bottom: 15px; }
.report-fields { width: 100%; display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.report-table { padding: 0; overflow-x: auto; }
.report-table table { width: 100%; min-width: 525px; border-collapse: collapse; }
.report-table th, .report-table td { padding: 11px 13px; text-align: left; }
.report-table th { font-size: .86rem; color: var(--muted); background: #f3f4ee; }
.report-table td { border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.report-table td:last-child { white-space: nowrap; }
.forms { display: grid; gap: 12px; }
label.field { display: grid; gap: 5px; font-weight: 650; min-width: 0; }
label.field span { font-size: .9rem; }
input:not([type='checkbox']):not([type='file']), textarea, select { display: block; width: 100%; padding: 9px 11px; min-height: 43px; border: 1px solid #d6d9d0; border-radius: 8px; background: white; color: var(--ink); font-size: 16px; }
textarea { min-height: 98px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-error { color: var(--red); font-weight: 620; }
.form-error:empty { display: none; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
dialog { padding: 0; border: none; color: var(--ink); border-radius: var(--radius); width: min(540px, calc(100% - 26px)); max-height: calc(100dvh - 28px); box-shadow: 0 22px 100px #25262250; }
dialog::backdrop { background: #23272085; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 16px 19px; border-bottom: 1px solid var(--line); }
.dialog-head button { min-width: 36px; min-height: 36px; padding: 0; font-size: 1.2rem; }
.dialog-body { padding: 19px; }
.dialog-body > img { display: block; max-width: 100%; max-height: 67vh; margin: auto; object-fit: contain; border-radius: 10px; }
.photo-preview { width: 100%; max-height: 200px; object-fit: contain; background: #eeefe9; border-radius: 10px; }
.photo-preview[hidden], [hidden] { display: none !important; }
.toasts { position: fixed; z-index: 5; right: 20px; bottom: 20px; display: grid; gap: 7px; max-width: min(370px, calc(100vw - 30px)); pointer-events: none; }
.toast { background: #30392d; color: white; border: 1px solid #52634c; padding: 12px 15px; border-radius: 10px; box-shadow: 0 4px 22px #25262224; }
.toast.error { background: #793b33; border-color: #8a4b42; }
.connection { margin-bottom: 15px; padding: 9px 12px; color: #754b17; background: #fcf0dc; border-radius: 8px; }

@media (max-width: 930px) {
  .app-layout { grid-template-columns: 177px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .main { padding-inline: 22px; }
}

@media (max-width: 700px) {
  .login-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 21px; gap: 15px; min-height: 115px; }
  .login-brand h1 { display: none; }
  .login-brand::before, .login-brand::after { width: 280px; }
  .login-main { padding: 26px 19px; place-items: start center; }
  .app-layout { display: block; }
  .sidebar { height: auto; min-height: 0; position: fixed; z-index: 2; top: auto; bottom: 0; width: 100%; padding: 5px 4px calc(5px + env(safe-area-inset-bottom)); background: #282f25; }
  .sidebar > .brand, .sidebar-account { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
  .nav button { flex-direction: column; justify-content: center; padding: 4px 2px; gap: 3px; font-size: .71rem; min-height: 48px; text-align: center; }
  .nav-icon { font-size: 1.11rem; }
  .topbar { height: 58px; padding-inline: 14px; }
  .topbar > span { display: none; }
  .topbar .brand { display: flex; }
  .topbar .brand-icon { width: 28px; height: 28px; border-radius: 8px; font-size: 20px; }
  .profile-chip span:last-child { max-width: 110px; }
  .main { padding: 20px 13px calc(84px + env(safe-area-inset-bottom)); }
  .heading { margin-bottom: 15px; gap: 8px; align-items: center; }
  .heading h1 { font-size: clamp(1.8rem, 8vw, 2.7rem); }
  .heading > .button { min-height: 40px; padding: 7px 10px; font-size: .86rem; }
  .stats { gap: 6px; margin-bottom: 16px; }
  .stat { padding: 10px 8px; gap: 4px; border-radius: 10px; }
  .stat span { font-size: .76rem; }
  .controls { margin-bottom: 12px; }
  .tabs button { padding-inline: 8px; }
  .line-status { padding: 11px 10px; }
  .line-status .button { flex: none; padding-inline: 9px; font-size: .86rem; }
  .directory { grid-template-columns: 1fr; }
  .report-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-head, .order-body, .order-actions { padding-inline: 12px; }
  .toasts { right: 12px; top: calc(61px + env(safe-area-inset-top)); bottom: auto; }
}

@media (max-width: 365px) {
  .order-ident { gap: 4px; }
  .route { grid-template-columns: 1fr; gap: 9px; }
  .form-row { grid-template-columns: 1fr; }
}
