@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  --bg: #F0EDE8;
  --bg-elevated: #F7F4EF;
  --surface: #FFFFFF;
  --surface-2: #F3EFE9;
  --surface-3: #E8E2D9;
  --border: rgba(31, 26, 22, 0.08);
  --border-strong: rgba(31, 26, 22, 0.14);
  --text: #1F1A16;
  --muted: #6B635A;
  --faint: #9A928A;
  --accent: #8F6344;
  --accent-2: #6B4A32;
  --accent-glow: rgba(107, 74, 50, 0.18);
  --accent-soft: rgba(143, 99, 68, 0.1);
  --gold: #A67C52;
  --gold-soft: rgba(166, 124, 82, 0.1);
  --running: #3D7A62;
  --running-bg: rgba(61, 122, 98, 0.1);
  --draft: #7A7268;
  --draft-bg: rgba(122, 114, 104, 0.08);
  --paused: #A16207;
  --paused-bg: rgba(161, 98, 7, 0.08);
  --done: #6B4A32;
  --done-bg: rgba(107, 74, 50, 0.08);
  --danger: #C53B3B;
  --danger-bg: rgba(197, 59, 59, 0.08);
  --chart-control: #6B4A32;
  --chart-control-soft: rgba(107, 74, 50, 0.1);
  --chart-treatment: #3D7A62;
  --chart-treatment-soft: rgba(61, 122, 98, 0.1);
  --chart-grid: rgba(31, 26, 22, 0.06);
  --analytics-card: #FFFFFF;
  --analytics-bg: #F0EDE8;
  --radius: 5px;
  --radius-sm: 4px;
  --radius-xs: 3px;
  --shadow-sm: 0 1px 2px rgba(42, 34, 24, 0.06);
  --shadow: 0 4px 18px rgba(42, 34, 24, 0.08);
  --shadow-lg: 0 14px 40px rgba(42, 34, 24, 0.12);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", "Cascadia Code", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}

/* ---- ambient background ---- */
.app-shell {
  position: relative;
  min-height: 100vh;
}

.ambient {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(143, 99, 68, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(166, 124, 82, 0.06), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(107, 74, 50, 0.05), transparent 50%);
}

.app-shell > header,
.app-shell > main {
  position: relative;
  z-index: 1;
}

/* ---- topbar (floating pill) ---- */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 24px 0;
  background: transparent;
  border: none;
  backdrop-filter: none;
}

.topbar-float {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 16px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(42, 34, 24, 0.04),
    0 8px 28px rgba(42, 34, 24, 0.08);
}

.topbar-float .brand {
  order: 1;
}

.topbar-float .spacer {
  order: 2;
  flex: 1 1 80px;
  min-width: 16px;
}

.topbar-float .topbar-actions {
  order: 3;
}

