/* Design system shared by the site, the login and the console.
   Tokens on :root, dark by default, light via [data-theme="light"] or the OS. */

:root {
  color-scheme: dark;
  --bg: #0c0b10;
  --bg-2: #121118;
  --surface: #17161e;
  --surface-2: #1e1c26;
  --surface-3: #27242f;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --txt: #f4f1ee;
  --txt-2: #c9c3c0;
  --txt-3: #8e8792;
  --brand: #ff5a1f;
  --brand-2: #ff8a3d;
  --brand-soft: rgba(255, 90, 31, .14);
  --telnyx: #00e3aa;
  --telnyx-soft: rgba(0, 227, 170, .12);
  --violet: #9085e9;
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, .12);
  --warn: #f5b54d;
  --warn-soft: rgba(245, 181, 77, .12);
  --err: #ff6b5e;
  --err-soft: rgba(255, 107, 94, .12);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .6);
  --shadow-sm: 0 6px 20px -10px rgba(0, 0, 0, .5);
  --glass: rgba(23, 22, 30, .72);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  /* charts: reference palette, dark steps */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --seq-1: #86b6ef; --seq-2: #5598e7; --seq-3: #3987e5; --seq-4: #256abf; --seq-5: #184f95;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f7f5f2; --bg-2: #efece7; --surface: #ffffff; --surface-2: #f6f3ef; --surface-3: #ece8e2;
    --line: rgba(20, 16, 12, .09); --line-strong: rgba(20, 16, 12, .18);
    --txt: #16131a; --txt-2: #4a4550; --txt-3: #7c7680;
    --brand-soft: rgba(255, 90, 31, .1); --telnyx: #00a67c; --telnyx-soft: rgba(0, 166, 124, .1);
    --ok: #13915a; --warn: #b77400; --err: #d23c2f;
    --shadow: 0 24px 60px -28px rgba(40, 30, 20, .28); --shadow-sm: 0 6px 20px -12px rgba(40, 30, 20, .25);
    --glass: rgba(255, 255, 255, .78);
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f5f2; --bg-2: #efece7; --surface: #ffffff; --surface-2: #f6f3ef; --surface-3: #ece8e2;
  --line: rgba(20, 16, 12, .09); --line-strong: rgba(20, 16, 12, .18);
  --txt: #16131a; --txt-2: #4a4550; --txt-3: #7c7680;
  --brand-soft: rgba(255, 90, 31, .1); --telnyx: #00a67c; --telnyx-soft: rgba(0, 166, 124, .1);
  --ok: #13915a; --warn: #b77400; --err: #d23c2f;
  --shadow: 0 24px 60px -28px rgba(40, 30, 20, .28); --shadow-sm: 0 6px 20px -12px rgba(40, 30, 20, .25);
  --glass: rgba(255, 255, 255, .78);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt); font: 500 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(34px, 5.2vw, 62px); font-weight: 700; }
h2 { font-size: clamp(24px, 2.8vw, 34px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: inherit; }
code, .mono { font-family: var(--font-mono); font-size: .88em; }
code.inline { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--txt-3); }
.dim { color: var(--txt-2); }

/* ---------- buttons ---------- */
.btn {
  --b: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; border: 1px solid transparent;
  background: var(--b); color: #fff; font: 700 14.5px/1 var(--font); cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, opacity .2s; text-decoration: none; white-space: nowrap;
  box-shadow: 0 10px 26px -12px color-mix(in srgb, var(--b) 70%, transparent);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--txt); border-color: var(--line-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--surface-2); color: var(--txt); border-color: var(--line); box-shadow: none; }
.btn.telnyx { --b: var(--telnyx); color: #04140f; }
.btn.danger { --b: var(--err); }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 9px; width: 38px; height: 38px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- forms ---------- */
label, .label { display: block; font-size: 12.5px; font-weight: 700; color: var(--txt-2); margin: 0 0 6px; letter-spacing: .01em; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--txt); font: 500 15px/1.35 var(--font);
  transition: border-color .2s, box-shadow .3s var(--ease), background .3s;
}
textarea { min-height: 120px; resize: vertical; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--txt-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--txt); font-size: 14px; cursor: pointer; }
.hint { font-size: 12.5px; color: var(--txt-3); margin-top: 5px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 23px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--txt-2); transition: transform .25s var(--ease), background .2s; }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.card.flat { box-shadow: none; }
.card h3 { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--txt-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.pill.telnyx { background: var(--telnyx-soft); color: var(--telnyx); border-color: color-mix(in srgb, var(--telnyx) 30%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.status { display: none; align-items: flex-start; gap: 9px; margin-top: 12px; padding: 10px 13px; border-radius: 11px; font-size: 13.5px; border: 1px solid var(--line); background: var(--surface-2); }
.status.show { display: flex; animation: rise .35s var(--ease); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.err { background: var(--err-soft); color: var(--err); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt-3); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.right { text-align: right; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 1000; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: 13px; background: var(--glass); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; animation: rise .35s var(--ease); }
.toast.err { border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.toast .ico { flex: none; font-weight: 800; }
.toast.ok .ico { color: var(--ok); } .toast.err .ico { color: var(--err); }

/* ---------- theme toggle ---------- */
.theme-toggle { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.theme-toggle button { border: 0; background: transparent; color: var(--txt-3); width: 30px; height: 28px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.theme-toggle button.on { background: var(--surface); color: var(--txt); box-shadow: var(--shadow-sm); }
.theme-toggle svg { width: 15px; height: 15px; }
.lang-switch { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.lang-switch button { border: 0; background: transparent; color: var(--txt-3); min-width: 32px; height: 28px; padding: 0 6px; border-radius: 8px; cursor: pointer; font: 700 11.5px/1 var(--font-mono); letter-spacing: .04em; transition: background .2s, color .2s; }
.lang-switch button:hover { color: var(--txt); }
.lang-switch button.on { background: var(--surface); color: var(--txt); box-shadow: var(--shadow-sm); }
.lang-switch button:focus-visible, .theme-toggle button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- modal ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--txt); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 4, 8, .55); backdrop-filter: blur(4px); }
dialog .dlg-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-head h3 { margin: 0; }
dialog .dlg-body { padding: 20px 22px; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.version { font-family: var(--font-mono); font-size: 11.5px; color: var(--txt-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
