:root {
  --brand: #2563eb;
  --brand-accent: #0ea5e9;
  --brand-soft: rgba(37, 99, 235, 0.1);
  --brand-ring: rgba(37, 99, 235, 0.28);

  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-sunken: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --sidebar-bg: #0f1729;
  --sidebar-fg: #94a3b8;
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);

  --text: #101828;
  --text-muted: #667085;
  --text-subtle: #98a2b3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;

  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --bad: #d92d20;
  --bad-bg: #fef3f2;
  --info: #175cd3;
  --info-bg: #eff8ff;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);

  --sidebar-w: 258px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elevated: #131a2c;
  --bg-sunken: #090d19;
  --surface: #131a2c;
  --surface-2: #182135;
  --sidebar-bg: #080c17;
  --sidebar-fg: #7d8ba4;
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.05);

  --text: #e6ebf5;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --border: #232c42;
  --border-strong: #2f3a54;

  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 14px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.011em; color: var(--text); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(14, 165, 233, 0.1), transparent 55%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

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

/* The brand name carries the sign-in card on its own, so it is sized to read as
   a heading rather than as a label next to an icon. */
.auth-brand strong {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.25;
}

.auth-brand img { max-height: 40px; max-width: 180px; }

.auth-logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 700; font-size: 16px;
  letter-spacing: -0.02em;
}

.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); margin-bottom: 22px; font-size: 13.5px; }
.auth-foot { margin-top: 20px; text-align: center; color: var(--text-subtle); font-size: 12.5px; }
.auth-foot a { color: var(--text-muted); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-head {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-head img { max-height: 32px; max-width: 150px; }

.sidebar-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 700; font-size: 13px;
  flex: 0 0 32px;
}

.sidebar-name {
  color: #fff; font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav { padding: 12px 10px 20px; flex: 1; }

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #4d5b74;
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-fg);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: var(--brand); color: var(--sidebar-fg-active); }
.nav-item.active .nav-ico { opacity: 1; }
.nav-ico { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.75; }
.nav-badge {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  color: #4d5b74;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-spacer { flex: 1; }

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-ring);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.menu { position: relative; }
.menu-trigger {
  display: flex; align-items: center; gap: 9px;
  background: transparent; border: 1px solid transparent;
  padding: 5px 8px; border-radius: 9px; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 13.5px;
}
.menu-trigger:hover { background: var(--surface-2); border-color: var(--border); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 600; font-size: 12px;
  flex: 0 0 32px;
}

