/* KISANIC Order Desk — green dashboard look */
:root {
  --g9: #0b3320;           /* deepest green */
  --g8: #12492e;
  --g7: #18603b;           /* primary */
  --g6: #1f7a4a;
  --g5: #2f9a5d;           /* accent */
  --g3: #9fd4b2;
  --g2: #cfe9d8;
  --g1: #e9f5ed;
  --bg: #eef2ee;
  --card: #ffffff;
  --ink: #101a14;
  --ink-2: #4c5a52;
  --ink-3: #87948c;
  --line: #e3e9e4;
  --amber: #b7791f; --amber-soft: #fdf3dd;
  --red: #c0412b;   --red-soft: #fbe6e1;
  --blue: #2b6aa3;  --blue-soft: #e2edf8;
  --violet: #6b4fb3; --violet-soft: #ece6fa;
  --gold: #e8b021; --silver: #a7b1ad; --bronze: #c98552;
  --hatch: repeating-linear-gradient(-45deg, var(--g2) 0 4px, transparent 4px 8px);
  --r-xl: 26px; --r-lg: 20px; --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 26, .04), 0 6px 24px rgba(16, 40, 26, .05);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* names older modules still use */
  --teal: var(--g7); --teal-2: var(--g6); --teal-soft: var(--g1); --paper: var(--bg);
  --leaf: var(--g5); --leaf-soft: var(--g1); --turmeric: var(--amber); --turmeric-soft: var(--amber-soft);
  --brick: var(--red); --brick-soft: var(--red-soft); --sky: var(--blue); --sky-soft: var(--blue-soft);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --g9: #08261a; --g8: #0f3a26; --g7: #5cc58a; --g6: #78d39f; --g5: #5cc58a; --g3: #2f6b49; --g2: #24503a; --g1: #16301f;
    --bg: #0c1510; --card: #141f19; --ink: #e8f0eb; --ink-2: #a9b8af; --ink-3: #74857b; --line: #23332a;
    --amber: #e7b453; --amber-soft: #3a2e14; --red: #ec8a75; --red-soft: #3c211b; --blue: #82b3e2; --blue-soft: #16283a;
    --violet: #b3a0ea; --violet-soft: #2a2340;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --g9: #08261a; --g8: #0f3a26; --g7: #5cc58a; --g6: #78d39f; --g5: #5cc58a; --g3: #2f6b49; --g2: #24503a; --g1: #16301f;
  --bg: #0c1510; --card: #141f19; --ink: #e8f0eb; --ink-2: #a9b8af; --ink-3: #74857b; --line: #23332a;
  --amber: #e7b453; --amber-soft: #3a2e14; --red: #ec8a75; --red-soft: #3c211b; --blue: #82b3e2; --blue-soft: #16283a;
  --violet: #b3a0ea; --violet-soft: #2a2340;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--g7); }
