/* R2M admin dashboard. Tokens first; dark mode follows the OS unless the user picks one. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --surface-3: #eef0ec;
  --border: #e2e5df;
  --border-strong: #cfd4cc;
  --text: #121614;
  --text-2: #3d4440;
  --muted: #6c7470;
  --accent: #14937f;
  --accent-strong: #0f7a69;
  --accent-ink: #0b5c50;
  --accent-soft: #e2f4ef;
  --brand: #2cc4b0;
  --on-accent: #ffffff;
  --danger: #c2413a;
  --danger-soft: #fbebea;
  --warn: #a8670f;
  --warn-soft: #fbf1df;
  --ok: #2b7a4b;
  --ok-soft: #e5f3ea;
  --info: #3461c1;
  --info-soft: #e8eefb;
  --violet: #6b4fc4;
  --violet-soft: #efebfb;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 20, .08), 0 2px 6px rgba(16, 24, 20, .05);
  --shadow-lg: 0 24px 64px rgba(16, 24, 20, .18), 0 4px 12px rgba(16, 24, 20, .08);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar: 236px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f0e; --surface: #131716; --surface-2: #171c1a; --surface-3: #1d2321;
    --border: #252b29; --border-strong: #343c39; --text: #e9edeb; --text-2: #c3cac6; --muted: #88918d;
    --accent: #2cc4b0; --accent-strong: #4fd3c1; --accent-ink: #8ce7da; --accent-soft: rgba(44, 196, 176, .13); --on-accent: #04211d;
    --danger: #f0716a; --danger-soft: rgba(240, 113, 106, .13); --warn: #e5a54b; --warn-soft: rgba(229, 165, 75, .13);
    --ok: #5cc98b; --ok-soft: rgba(92, 201, 139, .13); --info: #7fa2f0; --info-soft: rgba(127, 162, 240, .13);
    --violet: #a993f0; --violet-soft: rgba(169, 147, 240, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f0e; --surface: #131716; --surface-2: #171c1a; --surface-3: #1d2321;
  --border: #252b29; --border-strong: #343c39; --text: #e9edeb; --text-2: #c3cac6; --muted: #88918d;
  --accent: #2cc4b0; --accent-strong: #4fd3c1; --accent-ink: #8ce7da; --accent-soft: rgba(44, 196, 176, .13); --on-accent: #04211d;
  --danger: #f0716a; --danger-soft: rgba(240, 113, 106, .13); --warn: #e5a54b; --warn-soft: rgba(229, 165, 75, .13);
  --ok: #5cc98b; --ok-soft: rgba(92, 201, 139, .13); --info: #7fa2f0; --info-soft: rgba(127, 162, 240, .13);
  --violet: #a993f0; --violet-soft: rgba(169, 147, 240, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #04211d;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: -.02em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); border: 0; background: none; cursor: pointer; text-align: left; width: 100%;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 560; }
.nav-item.active svg { opacity: 1; }
.nav-count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600; flex: none; text-transform: uppercase;
}
.env-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 8px; border-radius: 99px;
  background: var(--warn-soft); color: var(--warn); font-weight: 560; align-self: flex-start; margin-left: 8px;
}
.env-pill.live { background: var(--ok-soft); color: var(--ok); }
.env-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.main { min-width: 0; padding: 28px 36px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -.025em; margin: 0; }
.page-sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font-weight: 520; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: none; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 15px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  height: 36px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; width: 100%; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 80px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search .input { padding-left: 32px; width: 280px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: none; padding: 5px 11px; border-radius: 6px; cursor: pointer; color: var(--text-2);
  font-size: 13px; font-weight: 520; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg .count { color: var(--muted); font-size: 11.5px; margin-left: 4px; font-variant-numeric: tabular-nums; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; height: 36px; }
.stepper button { width: 34px; height: 100%; border: 0; background: var(--surface-2); cursor: pointer; font-size: 16px; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); }
.stepper input { width: 56px; text-align: center; border: 0; height: 100%; background: var(--surface); outline: none; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 99px; padding: 5px 12px;
  cursor: pointer; font-size: 13px; color: var(--text-2);
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 560; }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 560; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.free { background: var(--accent-soft); color: var(--accent-ink); }
.badge.lifetime { background: var(--violet-soft); color: var(--violet); }
.badge.subscription { background: var(--info-soft); color: var(--info); }
.badge.trial { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-3); color: var(--muted); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ------------------------------------------------------------ cards / KPIs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 12px; }
.card-title { font-weight: 620; letter-spacing: -.01em; }
.card-body { padding: 16px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 28px; font-weight: 640; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-foot { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.kpi.accent { background: linear-gradient(140deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 22px; margin-bottom: 18px;
  background: radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 60%), var(--surface);
}
.hero h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.hero p { margin: 4px 0 0; color: var(--muted); max-width: 560px; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.feed-icon svg { width: 15px; height: 15px; }
.feed-text { flex: 1; min-width: 0; }
.feed-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ------------------------------------------------------------ tables */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.table-wrap { overflow: auto; max-height: calc(100vh - 210px); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 560;
  font-size: 12px; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .08s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.dim td { color: var(--muted); }
.cell-main { font-weight: 540; }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.seats { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.seats .bar { width: 46px; height: 6px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .5; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ------------------------------------------------------------ overlays */
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 10, .38); backdrop-filter: blur(2px); z-index: 40; animation: fade .15s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 41;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s cubic-bezier(.2, .8, .2, 1);
}
.drawer-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer-title { font-size: 17px; font-weight: 640; letter-spacing: -.015em; word-break: break-all; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.list { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }

.modal-wrap { position: fixed; inset: 0; display: grid; place-items: center; z-index: 42; padding: 20px; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .8, .2, 1);
}
.modal-head { padding: 20px 24px 6px; }
.modal-title { font-size: 18px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
.modal-body { padding: 14px 24px 8px; display: flex; flex-direction: column; gap: 18px; }
.modal-foot { padding: 16px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.callout { display: flex; gap: 10px; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--accent); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.warn svg { color: var(--warn); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 420px; padding: 11px 14px;
  background: var(--text); color: var(--bg); border-radius: 9px; box-shadow: var(--shadow-md); animation: pop .18s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast svg { width: 16px; height: 16px; flex: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ sign in */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: #0b1412; color: #e6f1ee;
}
.auth-art svg.grid { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; }
.auth-art .brand-name, .auth-art .brand-sub { color: #e6f1ee; }
.auth-art .brand-sub { color: #8fb3ab; }
.auth-quote { position: relative; max-width: 440px; }
.auth-quote h1 { font-size: 34px; line-height: 1.12; letter-spacing: -.035em; margin: 0 0 12px; font-weight: 640; }
.auth-quote p { color: #9fbdb6; margin: 0; font-size: 15px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-card h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.steps { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* ------------------------------------------------------------ responsive */
.menu-btn { display: none; }
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 45; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { padding: 18px 16px 48px; }
  .menu-btn { display: inline-flex; }
  .search .input { width: 100%; }
  .search { flex: 1; }
  .hero { flex-direction: column; align-items: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .hide-sm { display: none; }
}