.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 60;
}
.menu-panel.open { display: block; }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-head { padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 13.5px; }
.menu-head span { color: var(--text-muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.content { padding: 24px; flex: 1; max-width: 1500px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head .page-sub { color: var(--text-muted); font-size: 13.5px; margin: 0; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { margin: 0; }
.card-head .card-sub { color: var(--text-muted); font-size: 12.5px; margin: 2px 0 0; }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; gap: 10px; align-items: center;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ---------- Stats ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.stat-meta { font-size: 12px; color: var(--text-subtle); margin-top: 5px; }
.stat-ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  position: absolute; top: 15px; right: 15px;
}
.stat.ok .stat-ico { background: var(--ok-bg); color: var(--ok); }
.stat.bad .stat-ico { background: var(--bad-bg); color: var(--bad); }
.stat.warn .stat-ico { background: var(--warn-bg); color: var(--warn); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

label.lbl, .lbl {
  display: block;
  font-size: 12.8px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.req { color: var(--bad); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="tel"], input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="search"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-sunken);
  color: var(--text-subtle);
  cursor: not-allowed;
}
input.is-error, select.is-error, textarea.is-error { border-color: var(--bad); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] {
  width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 16px; accent-color: var(--brand); cursor: pointer;
}
.check-label { font-size: 13.5px; }
.check-label small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 1px; }

.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.radio-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start;
  transition: border-color 0.12s, background 0.12s;
  background: var(--surface);
}
.radio-card:hover { border-color: var(--brand); }
.radio-card.selected { border-color: var(--brand); background: var(--brand-soft); }
.radio-card strong { display: block; font-size: 13.5px; }
.radio-card small { color: var(--text-muted); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(0.93); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(0.93); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; border-color: var(--border-strong); }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.2px;
}
table.data th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .t-main { font-weight: 550; }
table.data .t-sub { color: var(--text-muted); font-size: 12px; }
table.data .t-actions { text-align: right; white-space: nowrap; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-ico {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-subtle);
}
.empty h3 { margin-bottom: 5px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.8px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-wait { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.pill-muted { background: var(--surface-2); color: var(--text-subtle); border-color: var(--border); }
.pill-plain::before { display: none; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.4px;
  border: 1px solid transparent;
  align-items: flex-start;
}
.alert-ico { flex: 0 0 18px; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: currentColor; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: currentColor; }
.alert a { color: inherit; text-decoration: underline; }
.alert-body { min-width: 0; }

/* ---------- Compose ---------- */
.composer { position: relative; }
.composer textarea { font-size: 14px; min-height: 150px; }
.counter-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
}
.composer textarea { border-radius: var(--radius-sm) var(--radius-sm) 0 0; margin-bottom: 0; }
.counter-item strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.counter-warn { color: var(--warn); }
.counter-bad { color: var(--bad); }

.preview-phone {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.preview-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 11px 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
  line-height: 1.5;
}
.preview-sender {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Progress ---------- */
.progress {
  height: 7px;
  background: var(--bg-sunken);
  border-radius: 20px;
  overflow: hidden;
}
.progress-bar { height: 100%; background: var(--brand); border-radius: 20px; transition: width 0.3s; }
.progress-bar.ok { background: var(--ok); }
.progress-bar.bad { background: var(--bad); }
.progress-split { display: flex; height: 7px; border-radius: 20px; overflow: hidden; background: var(--bg-sunken); }
.progress-split span { display: block; height: 100%; }

/* ---------- Misc layout ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12.4px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .lbl { font-size: 11.5px; margin-bottom: 4px; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.pager-btn {
  padding: 6px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  background: var(--surface);
}
.pager-btn:hover { background: var(--surface-2); text-decoration: none; }
.pager-btn.is-disabled { opacity: 0.45; pointer-events: none; }
.pager-info { color: var(--text-muted); font-size: 12.5px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: 13.4px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

.code-block {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.3px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  line-height: 1.65;
}

.copy-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12.3px;
  word-break: break-all;
}
.copy-row .spacer { flex: 1; }

.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-block;
  line-height: 0;
}
.qr-box svg { width: 176px; height: 176px; display: block; }

.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
}
.recovery-grid span {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  letter-spacing: 0.06em;
}

.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  background: var(--surface-2);
}
.drop-zone { position: relative; }
label.drop-zone { display: block; margin: 0; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

/* Hidden, but still focusable and still validated - see initDropZone(). */
.drop-zone input[type="file"] {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-ico { display: block; color: var(--text-subtle); margin-bottom: 8px; }
.drop-title { display: block; font-size: 14.5px; color: var(--text); word-break: break-word; }
.drop-sub { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }
.drop-browse { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.drop-formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.drop-limit { font-size: 11.5px; color: var(--text-subtle); margin-left: 4px; }

/* After a choice: green when the file is usable, red when it is not. */
.drop-zone.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.drop-zone.has-file .drop-ico { color: var(--ok); }
.drop-zone.is-invalid { border-color: var(--bad); background: var(--bad-bg); }
.drop-zone.is-invalid .drop-ico,
.drop-zone.is-invalid .drop-title { color: var(--bad); }

.toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 11px 15px;
  font-size: 13.4px;
  min-width: 240px;
  max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.55);
  display: none;
  place-items: center;
  z-index: 90;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: grid; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

.mobile-only { display: none; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .content { padding: 16px; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 35; display: none;
  }
  .sidebar-scrim.open { display: block; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dt { margin-top: 8px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .hide-sm { display: none !important; }
  .auth-card { padding: 24px; }
  .recovery-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .page-head-actions, .filters, .pager { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* ---- Template composer: locked wording, one field per blank ---- */
.tpl-lock { margin-bottom: 16px; }

.tpl-lock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

/* The registered wording. Deliberately not an input: there is nothing here to
   type into, and it should not look as though there were. */
.tpl-body {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Each blank, showing whatever has been typed into it so far. */
.tpl-slot {
  display: inline;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--info) 22%, transparent);
  font-weight: 600;
  word-break: break-all;
}

.tpl-slot-empty {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--border);
  border-color: color-mix(in srgb, var(--warn) 24%, transparent);
  font-weight: 500;
  font-style: italic;
}

.tpl-vars-head {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 10px;
}

.tpl-var { margin-bottom: 12px; }

.tpl-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpl-var-row input { flex: 1; min-width: 0; }
.tpl-var-row input[readonly] { background: var(--bg-sunken); color: var(--text-muted); }

.tpl-var-src {
  flex: 0 0 auto;
  width: auto;
  max-width: 44%;
  font-size: 12.5px;
}

.tpl-var-count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-subtle);
  min-width: 48px;
  text-align: right;
}

.tpl-var-count.over { color: var(--bad); font-weight: 650; }

@media (max-width: 560px) {
  .tpl-var-row { flex-wrap: wrap; }
  .tpl-var-src { max-width: 100%; width: 100%; }
  .tpl-var-row input { flex: 1 1 60%; }
}

/* Shown while no template has been chosen, in place of the message box. */
.tpl-prompt {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--info) 20%, transparent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.tpl-prompt strong { display: block; margin-bottom: 2px; }
.tpl-prompt-ico { flex: 0 0 auto; margin-top: 1px; color: var(--info); }

/* ---- Template import card ---- */
.import-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 16px;
}

.import-notes {
  list-style: none;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px 24px;
}

.import-notes li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.import-notes li svg { flex: 0 0 auto; margin-top: 2px; }
.import-notes strong { color: var(--text); font-weight: 600; }

/* A long single-line sample, such as a GET URL, wraps instead of scrolling. */
.code-block.code-wrap { white-space: pre-wrap; word-break: break-all; }

/* Two-step marker beside a login on the accounts list. */
.mfa-tag {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  vertical-align: 1px;
  gap: 3px;
}

/* What the uploaded file filled in, above the blanks. */
.tpl-vars-note {
  margin: -4px 0 12px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.55;
}

/* The banner shown while an administrator is signed in as a customer. */
.alert.impersonating {
  align-items: center;
  border-width: 2px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.impersonating-back { margin-left: auto; flex: 0 0 auto; }
