:root {
  /* चलचित्र is a Hindi film-streaming app; this is its one-operator ops
     panel. Palette pulls the two brand colors already used in the mobile
     app and the site's own retheme (App.tsx's ACCENT_COLOR, the gradient in
     injectedScript.ts) rather than a generic dashboard gold/blue. */
  --bg: #0b0710;
  --panel: #170f21;
  --panel-2: #1f1729;
  --border: #33253f;
  --text: #f4ecf1;
  --text-dim: #9c8ca7;
  --accent: #ff5a3c;
  --accent-2: #c2226f;
  --accent-gradient: linear-gradient(98deg, #ff5a3c 0%, #c2226f 100%);
  --accent-text: #ffffff;
  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.15);
  --danger: #fb5b74;
  --danger-dim: rgba(251, 91, 116, 0.15);
  --film: #2a1d38;
  --radius: 12px;

  /* Bebas Neue for the English wordmark/eyebrows only — a tall condensed
     poster caps face, used sparingly, never for body copy. Tiro Devanagari
     Hindi pairs a serif Devanagari with it for the actual "चलचित्र" mark,
     the same contrast old Hindi-film title cards use (bold Latin caps next
     to a more ornamental script). IBM Plex Mono gives the data columns
     (emails, dates, the one-time password) a ledger/box-office-register
     texture instead of reading as the same UI font as the buttons.  */
  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-hi: "Tiro Devanagari Hindi", "Noto Sans Devanagari", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.view { min-height: 100vh; }
[hidden] { display: none !important; }

/* A recurring punched-film-strip band along the top edge of every major
   surface (topbar, table card, modal cards, the login card) — the one
   signature motif tying the panel back to "moving picture", used
   consistently rather than scattered across several different ornaments. */
.filmstrip {
  position: relative;
}
.filmstrip::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  background-image: linear-gradient(90deg, var(--film) 0 9px, transparent 9px 16px);
  background-size: 16px 7px;
  background-repeat: repeat-x;
  border-radius: var(--radius) var(--radius) 0 0;
}
.table-wrap.filmstrip::before {
  border-radius: 0;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 14px 0 0;
}
.brand-hi {
  font-family: var(--font-hi);
  font-size: 2.1rem;
  font-weight: 400;
  color: var(--text);
}
.brand-en {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}
.brand.small { margin-top: 0; }
.brand.small .brand-hi { font-size: 1.35rem; }
.brand.small .brand-en { font-size: 0.85rem; }

/* ---------- Login ---------- */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* A soft projector beam falling from top-center rather than two generic
     symmetric radial blobs — a dark theatre with one cone of light. */
  background:
    radial-gradient(ellipse 60% 55% at 50% -10%, rgba(255, 90, 60, 0.16), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(194, 34, 113, 0.10), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.subtitle {
  color: var(--text-dim);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.login-card label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 10px;
}

.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-top: 4px;
  outline: none;
  transition: border-color 0.15s ease;
}
.login-card input:focus {
  border-color: var(--accent);
}

/* The toggle sits inside the field rather than beside it, so the input keeps
   the full width of the card and the control reads as part of it. */
.password-field {
  position: relative;
  display: flex;
  flex-direction: column;
}
.password-field input {
  /* Room for the button, so a long password never runs under it. */
  padding-right: 44px !important;
}
.password-toggle {
  position: absolute;
  right: 6px;
  bottom: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.password-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.password-toggle .eye-off { display: none; }
.password-toggle.revealed { color: var(--accent); }
.password-toggle.revealed .eye-open { display: none; }
.password-toggle.revealed .eye-off { display: block; }

#login-btn {
  margin-top: 20px;
  background: var(--accent-gradient);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}
#login-btn:hover { filter: brightness(1.08); }
#login-btn:disabled { opacity: 0.6; cursor: default; }

