/* ==========================================================================
   PCB Campus Mission Hub — Base design system: tokens (dark/light), layout shell, navigation and shared components
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --gap: 20px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Light theme */
  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 108, 246, .08), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e5e7ef;
  --border-strong: #d5d9e4;
  --text: #11131a;
  --text-2: #3c4252;
  --muted: #6b7286;
  --faint: #9aa1b2;

  --accent: #6d5cf0;
  --accent-2: #0ea5c6;
  --accent-soft: rgba(109, 92, 240, .10);
  --accent-ring: rgba(109, 92, 240, .35);
  --gold: #c98a14;
  --gold-soft: rgba(201, 138, 20, .12);
  --success: #0f9f6e;
  --success-soft: rgba(15, 159, 110, .12);
  --warning: #c27c0e;
  --warning-soft: rgba(194, 124, 14, .12);
  --danger: #d9434e;
  --danger-soft: rgba(217, 67, 78, .10);
  --info: #2a7de1;
  --info-soft: rgba(42, 125, 225, .10);

  --shadow-sm: 0 1px 2px rgba(16, 20, 35, .05);
  --shadow: 0 1px 2px rgba(16, 20, 35, .04), 0 4px 16px rgba(16, 20, 35, .05);
  --shadow-lg: 0 12px 40px rgba(16, 20, 35, .14);
  --heat-0: #eceef4;
}

/* Native controls (date/time pickers, scrollbars) follow the app theme, not the device theme.
   Without this a device in dark mode draws a light calendar icon on the light theme's white inputs. */
:root, [data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

[data-theme="dark"] {
  --bg: #0a0b10;
  --bg-grad: radial-gradient(1000px 520px at 100% -10%, rgba(124, 108, 246, .12), transparent 60%),
             radial-gradient(800px 400px at -10% 110%, rgba(34, 211, 238, .05), transparent 60%);
  --surface: #12141b;
  --surface-2: #171a23;
  --surface-3: #1e222d;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .12);
  --text: #eceef3;
  --text-2: #c3c8d4;
  --muted: #8a91a5;
  --faint: #5f6678;

  --accent: #8b7cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(139, 124, 255, .14);
  --accent-ring: rgba(139, 124, 255, .45);
  --gold: #f2b84b;
  --gold-soft: rgba(242, 184, 75, .12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --heat-0: #1b1e28;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.xsmall { font-size: 11.5px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
[data-theme="dark"] .theme-light-only, [data-theme="light"] .theme-dark-only { display: none; }
.hidden { display: none !important; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  padding: 16px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 18px var(--accent-ring);
}
.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.sidebar .sidebar-close { display: none; }

.nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 0 10px 4px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--text); }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-link.is-active .icon { color: var(--accent); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; border-radius: var(--radius-pill); padding: 0 7px; line-height: 18px; }

.sidebar-level {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); transition: border-color .2s;
}
.sidebar-level:hover { border-color: var(--accent-ring); }
.sidebar-level-top { display: flex; align-items: center; justify-content: space-between; }
.lvl-chip {
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .04em;
  padding: 2px 8px; border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 17px; font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.content { flex: 1; padding: 24px 28px 40px; width: 100%; max-width: 1440px; margin: 0 auto; }
.content:focus { outline: none; }
.app-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding: 16px 28px 24px; font-size: 12px; color: var(--faint); max-width: 1440px; width: 100%; margin: 0 auto;
}
.page-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.sp-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; margin-right: 4px;
  border-radius: var(--radius-pill); background: var(--gold-soft); color: var(--gold); font-size: 13px;
}
.sp-chip strong { font-family: var(--font-display); color: var(--text); }
.sp-chip small { font-weight: 600; font-size: 10.5px; letter-spacing: .06em; }
.sp-chip .icon { width: 16px; height: 16px; }