:focus-visible { outline: 3px solid var(--g5); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
h1 { font-size: 1.85rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: .87rem; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
svg { flex: none; }

/* ======================================================= shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); }
.side { display: none; }
.main { padding: 12px 16px 120px; width: 100%; max-width: 1320px; margin: 0 auto; min-width: 0; }

.header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  background: var(--card); border-radius: var(--r-lg); padding: 10px 12px 10px 14px; box-shadow: var(--shadow);
}
.header .brand { display: flex; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 999px;
  padding: 0 14px; min-height: 42px; color: var(--ink-3); max-width: 420px; text-decoration: none; font-size: .92rem; min-width: 0;
}
.search input { width: 100%; }
.search svg { width: 18px; height: 18px; }
.search kbd { margin-left: auto; font: inherit; font-size: .75rem; background: var(--card); border-radius: 6px; padding: 1px 7px; color: var(--ink-3); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 0; background: var(--bg);
  color: var(--ink-2); cursor: pointer; position: relative; text-decoration: none; flex: none;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--card); }
.me-chip { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
@media (max-width: 959px) { .header { gap: 8px; padding: 8px; } .header .me-chip { display: none; } }
.me-chip .who { line-height: 1.2; text-align: right; }
.me-chip .who b { display: block; font-size: .92rem; }
.me-chip .who span { font-size: .78rem; color: var(--ink-3); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--ink); letter-spacing: -.02em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 25%, var(--g5), var(--g8)); box-shadow: inset 0 0 0 3px rgba(255,255,255,.18);
}
.brand-mark svg { width: 19px; height: 19px; }

.avatar {
  --av: var(--g7); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--av) 18%, var(--card)); color: var(--av); font-weight: 750; font-size: .9rem;
  letter-spacing: .01em;
}
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; }

/* mobile bottom tabs */
.tabbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  background: var(--card); border-radius: 22px; padding: 6px; box-shadow: 0 8px 30px rgba(16, 40, 26, .16);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 6px; font-size: .7rem; font-weight: 600; color: var(--ink-3); text-decoration: none; border-radius: 16px;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { color: #fff; background: linear-gradient(160deg, var(--g6), var(--g8)); }
.tabbar .badge { position: absolute; top: 2px; right: calc(50% - 22px); }

@media (min-width: 960px) {
  .shell { grid-template-columns: 252px minmax(0, 1fr); gap: 16px; padding: 16px; }
  .tabbar { display: none; }
  .main { padding: 0 0 48px; }
  .header .brand { display: none; }
  .side {
    display: flex; flex-direction: column; position: sticky; top: 16px; height: calc(100vh - 32px);
    background: var(--card); border-radius: var(--r-xl); padding: 22px 16px 16px; box-shadow: var(--shadow); overflow-y: auto;
  }
  .side .brand { padding: 0 8px 22px; }
  .side h6 { margin: 14px 12px 8px; font-size: .7rem; letter-spacing: .12em; color: var(--ink-3); font-weight: 700; }
  .side a.nav {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--ink-3); text-decoration: none; font-weight: 600; font-size: .94rem;
  }
  .side a.nav svg { width: 20px; height: 20px; }
  .side a.nav:hover { color: var(--ink); background: var(--bg); }
  .side a.nav[aria-current="page"] { color: var(--ink); font-weight: 750; }
  .side a.nav[aria-current="page"] svg { color: var(--g7); }
  .side a.nav[aria-current="page"]::before {
    content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 5px; border-radius: 0 6px 6px 0; background: var(--g7);
  }
  .side .badge { margin-left: auto; }
  .promo {
    margin-top: auto; border-radius: var(--r-lg); padding: 18px 16px; color: #fff; position: relative; overflow: hidden;
    background: radial-gradient(120% 90% at 100% 0%, var(--g6), transparent 60%), linear-gradient(160deg, var(--g8), var(--g9));
  }
  .promo .ring { position: absolute; right: -40px; bottom: -60px; width: 170px; height: 170px; border-radius: 50%; border: 22px solid rgba(255,255,255,.06); }
  .promo b { display: block; font-size: 1.02rem; margin: 10px 0 4px; }
  .promo p { margin: 0 0 12px; font-size: .82rem; opacity: .8; }
  .promo .btn { background: var(--g5); border-color: transparent; color: #fff; min-height: 36px; font-size: .85rem; }
  .promo .brand-mark { width: 30px; height: 30px; background: #fff; color: var(--g8); box-shadow: none; }
}

.badge {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--g8); color: #fff; font-size: .7rem; font-weight: 750;
}
.badge.warn { background: var(--red); }

/* ======================================================= page head */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 6px 0 20px; }
.page-head .t { flex: 1 1 260px; }
.page-head .sub { margin: 4px 0 0; color: var(--ink-3); font-size: .95rem; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ======================================================= controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--g3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(160deg, var(--g6), var(--g8)); border-color: transparent; color: #fff; }
.btn.primary:hover { background: linear-gradient(160deg, var(--g7), var(--g9)); }
.btn.outline { border-color: var(--g7); color: var(--g7); background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--g7); }
.btn.soft { background: var(--g1); border-color: transparent; color: var(--g8); }
.btn.small { min-height: 34px; padding: 0 14px; font-size: .86rem; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .85rem; font-weight: 650; margin-bottom: 6px; color: var(--ink-2); }
label.field > span .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
textarea.input { min-height: 76px; resize: vertical; }
.input:focus { outline: none; border-color: var(--g5); box-shadow: 0 0 0 4px var(--g1); }
.input[readonly] { background: var(--bg); color: var(--ink-2); }
.input.invalid { border-color: var(--red); }
.input.pill { border-radius: 999px; min-height: 40px; }
.hint { font-size: .82rem; color: var(--ink-3); margin-top: 4px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .row3 { grid-template-columns: 1fr 1fr; } }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 15px; border-radius: 999px; cursor: pointer; font-weight: 650; color: var(--ink-3); font-size: .9rem; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--g8); color: #fff; }
.seg.soft { background: var(--bg); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-weight: 650; color: var(--ink-2); font-size: .9rem;
}
.chip[aria-pressed="true"] { border-color: var(--g7); background: var(--g1); color: var(--g8); }
.chip .count { margin-left: 6px; font-size: .78rem; color: var(--ink-3); }

.card { background: var(--card); border-radius: var(--r-xl); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { flex: 1; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

/* round ↗ link */
.go {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--line); color: var(--ink); background: var(--card); text-decoration: none;
}
.go svg { width: 16px; height: 16px; }

/* ======================================================= status tags */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--bg); color: var(--ink-2);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.s-new { color: var(--g7); background: var(--g1); }
.tag.s-confirm { color: var(--violet); background: var(--violet-soft); }
.tag.s-check, .tag.s-pending { color: var(--amber); background: var(--amber-soft); }
.tag.s-paid, .tag.s-delivered { color: var(--g6); background: var(--g1); }
.tag.s-sent, .tag.s-transit { color: var(--blue); background: var(--blue-soft); }
.tag.s-returned, .tag.s-notpaid, .tag.s-cancelled, .tag.s-junk { color: var(--red); background: var(--red-soft); }
.chan { font-size: .78rem; color: var(--ink-3); }

/* ======================================================= order form */
.form-wrap { max-width: 680px; }
.form-group { padding: 20px; background: var(--card); border-radius: var(--r-xl); margin-bottom: 14px; box-shadow: var(--shadow); }
.form-group > h3 { margin-bottom: 14px; }
.item { border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin-bottom: 10px; }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; background: var(--card); }
.stepper button { width: 42px; height: 40px; border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--g7); }
.stepper output { min-width: 30px; text-align: center; font-weight: 700; }
.line-price { margin-left: auto; font-weight: 700; }
.item-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

