/* Same language as the Mini App: system font, near-black ink and primary buttons, quiet neutrals,
   radius 12–16, soft shadows. Admin stays denser than the Mini App. */
:root {
  color-scheme: light;
  --bg: #f7f7f7;
  --paper: #ffffff;
  --ink: #222222;
  --muted: #6a6a6a;
  --faint: #b0b0b0;
  --line: #ebebeb;
  --line-2: #dddddd;
  --fill: #f5f5f5;
  --accent: #222222;
  --gold: #f6c343;
  --success: #146c3c;
  --success-bg: #e8f5ee;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-2); }
a:hover { text-decoration-color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1 { font-size: 26px; line-height: 32px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--paper); border-right: 1px solid var(--line); padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.04em; padding: 4px 10px 22px; }
.brand::before {
  content: ""; width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='6.2'/%3E%3Cpath d='M12 8.8V12l2.1 1.4'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.brand small { display: block; color: var(--muted); font-weight: 500; letter-spacing: 0; font-size: 12px; line-height: 14px; }
.side a { display: block; padding: 9px 12px; border-radius: 10px; color: var(--ink); margin-bottom: 2px; text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--fill); }
.side a.active { background: var(--fill); font-weight: 800; box-shadow: inset 3px 0 0 var(--ink); }
.main { padding: 24px 28px 40px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .muted { margin-top: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
input, select, textarea { background: var(--paper); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; min-height: 38px; color: var(--ink); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input[type="checkbox"] { min-height: 0; accent-color: var(--ink); }
textarea { min-height: 72px; width: 100%; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 10px;
  padding: 8px 14px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #000; }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); background: var(--paper); }
.btn:disabled, .btn:disabled:hover { background: #d4d4d4; border-color: #d4d4d4; color: #fff; cursor: not-allowed; }
.btn.ghost:disabled, .btn.ghost:disabled:hover { background: var(--paper); border-color: var(--line); color: var(--faint); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.bulk-bar label { flex: 1 1 260px; }
.bulk-count { align-self: center; min-width: 110px; font-weight: 700; font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: #efefef; }
.segmented .btn.ghost { border-color: transparent; background: transparent; min-height: 32px; padding: 5px 12px; color: var(--muted); }
.segmented .btn.ghost.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 4px; }
.kpi, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi p { margin: 0; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; line-height: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.panel { margin-top: 14px; }
.panel h2 { font-size: 16px; line-height: 22px; font-weight: 800; margin: 0 0 10px; }
.panel .topbar h2 { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.live-swatch { background: repeating-linear-gradient(-45deg, #2a78d6, #2a78d6 2px, #d5e4f6 2px, #d5e4f6 4px); }
.chart-table { margin-top: 12px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; width: max-content; }
.chart-table .table-wrap { overflow: auto; margin-top: 8px; }
td a { color: var(--ink); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #fafafa; font-size: 12px; color: var(--muted); font-weight: 700; }
th a { color: var(--muted); text-decoration: none; }
th a:hover { color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
tr[data-person] { cursor: pointer; }
tr[data-person]:hover { background: #fafafa; }
.meter { width: 72px; height: 6px; background: #ececec; border-radius: 99px; display: inline-block; vertical-align: middle; margin-right: 8px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.chip { display: inline-block; background: var(--gold); color: #3d2a00; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.reason { display: inline-block; border: 1px solid var(--line-2); border-radius: 99px; padding: 1px 9px; margin-right: 4px; color: var(--muted); font-size: 12px; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; color: var(--muted); }
.banner { background: #fff7ed; border: 1px solid #fde3c3; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.ok { background: var(--success-bg); border-color: #bfe5cf; color: var(--success); font-weight: 600; }
.budget { height: 12px; background: #ececec; border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.budget span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(400px, 100%); }
.login h1 { margin-bottom: 2px; }
.login label { margin-top: 12px; }
.sheet {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 100%);
  background: var(--paper); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0, 0, 0, 0.1);
  padding: 20px; overflow: auto; z-index: 5;
}
.sheet[hidden] { display: none; }
.sheet form, .stack { display: grid; gap: 10px; margin-top: 12px; }
.panel > form:not(.inline), .stack { display: grid; gap: 12px; max-width: 640px; }
.panel > form:not(.inline) > .btn, .stack > .btn { justify-self: start; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 4; }
.scrim[hidden] { display: none; }
.muted { color: var(--muted); }
.caption { color: var(--muted); font-size: 12px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
details.panel > summary { cursor: pointer; font-weight: 800; }
.side a .count { float: right; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 12px; line-height: 22px; text-align: center; font-weight: 800; }
.chip.soft { background: var(--fill); color: var(--ink); }
.chip.ok { background: var(--success-bg); color: var(--success); }

/* Join requests */
.join-list { display: grid; gap: 14px; }
.join-card { display: grid; gap: 16px; margin-top: 0; padding: 20px; }
.join-head { display: flex; gap: 14px; align-items: center; }
.join-head h2 { margin: 0; font-size: 17px; }
.join-head p { margin: 2px 0 0; }
.join-head .chip { margin-left: auto; }
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 800; letter-spacing: 0.02em; }
.join-body { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); gap: 24px; align-items: start; padding-top: 16px; border-top: 1px solid var(--line); }
.join-card .facts { margin: 0; }
.join-actions { display: grid; gap: 12px; }
.join-actions form.inline label { flex: 1 1 180px; }
.join-actions form.inline select, .join-actions form.inline input { width: 100%; }
form.reject { border-top: 1px dashed var(--line-2); padding-top: 12px; }
.pilot { min-width: 240px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.pilot p { margin: 0 0 8px; }
.meter.wide { width: 100%; height: 8px; margin: 0; }
.empty { text-align: center; padding: 36px 12px; }
.empty p { margin: 6px 0 0; }

@media (max-width: 1000px) {
  .join-body { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: flex; gap: 4px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .side a { white-space: nowrap; }
  .side a.active { box-shadow: inset 0 -3px 0 var(--ink); }
  .brand { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px; }
}

/* v3 */
.kpi-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 16px; }
.kpi-meta.trend { color: var(--ink); font-weight: 600; }
.rule-banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #f3f6fb; border: 1px solid #d9e3f2; font-size: 14px; line-height: 20px; }
.review-table table { font-size: 14px; }
.review-table td, .review-table th { font-size: 14px; }
.review-table th { font-size: 13px; }
.review-table .reason { font-size: 13px; }
.review-table .group-row th { background: #fafafa; text-align: left; font-weight: 800; padding-top: 12px; }
.reason { cursor: help; }
label.needs select { border-color: #d97706; box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
