/* ---------- THEME ---------- */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #eef1f8;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --line: rgba(15, 30, 60, 0.09);
  --line-strong: rgba(15, 30, 60, 0.18);
  --text: #0f1b33;
  --muted: #5a6885;
  --faint: #8592ad;
  --accent: #0284c7;
  --accent-2: #0891b2;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px -18px rgba(15, 30, 60, 0.35);
  color-scheme: light;
}
:root[data-theme="light"] .btn { background: var(--panel); }
:root[data-theme="light"] .btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
:root[data-theme="light"] .btn.danger { color: #b91c1c; background: rgba(248, 113, 113, 0.1); }

body { background: var(--bg); min-height: 100vh; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.wrap-gap { flex-wrap: wrap; margin-top: 16px; }
.stack { display: grid; gap: 18px; align-content: start; }
.hint { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.error { color: var(--red); font-size: 14px; margin: 12px 0 0; }
code { font-size: 12px; background: rgba(127, 127, 127, 0.15); padding: 1px 5px; border-radius: 5px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.brand b { color: var(--accent); }
.brand .logo { width: 30px; height: 30px; flex: none; }

/* ---------- BOOT ---------- */
.boot, .center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- AUTH ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(56, 189, 248, 0.25), transparent 60%),
    linear-gradient(160deg, #06101f, #0d1d3a);
  color: #e8eefb;
}
.auth-side .brand b { color: #38bdf8; }
.auth-side h1 { font-family: var(--font-display); font-size: clamp(34px, 4vw, 52px); letter-spacing: -0.03em; line-height: 1; margin: 0 0 14px; }
.auth-side p { color: #9aaacb; max-width: 420px; margin: 0; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: center; }
.auth-points li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 10px #38bdf8; }
.auth-side .fine { font-size: 13px; color: #6b7a9a; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(420px, 100%); }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.note { font-size: 13px; padding: 12px 14px; border-radius: 10px; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); margin-bottom: 18px; color: var(--text); }
.note ul { margin: 6px 0 0; padding-left: 18px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; padding: 0; justify-self: start; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; gap: 20px; }
  .auth-points, .auth-side .fine { display: none; }
}

.pending-card { max-width: 440px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 36px 28px; box-shadow: var(--shadow); }
.pending-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 16px; background: rgba(251, 191, 36, 0.14); color: var(--amber); }
.pending-icon svg { width: 28px; height: 28px; }
.pending-card h2 { font-family: var(--font-display); margin: 0 0 8px; }
.pending-card p { color: var(--muted); margin: 0 0 22px; }

/* ---------- FORMS ---------- */
.form { display: grid; gap: 14px; }
.form.two { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form.two { grid-template-columns: 1fr; } }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text);
  font-size: 14px; font-weight: 400; transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18); }
select:disabled { opacity: 0.6; }

/* ---------- APP SHELL ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto;
}
.sidebar > .brand { padding: 4px 8px; }
.side-nav { display: grid; gap: 18px; flex: 1; align-content: start; }
.nav-group { display: grid; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 14px; }
.side-nav a svg { width: 18px; height: 18px; flex: none; }
.side-nav a:hover { background: var(--panel-2); color: var(--text); }
.side-nav a.active { background: rgba(56, 189, 248, 0.12); color: var(--accent); }
.count { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--amber); color: #1a1100; }
.seg .count { margin-left: 4px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.side-user .who { flex: 1; min-width: 0; display: grid; }
.side-user b, .side-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user b { font-size: 14px; }
.side-user .who span { font-size: 12px; color: var(--muted); }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-title { flex: 1; min-width: 0; }
.top-title h1 { margin: 0; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
.top-title span { color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.xs { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.xs svg { width: 15px; height: 15px; }
.menu-btn { display: none; }

.clock { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--text); }
.clock svg { width: 16px; height: 16px; color: var(--accent); }
.clock.on { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.1); }
.clock.on span:not(.live) { font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; }
.clock .live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.view { padding: 24px 28px 48px; display: grid; gap: 18px; align-content: start; max-width: 1280px; width: 100%; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform 0.22s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.45); }
  .menu-btn { display: grid; }
  .topbar { padding: 12px 16px; }
  .view { padding: 18px 16px 40px; }
  #demoBadge { display: none; }
}
@media (max-width: 560px) {
  .top-title span { display: none; }
  .clock b { display: none; }
  .clock:not(.on) b { display: inline; }
}

/* ---------- CARDS ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }
.link { color: var(--accent); font-size: 13px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.profile-grid { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 1100px) { .grid-2, .profile-grid { grid-template-columns: 1fr; } }

.welcome { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.16), rgba(34, 211, 238, 0.04) 60%), var(--panel); }
.welcome h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em; }
.welcome p { margin: 0; }
.welcome .row { flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 2px; overflow: hidden; box-shadow: var(--shadow); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.stat.blue::before { background: #60a5fa; }
.stat.violet::before { background: var(--violet); }
.stat.amber::before { background: var(--amber); }
.stat.green::before { background: var(--green); }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat b { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; }
.stat small { color: var(--faint); font-size: 12px; }

.empty { color: var(--faint); font-size: 14px; text-align: center; padding: 26px 12px; }

/* ---------- PEOPLE / AVATARS ---------- */
.avatar { --h: 200; width: 38px; height: 38px; flex: none; border-radius: 11px; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 13px; color: hsl(var(--h) 80% 88%); background: linear-gradient(135deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 40) 60% 32%)); }
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.avatar.lg { width: 60px; height: 60px; border-radius: 16px; font-size: 20px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.people li:hover { background: var(--panel-2); }
.people li > div { flex: 1; min-width: 0; display: grid; }
.people b { font-size: 14px; }
.people span { font-size: 12px; color: var(--muted); }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user > div { display: grid; min-width: 0; }
.cell-user b { font-size: 14px; white-space: nowrap; }
.cell-user span { font-size: 12px; color: var(--muted); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 110px 1fr 64px; align-items: center; gap: 10px; font-size: 13px; }
.bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bars .mono { text-align: right; }

/* ---------- PILLS / CHIPS ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap;
  background: rgba(148, 163, 184, 0.14); color: var(--muted); }
.pill.green { background: rgba(52, 211, 153, 0.14); color: #10b981; }
.pill.blue { background: rgba(56, 189, 248, 0.14); color: #0ea5e9; }
.pill.violet { background: rgba(167, 139, 250, 0.16); color: #8b5cf6; }
.pill.amber { background: rgba(251, 191, 36, 0.16); color: #d97706; }
.pill.orange { background: rgba(251, 146, 60, 0.16); color: #ea580c; }
.pill.red { background: rgba(248, 113, 113, 0.16); color: #ef4444; }
:root:not([data-theme="light"]) .pill.green { color: #6ee7b7; }
:root:not([data-theme="light"]) .pill.blue { color: #7dd3fc; }
:root:not([data-theme="light"]) .pill.violet { color: #c4b5fd; }
:root:not([data-theme="light"]) .pill.amber { color: #fcd34d; }
:root:not([data-theme="light"]) .pill.orange { color: #fdba74; }
:root:not([data-theme="light"]) .pill.red { color: #fca5a5; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; }
.seg button.on { background: rgba(56, 189, 248, 0.14); color: var(--accent); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 170px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 500; cursor: pointer; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.green { background: var(--green); } .dot.blue { background: #38bdf8; } .dot.orange { background: var(--orange); }
.dot.amber { background: var(--amber); } .dot.red { background: var(--red); } .dot.gray { background: var(--faint); }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tbody tr:hover td { background: var(--panel-2); }
td.reason { max-width: 320px; color: var(--muted); }

/* ---------- RECORDS TIMELINE ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tl-item { --c: var(--faint); position: relative; padding: 12px 14px 12px 18px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.tl-item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--c); }
.tl-item.green { --c: var(--green); } .tl-item.blue { --c: #38bdf8; } .tl-item.orange { --c: var(--orange); }
.tl-item.amber { --c: var(--amber); } .tl-item.red { --c: var(--red); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-head .icon-btn { margin-left: auto; }
.tl-item p { margin: 6px 0 0; font-size: 14px; }
.tl-target { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }

/* ---------- ANNOUNCEMENTS ---------- */
.ann-mini { padding: 12px 0; border-top: 1px solid var(--line); }
.ann-mini:first-of-type { border-top: 0; padding-top: 0; }
.ann-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--faint); }
.ann-mini h4 { margin: 4px 0; font-size: 15px; }
.ann-mini p { margin: 0; color: var(--muted); font-size: 14px; }
.pin { display: inline-flex; align-items: center; gap: 4px; color: var(--amber); font-size: 12px; font-weight: 600; }
.pin svg { width: 13px; height: 13px; }
.ann-list { display: grid; gap: 14px; }
.ann header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ann.pinned { border-color: rgba(251, 191, 36, 0.4); }
.ann h3 { margin: 14px 0 6px; font-family: var(--font-display); font-size: 19px; }
.ann-body { color: var(--muted); }

/* ---------- PROFILE ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-head h3 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.profile-head p { margin: 0 0 6px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 0; }
.kv dt { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kv dd { margin: 2px 0 0; font-weight: 500; }
.bio { color: var(--muted); padding: 12px 14px; border-radius: 10px; background: var(--panel-2); margin: 16px 0 0; }
.sub-h { margin: 22px 0 10px; font-size: 14px; }

/* ---------- MODAL ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(3, 7, 16, 0.6); backdrop-filter: blur(4px); animation: fade 0.15s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6); animation: pop 0.18s ease; }
.modal.wide { width: min(640px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body > p { margin-top: 0; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* ---------- TOASTS ---------- */
.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: grid; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 11px; font-size: 14px; font-weight: 500; background: var(--panel); border: 1px solid var(--line-strong); border-left: 3px solid var(--green); box-shadow: var(--shadow); animation: pop 0.2s; transition: opacity 0.3s, transform 0.3s; max-width: min(360px, calc(100vw - 32px)); }
.toast.error { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); }
.form label.check.consent { align-items: flex-start; font-size: 13px; color: var(--muted); }
.form label.check.consent input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.form label.check.consent a, .auth-side .fine a { color: var(--accent); text-decoration: underline; }
