/* Relay Calls — the phone system on a screen.
   Same visual language as Relay Accounting, so the two feel like one product.
    Nothing coloured that is not a signal: green is "callers get through", amber
   is "something is off", red is "callers are not being answered". */

:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --fg: #1c1a17;
  --muted: #6b6660;
  --faint: #918b83;
  --line: #e4e0d9;
  --line-strong: #cfcac1;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --good-bg: #ecfdf3;
  --warn-bg: #fffbeb;
  --bad-bg: #fef2f2;
  --shadow: 0 8px 28px rgba(28, 26, 23, .14);
  --radius: 8px;
}

/* Dark is opt-in, not inherited from the operating system.
   Matches Relay Accounting: dark is a choice, not something the operating
   system decides on a schedule. `data-theme="dark"` on <html> turns it on,
   and the toggle remembers the choice. */
:root[data-theme="dark"] {
  --bg: #161513; --panel: #1e1d1a; --fg: #eceae6; --muted: #9b958d;
  --faint: #7c766e; --line: #2e2c28; --line-strong: #403d38;
  --accent: #7ea2ff; --accent-fg: #10131c;
  --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --good-bg: #0e2a1a; --warn-bg: #2a2210; --bad-bg: #2c1516;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
}
/* The date picker's own popup renders light by default too. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.boot { padding: 4rem; color: var(--muted); text-align: center; }

/* ---- Shell ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 650; letter-spacing: -.01em; padding: .25rem .5rem 1rem; font-size: 15px; }
.brand small { display: block; font-weight: 400; color: var(--faint); font-size: 12px; }
.navlink {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .4rem .55rem; border-radius: 6px; color: var(--muted);
  text-decoration: none; cursor: pointer; border: 0; background: none;
  font: inherit; text-align: left; width: 100%;
}
.navlink:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); color: var(--fg); }
.navlink.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--fg); font-weight: 550; }
.navgroup { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
            color: var(--faint); padding: 1rem .55rem .25rem; }
.badge { font-size: 11px; background: var(--accent); color: var(--accent-fg);
         border-radius: 999px; padding: .05rem .4rem; font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line);
                font-size: 12px; color: var(--faint); }

.main { padding: 1.5rem 2rem 5rem; max-width: 1200px; }
h1 { font-size: 1.35rem; margin: 0 0 .15rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 1.75rem 0 .6rem; }
.sub { color: var(--muted); margin: 0 0 1.5rem; }

/* ---- Panels and tables ------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line);
         border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.panel-head { padding: .7rem 1rem; border-bottom: 1px solid var(--line);
              display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-body { padding: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 11.5px;
     text-transform: uppercase; letter-spacing: .04em;
     padding: .5rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .5rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--fg) 3%, transparent); }
/* Money lines up only if the digits are the same width. */
.num { text-align: right; font-variant-numeric: tabular-nums;
       font-feature-settings: "tnum"; white-space: nowrap; }
.neg { color: var(--bad); }
.total td { font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.dim { color: var(--muted); }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ---- Controls ---------------------------------------------------------- */
button, .btn {
  font: inherit; padding: .38rem .75rem; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--fg);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--fg); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: .1rem .2rem; text-decoration: underline; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

input, select, textarea {
  font: inherit; padding: .38rem .55rem; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.num-input { text-align: right; font-variant-numeric: tabular-nums; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }

/* ---- Status ------------------------------------------------------------ */
.pill { display: inline-block; font-size: 11px; padding: .1rem .45rem; border-radius: 999px;
        border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: transparent; }

.note { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 13px; }
.note.good { background: var(--good-bg); color: var(--good); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad  { background: var(--bad-bg);  color: var(--bad); }
.note.info { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.35rem; font-variant-numeric: tabular-nums; margin-top: .15rem; letter-spacing: -.01em; }
.stat .m { font-size: 12px; color: var(--faint); margin-top: .1rem; }


/* ---- Auth -------------------------------------------------------------- */
.auth { max-width: 360px; margin: 12vh auto; padding: 0 1rem; }
.auth h1 { margin-bottom: .25rem; }

/* ---- Modal ------------------------------------------------------------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid;
            place-items: center; padding: 1rem; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; border: 1px solid var(--line);
         width: min(640px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line);
              display: flex; justify-content: flex-end; gap: .5rem; }

@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .navgroup { display: none; }
  .main { padding: 1rem; }
  th, td { padding: .45rem .6rem; }
}


/* ---- Relay Calls ------------------------------------------------------- */
/* A grid column grows to fit its widest child unless told otherwise, and one
   long routing description would then push the whole page sideways on a
   phone. Tables scroll inside their panel instead. */
.shell > div { min-width: 0; }
.panel { overflow-x: auto; }

.topbar { position: sticky; top: 0; z-index: 20; background: var(--warn-bg); color: var(--warn);
          border-bottom: 1px solid var(--line); padding: .55rem 2rem;
          display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.topbar.hidden { display: none; }

/* A routing tree: each nested step is indented with a rule, so "when open →
   menu → press 1 → ring group" reads top to bottom like the call itself. */
.target { display: grid; gap: .45rem; }
.target .tline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.target .branch { border-left: 2px solid var(--line-strong); padding: .15rem 0 .15rem .8rem; margin-left: .2rem; }
.target .branch > .blabel { font-size: 11.5px; color: var(--muted); text-transform: uppercase;
                            letter-spacing: .04em; margin-bottom: .3rem; }
.target select { min-width: 10rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        margin-bottom: 1rem; }
.card > .card-head { padding: .7rem 1rem; border-bottom: 1px solid var(--line);
                     display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.card > .card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card > .card-body { padding: 1rem; }
.card.collapsed > .card-body { display: none; }
.card.collapsed > .card-head { border-bottom: 0; }
.card-head .summary { color: var(--muted); font-size: 12.5px; flex: 1; min-width: 0;
                      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hours { display: grid; grid-template-columns: 4.5rem 1fr; gap: .4rem .75rem; align-items: center; }
.hours .day { font-weight: 550; text-transform: capitalize; }
.hours .ranges { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.hours .range { display: inline-flex; gap: .25rem; align-items: center; }
.hours input[type=time] { width: 7.2rem; }

.chk { display: inline-flex; gap: .4rem; align-items: center; font-size: 13px; color: var(--fg); margin: 0; }
.chk input { margin: 0; }
.optrow { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: .75rem; align-items: start;
          padding: .6rem 0; border-top: 1px solid var(--line); }
.optrow:first-child { border-top: 0; }
.secret { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.issues { margin: 0; padding-left: 1.1rem; }
.issues li { margin: .15rem 0; }
.flow { color: var(--muted); font-size: 12.5px; }
.flow b { color: var(--fg); font-weight: 550; }
audio { height: 32px; vertical-align: middle; max-width: 100%; }
.rec { color: var(--bad); }
.empty { color: var(--muted); padding: 1.5rem 1rem; text-align: center; }

@media (max-width: 780px) {
  .topbar { padding: .55rem 1rem; }
  /* On a phone the nav is a wrapped row of links, so "Close now" on the
     Overview is one screen away, not under eleven full-width rows. */
  .sidebar .navlink { width: auto; padding: .3rem .55rem; }
  .sidebar .brand { width: 100%; padding-bottom: .25rem; }
  .sidebar .sidebar-foot { width: 100%; margin-top: .25rem; padding-top: .5rem; }
  .optrow { grid-template-columns: 1fr; }
  .hours { grid-template-columns: 1fr; }
}