.error {
  color: var(--danger);
  background: var(--danger-dim);
  border: 1px solid rgba(251, 91, 116, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-top: 12px;
}

/* ---------- Dashboard shell ---------- */
.shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
}
.sidebar .brand { margin: 0 6px; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
/* A sprocket-hole square that fills in on the active item — the same
   filmstrip motif as the card edges, at the size of a bullet. */
.side-nav-marker {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--film);
  flex: 0 0 auto;
  transition: background 0.15s ease;
}
.side-nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.side-nav-item.active {
  color: var(--accent);
  background: rgba(255, 90, 60, 0.09);
}
.side-nav-item.active .side-nav-marker { background: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.sidebar-foot .whoami {
  margin-bottom: 4px;
  padding: 0 2px;
  word-break: break-all;
  line-height: 1.4;
}

.whoami {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn.ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn.small { padding: 6px 10px; font-size: 0.78rem; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }

.content {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 60px;
  max-width: 1100px;
}
.panel + .panel { margin-top: 0; }

/* The hamburger only exists on the narrow layout; on the desktop sidebar
   everything is visible at once and there is nothing to toggle. */
.nav-toggle { display: none; }
.nav-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-icon-close { display: none; }

/* Below this the sidebar becomes a sticky top navbar: brand on the left,
   hamburger on the right, and the nav plus account actions collapsed into a
   drawer underneath. Laying them all out in one wrapping row instead put
   five controls on two cramped lines and ate the top of every screen. */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto;
    flex: none;
    min-height: 0;
    position: sticky;
    top: 0;
    z-index: 40;
    align-self: stretch;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { margin: 0; }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
  }
  .nav-toggle:hover { color: var(--text); }
  .sidebar.open .nav-toggle { color: var(--accent); border-color: var(--accent); }
  .sidebar.open .nav-icon-open { display: none; }
  .sidebar.open .nav-icon-close { display: block; }

  /* Collapsed by default; the drawer is the full-width second row. */
  .side-nav,
  .sidebar-foot {
    display: none;
    flex-basis: 100%;
    width: 100%;
  }
  .sidebar.open .side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
  }
  .sidebar.open .side-nav-item {
    font-size: 1rem;
    padding: 12px;
  }
  .sidebar.open .sidebar-foot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 10px;
    margin-left: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .sidebar.open .sidebar-foot .whoami {
    max-width: none;
    margin-bottom: 2px;
    white-space: normal;
    word-break: break-all;
  }
}



/* ---------- Analytics ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--text);
}
.stat-value.stat-active { color: var(--success); }
.stat-value.stat-inactive { color: var(--danger); }

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.chart-card h3 {
  margin: 0 0 18px;
  font-size: 0.95rem;
  font-weight: 700;
}

/* Free trial on signup — an inline setting inside the dashboard, styled like
   the modal form fields so it reads as part of the same system. */
.settings-card h3 { margin-bottom: 8px; }
.settings-help {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 0.86rem;
  line-height: 1.5;
  max-width: 60ch;
}
.settings-help strong { color: var(--text); }
.settings-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.settings-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-input-wrap input[type="number"] {
  width: 6.5ch;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.settings-input-wrap input[type="number"]::-webkit-outer-spin-button,
.settings-input-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.settings-input-wrap input[type="number"]:focus { border-color: var(--accent); }
.settings-unit { color: var(--text-dim); font-size: 0.86rem; }
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.settings-status {
  color: var(--text-dim);
  font-size: 0.84rem;
  min-height: 1.2em;
}
.settings-card .error { margin: 12px 0 0; }
.signup-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
}
.signup-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.signup-bar {
  width: 100%;
  max-width: 26px;
  background: var(--accent-gradient);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.signup-bar-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.signup-bar-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.expiring-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.expiring-row:last-child { border-bottom: none; }
.expiring-row .expiring-date { color: var(--danger); }

/* Sign-in audit rows */
.event-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1.4fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.event-row:last-child { border-bottom: none; }
.event-badge {
  justify-self: start;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.event-badge.ok { background: var(--success-dim); color: var(--success); }
.event-badge.fail { background: var(--danger-dim); color: var(--danger); }
.event-who {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-meta,
.event-when {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-when { justify-self: end; }

.content-header {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}
.content-header-titles .eyebrow { margin-bottom: 2px; }
.content-header h2 { margin: 0; font-size: 1.3rem; font-weight: 700; }
.count-pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  align-self: center;
}
.add-user-btn {
  margin-left: auto;
  background: var(--accent-gradient);
  color: var(--accent-text);
  border: none;
}

.loading { color: var(--text-dim); }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; table-layout: fixed; }
thead th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:nth-child(1) { width: 27%; }
thead th:nth-child(2) { width: 15%; }
thead th:nth-child(3) { width: 11%; }
thead th:nth-child(4) { width: 15%; }
thead th:nth-child(5) { width: 18%; }
thead th.actions-col { width: 14%; }
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Emails, dates and the "activated by" column read as ledger entries —
   monospace gives that box-office-register texture the rest of the UI
   (labels, buttons) deliberately doesn't have. */
tbody td:nth-child(1),
tbody td:nth-child(2),
tbody td:nth-child(4),
tbody td:nth-child(5) {
  font-family: var(--font-mono);
  color: var(--text-dim);
}
tbody td:nth-child(1),
tbody td:nth-child(5) {
  font-size: 0.82rem;
}
tbody td:nth-child(2),
tbody td:nth-child(4) {
  font-size: 0.76rem;
  letter-spacing: -0.01em;
}
tbody td:nth-child(1) { color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 90, 60, 0.03); }

/* Status reads as a torn ticket stub: a dashed tear-edge on the left of an
   otherwise plain pill, rather than a generic solid-color badge. */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px 3px 8px;
  border-left: 2px dashed currentColor;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.95;
}
.status-badge.active { background: var(--success-dim); color: var(--success); }
.status-badge.inactive { background: var(--danger-dim); color: var(--danger); }

