:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --line: #e4e2dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #1d5ea8;
  --track: #ecebe6;
  --good: #1f7a3a;   --good-bg: #e3f2e6;
  --warn: #8a5a00;   --warn-bg: #fbefd4;
  --bad: #a23a39;    --bad-bg: #f8e1e0;
  --warn-fill: #c98500;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --line: #2c2c2a;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #3987e5;
    --accent-ink: #7cb2f2;
    --track: #262624;
    --good: #7fd18f;   --good-bg: #1d3323;
    --warn: #f0c060;   --warn-bg: #3a2e14;
    --bad: #f09a99;    --bad-bg: #3b1f1f;
    --warn-fill: #c98500;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 8px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--text-2); font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand.big { font-size: 24px; justify-content: center; }
.biz { color: var(--text-2); padding-left: 16px; border-left: 1px solid var(--line); }
nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); }
nav a.on { background: var(--track); color: var(--text); font-weight: 600; }
nav a:hover { text-decoration: none; background: var(--track); }

main { max-width: 1040px; margin: 0 auto; padding: 24px; }
.flash { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two .card { margin-bottom: 16px; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 16px; }
.hero-main { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.hero-num { font-size: 52px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 8px 0; font-variant-numeric: tabular-nums; }
.tiles { display: grid; gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.tile .num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .of { font-size: 15px; font-weight: 400; color: var(--muted); }
.meter { height: 8px; background: var(--track); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter span.warn { background: var(--warn-fill); }
.note { color: var(--warn); font-size: 13px; margin-top: 6px; }

/* Bar chart (single series, one hue) */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; height: 180px; align-items: end; }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; outline: none; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar-stack { width: 40%; max-width: 36px; display: flex; flex-direction: column; align-items: center; }
.bar { width: 100%; flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-val { font-size: 12px; color: var(--text-2); padding-bottom: 4px; font-variant-numeric: tabular-nums; }
.bar-label { font-size: 12px; color: var(--muted); padding-top: 6px; }
.tip {
  position: absolute; bottom: calc(100% - 8px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .1s;
}
.bar-col:hover .tip, .bar-col:focus .tip { opacity: 1; }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(1.12); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li a { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); }
.list li:first-child a { border-top: 0; }
.list li a:hover { text-decoration: none; background: var(--track); }
.list .when { color: var(--muted); font-size: 13px; }
.list .who { font-weight: 600; text-align: right; }
.list .what { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.more { font-size: 13px; font-weight: 400; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--track); }
.nowrap { white-space: nowrap; }
.num-col { font-variant-numeric: tabular-nums; }
.summary { color: var(--text-2); }
.pad { padding: 20px; }
.pager { display: flex; justify-content: space-between; }

/* Pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: capitalize; }
.pill.confirmed { background: var(--good-bg); color: var(--good); }
.pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.cancelled { background: var(--bad-bg); color: var(--bad); }
.pill.confirmed::before { content: "✓ "; }
.pill.pending::before { content: "… "; }
.pill.cancelled::before { content: "✕ "; }

/* Call detail */
.back { display: inline-block; margin-bottom: 4px; font-size: 14px; }
audio { width: 100%; }
.order-link { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.ai { background: var(--track); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.caller { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.caller .who { color: rgba(255, 255, 255, .8); }

/* Orders */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 14px; }
.filters a.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.filters a:hover { text-decoration: none; }
.order-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.items { white-space: pre-wrap; font: inherit; background: var(--track); padding: 12px; border-radius: 10px; margin: 12px 0; }
.order-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* Login */
.login { max-width: 360px; margin: 10vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; text-align: center; }
.login form { display: grid; gap: 14px; text-align: left; margin-top: 20px; }
.login label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
button { font: inherit; font-weight: 600; padding: 11px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; }
button:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
  .top { padding: 12px 16px; }
  .biz { border-left: 0; padding-left: 0; }
  nav { margin-left: 0; width: 100%; }
  main { padding: 16px; }
  .hero, .two { grid-template-columns: 1fr; }
  .hero-num { font-size: 40px; }
  .msg { max-width: 92%; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}
