/* BEESBOOK admin website — one small stylesheet, no build step, no external files.
   Colours and sizes are the mobile app's own tokens (mobile/src/theme): the logo's amber and navy, never purple. */

:root {
  --primary: #f59e0b;
  --primary-dark: #b45309;
  --primary-light: #fef3c7;
  --gold: #fcd34d;
  --ink: #0f172a;
  --surface: #f1f5f9;
  --white: #ffffff;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --income: #16a34a;
  --income-light: #dcfce7;
  --expense: #dc2626;
  --expense-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --topbar: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary-dark); }
h1 { font-size: 28px; line-height: 34px; font-weight: 800; margin: 0 0 4px; }
h2 { font-size: 20px; line-height: 26px; font-weight: 700; margin: 0; }
h3 { font-size: 16px; line-height: 21px; font-weight: 700; margin: 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- top bar: the logo lives here */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--ink); color: var(--white);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; }
.brand img { width: 40px; height: 40px; flex-shrink: 0; }
.brand-name { font-weight: 800; letter-spacing: 0.8px; font-size: 18px; line-height: 20px; color: var(--ink); }
.brand-name span { color: var(--primary-dark); }
.brand-name--light { color: var(--white); }
.brand-name--light span { color: var(--gold); }
.brand small { display: block; font-size: 11px; line-height: 13px; font-style: italic; font-weight: 600; color: var(--gold); }
.topbar-spacer { flex: 1; }
.topbar .who { font-size: 14px; color: #cbd5e1; text-align: right; line-height: 1.2; }
.topbar .who strong { display: block; color: var(--white); }
.menu-btn { display: none; background: transparent; border: 0; color: var(--white); padding: 6px; border-radius: var(--radius-sm); cursor: pointer; }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell: sidebar + content */
.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--white); border-right: 1px solid var(--border);
  padding: 12px; position: sticky; top: var(--topbar); align-self: flex-start;
  height: calc(100vh - var(--topbar)); overflow-y: auto;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--text-2); font-weight: 600; text-decoration: none;
}
.nav a:hover { background: var(--surface); }
.nav a.active { background: var(--primary-light); color: var(--primary-dark); }
.nav .group { margin: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.nav form { margin: 0; }
.nav button { width: 100%; background: transparent; border: 0; font: inherit; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); color: var(--text-2); font-weight: 600; }
.nav button:hover { background: var(--surface); }
.content { flex: 1; min-width: 0; padding: 24px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--text-2); margin: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- cards and grids */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card > header p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat { padding: 14px 16px; }
.stat__label { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--primary-dark); }
.stat__value { font-size: 28px; line-height: 34px; font-weight: 800; }
.stat__sub { font-size: 13px; color: var(--text-2); }
.stat--warn .stat__value { color: var(--warning); }
.stat--bad .stat__value { color: var(--expense); }
.stat--good .stat__value { color: var(--income); }
.kv { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover td { background: #f8fafc; }
td .sub { display: block; font-size: 13px; color: var(--text-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- badges, buttons */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 18px; white-space: nowrap; }
.badge--success { background: var(--income-light); color: var(--income); }
.badge--danger { background: var(--expense-light); color: var(--expense); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--primary { background: var(--primary-light); color: var(--primary-dark); }
.badge--muted { background: var(--surface); color: var(--text-2); }
.badge--dark { background: var(--ink); color: var(--white); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-md); border: 1px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--ink); }
.btn-primary:hover { background: #d97706; }
.btn-outline { background: var(--white); border-color: var(--primary); color: var(--primary-dark); }
.btn-outline:hover { background: var(--primary-light); }
.btn-secondary { background: var(--white); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface); }
.btn-danger { background: var(--expense); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > label, .label { font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.input, select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
textarea { min-height: 96px; resize: vertical; }
.help { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }
.check span { font-weight: 600; }
.check small { display: block; font-weight: 400; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 180px; }
.filters .field.grow { flex: 1; min-width: 240px; }

/* ---------------------------------------------------------------- alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-md); border: 1px solid; margin-bottom: 16px; }
.alert strong { display: block; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert--success { background: var(--income-light); border-color: #86efac; color: #14532d; }
.alert--error { background: var(--expense-light); border-color: #fca5a5; color: #7f1d1d; }
.alert--warning { background: var(--warning-light); border-color: #fcd34d; color: #78350f; }
.alert--info { background: var(--primary-light); border-color: #fcd34d; color: #78350f; }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; color: var(--text-2); font-size: 14px; }
.pager nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager .page {
  min-width: 38px; padding: 6px 12px; text-align: center; text-decoration: none;
  color: var(--text); background: var(--white); border: 1px solid var(--border); border-radius: 10px;
}
.pager a:hover { background: var(--primary-light); border-color: var(--primary); }
.pager .current { background: var(--primary); border-color: var(--primary); color: var(--ink); font-weight: 700; }
.pager .disabled { opacity: 0.4; }

/* ---------------------------------------------------------------- bar chart (plain CSS, no script) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.bars .col { position: relative; flex: 1; min-width: 4px; height: 100%; display: flex; align-items: flex-end; }
.bars .bar { width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .bar--fail { position: absolute; left: 0; bottom: 0; background: var(--expense); border-radius: 0; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------------------------------------------------------------- support tools (user page) */
details.tool { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--white); margin-bottom: 10px; }
details.tool > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.tool > summary::-webkit-details-marker { display: none; }
details.tool > summary::after { content: "+"; font-size: 20px; color: var(--primary-dark); }
details.tool[open] > summary::after { content: "–"; }
details.tool > .body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
details.tool.danger > summary { color: var(--expense); }
/* A small "open to confirm" control inside a table row (e.g. Make inactive). It opens in place, so the table never clips it. */
details.pop { display: inline-block; vertical-align: top; text-align: left; }
details.pop > summary { list-style: none; cursor: pointer; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop .pop__body { width: 270px; max-width: 100%; margin-top: 8px; padding: 12px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); white-space: normal; }
details.pop .pop__body p { font-size: 13px; }
details.meta > summary { cursor: pointer; color: var(--primary-dark); font-size: 13px; }
details.meta pre { margin: 6px 0 0; padding: 8px 10px; background: var(--surface); border-radius: var(--radius-sm); font-size: 12px; white-space: pre-wrap; word-break: break-word; max-width: 420px; }

/* ---------------------------------------------------------------- sign-in page */
.auth-wrap { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px 24px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 18px; }
.auth-card .btn { width: 100%; }
.auth-foot { text-align: center; margin-top: 14px; font-size: 14px; color: var(--text-2); }

/* ---------------------------------------------------------------- narrower screens */
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; left: -270px; top: var(--topbar); z-index: 40; transition: left 0.2s; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25); }
  body.nav-open .sidebar { left: 0; }
  .content { padding: 16px; }
  .topbar .who { display: none; }
  .brand small { display: none; }
  .kv { grid-template-columns: 1fr; }
}