.icon-btn {
  position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--text-2); transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.dot-count {
  position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-pill); background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; flex: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #000), var(--accent-2));
  color: #fff; font-family: var(--font-display); font-weight: 700; letter-spacing: .02em;
}
.avatar-sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 20px; font-size: 24px; }
.avatar-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: var(--radius);
  background: transparent; border: 1px solid transparent; cursor: pointer;
}
.avatar-btn:hover { background: var(--surface-3); }
.avatar-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.avatar-meta strong { font-size: 13px; }
.avatar-meta small { font-size: 11px; color: var(--muted); }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none;
  transform-origin: top right; animation: pop .14s var(--ease);
}
.dropdown.is-open .dropdown-menu { display: block; }
.dropdown-wide { width: 360px; max-width: calc(100vw - 24px); }
.dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: 0; cursor: pointer; text-align: left; color: var(--text-2);
}
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item.danger:hover { color: var(--danger); background: var(--danger-soft); }
.dropdown-user { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-user span:last-child { display: flex; flex-direction: column; min-width: 0; }
.dropdown-user small { color: var(--muted); }
.dropdown-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; margin-top: 4px; border-top: 1px solid var(--border); color: var(--accent); font-weight: 500; font-size: 13px; }
.dropdown-foot .icon { width: 15px; height: 15px; }
.dropdown-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; color: var(--muted); }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--surface-3); }
.notif-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: transparent; flex: none; }
.notif-item.is-unread .notif-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.notif-body { display: flex; flex-direction: column; min-width: 0; }
.notif-body strong { font-size: 13px; font-weight: 600; }
.notif-body small { color: var(--muted); font-size: 12.5px; }
.notif-body em { font-style: normal; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; font-weight: 500; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Layout grid ---------- */
.grid { display: grid; gap: var(--gap); }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.col-8 { grid-column: span 8; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; } .col-7 { grid-column: span 7; } .col-5 { grid-column: span 5; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--gap); }
.section-gap { margin-top: var(--gap); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); min-width: 0;
}
.card-pad { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-header h2, .card-title { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-header h2 .icon { color: var(--muted); width: 17px; height: 17px; }
.card-header .link { font-size: 12.5px; color: var(--accent); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.card-header .link .icon { width: 14px; height: 14px; }
.card-body { padding: 16px 20px 20px; }
.card-interactive { transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; }
.card-interactive:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* KPI tiles */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-icon.gold { background: var(--gold-soft); color: var(--gold); }
.kpi-icon.success { background: var(--success-soft); color: var(--success); }
.kpi-icon.info { background: var(--info-soft); color: var(--info); }
.kpi-icon.cyan { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); }
.kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-foot .up { color: var(--success); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px -4px var(--accent-ring); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}

/* ---------- Pills, chips, tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; letter-spacing: .01em;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-neutral { background: var(--surface-3); color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--radius-xs);
  font-size: 12px; color: var(--text-2); background: var(--surface-3); white-space: nowrap;
}
.tag .icon { width: 13px; height: 13px; color: var(--muted); }
.tag-sp { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.tag-sp .icon { color: var(--gold); }
.diff { display: inline-flex; gap: 3px; align-items: center; }
.diff i { width: 5px; height: 12px; border-radius: 2px; background: var(--surface-3); }
.diff-low i:nth-child(-n+1), .diff-medium i:nth-child(-n+2), .diff-high i:nth-child(-n+3) { background: currentColor; }
.diff-low { color: var(--success); } .diff-medium { color: var(--warning); } .diff-high { color: var(--danger); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .icon { width: 15px; height: 15px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--muted); line-height: 18px; }
.tab.is-active .count { background: var(--accent-soft); color: var(--accent); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border); overflow-x: auto; max-width: 100%; }
.segmented a { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.progress > span {
  display: block; height: 100%; border-radius: inherit; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .9s var(--ease);
}
.progress-sm { height: 5px; }
.level-reqs { display: grid; gap: 8px; width: 100%; }
.level-req .row-between { margin-bottom: 4px; }
.level-req .icon { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
.level-req.is-met .num .icon { color: var(--success); margin: 0 0 0 2px; }
.progress-lg { height: 10px; }
.progress.gold > span { background: linear-gradient(90deg, #d99a1e, var(--gold)); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }

.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--surface-3); }
.ring .ring-bar { stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring-label strong { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.ring-label small { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: var(--gap); }
.toolbar .grow { flex: 1; min-width: 200px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a91a5' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
/* Date & time pickers: visible, clickable calendar/clock icon in both themes */
.input[type="date"], .input[type="datetime-local"], .input[type="time"], .input[type="month"] { cursor: text; }
.input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .85; padding: 4px; margin-right: -4px; border-radius: 6px; transition: opacity .15s, background-color .15s; }
.input::-webkit-calendar-picker-indicator:hover, .input:focus::-webkit-calendar-picker-indicator { opacity: 1; background-color: var(--accent-soft); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 38px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.qty button { width: 34px; height: 36px; border: 0; background: var(--surface-3); cursor: pointer; display: grid; place-items: center; }
.qty input { width: 52px; height: 36px; border: 0; text-align: center; background: var(--surface); }

/* Password strength meter */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-meter span { height: 4px; border-radius: 4px; background: var(--surface-3); transition: background .2s; }
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--info); }
.pw-meter[data-score="4"] span { background: var(--success); }


