/* ==========================================================================
   Expert Batteries — admin dashboard & member portal
   Shares the palette in css/styles.css so the private pages match the site.
   ========================================================================== */

:root {
  --bg: #070a12;
  --bg-2: #0b1020;
  --surface: #0f1524;
  --surface-2: #141c2f;
  --surface-3: #1a2338;
  --line: #232e45;
  --line-soft: #1a2336;

  --text: #e9eef9;
  --muted: #97a5c0;
  --muted-2: #6f7d99;

  --accent: #22d3ee;
  --accent-2: #7dd3fc;
  --warn: #ffc53d;
  --ok: #3ddc97;
  --danger: #ff6b6b;

  --radius: 16px;
  --radius-sm: 10px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Manrope', 'Inter', system-ui, sans-serif;
  --t: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(34, 211, 238, 0.09), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -0.02em; margin: 0 0 0.4em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.9em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
strong { color: #fff; font-weight: 650; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.tiny { font-size: 0.78rem; color: var(--muted-2); margin: 0; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------- buttons ---------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; transition: border-color var(--t), background var(--t), transform var(--t);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #33415e; background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #22d3ee, #0fb6d4); border-color: transparent; color: #04121a; }
.btn-primary:hover { background: linear-gradient(180deg, #4de0f6, #19c3e2); color: #04121a; }
.btn-danger { border-color: rgba(255, 107, 107, 0.45); color: #ffb3b3; background: rgba(255, 107, 107, 0.08); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.16); color: #ffd0d0; }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 8px; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

/* ----------------------------------- inputs ---------------------------- */
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #0c1220; color: var(--text);
  font: inherit; transition: border-color var(--t), box-shadow var(--t);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15); outline: none; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea.input { min-height: 84px; resize: vertical; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .field-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ------------------------------------ card ----------------------------- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }

/* ------------------------------------ auth ----------------------------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { width: 42px; height: auto; }
.auth-brand strong { font-family: var(--font-head); letter-spacing: 0.14em; font-size: 0.9rem; }
.auth-brand span { display: block; font-size: 0.72rem; letter-spacing: 0.18em; color: var(--muted-2); text-transform: uppercase; }
.auth-alt { margin: 16px 0 0; font-size: 0.85rem; color: var(--muted); text-align: center; }

.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.86rem; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.35); color: #ffc0c0; }
.alert-ok { background: rgba(61, 220, 151, 0.1); border-color: rgba(61, 220, 151, 0.3); color: #b9f5d8; }
.alert-info { background: rgba(34, 211, 238, 0.08); border-color: rgba(34, 211, 238, 0.28); color: #bfeef9; }

/* ------------------------------------ shell ---------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 22px;
  background: rgba(11, 16, 32, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.side-brand img { width: 34px; }
.side-brand strong { display: block; font-family: var(--font-head); font-size: 0.86rem; letter-spacing: 0.12em; }
.side-brand span { font-size: 0.68rem; letter-spacing: 0.16em; color: var(--muted-2); text-transform: uppercase; }

.side-nav { display: grid; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 0.9rem;
  transition: background var(--t), color var(--t);
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.is-active { background: rgba(34, 211, 238, 0.12); color: var(--accent); }
.side-nav .count { font-size: 0.72rem; background: rgba(34, 211, 238, 0.15); color: var(--accent); border-radius: 999px; padding: 1px 8px; }

.side-foot { margin-top: auto; display: grid; gap: 8px; font-size: 0.8rem; color: var(--muted-2); }
.side-foot .who { color: var(--text); font-weight: 600; font-size: 0.84rem; word-break: break-word; }

.main { padding: 26px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.topbar .sub { color: var(--muted); font-size: 0.86rem; margin: 2px 0 0; }

/* ------------------------------------ KPIs ----------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .k-label { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); margin: 0 0 6px; }
.kpi .k-value { font-family: var(--font-head); font-size: 1.85rem; font-weight: 800; line-height: 1.1; }
.kpi .k-sub { font-size: 0.78rem; color: var(--muted); margin: 6px 0 0; }
.kpi.is-accent { border-color: rgba(34, 211, 238, 0.35); box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.12) inset; }

/* ------------------------------------ tables --------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data th { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; background: rgba(255, 255, 255, 0.02); position: sticky; top: 0; }
table.data tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.is-link { cursor: pointer; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------ badges --------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: 999px; font-size: 0.74rem; font-weight: 650; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-new, .badge-lead { color: #ffd88a; background: rgba(255, 197, 61, 0.12); border-color: rgba(255, 197, 61, 0.32); }
.badge-confirmed { color: #9de9f7; background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.32); }
.badge-scheduled { color: #b8e4ff; background: rgba(125, 211, 252, 0.12); border-color: rgba(125, 211, 252, 0.3); }
.badge-completed, .badge-active { color: #a5f0cc; background: rgba(61, 220, 151, 0.12); border-color: rgba(61, 220, 151, 0.32); }
.badge-cancelled, .badge-blocked { color: #ffb3b3; background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.32); }
.badge-lapsed { color: #d6c4ff; background: rgba(159, 140, 255, 0.12); border-color: rgba(159, 140, 255, 0.3); }
.badge-tier { color: #ffe6a8; background: rgba(255, 197, 61, 0.1); border-color: rgba(255, 197, 61, 0.3); }
.badge-none { color: var(--muted-2); background: rgba(255, 255, 255, 0.04); border-color: var(--line); }

/* ------------------------------------ toolbar -------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; min-width: 210px; }
.toolbar select.input { width: auto; min-width: 150px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 0.84rem; }

/* ------------------------------------ detail --------------------------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; font-size: 0.88rem; }
.kv dt { color: var(--muted-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 2px; }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--line); display: grid; gap: 14px; }
.timeline li { position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: -24px; top: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface-3); border: 2px solid var(--line);
}
.timeline li.is-status::before { border-color: var(--accent); background: var(--accent); }
.timeline .when { font-size: 0.75rem; color: var(--muted-2); }
.timeline .what { font-size: 0.88rem; }

.empty { padding: 26px; text-align: center; color: var(--muted-2); font-size: 0.9rem; }

/* ------------------------------------ dialog + toast ------------------- */
dialog.modal {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  border-radius: var(--radius); padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px -30px #000;
}
dialog.modal::backdrop { background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(3px); }
dialog.modal .modal-body { padding: 22px; }
dialog.modal h2 { margin-top: 0; }
dialog.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(12px);
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 0.86rem; box-shadow: 0 18px 40px -18px #000;
  opacity: 0; pointer-events: none; transition: opacity var(--t), transform var(--t); z-index: 60; max-width: calc(100vw - 32px);
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { border-color: rgba(255, 107, 107, 0.5); color: #ffc0c0; }

/* ------------------------------------ meta rows ------------------------ */
.person { display: flex; align-items: center; gap: 10px; }
.person .tiny { white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center; font-weight: 700; font-size: 0.78rem;
  background: rgba(34, 211, 238, 0.14); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.28);
}

/* ------------------------------------ responsive ----------------------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; padding: 12px 14px; }
  .side-nav { display: flex; gap: 6px; }
  .side-nav a { white-space: nowrap; padding: 7px 11px; }
  .side-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: 10px; }
  .side-foot .tiny { display: none; }
  .main { padding: 20px 16px 48px; }
  .detail-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 104px 1fr; }
}
@media (max-width: 720px) {
  /* Keep columns readable and let the wrapper scroll instead of crushing cells. */
  table.data { min-width: 620px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value { font-size: 1.45rem; }
  .toolbar select.input { flex: 1 1 auto; }
}
