/* ===========================================================================
   Call Console — a billing desk for tracked phone numbers.
   Palette is drawn from switchboard hardware: aubergine panel, porcelain
   faceplate, copper for money, jade for settled, rose for outstanding.
   =========================================================================== */

:root {
  --ink: #191325;
  --plum: #3e2a5b;
  --plum-soft: #6a4f8f;
  --copper: #b6653a;
  --copper-soft: #f0dfd2;
  --jade: #2c7358;
  --jade-soft: #dcece5;
  --rose: #a52f4c;
  --rose-soft: #f6dee4;
  --porcelain: #f1eff4;
  --card: #ffffff;
  --line: #e0dbe8;
  --line-soft: #efecf4;
  --muted: #6c6383;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --shadow: 0 1px 2px rgba(25, 19, 37, 0.05), 0 8px 24px -14px rgba(25, 19, 37, 0.28);
  --pad: clamp(16px, 4vw, 28px);

  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Archivo', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --tab-h: 62px;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--porcelain);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: clamp(26px, 6vw, 34px); line-height: 1.1; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
a { color: var(--plum); }

:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
  border-radius: 3px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: grid; gap: 14px; }
.center-screen { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }

/* ------------------------------------------------------------------ shell */

.shell { min-height: 100dvh; }

.rail {
  position: fixed; inset: 0 auto 0 0; width: 232px;
  background: var(--ink); color: #efeaf6;
  padding: 26px 16px; display: none; flex-direction: column; gap: 4px; z-index: 20;
}
.rail .brand { padding: 0 10px 22px; }
.rail .brand-mark {
  font-family: var(--font-display); font-size: 21px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 9px;
}
.rail .brand-sub { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #9a8fb4; margin-top: 3px; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: #c7bcdd; text-decoration: none; font-weight: 500; font-size: 14px;
  border: 0; background: none; width: 100%; cursor: pointer; text-align: left;
  font-family: inherit;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link[aria-current='page'] { background: var(--plum); color: #fff; }
.nav-link .glyph { width: 18px; text-align: center; opacity: 0.9; }

.rail-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }

.main { padding: var(--pad) var(--pad) calc(var(--tab-h) + 34px); }
.page-head { margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--ink); display: flex; align-items: stretch;
}
.tabbar button {
  flex: 1; border: 0; background: none; color: #9c92b6; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  border-top: 2px solid transparent;
}
.tabbar button .glyph { font-size: 17px; line-height: 1; }
.tabbar button[aria-current='page'] { color: #fff; border-top-color: var(--copper); }

@media (min-width: 900px) {
  .rail { display: flex; }
  .tabbar { display: none; }
  .main { margin-left: 232px; padding-bottom: 60px; max-width: 1240px; }
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.card-pad { padding: 16px; }
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* Stat: the number leads, in the display face, with a copper hairline under
   the label so a column of stats reads as a ledger rather than a dashboard. */
.stat { padding: 14px 15px; }
.stat .label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stat .value {
  font-family: var(--font-display); font-size: clamp(22px, 5vw, 28px);
  font-weight: 600; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums;
}
.stat .value.money { color: var(--copper); }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ------------------------------------------------------- the duration tape */
/* Signature element: talk time drawn as tape off a reel. The notch marks the
   billing threshold, the ticks are five-minute marks. */

.tape { position: relative; height: 22px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.tape .fill { position: absolute; inset: 0 auto 0 0; background: var(--plum); border-radius: 3px; }
.tape .fill.long { background: linear-gradient(90deg, var(--plum) 0%, var(--copper) 100%); }
.tape .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.45); }
.tape .notch { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--copper); opacity: 0.75; }
.tape .label {
  position: absolute; inset: 0; display: flex; align-items: center; padding-left: 8px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  color: #fff; mix-blend-mode: normal; text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.tape.slim { height: 6px; }
.tape.slim .label { display: none; }

/* ------------------------------------------------------------- call rows */

.calls { display: grid; gap: 10px; }

.call {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 14px; display: grid; gap: 10px; box-shadow: var(--shadow);
  border-left: 3px solid var(--plum-soft);
}
.call.unpriced { border-left-color: var(--rose); }
.call.priced { border-left-color: var(--jade); }
.call.selected { box-shadow: 0 0 0 2px var(--plum); }

.call .top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.call .profile { font-weight: 600; font-size: 15px; }
.call .when { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-family: var(--font-mono); }
.call .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.call .meta b { font-weight: 500; color: var(--ink); font-family: var(--font-mono); }
.call .actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.price-tag {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px dashed var(--copper); color: var(--copper); background: #fff;
  padding: 7px 12px; border-radius: 999px; font-weight: 600; font-size: 14px;
  cursor: pointer; font-family: var(--font-ui); font-variant-numeric: tabular-nums;
}
.price-tag.set { border-style: solid; background: var(--copper-soft); }
.price-tag:hover { background: var(--copper-soft); }

/* -------------------------------------------------------------- controls */

.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 15px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--plum-soft); }
.btn.primary { background: var(--plum); border-color: var(--plum); color: #fff; }
.btn.primary:hover { background: #4b3470; }
.btn.copper { background: var(--copper); border-color: var(--copper); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--plum); }
.btn.danger { color: var(--rose); border-color: var(--rose-soft); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.field .hint { font-size: 12px; color: var(--muted); }

input, select, textarea {
  font-family: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--plum-soft); outline: none; box-shadow: 0 0 0 3px rgba(106,79,143,0.15); }
input.mono { font-family: var(--font-mono); }
textarea { min-height: 74px; resize: vertical; }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.filters .full { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(4, 1fr); } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--line-soft); color: var(--muted); white-space: nowrap;
}
.chip.jade { background: var(--jade-soft); color: var(--jade); }
.chip.rose { background: var(--rose-soft); color: var(--rose); }
.chip.copper { background: var(--copper-soft); color: var(--copper); }
.chip.plum { background: #ebe4f5; color: var(--plum); }

.segmented { display: inline-flex; background: var(--line-soft); padding: 3px; border-radius: 999px; gap: 2px; }
.segmented button {
  border: 0; background: none; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; border-radius: 999px; color: var(--muted); cursor: pointer;
}
.segmented button[aria-pressed='true'] { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ------------------------------------------------------------- calendar */

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { font-size: 10.5px; text-align: center; color: var(--muted); font-weight: 700; letter-spacing: 0.08em; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1 / 1.12; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; padding: 5px 5px 4px; display: flex; flex-direction: column;
  gap: 3px; cursor: pointer; font-family: inherit; text-align: left; min-width: 0;
}
.cal-day.empty { border-style: dashed; background: transparent; cursor: default; opacity: 0.45; }
.cal-day .num { font-size: 11.5px; font-weight: 700; color: var(--muted); font-family: var(--font-mono); }
.cal-day.today .num { color: var(--copper); }
.cal-day.today { border-color: var(--copper); }
.cal-day.active { box-shadow: 0 0 0 2px var(--plum); border-color: var(--plum); }
.cal-day .amt { font-size: 10.5px; font-weight: 700; color: var(--copper); font-family: var(--font-mono); margin-top: auto; }
.cal-day .cnt { font-size: 10px; color: var(--muted); }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--rose); }

