/* act.texnet.ca — call tracking
   Replaces a 2013 interface: fixed-width, image buttons, jQuery UI dialogs
   with iframes inside them. This is fluid, keyboard-navigable, and works on a
   phone, which the old one did not. */

:root {
  --bg:         #f6f7f9;
  --surface:    #ffffff;
  --surface-2:  #eef1f5;
  --ink:        #14181f;
  --ink-soft:   #414c5c;
  --muted:      #6b7686;
  --rule:       #dfe4ea;
  --rule-soft:  #eceff3;
  --accent:     #1668b3;
  --accent-ink: #ffffff;
  --accent-dim: #e6f0f9;
  --good:       #1c7350;
  --good-dim:   #e2f0ea;
  --warn:       #8a5a11;
  --warn-dim:   #f8eeda;
  --bad:        #a8403a;
  --bad-dim:    #f7e5e3;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Inter Tight", var(--sans);

  --r: 8px;
  --shell: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0f1319;
    --surface:   #161b23;
    --surface-2: #1d232d;
    --ink:       #e8ebef;
    --ink-soft:  #bcc4d0;
    --muted:     #8b95a4;
    --rule:      #28303b;
    --rule-soft: #212832;
    --accent:    #5aa9e8;
    --accent-ink:#0f1319;
    --accent-dim:#15293c;
    --good:      #5bbd95;
    --good-dim:  #13291f;
    --warn:      #d5a45b;
    --warn-dim:  #2a2113;
    --bad:       #e0877f;
    --bad-dim:   #2c1a18;
  }
}
:root[data-theme="dark"] {
  --bg:#0f1319; --surface:#161b23; --surface-2:#1d232d;
  --ink:#e8ebef; --ink-soft:#bcc4d0; --muted:#8b95a4;
  --rule:#28303b; --rule-soft:#212832;
  --accent:#5aa9e8; --accent-ink:#0f1319; --accent-dim:#15293c;
  --good:#5bbd95; --good-dim:#13291f; --warn:#d5a45b; --warn-dim:#2a2113;
  --bad:#e0877f; --bad-dim:#2c1a18;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------- top bar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  padding: 14px 0;
}
.brand-mark {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  display: block;
  padding: 16px 12px 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a.is-current { color: var(--ink); border-bottom-color: var(--accent); }
.nav a:focus-visible,
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

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

.shell { max-width: var(--shell); margin: 0 auto; padding: 26px 20px 80px; }

.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-sub { color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------ card */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--surface);
}
.card-title { font-family: var(--display); font-weight: 600; font-size: 1rem; }
.card-body { padding: 16px; }

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

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.control { display: flex; align-items: center; gap: 6px; }
.control label { font-size: 12.5px; color: var(--muted); }

select {
  font: inherit;
  font-size: 13.5px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* ----------------------------------------------------------- chart */

.chart-wrap { overflow-x: auto; padding: 8px 4px 0; }
.chart { display: block; width: 100%; min-width: 560px; height: auto; }
.chart .grid    { stroke: var(--rule-soft); stroke-width: 1; }
.chart .axis    { stroke: var(--rule); stroke-width: 1; }
.chart .bar     { fill: var(--accent); }
.chart .bar:hover { fill: var(--ink); }
.chart .bar-total {
  fill: var(--ink);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
}
.chart .x-label {
  fill: var(--muted); font-size: 11.5px; text-anchor: middle;
}
.chart .y-label {
  fill: var(--muted); font-size: 11px; text-anchor: end;
}

.chart-empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ----------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--rule);
  border-top: 1px solid var(--rule);
}
.stat { background: var(--surface); padding: 14px 16px; }
.stat-n {
  font-family: var(--display); font-weight: 700; font-size: 1.5rem;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.stat-l { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
  white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.dim, .dim { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ pill */

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-good { background: var(--good-dim); color: var(--good); }
.pill-warn { background: var(--warn-dim); color: var(--warn); }
.pill-bad  { background: var(--bad-dim);  color: var(--bad); }
.pill-mute { background: var(--surface-2); color: var(--muted); }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- sign in
   Standalone auth pages. No topbar: every nav link needs a session. */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.auth-wrap { width: 100%; max-width: 380px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 30px 28px 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
}

.auth-title {
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.auth-note {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
  margin: 0 0 18px;
}

.auth-note code {
  font-size: 0.83em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

.auth-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

.auth-error {
  background: var(--bad-dim);
  color: var(--bad);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.875rem;
  margin: 0 0 16px;
}

.auth-form { display: grid; gap: 7px; }

.auth-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.auth-input {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  width: 100%;
  margin-bottom: 8px;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.auth-btn {
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 6px;
  cursor: pointer;
}

.auth-btn:hover { filter: brightness(1.07); }

/* Sign out sits in the topbar, styled to read as nav rather than a control. */
.signout {
  margin-left: auto;
  display: flex;
}

.signout button {
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 6px 2px;
  cursor: pointer;
}

.signout button:hover { color: var(--ink); }

/* ------------------------------------------------------------ forms
   Shared by the Numbers and Settings screens. */

input[type="text"],
input[type="password"],
input[type="tel"] {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 10px;
  max-width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input.mono-input { font-variant-numeric: tabular-nums; }

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }

.btn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.07); border-color: transparent; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--rule-soft);
  background: var(--surface-2);
}

.notice {
  border-radius: 6px;
  padding: 10px 13px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.notice-good { background: var(--good-dim); color: var(--good); }
.notice-warn { background: var(--warn-dim); color: var(--warn); }
.notice-bad  { background: var(--bad-dim);  color: var(--bad); }

/* A URL meant to be copied out and pasted into someone else's console. */
.urlbox {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px 20px;
  align-items: start;
  padding: 16px;
}
.form-grid > .lbl {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-top: 8px;
}
.help { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; gap: 6px 0; }
  .form-grid > .lbl { padding-top: 14px; }
}

.kv { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 9px 20px; padding: 16px; font-size: 13.5px; }
.kv > dt { color: var(--muted); }
.kv > dd { margin: 0; color: var(--ink); }

/* A nav entry for a page that does not exist yet — present, but inert. */
.nav-todo {
  display: block;
  padding: 16px 12px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