tbody td.actions-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-family: var(--font-body);
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  padding: 4px 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}
.icon-btn[aria-expanded="true"] {
  color: var(--accent);
  background: var(--panel-2);
  border-color: var(--accent);
}

/* Positioned from JS (fixed, off the button's rect) rather than absolutely
   inside the cell: the table container is a scroll container, which would
   clip a menu opened on one of the last rows. */
.row-menu {
  position: fixed;
  z-index: 30;
  min-width: 178px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.row-menu-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--text-dim);
}
.row-menu-item:hover { background: rgba(255, 255, 255, 0.05); }
.row-menu-item:hover svg { color: inherit; }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger-dim); }

/* Read-only detail rows in the View modal */
.detail-list {
  margin: 14px 0 4px;
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 10px 14px;
  align-items: baseline;
}
.detail-list dt {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.detail-list dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-word;
}
.detail-list dd.detail-id {
  font-size: 0.75rem;
  color: var(--text-dim);
  user-select: all;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
}

.load-more-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  max-width: 320px;
}
.toast.error { border-color: rgba(251, 91, 116, 0.5); color: #ffb9c4; }
.toast.success { border-color: rgba(52, 211, 153, 0.5); color: #b6f5dc; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.modal-card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.password-value {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 20px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  user-select: all;
  word-break: break-all;
}
.modal-card #reset-password-close {
  width: 100%;
  background: var(--accent-gradient);
  color: var(--accent-text);
}

.modal-form {
  display: flex;
  flex-direction: column;
}
.modal-form label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 10px;
}
.modal-form input[type="email"],
.modal-form input[type="password"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-top: 4px;
  outline: none;
}
.modal-form input:focus {
  border-color: var(--accent);
}
.modal-form input:disabled {
  opacity: 0.5;
}
.modal-form .hint {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 10px 0 0;
  line-height: 1.4;
}
.field-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}
.field-row > div {
  flex: 1;
  min-width: 0;
}
.field-row select,
.field-row input[type="date"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  margin-top: 4px;
  outline: none;
}
.field-row select:focus,
.field-row input:focus {
  border-color: var(--accent);
}
.reset-password-inline {
  width: 100%;
  margin-top: 16px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text);
}
.checkbox-label input {
  width: auto;
  margin: 0;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn {
  flex: 1;
}
.modal-actions #add-user-submit,
.modal-actions #edit-user-submit {
  background: var(--accent-gradient);
  color: var(--accent-text);
  border: none;
}

/* ---------- Filters ---------- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.filters-bar input[type="search"] {
  flex: 1;
  min-width: 180px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  outline: none;
}
.filters-bar input[type="search"]:focus {
  border-color: var(--accent);
}
.filters-bar select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}
.filters-bar select:focus {
  border-color: var(--accent);
}

/* Delete sits apart from the ticket-green/red activate/deactivate pair — an
   outlined danger button reads as "destructive and deliberate" rather than
   a third same-weight action button competing with those two. */
