/* Door To Door Mart — design tokens + shared components (store, account, admin) */
:root {
  --brand-900: #063B2C;
  --brand-800: #0A5240;
  --brand-700: #0E6B4F;
  --brand-600: #14845F;
  --brand-100: #DDF3E9;
  --brand-50: #F0FAF5;
  --accent-600: #D9831F;
  --accent-500: #F2A541;
  --accent-100: #FDEFD9;

  --ink-900: #17211C;
  --ink-700: #3A4741;
  --ink-500: #66736D;
  --ink-400: #8A968F;
  --line: #E3E8E5;
  --line-strong: #CBD3CE;
  --surface: #FFFFFF;
  --surface-2: #F6F8F7;
  --page: #F4F6F5;

  --danger-700: #B42318;
  --danger-50: #FEF3F2;
  --warn-700: #A15C07;
  --warn-50: #FFF8E6;
  --info-700: #175CD3;
  --info-50: #EFF6FF;
  --ok-700: #067647;
  --ok-50: #ECFDF3;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .06);
  --shadow: 0 4px 16px rgba(16, 24, 20, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 20, .14);
  --focus: 0 0 0 3px rgba(20, 132, 95, .35);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --font: "Hind Siliguri", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --container: 1240px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55;
  color: var(--ink-900); background: var(--page);
}
img { max-width: 100%; display: block; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-800); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--s3); font-weight: 700; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h2 { font-size: clamp(1.2rem, 2vw, 1.45rem); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 var(--s3); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-500); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-800); color: #fff; }
.btn-accent { background: var(--accent-500); color: #2b1a02; }
.btn-accent:hover { background: var(--accent-600); color: #1b1001; }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink-900); }
.btn-outline:hover { border-color: var(--brand-600); color: var(--brand-700); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink-900); }
.btn-danger { background: var(--danger-700); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }
.btn-danger-outline { background: var(--surface); border-color: #F4C7C3; color: var(--danger-700); }
.btn-danger-outline:hover { background: var(--danger-50); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 14px; color: var(--ink-700); }
.field .hint { font-size: 13px; color: var(--ink-500); }
.field .error { font-size: 13px; color: var(--danger-700); }
.req::after { content: " *"; color: var(--danger-700); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 15px; color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--danger-700); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand-700); }

.choice { display: flex; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--line-strong); }
.choice input { accent-color: var(--brand-700); width: 18px; height: 18px; margin-top: 3px; flex: none; }
.choice:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.choice-title { font-weight: 600; }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: var(--s5); }
.card-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.05rem; }
@media (max-width: 640px) { .card-body { padding: var(--s4); } .card-head { padding: var(--s3) var(--s4); } }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.7; white-space: nowrap; background: var(--surface-2); color: var(--ink-700); }
.badge-ok { background: var(--ok-50); color: var(--ok-700); }
.badge-warn { background: var(--warn-50); color: var(--warn-700); }
.badge-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-info { background: var(--info-50); color: var(--info-700); }
.badge-brand { background: var(--brand-100); color: var(--brand-800); }
.badge-accent { background: var(--accent-500); color: #2b1a02; }
.badge-demo { background: #312E81; color: #fff; letter-spacing: .06em; font-size: 11px; }

.status-pending { background: var(--warn-50); color: var(--warn-700); }
.status-confirmed { background: var(--info-50); color: var(--info-700); }
.status-processing { background: #F4F3FF; color: #5925DC; }
.status-shipped { background: #EEF4FF; color: #3538CD; }
.status-delivered { background: var(--ok-50); color: var(--ok-700); }
.status-cancelled { background: var(--danger-50); color: var(--danger-700); }
.pay-unpaid { background: var(--surface-2); color: var(--ink-700); }
.pay-pending_verification { background: var(--warn-50); color: var(--warn-700); }
.pay-paid { background: var(--ok-50); color: var(--ok-700); }
.pay-failed { background: var(--danger-50); color: var(--danger-700); }
.pay-refunded { background: var(--info-50); color: var(--info-700); }

/* ---------- alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 14.5px; }
.alert-success { background: var(--ok-50); border-color: #ABEFC6; color: var(--ok-700); }
.alert-error { background: var(--danger-50); border-color: #FECDCA; color: var(--danger-700); }
.alert-warn { background: var(--warn-50); border-color: #FEDF89; color: var(--warn-700); }
.alert-info { background: var(--info-50); border-color: #B2DDFF; color: var(--info-700); }
.flash-stack { display: grid; gap: var(--s2); margin: var(--s4) 0; }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFA; }
.table .num { text-align: right; white-space: nowrap; }

/* ---------- empty state */
.empty { text-align: center; padding: var(--s12) var(--s4); color: var(--ink-500); }
.empty .empty-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); display: grid; place-items: center; margin: 0 auto var(--s4); }
.empty .empty-icon .icon { width: 30px; height: 30px; }
.empty h2, .empty h3 { color: var(--ink-900); margin-bottom: 6px; }

/* ---------- pagination */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin: var(--s6) 0; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-700); font-weight: 600; }
.pager .current { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

/* ---------- dialog (confirmations) */
dialog.confirm { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow-lg); }
dialog.confirm::backdrop { background: rgba(10, 20, 15, .45); }
dialog.confirm .dlg-body { padding: var(--s6); }
dialog.confirm .dlg-actions { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s4) var(--s6); background: var(--surface-2); }

/* ---------- toast */
.toast-host { position: fixed; z-index: 90; left: 50%; bottom: 88px; transform: translateX(-50%); display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink-900); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14.5px; display: flex; gap: 10px; align-items: center; animation: toast-in .2s ease-out; pointer-events: auto; }
.toast.error { background: var(--danger-700); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- skeleton */
.skeleton { background: linear-gradient(90deg, #EEF1EF 25%, #F6F8F7 37%, #EEF1EF 63%); background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .no-print { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* ---------- totals (cart, checkout, order detail, admin) */
.totals { display: grid; gap: 10px; font-size: 15px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .save { color: var(--ok-700); }
.totals .grand { border-top: 1px dashed var(--line-strong); padding-top: 12px; font-size: 18px; font-weight: 700; }