.bill {
  position: sticky; bottom: 92px; z-index: 20; margin-top: 8px; color: #fff; border-radius: var(--r-xl); padding: 16px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: end;
  background: radial-gradient(90% 120% at 100% 0%, var(--g6), transparent 55%), linear-gradient(160deg, var(--g8), var(--g9));
  box-shadow: 0 10px 30px rgba(11, 51, 32, .3);
}
.bill .lines { font-size: .86rem; opacity: .85; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.bill .collect { text-align: right; }
.bill .collect small { display: block; font-size: .78rem; opacity: .8; }
.bill .collect strong { font-size: 2rem; line-height: 1; font-weight: 800; letter-spacing: -.02em; }
.bill .btn { grid-column: 1 / -1; margin-top: 10px; background: #fff; color: var(--g8); border-color: #fff; min-height: 48px; font-size: 1.02rem; }
@media (min-width: 960px) { .bill { bottom: 16px; } }

details.more { margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--g7); font-weight: 650; padding: 6px 0; }

/* ======================================================= lists & tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; border: 1.5px solid var(--line); }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; font-weight: 650; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--g1) 55%, transparent); }
table.grid tr.selected { background: var(--g1); }
table.grid .num { text-align: right; }
table.grid input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--g7); }

.order-cards { display: grid; gap: 10px; }
.ocard { background: var(--card); border-radius: var(--r-lg); padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow); }
.ocard .top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ocard .id { font-weight: 750; }
.ocard .items { font-size: .88rem; color: var(--ink-2); margin: 4px 0 8px; }
.ocard .bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ocard .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

@media (max-width: 959px) { .desktop-only { display: none !important; } }
@media (min-width: 960px) { .mobile-only { display: none !important; } }

.bulkbar {
  position: sticky; bottom: 96px; z-index: 15; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--g9); color: #fff; padding: 10px 16px; border-radius: 999px; margin-top: 12px;
}
.bulkbar select { min-height: 36px; border-radius: 999px; border: 0; padding: 0 12px; color: #101a14; }
@media (min-width: 960px) { .bulkbar { bottom: 16px; } }

/* ======================================================= drawer & dialogs */
.scrim { position: fixed; inset: 0; background: rgba(8, 24, 16, .45); z-index: 50; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); z-index: 51;
  background: var(--bg); overflow-y: auto; padding: 18px 18px 120px; box-shadow: -10px 0 30px rgba(0,0,0,.18);
}
@media (min-width: 640px) { .drawer { top: 10px; bottom: 10px; right: 10px; border-radius: var(--r-xl); } }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.drawer-head h2 { flex: 1; font-size: 1.35rem; }
.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 52;
  width: min(470px, calc(100% - 28px)); max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--card); border-radius: var(--r-xl); padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.dialog h2 { margin-bottom: 6px; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dupe { border: 1.5px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-top: 8px; font-size: .9rem; }
.reasons { display: grid; gap: 8px; margin: 14px 0 6px; }
.reasons label { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: var(--r); cursor: pointer; font-weight: 600; }
.reasons label:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.reasons input { accent-color: var(--red); width: 18px; height: 18px; margin: 0; }

.history { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history .when { color: var(--ink-3); font-size: .8rem; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60;
  background: var(--g9); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.error { background: var(--red); }
@media (min-width: 960px) { .toast { bottom: 28px; } }

.banner { padding: 12px 16px; border-radius: var(--r); margin-bottom: 14px; font-size: .92rem; }
.banner.warn { background: var(--amber-soft); }
.banner.err { background: var(--red-soft); }
.banner.ok { background: var(--g1); }

/* ======================================================= success */
.done { text-align: center; padding: 36px 20px; max-width: 540px; margin: 0 auto; }
.done .oid { font-size: 2.2rem; font-weight: 800; letter-spacing: -.01em; color: var(--g7); margin: 10px 0 4px; }
.done .amt { font-size: 1.15rem; }
.done .btn { margin-top: 20px; }

/* ======================================================= dashboard */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.kpi { background: var(--card); border-radius: var(--r-xl); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .k-top { display: flex; align-items: center; gap: 8px; }
.kpi .k-top span { flex: 1; font-weight: 650; font-size: .95rem; }
.kpi b { font-size: 2.3rem; font-weight: 800; line-height: 1.05; letter-spacing: -.03em; overflow-wrap: anywhere; }
.kpi b.sm { font-size: 1.75rem; }
.kpi .delta { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--ink-3); flex-wrap: wrap; }
.kpi .delta i { font-style: normal; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 6px; font-weight: 750; background: var(--g1); color: var(--g7); }
.kpi .delta i.down { background: var(--red-soft); color: var(--red); }
.kpi .delta i.flat { background: var(--bg); color: var(--ink-3); }
.kpi.hero { color: #fff; background: radial-gradient(110% 100% at 100% 0%, var(--g6), transparent 60%), linear-gradient(160deg, var(--g8), var(--g9)); }
.kpi.hero .go { background: #fff; border-color: #fff; color: var(--g9); }
.kpi.hero .delta { color: rgba(255,255,255,.75); }
.kpi.hero .delta i { background: rgba(255,255,255,.16); color: #fff; }
.kpi.alert b { color: var(--amber); }
@media (max-width: 480px) { .kpi b { font-size: 1.8rem; } .kpi b.sm { font-size: 1.35rem; } .kpi { padding: 15px; } }

.dash-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1100px) {
  .dash-grid { grid-template-columns: 1.55fr 1fr 1fr; }
  .dash-grid .span2 { grid-column: span 2; }
}
.dash-grid > .card { margin: 0; }

/* weekly pill bars */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 200px; padding-top: 34px; }
.week .col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; position: relative; }
.week .bar { width: 100%; max-width: 46px; border-radius: 999px; background: var(--g3); min-height: 14%; position: relative; }
.week .bar.hatch { background: var(--hatch); border: 1.5px solid var(--g2); }
.week .bar.mid { background: var(--g6); }
.week .bar.top { background: var(--g8); }
.week .bar .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 8px; padding: 1px 8px; font-size: .74rem; font-weight: 750; color: var(--ink-2);
}
.week .day { font-size: .8rem; color: var(--ink-3); font-weight: 650; }
.week .col.today .day { color: var(--ink); }

/* reminder */
.remind h3 { font-size: 1.35rem; color: var(--g8); line-height: 1.25; margin: 4px 0 6px; }
.remind .when { color: var(--ink-3); font-size: .88rem; margin-bottom: 18px; }

/* small lists */
.mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.mini li { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mini .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--g1); color: var(--g7); }
.mini .ico svg { width: 18px; height: 18px; }
.mini .txt { flex: 1; min-width: 0; }
.mini .txt b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .txt span { font-size: .8rem; color: var(--ink-3); }
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 750; white-space: nowrap; }
.pill.ok { background: var(--g1); color: var(--g7); }
.pill.busy { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: var(--bg); color: var(--ink-3); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }

/* gauge */
.gauge { position: relative; max-width: 260px; margin: 6px auto 0; }
.gauge svg { width: 100%; display: block; }
.gauge .center { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; }
.gauge .center b { display: block; font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.gauge .center span { font-size: .8rem; color: var(--ink-3); }
.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* dark value tile */
.tile-dark {
  color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--g8), var(--g9));
}
.tile-dark .waves { position: absolute; inset: 0; opacity: .35; pointer-events: none; }
.tile-dark h3 { opacity: .85; font-weight: 650; position: relative; }
.tile-dark .big { position: relative; font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 4px; }
.tile-dark .sub { position: relative; opacity: .75; font-size: .85rem; }
.tile-dark .row-btns { position: relative; display: flex; gap: 10px; margin-top: 18px; }
.tile-dark .row-btns a { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--g9); }
.tile-dark .row-btns a.alt { background: var(--red); color: #fff; }
.tile-dark .row-btns svg { width: 18px; height: 18px; }

.two { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .two { grid-template-columns: 1fr 1fr; } }
.two > .card { margin: 0; }
.bars { display: grid; gap: 8px; }
.bars .b { display: grid; grid-template-columns: minmax(90px, 150px) 1fr 64px; gap: 10px; align-items: center; font-size: .87rem; }
.bars .b > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b .track { display: block; height: 12px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bars .b .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--g5), var(--g7)); border-radius: 999px; }
.bars .b .v { text-align: right; color: var(--ink-2); }
.chart svg { width: 100%; height: 190px; display: block; }

