/* Chitko admin (docs/ADMIN-PLAN.md): the app's dark palette (src/constants/color-themes.ts). */
:root {
  color-scheme: dark;
  --page: #11100f;
  --card: #1d1b1a;
  --tile: #2a2624;
  --tile-strong: #36302d;
  --line: #34302d;
  --text: #f7f2ee;
  --soft: #b5ada7;
  --muted: #8f8781;
  --faint: #5f5853;
  --accent: #ff6a4d;
  --bar: #f0603f;
  --bar-hover: #ff7d63;
  --danger: #ff5048;
  --good: #6ee7c5;
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button, input, select { font: inherit; color: inherit; }

.app { min-height: 100vh; }

/* Sign-in and the new passkey */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 28px;
  padding: 32px 24px 28px;
  text-align: center;
}
.gate-logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 18px; }
.gate h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.3px; }
.gate p { margin: 0 0 22px; color: var(--soft); }
.gate .note { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.gate .error { margin: 16px 0 0; color: var(--danger); font-size: 14px; min-height: 20px; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--tile);
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { background: var(--tile-strong); }
.button:disabled { opacity: 0.45; cursor: default; }
.button.primary { background: var(--text); color: #11100f; }
.button.primary:hover { background: #fff; }
.button.wide { width: 100%; }
.button.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }
.button.danger:hover { background: rgba(255, 80, 72, 0.12); }
.button.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(17, 16, 15, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.tab {
  padding: 8px 12px;
  border-radius: 11px;
  color: var(--soft);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--tile); color: var(--text); }
.signout { margin-left: 4px; }

@media (max-width: 640px) {
  .top-inner { flex-wrap: wrap; }
  .brand span { display: none; }
  .tabs { margin-left: 0; order: 3; width: 100%; }
  .signout { margin-left: auto; }
}

/* Page */
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }
.page-title { margin: 6px 0 4px; font-size: 26px; letter-spacing: -0.4px; word-break: break-word; }
.page-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; word-break: break-word; }
.back { display: inline-block; margin: 2px 0 8px; color: var(--soft); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--text); }

.section { margin: 26px 0 0; }
.section > h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -0.2px; }
.section > .hint { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }
.grid-2 > .card + .card { margin-top: 0; }
.card .table-wrap + h3 { margin-top: 20px; }
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--soft); font-weight: 650; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--card); border-radius: 18px; padding: 14px 16px; min-width: 0; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 750; letter-spacing: -0.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--soft); font-size: 13px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
@media (max-width: 400px) { .grid-2 { grid-template-columns: 1fr; } }

/* Meters: how much of a budget is used */
.meter { height: 8px; background: var(--tile); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.meter > i { display: block; height: 100%; background: var(--bar); border-radius: 4px; min-width: 2px; }

/* Bars by day */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.on { fill: var(--bar-hover); }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--tile-strong);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  display: none;
}
.chart-empty { color: var(--muted); font-size: 14px; padding: 18px 0 6px; }
details.data { margin-top: 10px; }
details.data summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td a { text-decoration-color: var(--faint); text-underline-offset: 3px; }
td a:hover { text-decoration-color: var(--soft); }
.muted { color: var(--muted); }
.soft { color: var(--soft); }

/* Accounts */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.search {
  flex: 1 1 240px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 0;
  background: var(--card);
  outline: none;
}
.search:focus { box-shadow: inset 0 0 0 1.5px var(--faint); }
.select {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 0;
  background: var(--card);
}
.rows { display: grid; gap: 8px; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--card);
  text-decoration: none;
}
.row:hover { background: #24211f; }
.row .email { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .cell { font-size: 14px; }
.row .cell small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row .email { grid-column: 1 / -1; }
}
.count { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

/* Lists inside cards */
.list { display: grid; gap: 0; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 650; word-break: break-word; }
.item-sub { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px; background: var(--tile); color: var(--soft); margin-left: 6px; vertical-align: 1px; }
.tag.good { color: var(--good); }
.tag.warn { color: var(--accent); }

.form-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.input {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 0;
  background: var(--tile);
  outline: none;
  min-width: 0;
}
.input:focus { box-shadow: inset 0 0 0 1.5px var(--faint); }
.input.code { width: 9.5em; letter-spacing: 3px; font-variant-numeric: tabular-nums; }
.input.money { width: 7em; }
.input.email { flex: 1 1 240px; }

.danger-zone { box-shadow: inset 0 0 0 1px rgba(255, 80, 72, 0.35); }
.step { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step-number {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 13px;
  background: var(--tile);
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step.done .step-number { background: var(--good); color: #11100f; }
.step-body { flex: 1; min-width: 0; }
.step-body p { margin: 0; color: var(--soft); font-size: 14px; }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.failed { color: var(--danger); padding: 24px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #11100f;
  font-weight: 650;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* «PRO» as in the app (src/features/pro/pro-tag.tsx): the logo's colours round a plate. */
.pro-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  margin-left: 8px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    conic-gradient(#ff5048, #6ee7c5, #4aa3ff, #9a5cff, #ffd43b, #ff9a3c, #ff5048) border-box;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  line-height: 1;
  vertical-align: 3px;
  white-space: nowrap;
  flex: none;
}
.pro-badge.small { height: 17px; font-size: 9.5px; padding: 0 5px; vertical-align: 1px; }
.pro-badge.test { background: transparent; border: 1.5px dashed var(--faint); color: var(--muted); }
.page-title .pro-badge { height: 24px; font-size: 12px; vertical-align: 5px; }
.row .email { display: flex; align-items: center; min-width: 0; }
.row .email-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card h3.gap { margin-top: 18px; }
.card .select { background: var(--tile); }
