/* Kardio admin dashboard — extends site.css (brand tokens live there). Dark-mode aware via the
   same :root variables; mobile first. */

:root {
  --success: #27784B;
  --success-soft: #DDEFE3;
  --danger: #C93E1F;
  --danger-soft: #FBE3DC;
  --warning-soft: #FFF1D6;
  --chart-primary: var(--navy);
  --chart-accent: var(--amber);
  --chart-grid: rgba(11, 54, 78, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --success: #6FCF97;
    --success-soft: #1E3A2E;
    --danger: #F79A86;
    --danger-soft: #3A2620;
    --warning-soft: #33301F;
    --chart-primary: var(--amber);
    --chart-accent: var(--coral);
    --chart-grid: rgba(245, 239, 230, 0.1);
  }
}

.admin-main {
  padding-top: 24px;
  padding-bottom: 48px;
}

.admin-nav {
  align-items: center;
  gap: 12px;
}

.admin-badge {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-primary);
  background: var(--primary);
  border-radius: 999px;
  padding: 4px 10px;
}

.admin-who {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.88rem; }
[hidden] { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border-strong); }
.btn-outline:not(:disabled):hover { background: var(--bg-subtle); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--primary); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 0.92rem; }

/* Cards */
.admin-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 0 16px;
}

.admin-card h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.card-head h2 { margin: 0; }

/* Sign-in */
.signin-card {
  max-width: 420px;
  margin: 32px auto;
}

.signin-card h1 { font-size: 1.6rem; }

form label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin: 12px 0 4px;
}

input[type="email"],
input[type="password"],
select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

form .btn { width: 100%; margin-top: 16px; }
.signin-card .btn-outline { width: 100%; }

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 16px 0;
}

.or::before,
.or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.error {
  color: var(--danger);
  font-weight: 600;
  margin: 12px 0 0;
}

.error.banner {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 0 0 16px;
}

/* Dashboard head */
.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-head h1 { font-size: 1.8rem; margin: 0; }
.dash-head .muted { margin: 4px 0 0; font-size: 0.9rem; }

.dash-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.range-label {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.range-label select { width: auto; min-width: 120px; }

/* Totals */
.totals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 720px) {
  .totals { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-label small { font-weight: 400; }

/* Charts */
.chart-wrap {
  position: relative;
  height: 240px;
}

.donut-wrap {
  position: relative;
  height: 160px;
  margin-bottom: 8px;
}

.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2 .admin-card,
.grid-3 .admin-card { margin: 0; }

@media (min-width: 820px) {
  .grid-2 { grid-template-columns: 3fr 2fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Tables */
.table-wrap { overflow-x: auto; }

table { font-size: 0.92rem; margin: 0 0 8px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.pct { font-weight: 700; border-radius: 6px; }
td.none { color: var(--text-muted); font-weight: 400; }

/* Funnel */
.funnel {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.funnel li { display: grid; gap: 4px; }

.funnel .label {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 600;
}

.funnel .bar {
  height: 14px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.funnel .bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  min-width: 2px;
}

/* Key lists */
.key-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.92rem;
}

.key-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.key-list li:last-child { border-bottom: 0; }

.key-list .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
}

/* AI */
.ai-totals {
  display: flex;
  gap: 24px;
  margin-bottom: 8px;
}

.ai-totals > div { display: flex; flex-direction: column; }

/* Reports */
.reports,
.feedback {
  list-style: none;
  padding: 0;
  margin: 0;
}

.report {
  display: grid;
  gap: 6px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.report:last-child { border-bottom: 0; }

.report .row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text);
}

.chip.reason { background: var(--warning-soft); }
.chip.status-resolved { background: var(--success-soft); color: var(--success); }
.chip.status-dismissed { background: var(--bg-subtle); color: var(--text-muted); }
.chip.status-open { background: var(--danger-soft); color: var(--danger); }

.report .target { font-weight: 700; }
.report .target.missing { color: var(--text-muted); font-weight: 400; font-style: italic; }
.report .details { color: var(--text-muted); font-size: 0.92rem; }
.report .meta { color: var(--text-muted); font-size: 0.82rem; }
.report .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

.feedback li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.feedback li:last-child { border-bottom: 0; }
.feedback .meta { color: var(--text-muted); font-size: 0.82rem; }

.hint { margin-top: 24px; }

/* Confirm sheet */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 54, 78, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

@media (min-width: 600px) {
  .confirm-backdrop { align-items: center; }
}

.confirm-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 12px 32px var(--shadow);
}

.confirm-sheet h2 { margin: 0 0 6px; font-size: 1.2rem; }
.confirm-sheet p { margin: 0 0 16px; white-space: pre-line; }
.confirm-actions { display: grid; gap: 8px; }
.confirm-actions .btn { width: 100%; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 60;
  max-width: calc(100% - 32px);
}

.toast.error { background: var(--danger); }

.footer-admin { opacity: 0.7; }