/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-strong { font-weight: 600; }
.table .t-right { text-align: right; }
.pts-pos { color: var(--success); font-weight: 600; font-family: var(--font-display); }
.pts-neg { color: var(--danger); font-weight: 600; font-family: var(--font-display); }

/* ---------- Empty states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.empty-ic .icon { width: 24px; height: 24px; }
.empty h3 { color: var(--text); font-size: 15px; }
.empty p { max-width: 380px; font-size: 13px; }

/* ---------- Detail layout ---------- */
.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.detail-head .mission-ic { width: 52px; height: 52px; border-radius: 14px; }
.detail-head h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.25; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fact { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.fact small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.fact small .icon { width: 14px; height: 14px; }
.fact strong { display: block; margin-top: 4px; font-size: 14px; }
.prose { color: var(--text-2); white-space: pre-line; }
.prose-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; margin-bottom: 6px; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 13px; background: var(--info-soft); color: var(--text-2); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.callout .icon { color: var(--info); margin-top: 1px; }
.callout.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.callout.warning .icon { color: var(--warning); }
.callout.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.callout.success .icon { color: var(--success); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger .icon { color: var(--danger); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 20px); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.page-link { min-width: 34px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); display: grid; place-items: center; border: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.page-link:hover { border-color: var(--border-strong); }
.page-link.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-link.is-disabled { opacity: .4; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }

/* ---------- SweetAlert2 theming ---------- */
.swal2-popup.cmh-popup {
  background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important; font-family: var(--font-ui); padding: 24px 22px 22px;
}
.swal2-popup.cmh-popup .swal2-title { color: var(--text); font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.swal2-popup.cmh-popup .swal2-html-container { color: var(--text-2); font-size: 14px; }
.swal2-popup.cmh-popup .swal2-input, .swal2-popup.cmh-popup .swal2-textarea {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: none; font-size: 14px;
}
.swal2-popup.cmh-popup .swal2-textarea { margin: 14px 0 0; width: 100%; }
.swal2-popup.cmh-popup .swal2-validation-message { background: var(--danger-soft); color: var(--danger); }
.swal2-popup.cmh-popup .swal2-actions { gap: 8px; }
.swal2-popup.cmh-toast { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border); box-shadow: var(--shadow-lg) !important; border-radius: var(--radius) !important; }
.swal2-popup.cmh-toast .swal2-title { color: var(--text); font-size: 14px; }
.swal2-container.swal2-backdrop-show { background: rgba(5, 6, 10, .55) !important; backdrop-filter: blur(3px); }
.swal-xp { font-family: var(--font-display); font-size: 40px; font-weight: 700; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.swal-summary { display: grid; gap: 8px; text-align: left; margin-top: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.swal-summary div { display: flex; justify-content: space-between; gap: 12px; }
.swal-summary span { color: var(--muted); }
.lightbox-img { max-height: 70vh; width: auto; margin: 0 auto; border-radius: var(--radius); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .45s var(--ease) both; }
.reveal:nth-child(2) { animation-delay: .04s; } .reveal:nth-child(3) { animation-delay: .08s; } .reveal:nth-child(4) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Profile pictures */
.avatar-photo { overflow: hidden; padding: 0; background: var(--surface-3); }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xl { width: 96px; height: 96px; border-radius: 24px; }
.photo-editor { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.photo-editor form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Modal forms (Add / Edit) ---------- */
.cmh-modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: flex-start; justify-content: center; padding: 4vh 16px; }
.cmh-modal.is-open { display: flex; }
.cmh-modal-backdrop { position: absolute; inset: 0; background: rgba(5, 6, 12, .55); backdrop-filter: blur(3px); }
.cmh-modal-panel { position: relative; width: min(1180px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); overflow: hidden; animation: cmh-modal-in .18s ease-out; }
@keyframes cmh-modal-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.cmh-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.cmh-modal-head h2 { font-family: var(--font-display); font-size: 18px; }
.cmh-modal-head .icon-btn { font-size: 24px; line-height: 1; flex: none; }
.cmh-modal-body { overflow-y: auto; padding: 20px; overscroll-behavior: contain; }
.cmh-modal-body:focus { outline: none; }
.cmh-modal-body .sticky-side { position: static; }
.cmh-modal-loading { display: grid; place-items: center; min-height: 240px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: cmh-spin .8s linear infinite; }
@keyframes cmh-spin { to { transform: rotate(360deg); } }
html.modal-open, html.modal-open body { overflow: hidden; }
@media (max-width: 720px) {
  .cmh-modal { padding: 0; }
  .cmh-modal-panel { max-height: 100vh; height: 100%; border-radius: 0; border: 0; }
  .cmh-modal-body { padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }
}