/* ======================================================= leaderboard */
.lb { max-width: 760px; margin: 0 auto; }
.lb-card {
  border-radius: var(--r-xl); padding: 20px 18px 22px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(90% 70% at 50% 0%, var(--g6), transparent 70%), linear-gradient(170deg, var(--g8), var(--g9));
}
.lb-card .seg { background: rgba(255,255,255,.1); border-color: transparent; }
.lb-card .seg button { color: rgba(255,255,255,.75); }
.lb-card .seg button[aria-pressed="true"] { background: #fff; color: var(--g9); }
.lb-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 8px; }
.lb-top .label { font-size: .85rem; opacity: .75; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 10px; margin-top: 26px; }
.podium .p { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.podium .pic { position: relative; margin-bottom: 10px; }
.podium .avatar { width: 66px; height: 66px; font-size: 1.25rem; background: rgba(255,255,255,.14); color: #fff; box-shadow: 0 0 0 3px var(--ring, rgba(255,255,255,.4)); }
.podium .p1 .avatar { width: 86px; height: 86px; font-size: 1.6rem; }
.podium .p1 { --ring: var(--gold); } .podium .p2 { --ring: var(--silver); } .podium .p3 { --ring: var(--bronze); }
.podium .crown { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); width: 38px; height: 30px; color: var(--gold); }
.podium .num {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .75rem; font-weight: 800; color: var(--g9); background: var(--ring); border: 2px solid var(--g9);
}
.podium .name { font-weight: 750; font-size: .95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.podium .score { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 1.1rem; color: #c8f2d6; }
.podium .score svg { width: 16px; height: 16px; }
.podium .chg { font-size: .74rem; margin-top: 2px; }
.podium .base {
  width: 100%; margin-top: 10px; border-radius: 18px 18px 6px 6px; display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 800; color: rgba(255,255,255,.85);
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.04));
}
.podium .p1 .base { height: 96px; background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.06)); }
.podium .p2 .base { height: 70px; }
.podium .p3 .base { height: 54px; }
.podium .empty-slot .avatar { opacity: .35; }

