:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17221a;
  background: #f5f7f3;
  font-synthesis: none;
  --surface: #ffffff;
  --border: #dfe6dc;
  --muted: #697469;
  --green: #2f6a43;
  --green-dark: #245435;
  --green-soft: #e8f3eb;
  --amber: #9a6115;
  --amber-soft: #fff4df;
  --red: #a33b36;
  --red-soft: #fbeceb;
  --slate-soft: #eef1ed;
  --shadow: 0 12px 34px rgba(39, 57, 42, .06);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--background, #f5f7f3); }
a { color: inherit; }
button, input, select { font: inherit; }
.shell { width: min(1480px, 100%); margin: 0 auto; padding: 36px clamp(20px, 4vw, 56px) 64px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.page-header h1 { margin: 4px 0 6px; font-size: clamp(30px, 3vw, 42px); line-height: 1.08; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: #748071; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.lede { margin: 0; color: var(--muted); font-size: 14px; }
.header-action { flex: 0 0 auto; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.header-actions form { margin: 0; }
.logout-button { padding: 8px 4px; color: #718074; background: transparent; border: 0; font-size: 12px; font-weight: 700; cursor: pointer; }
.logout-button:hover { color: var(--green); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button--primary { color: #fff; background: var(--green); box-shadow: 0 7px 18px rgba(47,106,67,.2); }
.button--primary:hover:not(:disabled) { background: var(--green-dark); }
.button--primary:disabled { color: #dbe8de; background: #688674; cursor: wait; box-shadow: none; opacity: 1; }
.button--secondary { color: #253128; background: #f2f5f0; border-color: var(--border); }
.button--compact { min-height: 30px; margin-top: 9px; padding: 5px 9px; color: #67511e; background: #fff8e9; border-color: #ead8b1; font-size: 11px; }
.button--compact:disabled { color: #7a7466; background: #f2f3ef; border-color: #e0e4dc; cursor: wait; }
.button-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.button-spinner.is-hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1.55fr 1.35fr .9fr; gap: 14px; margin-bottom: 22px; }
.metric-card, .stat-card { position: relative; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card { display: flex; align-items: center; gap: 14px; }
.metric-card--link { text-decoration: none; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.metric-card--link:hover { transform: translateY(-2px); border-color: #a9c8b1; box-shadow: 0 15px 34px rgba(39,57,42,.1); }
.metric-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px; font-size: 17px; font-weight: 800; }
.metric-icon--green { color: var(--green); background: var(--green-soft); }
.metric-icon--amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon--sage { color: #4d684f; background: #edf2e9; }
.metric-icon--slate { color: #556059; background: var(--slate-soft); }
.metric-grow { flex: 1; min-width: 0; }
.metric-label, .stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-card strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 17px; line-height: 1.25; }
.metric-card small, .stat-card small { display: block; margin-top: 4px; color: #7a837a; font-size: 11px; }
.card-arrow { margin-left: auto; color: var(--green); font-size: 20px; transition: transform .15s ease; }
.metric-card--link:hover .card-arrow { transform: translateX(3px); }
.progress { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: #edf1eb; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#d39a3c,#64a36f); transition: width .3s ease; }

.panel, .notice, .detail, .api { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.panel { margin-top: 18px; overflow: hidden; }
.notice { display: flex; gap: 18px; padding: 14px 18px; color: var(--muted); font-size: 13px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 22px; border-bottom: 1px solid #e9eee7; }
.panel-heading h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.015em; }
.record-count, .period-chip { padding: 6px 10px; border-radius: 99px; color: #647064; background: #f0f3ef; font-size: 11px; font-weight: 700; }

.controls { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(190px, 280px) auto auto; align-items: center; gap: 10px; padding: 14px 22px; border-bottom: 1px solid #e9eee7; background: #fbfcfa; }
.controls input, .controls select { width: 100%; height: 42px; padding: 0 12px; color: #243027; background: #fff; border: 1px solid #d7dfd4; border-radius: 9px; outline: none; }
.controls input:focus, .controls select:focus { border-color: #7baa85; box-shadow: 0 0 0 3px rgba(78,133,91,.12); }
.clear-filter { color: var(--green); font-size: 13px; font-weight: 700; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 13px 14px; border-bottom: 1px solid #edf0eb; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; color: #667065; background: #f7f9f6; font-size: 11px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8faf7; }
tbody tr:last-child td { border-bottom: 0; }
.order-link { color: #294e34; font-weight: 800; text-decoration: none; }
.order-link:hover { color: var(--green); text-decoration: underline; text-decoration-color: #a6c2ad; text-underline-offset: 3px; }
.tracking-link { display: block; width: fit-content; margin-top: 5px; color: #52715a; font-size: 10px; font-weight: 750; text-decoration: none; }
.tracking-link:hover { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.customer-cell { max-width: 240px; color: #566158; overflow-wrap: anywhere; }
.time-primary { display: block; font-weight: 750; white-space: nowrap; }
td small { display: block; margin-top: 3px; color: #7a837a; font-size: 10px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; width: fit-content; max-width: 220px; min-height: 24px; padding: 4px 9px; border: 1px solid transparent; border-radius: 99px; font-size: 10.5px; font-weight: 800; line-height: 1.2; }
.badge--success { color: #2c6840; background: var(--green-soft); border-color: #cde4d2; }
.badge--pending { color: #885610; background: var(--amber-soft); border-color: #f1dbb5; }
.badge--danger { color: #963833; background: var(--red-soft); border-color: #efcecb; }
.badge--neutral { color: #626b64; background: var(--slate-soft); border-color: #dfe4df; }

.statistics-header { margin-bottom: 22px; }
.statistics-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.statistics-toolbar strong { display: block; margin-top: 3px; }
.period-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: #f0f3ef; }
.period-tabs a { padding: 7px 11px; border-radius: 7px; color: #657066; font-size: 12px; font-weight: 750; text-decoration: none; }
.period-tabs a:hover, .period-tabs a.is-active { color: #fff; background: var(--green); }
.statistics-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.stat-card strong { display: block; margin-top: 8px; font-size: clamp(22px,2vw,30px); letter-spacing: -.035em; }
.stat-card--success { border-top: 3px solid #6ba579; }
.stat-card--danger { border-top: 3px solid #cf7a73; }
.stat-card--accent { border-top: 3px solid #4c825a; }
.chart-panel { padding-bottom: 10px; overflow: visible; }
.chart-wrap { position: relative; padding: 14px 20px 0; overflow-x: auto; }
#delivery-chart { display: block; width: 100%; min-width: 700px; height: auto; }
.chart-grid { stroke: #e6ebe4; stroke-width: 1; }
.chart-axis { fill: #7a847a; font: 11px Inter, sans-serif; }
.chart-axis--x { font-size: 10px; }
.chart-line { fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: #fff; stroke: var(--green); stroke-width: 3; cursor: pointer; outline: none; }
.chart-point:hover, .chart-point:focus { fill: var(--green-soft); stroke-width: 4; }
.chart-tooltip { position: absolute; z-index: 5; width: 210px; padding: 11px 12px; color: #fff; background: #25352a; border-radius: 9px; box-shadow: 0 8px 22px rgba(20,32,23,.2); pointer-events: none; }
.chart-tooltip strong, .chart-tooltip span, .chart-tooltip small { display: block; }
.chart-tooltip span { margin-top: 3px; font-size: 17px; font-weight: 800; }
.chart-tooltip small { margin-top: 4px; color: #d1ddd3; font-size: 10px; }
.empty-state { padding: 28px; color: #7a847b; text-align: center; }
.empty-state--chart { display: grid; justify-items: center; gap: 5px; padding: 38px 20px; }
.empty-state--chart span { color: #91a094; font-size: 28px; }
.empty-state--chart strong { color: #4c5850; }
.empty-state--chart p { margin: 0; font-size: 13px; }

.detail, .api { padding: 18px; margin: 14px 0; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.detail h2 { margin: 0 0 14px; font-size: 18px; }
.detail dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 18px; margin: 0; }
.detail dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.detail dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.detail dd small { display: block; margin-top: 5px; color: var(--muted); }
.tracking-list { display: grid; gap: 0; }
.tracking-list article { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 20px; border-bottom: 1px solid #edf0eb; }
.tracking-list article:last-child { border-bottom: 0; }
.tracking-list small { display: block; margin-top: 4px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.cards article { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
pre { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 50% 0%, #edf4eb 0, #f5f7f3 42%, #f5f7f3 100%); }
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid var(--border); border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: 0 22px 60px rgba(39,57,42,.11); }
.login-lock { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 22px; color: var(--green); background: var(--green-soft); border: 1px solid #cde4d2; border-radius: 13px; font-size: 23px; font-weight: 800; }
.login-card h1 { margin: 7px 0 10px; font-size: 31px; line-height: 1.08; letter-spacing: -.035em; }
.login-intro { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-form { display: grid; gap: 9px; }
.login-form label { color: #4d5a50; font-size: 12px; font-weight: 750; }
.login-form input[type="password"] { width: 100%; height: 52px; padding: 0 15px; color: #1f2e23; background: #fbfcfa; border: 1px solid #ced9cc; border-radius: 11px; outline: none; font-size: 21px; font-weight: 800; letter-spacing: .28em; text-align: center; }
.login-form input[type="password"]:focus { border-color: #6f9e79; box-shadow: 0 0 0 4px rgba(78,133,91,.12); }
.login-error { margin: 2px 0 0; color: #9b4038; font-size: 12px; font-weight: 700; }
.login-submit { width: 100%; min-height: 48px; margin-top: 8px; }

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .statistics-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .shell { padding: 24px 14px 44px; }
  .page-header, .statistics-toolbar { align-items: stretch; flex-direction: column; }
  .header-actions { align-items: stretch; flex-direction: column; }
  .header-actions .button, .header-actions form .button { width: 100%; }
  .logout-button { width: 100%; }
  .login-card { padding: 28px 22px; border-radius: 18px; }
  .header-action .button { width: 100%; }
  .dashboard-grid, .statistics-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail dl { grid-template-columns: 1fr; gap: 4px; }
  .controls { grid-template-columns: 1fr; }
  .period-tabs { overflow-x: auto; }
  .period-tabs a { flex: 0 0 auto; }
  th, td { padding: 11px 10px; }
  th:nth-child(3), td:nth-child(3), th:nth-child(8), td:nth-child(8) { display: none; }
}