.btn.danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(251, 91, 116, 0.45);
}
.btn.danger-outline:hover:not(:disabled) {
  background: var(--danger-dim);
  filter: none;
}
.btn.danger-outline:disabled {
  color: var(--text-dim);
  border-color: var(--border);
}

@media (prefers-color-scheme: light) {
  /* Panel intentionally stays dark-themed for both modes — a deliberate
     single look for an internal admin tool, not a themed public page. */
}

/* ---------- Phone ---------- */
@media (max-width: 720px) {
  .content { padding: 20px 14px 48px; }
  .sidebar { padding: 10px 14px; }
  .content-header { flex-wrap: wrap; }
  .add-user-btn { margin-left: auto; }

  /* Filters: search on its own line, the three selects sharing the next. */
  .filters-bar { gap: 8px; }
  .filters-bar input[type="search"] { flex: 1 0 100%; min-width: 0; }
  /* Two per row, not three: at 390px a third of the row is ~115px, which
     clipped "All statuses" to "All statuse" and "Default order" to
     "Default ord". */
  .filters-bar select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 9px 10px;
  }

  /* The six-column table can't survive a 390px screen — every cell
     truncates to two characters. Below this width each row becomes a card:
     the email is the heading, the rest are labelled key/value lines, and the
     actions menu pins to the card's top-right corner. */
  .table-wrap { overflow: visible; }
  #users-table thead { display: none; }
  #users-table,
  #users-table tbody,
  #users-table tr,
  #users-table td {
    display: block;
    width: auto;
  }
  #users-table tr {
    position: relative;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  #users-table tbody tr:last-child { border-bottom: none; }
  #users-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 3px 0;
    border: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  #users-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  /* Email is the card's title, not a labelled field. */
  #users-table tbody td:nth-child(1) {
    display: block;
    padding-right: 42px;
    margin-bottom: 8px;
    font-size: 0.86rem;
    color: var(--text);
    word-break: break-all;
  }
  #users-table tbody td:nth-child(1)::before { display: none; }
  #users-table tbody td.actions-cell {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 0;
  }
  #users-table tbody td.actions-cell::before { display: none; }

  /* Two-up stat tiles instead of four full-width blocks of scrolling. */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-tile { padding: 16px 14px; }
  .stat-value { font-size: 1.9rem; }
  .chart-card { padding: 18px 14px; }

  /* Fourteen "12 Sep" labels forced the chart wider than the screen and
     took the whole page into horizontal scroll. On a phone the day number
     alone is enough — the month is already in the card's title. */
  .signup-chart { gap: 3px; height: 120px; }
  .signup-bar-label {
    font-size: 0;
    letter-spacing: 0;
  }
  .signup-bar-label::after {
    content: attr(data-short);
    font-size: 0.62rem;
  }
  .signup-bar-count { font-size: 0.62rem; }

  .expiring-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 0.8rem;
    word-break: break-all;
  }

  .modal { padding: 14px; }
  .modal-card { padding: 22px 18px; }
  .detail-list { grid-template-columns: 92px 1fr; gap: 8px 12px; }
  .field-row { flex-direction: column; gap: 0; }
}

/* The per-device switch sits inside the trial form, above its buttons. */
.settings-toggle {
  align-items: flex-start;
  margin: 4px 0 12px;
  max-width: 60ch;
  line-height: 1.45;
}
.settings-toggle input { margin-top: 4px; }

/* Sortable column headers */
.sort-th { background: none; border: 0; color: inherit; font: inherit; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sort-th::after { content: "↕"; opacity: .35; font-size: .85em; }
.sort-th.on { color: var(--accent, #ff5a3c); }
.sort-th.on[data-dir="asc"]::after { content: "↑"; opacity: 1; }
.sort-th.on[data-dir="desc"]::after { content: "↓"; opacity: 1; }
.sort-th.on[data-dir=""]::after { content: "•"; opacity: 1; }
.sort-th:focus-visible { outline: 2px solid var(--accent, #ff5a3c); outline-offset: 2px; border-radius: 4px; }
