/* =============================================================
   Design system - shared across login, totp, dashboard, users
   Dark, calm, instrument-panel aesthetic. Heebo carries both
   Latin and Hebrew text (RTL-safe); JetBrains Mono is reserved
   for numeric/code content that never needs to render in Hebrew.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Surfaces */
  --ink:            #12151c;
  --surface:        #1a1f29;
  --surface-raised: #232937;
  --surface-hover:  #2a3140;
  --line:           #2e3646;
  --line-soft:      #232937;

  /* Text */
  --text:      #e4e7ed;
  --text-dim:  #8b93a3;
  --text-faint:#5b6472;

  /* Signal (live / active / focus) */
  --signal:      #5eead4;
  --signal-dim:  #2dd4bf;
  --signal-soft: rgba(94, 234, 212, 0.12);
  --signal-ring: rgba(94, 234, 212, 0.35);

  /* Status */
  --danger:      #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning:     #fbbf24;
  --warning-soft:rgba(251, 191, 36, 0.12);
  --success:     #5eead4;
  --success-soft:rgba(94, 234, 212, 0.12);

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.2), 0 8px 24px -8px rgba(0,0,0,0.4);
  --shadow-raised: 0 4px 16px -4px rgba(0,0,0,0.5);

  --font-ui:   'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(94,234,212,0.06), transparent 60%),
    var(--ink);
  background-attachment: fixed;
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; }

::selection { background: var(--signal-soft); color: var(--text); }

/* Visible keyboard focus everywhere - never suppressed */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Login page ------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(800px 500px at 50% 0%, rgba(94,234,212,0.08), transparent 60%);
  pointer-events: none;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  position: relative;
}

.login-box .brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-box h1 {
  font-size: 17px; margin: 0; font-weight: 700;
  letter-spacing: 0.01em;
}
.login-box .brand p {
  margin: 6px 0 0; font-size: 13px; color: var(--text-dim);
}

