:root {
  --ground: #F4F8FC;
  --surface: #FFFFFF;
  --surface-2: #EAF1FA;
  --ink: #16283F;
  --ink-soft: #51687F;
  --ink-faint: #8BA0B8;
  --accent: #2E7DD1;
  --accent-deep: #134C8C;
  --accent-soft: #E3EFFB;
  --on-accent: #FFFFFF;
  --line: #DDE7F2;
  --line-strong: #C6D6E8;
  --success: #1F8A5F;
  --success-bg: #E4F5EC;
  --danger: #C23B3B;
  --danger-bg: #FBEAEA;
  --warn: #A2731D;
  --warn-bg: #FBF1DC;
  --shadow: 0 1px 2px rgba(22, 40, 63, 0.05), 0 1px 1px rgba(22, 40, 63, 0.04);
  --shadow-md: 0 4px 16px rgba(22, 40, 63, 0.08);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0B1626;
    --surface: #101F35;
    --surface-2: #16283F;
    --ink: #EAF1FB;
    --ink-soft: #A9BEDA;
    --ink-faint: #7590B5;
    --accent: #6FAEEE;
    --accent-deep: #9BC7F5;
    --accent-soft: rgba(111, 174, 238, 0.14);
    --on-accent: #0B1626;
    --line: #223752;
    --line-strong: #2C4562;
    --success: #5FCB94;
    --success-bg: rgba(95, 203, 148, 0.14);
    --danger: #E37272;
    --danger-bg: rgba(227, 114, 114, 0.14);
    --warn: #E3B45C;
    --warn-bg: rgba(227, 180, 92, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font: 14.5px/1.55 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: "Manrope", sans-serif; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 23px; margin-bottom: 4px; }
h2 { font-size: 16.5px; margin: 30px 0 10px; color: var(--ink); }
.sub { color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }
.muted { color: var(--ink-soft); }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.nav-toggle-input { display: none; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 20px 20px 16px;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  flex: none;
}
.sidebar .brand svg { flex: none; color: var(--accent); }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav-group { margin-bottom: 4px; }
.nav-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 14px 10px 6px;
}
.nav a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }

.who {
  flex: none;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.who-info { flex: 1; min-width: 0; }
.who-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.who-actions a { font-size: 12.5px; color: var(--ink-faint); text-decoration: none; }
.who-actions a:hover, .who-actions a.active { color: var(--accent-deep); }
.who-name { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .role { display: inline-block; margin-top: 2px; font-size: 11px; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.who button.link { color: var(--ink-faint); font-size: 12.5px; }
.who button.link:hover { color: var(--danger); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-mobile {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; color: var(--ink); flex: none;
}
.brand-mobile { font-weight: 800; font-size: 15px; }
.scrim { display: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 30px 28px 60px; width: 100%; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 50; top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-md);
  }
  .nav-toggle-input:checked ~ .sidebar { transform: translateX(0); }
  .nav-toggle-input:checked ~ .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(10, 20, 35, .4);
  }
  .topbar-mobile { display: flex; }
  .wrap { padding: 22px 18px 48px; }
}

/* -------------------------------------------------------------- surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: var(--surface-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--ink-soft);
  border: 1px solid transparent;
}
.pill.member { background: var(--success-bg); color: var(--success); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 4px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 27px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }

/* ------------------------------------------------------------------ forms */
form.stack { display: grid; gap: 15px; max-width: 560px; }
form.stack label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 70px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

button, .btn {
  font: inherit; font-weight: 700; font-size: 13.5px; padding: 9px 17px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent-deep); background: var(--accent-deep); color: var(--on-accent);
  cursor: pointer; transition: opacity .12s ease;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
}
button:hover, .btn:hover { opacity: .88; text-decoration: none; }
.btn.secondary, button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.small, button.small { padding: 5px 11px; font-size: 12.5px; }
button.link { border: 0; background: none; color: var(--accent-deep); padding: 0; font-weight: 600; cursor: pointer; }
button.link:hover { opacity: .8; text-decoration: underline; }
button.danger, .btn.danger { border-color: var(--danger); background: var(--danger); }
.inline { display: inline; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.spacer { flex: 1; }

.error { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13.5px; }
.empty { color: var(--ink-faint); padding: 26px; text-align: center; font-size: 14px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--ink-faint); font-size: 12.5px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox input { width: auto; }

/* ------------------------------------------------------------------ login */
body.auth { background: var(--ground); }
body.auth::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(760px 420px at 18% -8%, var(--accent-soft), transparent 60%);
}
body.auth .wrap {
  min-height: 100vh; max-width: none; padding: 24px;
  display: flex; align-items: center; justify-content: center;
}
.login {
  max-width: 360px; width: 100%; margin: 0;
  box-shadow: var(--shadow-md);
}
.login .brand-mark { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; font-weight: 800; font-size: 16px; }
.login .brand-mark svg { color: var(--accent); }