.topbar-float > .seg {
  order: 4;
  flex: 1 1 100%;
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.03em;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.seg {
  display: flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
  display: block;
}

.brand small {
  font-weight: 500;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-group .ghost {
  border: none;
  border-radius: 7px;
  background: transparent;
}

.btn-group .ghost:hover {
  background: var(--surface-2);
}

.seg button {
  padding: 7px 14px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.ghost {
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  text-decoration: none;
}

.ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
  text-decoration: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}

.ghost-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.primary {
  padding: 9px 18px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.primary:active { transform: translateY(0); }

.savedot {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  min-width: 0;
  max-width: 148px;
  text-align: right;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.savedot .ts-sep {
  display: inline-block;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin: 0 0.04em;
  opacity: 0.9;
  transform: translateY(-0.04em);
}

.savedot .ts-time {
  margin-left: 0.55em;
}

.live-theme-sync .ts-sep {
  display: inline-block;
  font-size: 1.35em;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin: 0 0.03em;
  opacity: 0.75;
  transform: translateY(-0.04em);
}

.live-theme-sync .ts-time {
  margin-left: 0.5em;
}

.savedot.busy { color: var(--paused); }
.savedot.ok { color: var(--accent-2); }

/* ---- main ---- */
main {
  padding: 28px 28px 64px;
  max-width: 1320px;
  margin: 0 auto;
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.dash-head .sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.5;
}

.dash-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.order-view-seg button {
  padding: 6px 12px;
  font-size: 11.5px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 20px;
  align-items: start;
}

.grid--dashboard {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
}

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
  min-width: 0;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 1px var(--accent-soft);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head-main {
  flex: 1;
  min-width: 0;
}

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-head .card-edit,
.card-head .card-analytics {
  flex-shrink: 0;
}

.card-head .card-analytics {
  text-decoration: none;
}

.card-head .card-analytics:hover {
  color: var(--accent-2);
  border-color: var(--border-strong);
  background: var(--surface);
}

.card .sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.card .path {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--surface-2);
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  margin-bottom: 16px;
  word-break: break-all;
  border: 1px solid var(--border);
  color: var(--muted);
}

.health-placeholder { margin-bottom: 14px; }

.health-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  background: var(--surface-2);
}

.health-panel.ok { border-color: #b8c9a8; background: #f4f7ef; }
.health-panel.warn { border-color: #d9c89a; background: #faf6ec; }
.health-panel.err { border-color: #d4a59a; background: #faf0ec; }

.health-panel h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.health-summary {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.health-list {
  margin: 0 0 8px;
  padding-left: 0;
  list-style: none;
  font-size: 12px;
}

.health-list li {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  color: var(--muted);
}

.health-list li.ok span { color: #4a7c3b; }
.health-list li.bad span { color: var(--danger); }

.health-list code {
  font-size: 11px;
  word-break: break-all;
}

.health-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
}

.health-badge.ok { background: #e4eddc; color: #3d5c32; }
.health-badge.warn { background: #f0e8d4; color: #7a5e1e; }
.health-badge.err { background: #f5e0d8; color: #8f3d2c; }

.health-theme-drift { color: #7a5e1e !important; }

/* ---- funnel ---- */
.funnel-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.funnel-section h4,
.clarity-panel h4 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.funnel-section {
  margin-top: 12px;
}

.funnel-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px 4px;
}

.funnel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.funnel-table th,
.funnel-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.funnel-table th {
  color: var(--faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.funnel-table tbody tr:last-child td {
  border-bottom: none;
  font-weight: 600;
}

.funnel-table tbody tr:last-child td:not(:first-child) {
  color: var(--accent-2);
}

.funnel-pending { color: var(--faint); text-align: center; }
.funnel-live { text-align: center; }
.funnel-live b { font-weight: 700; font-variant-numeric: tabular-nums; }

.funnel-src {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.funnel-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
}

/* ---- metrics ---- */
.metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.card .metrics {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.metric-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color 0.2s var(--ease);
}

.metric-box:hover {
  border-color: var(--border-strong);
}

.metric-box h4 {
  margin: 0 0 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-weight: 700;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--muted);
}

.metric-row b {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.warn-box {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  background: var(--paused-bg);
  color: var(--paused);
  font-size: 12px;
  border: 1px solid rgba(180, 83, 9, 0.18);
  line-height: 1.45;
}

/* ---- clarity ---- */
.clarity-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.clarity-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.clarity-links .ghost {
  font-size: 12px;
  background: var(--surface-2);
}

/* ---- status badges ---- */
.status {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status.running {
  background: var(--running-bg);
  color: var(--running);
  border: 1px solid rgba(21, 128, 61, 0.18);
}

.status.draft {
  background: var(--draft-bg);
  color: var(--draft);
}

.status.paused {
  background: var(--paused-bg);
  color: var(--paused);
}

.status.done {
  background: var(--done-bg);
  color: var(--done);
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--accent-2);
}

/* ---- table ---- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: visible;
}

.table-wrap--static {
  overflow: visible;
}

@media (max-width: 768px) {
  .table-wrap:not(.table-wrap--static) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  background: var(--surface-2);
  font-weight: 700;
}

tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(42, 34, 24, 0.04); }

.table-actions {
  width: 1%;
  white-space: nowrap;
}

.table-actions-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.table-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.date-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

label.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  text-transform: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: normal;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

label.check-label:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

label.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 2px 0 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

label.check-label span {
  flex: 1;
  min-width: 0;
}

.check-label-sub {
  color: var(--muted);
  font-weight: 400;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(143, 99, 68, 0.38);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: var(--faint); }

textarea { min-height: 80px; resize: vertical; }

.hint {
  font-size: 11px;
  color: var(--faint);
  margin-top: 5px;
  line-height: 1.45;
}

/* ---- modal ---- */
body.modal-open {
  overflow: hidden;
}

body.password-change-required .app-shell {
  pointer-events: none;
  user-select: none;
}

body.password-change-required #passwordScrim {
  pointer-events: auto;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(42, 34, 24, 0.38);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 100;
}

.scrim.open { display: flex; }

.scrim--forced {
  z-index: 110;
  cursor: default;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: min(720px, 100%);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.35s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-lg { width: min(780px, 100%); }

.user-modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.user-modal .modal-body {
  max-height: none;
  overflow: visible;
}

.modal-head {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.modal-body {
  padding: 20px 24px;
  max-height: 70vh;
  overflow: auto;
}

.modal-foot {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius) var(--radius);
}

.del {
  color: var(--danger);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
}

.del:hover { background: var(--danger-bg); }

.x {
  font-size: 22px;
  line-height: 1;
  padding: 6px 10px;
  color: var(--muted);
  border-radius: var(--radius-xs);
}

.x:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ---- toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.3s var(--ease);
  z-index: 60;
  max-width: 380px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.err {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.25);
  color: #b91c1c;
}

/* ---- empty / settings ---- */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-state h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 20px;
  letter-spacing: -0.03em;
}

.live-theme-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.live-theme-box--err {
  border-color: rgba(251, 191, 36, 0.3);
  background: var(--paused-bg);
}

.live-theme-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.live-theme-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.live-theme-sync {
  font-size: 11px;
  color: var(--faint);
  margin-top: 10px;
}

.live-theme-err {
  font-size: 13px;
  color: var(--paused);
}

.settings-card {
  max-width: 560px;
  background: linear-gradient(165deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.users-card {
  max-width: none;
  width: 100%;
}

.users-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.users-table {
  width: 100%;
  table-layout: auto;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  min-width: 280px;
  width: 40%;
}

.users-table td:nth-child(2) code {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

/* ---- range sliders ---- */
.split-slider {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.split-slider > label {
  margin-bottom: 10px;
}

.split-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.split-labels strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.split-labels .control strong { color: var(--accent); }
.split-labels .treatment strong { color: var(--gold); }

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--split-pct, 50%),
    var(--surface-3) var(--split-pct, 50%),
    var(--surface-3) 100%
  );
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 2px;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(42, 34, 24, 0.12);
  cursor: grab;
}

.range-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(42, 34, 24, 0.12);
  cursor: grab;
}

.range-field {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.range-field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.range-field-head label {
  margin: 0;
}

.range-field-head output {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---- scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

@media (max-width: 1280px) {
  .brand small { display: none; }
  #userChipRole { display: none; }
  .savedot { display: none; }
  .topbar-divider { display: none; }
  #newBtn { padding: 8px 12px; font-size: 12px; }
}

@media (max-width: 900px) {
  header.topbar { padding: 12px 16px 0; }
  .topbar-float {
    padding: 12px 14px;
    border-radius: 12px;
  }
  .user-chip-name { max-width: 64px; }
  .btn-group .ghost { padding: 8px 10px; font-size: 11.5px; }
}

@media (max-width: 768px) {
  main { padding: 20px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
}

/* ---- login ---- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form label {
  display: block;
  margin-bottom: 14px;
}

.login-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.login-form input {
  width: 100%;
}

.login-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

/* ---- user chip / roles ---- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-height: 36px;
  max-width: min(100%, 280px);
  min-width: 0;
}

.user-chip-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 88px;
}

.user-chip-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
  flex-shrink: 0;
  margin: 0 2px;
}

.user-chip-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.user-chip-logout:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

.user-chip-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.user-chip-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

.account-password-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.role-badge.role-admin { background: var(--gold-soft); color: var(--accent-2); }
.role-badge.role-editor { background: var(--running-bg); color: var(--running); }
.role-badge.role-viewer { background: var(--draft-bg); color: var(--draft); }

.users-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.users-table code {
  word-break: normal;
}

.users-table .table-actions {
  text-align: right;
}

.danger-text { color: var(--danger) !important; }

#userScrim .modal { max-width: 480px; }