.login-box label {
  display: block; margin-top: 18px; font-size: 12.5px;
  color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.login-box input {
  width: 100%; padding: 12px 14px; margin-top: 8px; box-sizing: border-box;
  background: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: inherit; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-box input:focus {
  outline: none; border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}
.login-box button {
  margin-top: 26px; width: 100%; padding: 13px;
  background: var(--signal); color: var(--ink);
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14.5px; font-weight: 700; font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.login-box button:hover { background: var(--signal-dim); }
.login-box button:active { transform: scale(0.99); }

.error {
  color: var(--danger); font-size: 13px; margin-top: 14px;
  padding: 10px 12px; background: var(--danger-soft);
  border: 1px solid rgba(248,113,113,0.25); border-radius: var(--radius-sm);
}

/* --- Top nav ------------------------------------------------------ */

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(26,31,41,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 {
  font-size: 15.5px; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.01em;
}
.topbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-dim); text-decoration: none; font-size: 13.5px; font-weight: 600;
  padding: 7px 12px; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover { background: var(--surface-hover); color: var(--text); }
.topbar nav a.active { background: var(--signal-soft); color: var(--signal); }
.topbar .user-badge {
  font-size: 12.5px; color: var(--text-dim);
  padding: 6px 12px; margin-inline-end: 4px;
  border: 1px solid var(--line); border-radius: 999px;
}

/* --- Layout / cards ------------------------------------------------ */

main { padding: 28px; max-width: 880px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 22px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.card h2 {
  font-size: 14px; margin: 0 0 4px; color: var(--text); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.hint { font-size: 13px; color: var(--text-dim); margin: 4px 0 16px; line-height: 1.6; }

/* --- Buttons -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-raised); color: var(--text);
  cursor: pointer; font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--text-faint); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--signal); color: var(--ink); border-color: var(--signal); }
.btn-primary:hover { background: var(--signal-dim); border-color: var(--signal-dim); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: rgba(248,113,113,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* --- Forms ------------------------------------------------------------ */

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block; font-size: 12.5px; color: var(--text-dim); font-weight: 600;
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
/* Checkboxes and radios must be excluded here: the generic rule below sets
   width:100% and 10px padding, which turned every checkbox into a full-width
   bar and pushed its label out of place. That is what broke the two "Phone
   access security" toggles on this page - the box floated in the middle of
   the card with its text stranded beside it. */
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
  width: auto; max-width: none; padding: 0; margin: 0;
  accent-color: var(--signal);
  flex: none;
}

/* A label that CONTAINS its control is a checkbox row, not a field caption:
   it should read as a normal sentence beside the box, not as an uppercase
   micro-heading above it. */
/* .checkbox-row is the explicit hook; the :has() selectors below catch any
   markup that forgets it, on browsers that support them (Chrome 105+,
   Safari 15.4+, Firefox 121+). Either way the width:auto rule above is what
   actually stops the checkbox stretching, and that works everywhere. */
.form-field label.checkbox-row,
.form-field label:has(input[type="checkbox"]),
.form-field label:has(input[type="radio"]) {
  display: flex; align-items: center; gap: 10px;
  text-transform: none; letter-spacing: normal;
  font-size: 14px; font-weight: 500; color: var(--text);
  margin-bottom: 0; cursor: pointer;
}

.form-field input, .form-field select {
  width: 100%; max-width: 360px; padding: 10px 12px;
  background: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  color: var(--text); box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus, .form-field select:focus {
  outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft);
}
.form-field input::placeholder { color: var(--text-faint); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* Inline field-level feedback (replaces alert() popups) */
.field-msg { font-size: 12.5px; margin-top: 6px; min-height: 16px; }
.field-msg.error { background: none; border: none; padding: 0; color: var(--danger); }
.field-msg.success { color: var(--signal); }

/* --- Tables ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--line-soft); }
th {
  color: var(--text-dim); font-weight: 700; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
td { font-family: var(--font-mono); font-size: 12.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-raised); }

/* --- Status badges ---------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  font-family: var(--font-ui); text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-verified { background: var(--success-soft); color: var(--signal); }
.badge-failed, .badge-expired { background: var(--danger-soft); color: var(--danger); }

/* --- Empty states ------------------------------------------------------- */

.empty-state {
  text-align: center; padding: 36px 20px; color: var(--text-dim);
  border: 1px dashed var(--line); border-radius: var(--radius-md); font-size: 13.5px;
}

/* --- Utility ------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-raised); border: 1px solid var(--line);
  padding: 6px 8px 6px 14px; border-radius: 999px; font-size: 13px;
  font-family: var(--font-mono);
}
[dir="rtl"] .chip { padding: 6px 14px 6px 8px; }
.chip button {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  width: 20px; height: 20px; border-radius: 999px; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chip button:hover { background: var(--danger-soft); color: var(--danger); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.inline-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Text inputs only got their dark styling from `.form-field input`, so any
   input outside a .form-field - the "add a phone number" box, for one - fell
   back to the browser default: a pale grey bar with near-invisible
   placeholder text sitting on a dark card. Give every text input the same
   treatment, and let .form-field keep its own width rule. */
input[type="text"], input[type="password"], input[type="email"],
input[type="tel"], input[type="number"], input[type="search"], select, textarea {
  padding: 10px 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft);
}

.inline-add input { flex: 1; min-width: 180px; }

/* Keyboard focus was only styled on form fields, so tabbing through the
   buttons, links and chips gave no visible indication of position. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .card { padding: 18px; }
  /* The add-a-number row stacked awkwardly: the input kept a 180px floor
     while the button sat beside it, so both were cramped. */
  .inline-add { flex-direction: column; align-items: stretch; }
  .inline-add input { min-width: 0; width: 100%; }
  .inline-add .btn { width: 100%; }
}

/* The verification dashboard's two tables are inherently wide (8 and 5
   columns, including raw IVR parameters). On a phone they set the page's own
   width to 539px in a 390px viewport, so the whole layout scrolled sideways
   and the header slid off screen. Let each table scroll inside its own card
   instead of dragging the document with it. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-scroll table { min-width: 640px; }

/* --- Brand logo -----------------------------------------------------------
   The icon artwork already contains the Ringkey wordmark, so no text is set
   beside it - doing so would read the name twice. Sized by height (a header
   constrains height, not width) with width:auto preserving the portrait
   aspect ratio. */
.brand-logo {
  height: 48px;
  width: auto;
  display: block;
}
.topbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex: none;
}
.brand-logo-lg {
  height: 88px;
  width: auto;
  display: block;
  margin: 0 auto 10px;
}
/* The topbar sized itself around an h1; without one it needs its own floor. */
.topbar { min-height: 72px; }

@media (max-width: 640px) {
  .brand-logo { height: 38px; }
  .brand-logo-lg { height: 76px; }
}