.chg { display: inline-flex; align-items: center; gap: 2px; font-weight: 750; font-size: .78rem; }
.chg svg { width: 12px; height: 12px; }
.chg.up { color: #3fbf73; } .chg.down { color: #ef6a55; } .chg.same { color: var(--ink-3); } .chg.new { color: var(--gold); }
.lb-card .chg.same { color: rgba(255,255,255,.55); }

.lb-rows { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.lb-rows li {
  display: grid; grid-template-columns: 28px 34px 40px 1fr auto; gap: 10px; align-items: center;
  background: var(--card); border-radius: 999px; padding: 7px 18px 7px 12px; box-shadow: var(--shadow);
}
.lb-rows li.me { box-shadow: 0 0 0 2px var(--g5), var(--shadow); }
.lb-rows .rk { font-weight: 800; color: var(--ink-2); text-align: center; }
.lb-rows .who { min-width: 0; }
.lb-rows .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.lb-rows .who span { font-size: .76rem; color: var(--ink-3); }
.lb-rows .pts { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--g7); }
.lb-rows .pts svg { width: 16px; height: 16px; }
.mine {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px;
}
.mine div { background: var(--card); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow); }
.mine b { display: block; font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.mine span { font-size: .78rem; color: var(--ink-3); }
@media (max-width: 420px) {
  .podium .avatar { width: 54px; height: 54px; font-size: 1.05rem; }
  .podium .p1 .avatar { width: 70px; height: 70px; }
  .lb-rows li { grid-template-columns: 24px 30px 34px 1fr auto; padding-right: 14px; gap: 8px; }
  .mine b { font-size: 1.15rem; }
}

/* ======================================================= confirm inbox */
.inbox { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .inbox { grid-template-columns: 1fr 1fr; } }
.qcard { background: var(--card); border-radius: var(--r-xl); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.qcard .q-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qcard .q-top .id { font-weight: 750; }
.qcard .q-top .age { margin-left: auto; font-size: .8rem; color: var(--ink-3); }
.qcard .cust { font-size: 1.2rem; font-weight: 750; letter-spacing: -.01em; }
.qcard .callrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qcard .callrow .phone { font-weight: 700; font-size: 1.05rem; margin-right: 4px; }
.qcard .addr { color: var(--ink-2); font-size: .9rem; }
.qcard .prod { background: var(--bg); border-radius: var(--r); padding: 10px 14px; font-size: .9rem; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.qcard .prod b.money { font-size: 1.1rem; }
.qcard .q-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 4px; }
.wa { background: #e7f8ee; color: #128c4b; border-color: transparent; }

/* ======================================================= login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); padding: 30px; }
.login .brand { margin-bottom: 6px; }
.login .lead { color: var(--ink-3); margin: 0 0 20px; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--g7); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
pre.code { background: var(--bg); padding: 12px; border-radius: var(--r-sm); overflow-x: auto; font-size: .85rem; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: .92rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .kv { grid-template-columns: 96px 1fr; } }
