/* Owner dashboard. Shares tokens and type with the public homepage (site/styles.css); see DESIGN.md. */
:root {
  --navy: #0b1633; --navy-2: #14234a; --navy-ink: #c9d3ec;
  --amber: #ffc21a; --amber-ink: #3b2a00;
  --ground: #f2f4f8; --paper: #ffffff; --ink: #0b1633; --muted: #4a5675; --line: #dde2ec; --line-strong: #b9c2d6;
  --alarm: #c62a1d; --alarm-soft: #fdebe8; --ok: #17704a; --ok-soft: #e3f3ea; --warn: #7a5200; --warn-soft: #fff4d1;
  --bubble-in: #eceff5; --bubble-in-ink: #0b1633; --bubble-out: #1f5eff; --bubble-out-ink: #ffffff;
  --focus: #1f5eff;
  --shadow: 0 1px 2px rgb(11 22 51 / .06), 0 10px 28px -16px rgb(11 22 51 / .28);
  --radius: 16px;
  --font: "Archivo", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #070e22; --paper: #0f1a38; --ink: #e8edf8; --muted: #a3afc9; --line: #24315a; --line-strong: #3a4a7a;
    --alarm: #ff7a6e; --alarm-soft: #3a1512; --ok: #5ad39a; --ok-soft: #0f2e22; --warn: #ffd25e; --warn-soft: #332608;
    --bubble-in: #1b2850; --bubble-in-ink: #e8edf8; --bubble-out: #2f6bff;
    --focus: #ffc21a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -16px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #070e22; --paper: #0f1a38; --ink: #e8edf8; --muted: #a3afc9; --line: #24315a; --line-strong: #3a4a7a;
  --alarm: #ff7a6e; --alarm-soft: #3a1512; --ok: #5ad39a; --ok-soft: #0f2e22; --warn: #ffd25e; --warn-soft: #332608;
  --bubble-in: #1b2850; --bubble-in-ink: #e8edf8; --bubble-out: #2f6bff;
  --focus: #ffc21a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 1rem/1.55 var(--font); -webkit-font-smoothing: antialiased; }
::selection { background: var(--amber); color: var(--amber-ink); }
h1, h2, h3 { font-family: var(--font); font-weight: 800; font-stretch: 112%; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 .3em; text-wrap: balance; }
h1 { font-size: 2rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { display: block; font-size: .84rem; font-weight: 400; color: var(--muted); margin-top: .1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.error { color: var(--alarm); min-height: 1.2em; margin: .5rem 0 0; font-weight: 500; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Top bar: the homepage's navy nav, carried into the app */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; padding: .6rem max(16px, calc((100% - 1160px) / 2)); background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 2; }
.top :focus-visible { outline-color: var(--amber); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand rect { fill: var(--amber); }
.brand path { stroke: var(--navy); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.brand-name span { color: var(--amber); }
.top-actions { display: flex; gap: .5rem; align-items: center; min-width: 0; }
.top-actions select { width: auto; max-width: 46vw; margin: 0; min-height: 40px; background: var(--navy-2); color: #fff; border-color: rgb(255 255 255 / .25); }
.top .btn.ghost { color: #fff; border-color: rgb(255 255 255 / .35); min-height: 40px; }
.top .btn.ghost:hover { background: #fff; color: var(--navy); }

main { max-width: 1160px; margin: 0 auto; padding: 2rem 16px 4rem; }
.loading { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 700 .95rem var(--font); background: var(--ink); color: var(--paper); border: 1.5px solid transparent; border-radius: 999px; padding: .6rem 1.25rem; cursor: pointer; min-height: 44px; transition: background .2s, color .2s, transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgb(11 22 51 / .5); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--paper); border-color: var(--ink); }
.btn:disabled { opacity: .55; cursor: progress; transform: none; box-shadow: none; }
.link { background: none; border: 0; color: var(--ink); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); cursor: pointer; padding: .25rem; }
.link:hover { text-decoration-color: currentColor; }

/* Forms */
label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 1rem; }
input, select, textarea { display: block; width: 100%; margin-top: .35rem; font: 400 1rem var(--font); color: var(--ink); background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: .65rem .8rem; min-height: 48px; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input:user-invalid, textarea:user-invalid { border-color: var(--alarm); }
textarea { resize: vertical; }
label.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 500; }
label.check input { width: 20px; height: 20px; min-height: 0; margin: .1rem 0 0; flex: none; accent-color: var(--ink); }

/* Login, forgot and reset: navy panel beside the form, like the homepage hero */
.auth { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 64px - 6rem); align-items: center; justify-items: center; }
.auth-aside { display: none; }
.auth-card { width: 100%; max-width: 440px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.9rem; }
.auth-card > .muted { margin: 0 0 1.5rem; }
.auth-card .btn { width: 100%; margin-top: .25rem; min-height: 48px; }
.switch { text-align: center; margin: .9rem 0 0; }
@media (min-width: 900px) {
  .auth { grid-template-columns: 1fr 1fr; gap: 0; align-items: stretch; background: var(--paper); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); min-height: 600px; }
  .auth-aside { display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; padding: 3rem; background: radial-gradient(700px 400px at 90% 0%, var(--navy-2), transparent 60%), var(--navy); color: #fff; width: 100%; }
  .auth-aside h2 { font-size: 2.4rem; letter-spacing: -0.03em; line-height: 1.02; max-width: 12ch; }
  .auth-aside h2 span { color: var(--amber); display: block; }
  .auth-aside ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; color: var(--navy-ink); }
  .auth-aside li { display: flex; gap: .7rem; align-items: baseline; }
  .auth-aside li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); transform: translateY(-1px); }
  .auth-aside a { color: #fff; }
  .auth-card { border: 0; box-shadow: none; border-radius: 0; align-self: center; padding: 3rem; max-width: 480px; }
}

/* Dashboard header and setup */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.dash-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0; }
.dash-head .muted { margin: .3rem 0 0; }

.setup { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin: 1.5rem 0; box-shadow: var(--shadow); }
.setup h2 { margin-bottom: .9rem; }
.setup ul { list-style: none; margin: 0; padding: 0; display: grid; }
.setup li { display: grid; grid-template-columns: 132px 1fr; gap: .1rem 1rem; align-items: baseline; padding: .75rem 0; border-top: 1px solid var(--line); }
.setup li > :not(.state) { grid-column: 2; }
.setup .state { grid-row: span 2; }
.setup .state { justify-self: start; font-size: .74rem; font-weight: 700; letter-spacing: .02em; border-radius: 999px; padding: .25rem .7rem; white-space: nowrap; }
.setup .ok .state { background: var(--ok-soft); color: var(--ok); }
.setup .pending .state { background: var(--warn-soft); color: var(--warn); }
.setup .blocked .state { background: var(--alarm-soft); color: var(--alarm); }
.setup strong { font-size: 1rem; }
.setup span.detail { color: var(--muted); font-size: .9rem; }
.forwarding { margin-top: .5rem; border-top: 1px solid var(--line); padding-top: .25rem; }
.forwarding summary { font-weight: 600; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.forwarding ol { margin: .25rem 0 .5rem; padding-left: 1.25rem; display: grid; gap: .35rem; font-size: .92rem; overflow-wrap: anywhere; }

/* Tabs: segmented control */
.tabs { display: flex; gap: .25rem; margin: 1.75rem 0 1.25rem; padding: .3rem; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; width: max-content; max-width: 100%; overflow-x: auto; }
.tabs button { font: 600 .95rem var(--font); background: none; border: 0; border-radius: 999px; color: var(--muted); padding: .55rem 1.1rem; cursor: pointer; min-height: 40px; white-space: nowrap; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--ink); background: var(--ground); }
.tabs button[aria-selected="true"] { color: var(--paper); background: var(--ink); }

.empty { background: var(--paper); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 2rem 1.5rem; color: var(--muted); text-align: center; }

/* Jobs */
.jobs { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.job { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem 1.2rem; box-shadow: var(--shadow); min-width: 0; transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s; }
.job:hover { transform: translateY(-2px); box-shadow: 0 1px 2px rgb(11 22 51 / .06), 0 18px 36px -18px rgb(11 22 51 / .35); }
.job.urgent { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.job.emergency { border-color: color-mix(in srgb, var(--alarm) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--alarm) 30%, transparent), var(--shadow); }
.job header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; margin-bottom: .5rem; }
.job header h3 { font-size: 1.15rem; margin: 0; }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em; border-radius: 999px; padding: .25rem .65rem; background: var(--ground); color: var(--muted); margin: 0 .3rem .3rem 0; }
.badge::first-letter { text-transform: uppercase; }
.badge.emergency { background: var(--alarm); color: #fff; }
.badge.urgent { background: var(--warn-soft); color: var(--warn); }
.badge.flag { background: var(--warn-soft); color: var(--warn); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: .75rem 0 0; font-size: .94rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }

/* Conversations */
.convs { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) { .convs { grid-template-columns: 320px minmax(0, 1fr); } }
.conv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; align-content: start; }
.conv-list button { width: 100%; text-align: left; background: var(--paper); color: var(--ink); border: 1.5px solid var(--line); border-radius: 14px; padding: .8rem 1rem; cursor: pointer; font: inherit; font-weight: 600; transition: border-color .15s, background .15s; }
.conv-list button:hover { border-color: var(--line-strong); }
.conv-list button[aria-current="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.conv-list small { display: block; color: var(--muted); font-weight: 400; margin-top: .15rem; }
.thread { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; min-width: 0; box-shadow: var(--shadow); }
.bubbles { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.bubble { max-width: 85%; padding: .6rem .9rem; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.45; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); color: var(--bubble-in-ink); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-ink); border-bottom-right-radius: 6px; }
.bubble time { display: block; font-size: .74rem; opacity: .8; margin-top: .2rem; }

/* Settings and billing */
.settings, .billing { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); max-width: 760px; }
.billing { max-width: 640px; }
.settings-title { font-size: 1.6rem; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 1rem 0 0; padding: 1.25rem 0 0; min-width: 0; }
/* Floated legend sits inside the fieldset under its rule, so a two-line legend never crosses it. */
legend { float: left; width: 100%; font: 800 1.1rem var(--font); font-stretch: 112%; letter-spacing: -0.01em; padding: 0; margin: 0 0 1rem; }
legend + * { clear: both; }
legend .hint { font-stretch: 100%; letter-spacing: 0; }
.row { display: grid; gap: 0 .9rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.days { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1rem; }
.days label { display: inline-flex; align-items: center; gap: .45rem; margin: 0; border: 1.5px solid var(--line); border-radius: 999px; padding: .45rem .85rem; font-weight: 600; cursor: pointer; min-height: 40px; }
.days label:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.days input { width: auto; min-height: 0; margin: 0; accent-color: var(--amber); }
.question { border: 1.5px solid var(--line); border-radius: 14px; padding: 1rem 1rem 0; margin-bottom: .75rem; }
.question .remove { margin-bottom: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; }
.billing .actions { margin-top: 1.25rem; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: .8rem 1.1rem; margin: 0 0 1.25rem; font-weight: 600; }
.delete-customer { margin: .5rem 0 0; font-size: .85rem; min-height: 36px; padding: .4rem .9rem; }
.info { color: var(--ok); margin: .5rem 0 0; min-height: 0; font-weight: 500; }
.info:empty { display: none; }

@media (max-width: 560px) {
  main { padding-top: 1.25rem; }
  h1 { font-size: 1.6rem; }
  .auth-card, .settings, .billing { padding: 1.25rem; }
  .tabs { width: 100%; }
  .setup li { grid-template-columns: 1fr; }
  .setup li > :not(.state) { grid-column: 1; }
  .setup .state { grid-row: auto; margin-bottom: .3rem; }
  .tabs button { flex: 1 1 auto; padding: .55rem .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
