/* Oakshield dashboards (operator and partner). Design after TailAdmin (MIT, tailadmin.com): Outfit type, cool grey
   neutrals, 16px bordered cards and a white sidebar, in Oakshield green instead of TailAdmin's blue.
   Layout: a left sidebar on wide screens once signed in; a top bar on narrow ones. */
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/outfit-latin.woff2") format("woff2");
}

:root {
  --bg: #f9fafb;            /* gray-50 */
  --surface: #ffffff;
  --surface-2: #f2f4f7;     /* gray-100: icon chips, table heads */
  --line: #e4e7ec;          /* gray-200 */
  --line-strong: #d0d5dd;   /* gray-300: inputs */
  --ink: #101828;           /* gray-900 */
  --ink-2: #344054;         /* gray-700 */
  --muted: #667085;         /* gray-500 */
  --brand: #0e6b4d;
  --brand-dark: #0b5a41;
  --brand-tint: #ecf6f1;    /* the active menu item */
  --brand-ring: rgb(14 107 77 / .14);
  --good: #027a48;          /* success-700 */
  --good-tint: #ecfdf3;
  --warn: #b54708;          /* warning-700 */
  --warn-tint: #fffaeb;
  --danger: #d92d20;        /* error-600 */
  --danger-tint: #fef3f2;
  --info-tint: #f2f4f7;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px 0 rgb(16 24 40 / .05);
  --shadow-lg: 0 12px 16px -4px rgb(16 24 40 / .08), 0 4px 6px -2px rgb(16 24 40 / .03);
  --sidebar: 264px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d;
    --surface: #1a2231;
    --surface-2: #1d2939;
    --line: #1d2939;
    --line-strong: #344054;
    --ink: #f2f4f7;
    --ink-2: #d0d5dd;
    --muted: #98a2b3;
    --brand: #3fb58a;
    --brand-dark: #2f9a73;
    --brand-tint: rgb(63 181 138 / .12);
    --brand-ring: rgb(63 181 138 / .2);
    --good: #32d583;
    --good-tint: rgb(18 183 106 / .12);
    --warn: #fdb022;
    --warn-tint: rgb(247 144 9 / .12);
    --danger: #f97066;
    --danger-tint: rgb(240 68 56 / .12);
    --info-tint: #1d2939;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 600; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
code { font-family: Consolas, ui-monospace, monospace; font-size: 13px; }
a { color: var(--brand); }
.muted { color: var(--muted); margin: 4px 0 0; }
.error { color: var(--danger); margin: 8px 0 0; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }

button {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: var(--radius-sm); padding: 9px 16px; box-shadow: var(--shadow-xs);
}
button:hover { background: var(--surface-2); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--brand-ring); border-color: var(--brand);
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { filter: brightness(.95); background: var(--danger); }
button.small { padding: 5px 12px; font-size: 13px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.banner a { color: var(--brand); font-weight: 600; }
button.link { border: 0; background: none; box-shadow: none; color: var(--brand); padding: 4px 6px; }
button.link:hover { text-decoration: underline; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; box-shadow: var(--shadow-xs);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

/* Header: a top bar on narrow screens, the sidebar on wide ones (below) */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 17px; font-weight: 600; }
.brand span { display: block; color: var(--muted); font-size: 13px; }
.shield { width: 36px; height: 36px; fill: var(--brand); flex: none; }
.shield .tick { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; box-shadow: none;
  border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.chip-ok { color: var(--good); background: var(--good-tint); border-color: transparent; }
.chip-warn { color: var(--warn); background: var(--warn-tint); border-color: transparent; }

/* Menu: TailAdmin's menu items, horizontal in the top bar */
.tabs { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; flex-wrap: wrap; }
.tabs a {
  display: flex; align-items: center; gap: 10px; color: var(--ink-2); text-decoration: none;
  font-size: 14px; font-weight: 500; padding: 8px 12px; border-radius: var(--radius-sm);
}
.tabs a svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a:hover { background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--brand); background: var(--brand-tint); }
.tabs a[aria-current="page"] svg { stroke: var(--brand); }

/* The sidebar, once signed in, on screens wide enough for it */
@media (min-width: 1100px) {
  body:has(#tabs:not([hidden])) { padding-left: var(--sidebar); }
  body:has(#tabs:not([hidden])) .bar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 5;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; gap: 24px;
    padding: 28px 20px 20px; border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto;
  }
  body:has(#tabs:not([hidden])) .tabs { flex-direction: column; margin: 0; gap: 4px; flex-wrap: nowrap; }
  body:has(#tabs:not([hidden])) .tabs::before {
    content: "Menu"; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px 12px;
  }
  body:has(#tabs:not([hidden])) .tabs a { padding: 10px 12px; }
  body:has(#tabs:not([hidden])) .bar-actions { margin-top: auto; flex-direction: column; align-items: stretch; gap: 8px; }
  body:has(#tabs:not([hidden])) .bar-actions .chip { justify-content: flex-start; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; }
  body:has(#tabs:not([hidden])) #logoutButton { align-self: flex-start; padding-left: 12px; }
  body:has(#tabs:not([hidden])) .loading-bar { left: var(--sidebar); width: calc(100% - var(--sidebar)); }
}

/* Layout */
.page { padding: 24px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); max-width: 1400px; margin: 0 auto; }
@media (min-width: 768px) { .page { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.toggle input { box-shadow: none; accent-color: var(--brand); width: 16px; height: 16px; }

/* Metric tiles, after TailAdmin's metric cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { display: block; color: var(--muted); font-size: 14px; }
.stat-value { display: block; font-size: 30px; line-height: 1.2; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-attention .stat-value { color: var(--warn); }
.stat-red .stat-value { color: var(--danger); }

.columns { display: grid; grid-template-columns: minmax(320px, 2fr) minmax(0, 3fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .columns { grid-template-columns: 1fr; } }

/* Event list */
.events { list-style: none; margin: 0; padding: 0; }
.event { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--muted); box-shadow: 0 0 0 4px var(--surface-2); }
.level-Danger .event-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }
.level-Warning .event-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-tint); }
.level-Info .event-dot { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-tint); }
.event-title { font-weight: 600; }
.event-message { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.event-meta { color: var(--muted); font-size: 12px; }
.event-meta a { color: var(--brand); }
.event-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.handled { opacity: .55; }
.feed .events { max-height: 70vh; overflow-y: auto; }

/* Tables, after TailAdmin's basic tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
td .sub { display: block; color: var(--muted); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
#search { min-width: 220px; }

/* Badges */
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; background: var(--good-tint); color: var(--good); white-space: nowrap; }
.pill-Warning { background: var(--warn-tint); color: var(--warn); }
.pill-Danger { background: var(--danger-tint); color: var(--danger); }
.pill-quiet { color: var(--muted); background: var(--surface-2); }

/* One computer */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; margin-bottom: 16px; font-weight: 500; font-size: 14px; }
.back:hover { color: var(--brand); }
.device-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.span-2 { grid-column: span 2; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.big { font-size: 20px; font-weight: 700; }
.locked { background: var(--warn-tint); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--ink); }
.locked button { margin-top: 8px; }
#deviceLicence a { color: var(--brand); font-weight: 600; }
.danger-zone { border-color: var(--danger-tint); }
.danger-zone h2 { color: var(--danger); }
#removeConfirm { margin-left: 8px; }

/* Subscriptions */
.code { font-family: Consolas, ui-monospace, monospace; letter-spacing: .04em; }
td.code { font-size: 14px; white-space: nowrap; }
.pill-good { color: var(--good); }
.pill-quiet-ended { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.form-grid label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.form-grid textarea { resize: vertical; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.small-text { font-size: 13px; margin: 0; }
.page > .small-text { margin-top: 14px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.button-link {
  display: inline-block; font-size: 14px; font-weight: 500; text-decoration: none; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 16px; box-shadow: var(--shadow-xs);
}
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Loading */
.loading-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 30; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--brand), transparent); background-size: 50% 100%;
  background-repeat: no-repeat; animation: loading 1s linear infinite;
}
@keyframes loading { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { .loading-bar { animation: none; background: var(--brand); opacity: .5; } }

/* Insights */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 2fr) 3fr auto; gap: 12px; align-items: center; font-size: 14px; }
.bar-row .label { overflow-wrap: anywhere; }
.bar-track { display: block; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.feedback-reply a, .event-meta a { color: var(--brand); }
.bar-row .num { color: var(--muted); }
.feedback-reply { font-size: 13px; }
.feedback-text { color: var(--ink); white-space: pre-wrap; }

/* Banners (Payments, Updates) */
.banner { border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); }
.banner strong { display: block; font-size: 18px; }
.banner-test { background: var(--warn-tint); border-color: transparent; }
.banner-live { background: var(--brand-tint); border-color: transparent; }
.banner-off { background: var(--danger-tint); border-color: transparent; }
.env-card { display: grid; gap: 12px; align-content: start; }
.env-card h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.step { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.step h3 { margin: 0; font-size: 15px; font-weight: 600; }
.step-done h3::before { content: "\2713  "; color: var(--good); }
.price-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.price-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.price-grid input { width: 100%; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 220px; min-width: 0; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: 14px; }
.checks .ok::before { content: "\2713"; color: var(--good); font-weight: 700; }
.checks .bad::before { content: "\2716"; color: var(--danger); font-weight: 700; }
.checks span { color: var(--muted); display: block; font-size: 13px; }
.pill-test { background: var(--warn-tint); color: var(--warn); }
.dialog label { font-weight: 500; }

/* Sign in */
.login { display: grid; place-items: center; min-height: calc(100vh - 80px); padding: 16px; }
.login-card { width: min(400px, 100%); display: grid; gap: 10px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin-bottom: 0; }
.login-card label { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 4px; }

/* Dialogs */
.overlay { position: fixed; inset: 0; background: rgb(16 24 40 / .5); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dialog { width: min(540px, 100%); display: grid; gap: 12px; box-shadow: var(--shadow-lg); padding: 24px; }
.dialog textarea { width: 100%; font-family: Consolas, ui-monospace, monospace; font-size: 12px; resize: vertical; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 500; z-index: 20; box-shadow: var(--shadow-lg);
}
@media (prefers-reduced-motion: no-preference) { .toast { transition: opacity .2s; } }

/* Partner dashboard */
.referral-card { margin-bottom: 20px; display: grid; gap: 8px; }
.referral-card h2 { margin: 0; }
.narrow-card { max-width: 720px; display: grid; gap: 12px; }
.group-row td { background: var(--surface-2); font-weight: 600; }
.group-row td .sub { font-weight: 400; }
.device-row td.indent { padding-left: 32px; }
.defaults-form { display: grid; gap: 10px; }
.defaults-form .toggle { font-size: 14px; color: var(--ink); }
.defaults-form textarea { width: 100%; resize: vertical; }
.reseller-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Two-step sign-in */
#codeRow { display: grid; gap: 6px; }
#codeRow[hidden] { display: none; }
.tfa-qr { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: var(--radius-sm); margin: 6px 0; }
.tfa-steps { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }
.tfa-required { font-weight: 600; margin-top: 0; }
.tfa-secret { font-size: 15px; letter-spacing: .05em; overflow-wrap: anywhere; }
.tfa-codes { font: 600 16px/1.7 Consolas, ui-monospace, monospace; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 16px; margin: 0; }

/* Call verification */
.verify-card .card-head { margin-bottom: 0; }
.verify-code { margin: 10px 0 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.verify-digits { font: 700 34px/1 Consolas, ui-monospace, monospace; letter-spacing: .08em; color: var(--brand); }