/* ---------------------------------------------------------------- charts */

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 9px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--plum); }
.bar-fill.copper { background: var(--copper); }
.bar-val { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.spark { display: block; width: 100%; height: 46px; }

.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 68px; }
.hours .h { background: var(--plum-soft); border-radius: 2px 2px 0 0; min-height: 2px; }
.hours-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; font-size: 8.5px; color: var(--muted); text-align: center; margin-top: 4px; font-family: var(--font-mono); }

/* ----------------------------------------------------------------- sheet */

.overlay {
  position: fixed; inset: 0; background: rgba(25, 19, 37, 0.42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
  animation: fade 0.15s ease;
}
.sheet {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto; animation: rise 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.sheet .grabber { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: var(--r-lg); padding-bottom: 20px; }
  .sheet .grabber { display: none; }
}
@keyframes rise { from { transform: translateY(18px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button {
  padding: 12px 0; font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; cursor: pointer;
}
.keypad button:hover { background: var(--line-soft); }

/* ----------------------------------------------------------------- misc */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 80;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
  max-width: 90vw; text-align: center;
}
.toast.bad { background: var(--rose); }
@media (min-width: 900px) { .toast { bottom: 26px; left: calc(50% + 116px); } }

.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .big { font-family: var(--font-display); font-size: 19px; color: var(--ink); margin-bottom: 6px; }

.banner {
  border: 1px solid var(--copper); background: var(--copper-soft);
  color: #6f3a1c; padding: 11px 14px; border-radius: var(--r-md); font-size: 13.5px;
}
.banner.bad { border-color: var(--rose); background: var(--rose-soft); color: #7c1f36; }

.skeleton { background: linear-gradient(90deg, var(--line-soft), #fff, var(--line-soft)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-md); height: 76px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.login-card { width: 100%; max-width: 380px; }
.login-mark { font-family: var(--font-display); font-size: 30px; font-weight: 700; }
.login-rule { height: 3px; width: 46px; background: var(--copper); border-radius: 2px; margin: 14px 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Sync button spinner */
.spin { display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== additions for the PHP build ===================== */

.plain { background: var(--porcelain); }

.setup {
  max-width: 460px; margin: 48px auto; padding: 26px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.checklist { list-style: none; padding: 0; margin: 0 0 18px; }
.checklist li { padding: 7px 0 7px 26px; position: relative; font-size: 14px; border-bottom: 1px solid var(--line-soft); }
.checklist li:last-child { border-bottom: 0; }
.checklist li::before { position: absolute; left: 0; font-weight: 700; }
.checklist li.ok::before { content: '\2713'; color: var(--jade); }
.checklist li.warn::before { content: '!'; color: var(--copper); }

a.nav-link, a.btn, a.pill-link, a.cal-day-link { text-decoration: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(25,19,37,0.42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
}
.modal {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--r-lg); padding-bottom: 20px; }
}
.hidden { display: none !important; }

table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); }

.pill-link {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.pill-link[aria-current="true"] { background: var(--plum); border-color: var(--plum); color: #fff; }

.cal-day-link { color: inherit; display: block; }

.form-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

.muted-note { font-size: 12.5px; color: var(--muted); }

.flash {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 80;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
  max-width: 90vw; text-align: center;
}
.flash.bad { background: var(--rose); }
@media (min-width: 900px) { .flash { bottom: 26px; left: calc(50% + 116px); } }

/* ======================= Chimney Operation mark ======================= */

.logo { display: inline-flex; align-items: center; gap: 11px; }
.logo-svg { flex: none; overflow: visible; }

.logo-words { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.logo-name {
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: -0.015em; white-space: nowrap;
}
.logo-sub {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-top: 3px; white-space: nowrap;
}
.logo-lg .logo-name { font-size: 25px; }
.logo-sm .logo-name { font-size: 17px; }
.logo-sm .logo-sub  { font-size: 9.5px; letter-spacing: 0.12em; }

/* on the dark rail */
.rail .logo-name { color: #fff; }
.rail .logo-sub  { color: #9a8fb4; }

/* smoke: each puff rises, spreads and fades, then restarts */
.logo-svg .puff { opacity: 0; transform-origin: 32px 24px; }
.logo-svg .puff1 { animation: chimney-smoke 3.6s ease-out infinite; }
.logo-svg .puff2 { animation: chimney-smoke 3.6s ease-out infinite 1.2s; }
.logo-svg .puff3 { animation: chimney-smoke 3.6s ease-out infinite 2.4s; }


@keyframes chimney-smoke {
  0%   { opacity: 0;   transform: translate(0, 2px)      scale(.3); }
  12%  { opacity: .95; }
  40%  { opacity: .8;  transform: translate(-4px, -9px)   scale(.85); }
  70%  { opacity: .5;  transform: translate(2px, -17px)   scale(1.2); }
  100% { opacity: 0;   transform: translate(-6px, -26px)  scale(1.65); }
}

/* the ember breathes */
.logo-svg .ember { animation: chimney-ember 2.4s ease-in-out infinite; }
@keyframes chimney-ember {
  0%, 100% { opacity: 0.55; r: 2; }
  50%      { opacity: 1;    r: 2.6; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-svg .puff { animation: none; opacity: 0.3; }
  .logo-svg .ember { animation: none; opacity: 0.8; }
}

/* login screen gets the big mark */
.login-card .logo { margin-bottom: 2px; }

/* ================= additions for the single-page HTML build ================ */

.view { display: none; }
.view.on { display: block; }

.tabbar a, .tabbar button { text-decoration: none; }
a.nav-link, a.btn, a.pill-link { text-decoration: none; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(25,19,37,.42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
}
.modal {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--r-lg); padding-bottom: 20px; }
}
.hidden { display: none !important; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

.pill-link {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink); font-family: inherit;
}
.pill-link[aria-pressed="true"] { background: var(--plum); border-color: var(--plum); color: #fff; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); }

.flash {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  max-width: 90vw; text-align: center;
}
.flash.bad { background: var(--rose); }
@media (min-width: 900px) { .flash { bottom: 26px; left: calc(50% + 116px); } }

.spin { display: inline-block; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .logo-svg .puff { animation: none; opacity: .7; }
  .logo-svg .ember, .spin { animation: none; }
}

.boot { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* ===================== mobile corrections ===================== */

/* The wordmark was a fixed 25px and set never to wrap, so on a 320-360px
   phone it ran outside its card and sat on top of what was underneath. */
.logo { max-width: 100%; }
.logo-words { min-width: 0; flex: 1; }
.logo-name { white-space: normal; overflow-wrap: anywhere; }
.logo-lg .logo-name { font-size: clamp(17px, 5.6vw, 25px); line-height: 1.05; }
.logo-sm .logo-name { font-size: clamp(15px, 4.4vw, 17px); }
.logo-sub { white-space: normal; }

/* Anything using .spread should stack rather than collide when it runs out
   of room. */
.spread { flex-wrap: wrap; }
.page-head.spread { align-items: flex-start; }
.card-head { flex-wrap: wrap; }

@media (max-width: 560px) {
  .login-card { padding: 20px !important; }
  .page-head .sub { font-size: 13px; }
  .page-head.spread > * { min-width: 0; }
  .page-head.spread .toolbar { width: 100%; }
  .page-head.spread .toolbar .btn { flex: 1; }

  /* four stat cards were cramped two-up; give the numbers room */
  .grid-4 { gap: 8px; }
  .stat { padding: 11px 12px; }
  .stat .label { font-size: 10px; letter-spacing: .08em; }
  .stat .value { font-size: 19px; }

  .call { padding: 12px; }
  .call .top { flex-wrap: wrap; gap: 2px; }
  .call .when { font-size: 11.5px; }
  .call .actions { flex-wrap: wrap; gap: 8px; }
  .price-tag { flex: 1; justify-content: center; }

  .filters { grid-template-columns: 1fr; }
  .toolbar { width: 100%; }

  .cal-day { padding: 4px 3px; }
  .cal-day .num { font-size: 10.5px; }
  .cal-day .cnt { display: none; }
  .cal-day .amt { font-size: 9.5px; }

  .bar-row { grid-template-columns: 78px 1fr auto; font-size: 12px; }
  table.data { font-size: 12.5px; }
  th, td { padding: 8px 9px; }

  .modal { padding-left: 16px; padding-right: 16px; }
  .keypad { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}

/* very narrow phones */
@media (max-width: 360px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .tabbar button, .tabbar a { font-size: 9.5px; }
  .logo-sub { display: none; }
}

/* nothing should ever be able to push the page sideways */
html, body { max-width: 100%; overflow-x: hidden; }
.main { min-width: 0; }
.truncate { max-width: 100%; }

/* ---------------- status picker and status colours ---------------- */

.statuses { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 480px) { .statuses { grid-template-columns: repeat(4, 1fr); } }

.status-pick {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 11px 8px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.status-pick:hover { border-color: var(--plum-soft); }
.status-pick.on { background: var(--plum); border-color: var(--plum); color: #fff; }

.price-tag.st-offered  { border-color: var(--copper); background: var(--copper-soft); color: var(--copper); }
.price-tag.st-accepted,
.price-tag.st-paid     { border-color: var(--jade); background: var(--jade-soft); color: var(--jade); }
.price-tag.st-declined { border-color: var(--rose); background: var(--rose-soft); color: var(--rose); }

.call.declined { border-left-color: var(--rose); opacity: .82; }

.btn.sm.decline { color: var(--rose); padding: 6px 9px; }
.btn.sm.decline:hover { background: var(--rose-soft); }

@media (max-width: 560px) {
  .call .actions .row { width: 100%; }
  .call .actions .price-tag { flex: 1; }
}

/* jobs-a-day bars */
.daybars { display: flex; align-items: flex-end; gap: 2px; height: 90px; }
.daybars .db {
  flex: 1; min-width: 2px; background: var(--plum-soft);
  border-radius: 2px 2px 0 0; transition: background .15s ease;
}
.daybars .db:hover { background: var(--copper); }

/* command boxes with a copy button */
.cmdbox {
  display: flex; align-items: center; gap: 10px;
  background: var(--porcelain); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 10px 12px;
}
.cmdbox code, .cmdbox a {
  font-family: var(--font-mono); font-size: 12.5px;
  word-break: break-all; flex: 1; min-width: 0; color: var(--ink);
}
.cmdbox a { color: var(--plum); }
.cmdbox .btn { flex: none; }

/* ================= month bar, search and filters ================= */

.monthbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 10px 12px;
}
.monthbar strong {
  font-family: var(--font-display); font-size: 17px;
  white-space: nowrap; min-width: 0;
}
.monthbar .grow { flex: 1; }
.monthbar .btn { flex: none; }

.searchbar { display: flex; gap: 10px; align-items: center; margin: 12px 0; padding: 10px 12px; }
.searchbar input { flex: 1; min-width: 0; }
.searchbar .btn { flex: none; white-space: nowrap; }
#filterPanel { margin-bottom: 12px; }
#bulkBar { margin-bottom: 12px; }

/* ================= bottom bar: make the current tab obvious ================= */

.tabbar {
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,.08);
}
.tabbar button, .tabbar a {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-family: inherit; font-size: 10.5px; font-weight: 600;
  color: #b9b0cd;                     /* was too dim to read */
  border-top: 3px solid transparent;
  padding-top: 2px; text-decoration: none;
}
.tabbar button .glyph, .tabbar a .glyph { font-size: 18px; line-height: 1; }

.tabbar button[aria-current="page"],
.tabbar a[aria-current="page"] {
  color: #fff;
  border-top-color: var(--copper);
  background: linear-gradient(180deg, rgba(182,101,58,.28), rgba(182,101,58,0) 70%);
}
.tabbar button[aria-current="page"] .glyph,
.tabbar a[aria-current="page"] .glyph { color: #F0A55C; }

/* ================= mobile: stop things colliding ================= */

@media (max-width: 560px) {
  .monthbar { flex-wrap: nowrap; gap: 8px; }
  .monthbar strong { font-size: 15px; flex: 1; text-align: center; }
  .monthbar .grow { display: none; }
  .monthbar #syncNow { padding: 6px 10px; }

  .searchbar { flex-wrap: nowrap; }
  .searchbar input { font-size: 16px; }

  .filters { grid-template-columns: 1fr; gap: 8px; }

  #bulkBar .toolbar { gap: 6px; }
  #bulkBar .toolbar > * { flex: 1 1 auto; min-width: 0; }
  #bulkBar .chip { flex: 0 0 auto; }

  .grid-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .value { font-size: 20px; }
  .stat .foot { font-size: 11px; }

  .call .top { flex-wrap: wrap; }
  .call .top .when { width: 100%; }
  .call .meta { gap: 4px 10px; font-size: 12px; }
  .call .actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .call .actions .row { justify-content: space-between; }
  .call .actions .price-tag { width: 100%; justify-content: center; }

  .page-head h1 { font-size: 26px; }
  .cmdbox { flex-wrap: wrap; }
  .cmdbox .btn { width: 100%; }
}

/* the wordmark is just the name now */
.logo-sub { display: none; }
.logo-name { line-height: 1.1; }

/* ============ the mark, coloured for whatever it sits on ============ */

.logo-lg .logo-svg { width: 54px; height: 54px; }
.logo-sm .logo-svg { width: 42px; height: 42px; }

/* Light background — the login card. Dark stack reads well on pale. */
.logo-svg .stack  { fill: #4a3269; }
.logo-svg .crown  { fill: #B6653A; }
.logo-svg .bricks { stroke: rgba(255,255,255,.20); stroke-width: 1.2; }
.logo-svg .ember  { fill: #F0A55C; }
.logo-svg .puff   { fill: #8B79B4; }

/* Dark sidebar — flip it. A dark stack on a dark panel cannot be seen, which
   is exactly what was happening. */
.rail .logo-svg .stack  { fill: #E4DAF2; }
.rail .logo-svg .crown  { fill: #E8905A; }
.rail .logo-svg .bricks { stroke: rgba(62,42,91,.42); stroke-width: 1.3; }
.rail .logo-svg .ember  { fill: #FFC178; }
.rail .logo-svg .puff   { fill: #F3EEFB; }

/* a touch more presence in the sidebar */
.rail .brand { padding-bottom: 20px; }
.rail .logo { gap: 12px; }
.rail .logo-name { font-size: 18px; color: #fff; }


/* the smoke does the work of making the mark read, so give it some size */
.logo-svg .puff1 { r: 5.4; }
.logo-svg .puff2 { r: 6.4; }
.logo-svg .puff3 { r: 4.8; }

/* ================= brand bar, for phones and tablets ================= */

.topbar {
  display: none;
  position: sticky; top: 0; z-index: 40;
  background: var(--ink);
  padding: 10px var(--pad);
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar .logo-name { color: #fff; font-size: 19px; }
.topbar .logo-svg  { width: 38px; height: 38px; }
.topbar .logo-svg .stack  { fill: #E4DAF2; }
.topbar .logo-svg .crown  { fill: #E8905A; }
.topbar .logo-svg .bricks { stroke: rgba(62,42,91,.42); stroke-width: 1.3; }
.topbar .logo-svg .ember  { fill: #FFC178; }
.topbar .logo-svg .puff   { fill: #F3EEFB; }

@media (max-width: 899px) {
  .topbar { display: block; }
  .main { padding-top: 16px; }

  /* The brand belongs at the top; the section title belongs with the list it
     titles, not floating above the month and the figures. */
  #v-calls.on { display: flex; flex-direction: column; }
  #v-calls .page-head   { order: 5; margin: 4px 0 8px; }
  #v-calls .monthbar    { order: 1; }
  #v-calls #callStats   { order: 2; }
  #v-calls .searchbar   { order: 3; }
  #v-calls #filterPanel { order: 4; }
  #v-calls #bulkBar     { order: 6; }
  #v-calls #callList    { order: 7; }
  #v-calls #pager       { order: 8; }

  /* the eyebrow was just noise on a small screen */
  #v-calls .page-head .eyebrow { display: none; }
  #v-calls .page-head h1 { font-size: 20px; }

  /* Calendar and Reports read fine in document order, but the big heading
     wastes the top of a phone screen, so shrink it there too. */
  #v-calendar .page-head, #v-reports .page-head,
  #v-profiles .page-head, #v-admin .page-head, #v-account .page-head {
    margin-bottom: 12px;
  }
  #v-calendar .page-head h1, #v-reports .page-head h1,
  #v-profiles .page-head h1, #v-admin .page-head h1, #v-account .page-head h1 {
    font-size: 22px;
  }
  #v-calendar .page-head .sub, #v-reports .page-head .sub { display: none; }
}
