:root {
  --brand: #2563eb; --brand-ink: #fff; --accent: var(--brand);
  --bg: #f4f6fb; --card: #ffffff; --ink: #0f172a; --ink2: #334155; --muted: #64748b; --line: #e4e8f0; --soft: #f1f5f9;
  --good: #16a34a; --warn: #d97706; --bad: #dc2626; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px; --sidebar: 252px;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #0b1020; --card: #131a2e; --ink: #e8ecf6; --ink2: #c3cbe0; --muted: #8b97b5; --line: #232c47; --soft: #1a2340;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 10px; }
.right { margin-left: auto; } .hide { display: none !important; } .center { text-align: center; }
.mt { margin-top: 16px; } .mt2 { margin-top: 28px; } .mb { margin-bottom: 16px; }

/* ---------- shell ---------- */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.shell > div, .grid > * { min-width: 0; }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; padding: 4px 8px 16px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #7c3aed); display: grid; place-items: center; color: #fff; font-size: 17px; flex: none; }
.side-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; text-transform: uppercase; }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 10px; color: var(--ink2); font-weight: 600; background: none; border: 0; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover { background: var(--soft); }
.nav a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.nav .ico { width: 20px; text-align: center; flex: none; }
.team-pill { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-weight: 700; color: var(--ink2); cursor: pointer; }
.team-pill:hover { background: var(--soft); }
.team-pill.on { background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--ink); box-shadow: inset 3px 0 0 var(--tc); }
.team-pill .em { font-size: 18px; }
.main { padding: 26px 32px 60px; max-width: 1400px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; flex: none; background: var(--brand); }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.mobilebar { display: none; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: 4px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } .g5 { grid-template-columns: repeat(5, 1fr); }
.stat { padding: 16px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--c) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--c) 22%, var(--line)); }
.stat .k { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--c); text-transform: uppercase; }
.stat .v { font-size: 30px; font-weight: 800; color: var(--c); line-height: 1.15; margin-top: 4px; }
.stat .s { font-size: 12px; color: var(--c); opacity: .85; }
.hero { background: linear-gradient(120deg, #0f172a, color-mix(in srgb, var(--accent) 55%, #0f172a)); color: #fff; border-radius: 18px; padding: 24px 28px; margin-bottom: 18px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 65%); }
.hero h1 { font-size: 26px; } .hero .muted { color: #b6c2dc; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--c, #64748b) 14%, transparent); color: var(--c, #64748b); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #64748b); }
.badge.plain::before { display: none; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 8px; font-size: 11.5px; font-weight: 700; background: color-mix(in srgb, var(--c, #64748b) 14%, transparent); color: var(--c, #64748b); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer; transition: .12s; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; } .btn.lg { padding: 13px 24px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.iconbtn { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.iconbtn:hover { background: var(--soft); color: var(--ink); }
label.f { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
label.f small { text-transform: none; letter-spacing: 0; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); outline: none; }
input[type=date], input[type=time] { color-scheme: light dark; }
td:last-child { white-space: nowrap; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { min-height: 70px; resize: vertical; }
input[type=color] { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.pchip { padding: 8px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer; }
.pchip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--card)); color: var(--c); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--brand); } .switch input:checked + span::after { transform: translateX(16px); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 11px 14px; background: var(--soft); white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.taskline { display: flex; gap: 8px; align-items: baseline; } .taskline + .taskline { margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #16a34a); flex: none; transform: translateY(-1px); }
.blk { color: var(--bad); font-weight: 600; font-size: 13px; }
tr.pending td { background: color-mix(in srgb, var(--warn) 6%, var(--card)); }
.progress { height: 10px; border-radius: 99px; background: var(--soft); overflow: hidden; } .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #7c3aed); border-radius: 99px; transition: width .4s; }

/* tracker matrix */
.matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.matrix th, .matrix td { padding: 8px 10px; border-top: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; min-width: 118px; vertical-align: middle; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; z-index: 2; text-align: left; min-width: 190px; background: var(--card); box-shadow: 2px 0 0 var(--line); }
.matrix thead th { background: var(--soft); position: sticky; top: 0; z-index: 3; } .matrix thead th:first-child { z-index: 4; background: var(--soft); }
.matrix td.cell { cursor: pointer; font-size: 12px; } .matrix td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.matrix td.off { background: repeating-linear-gradient(45deg, var(--soft), var(--soft) 6px, transparent 6px, transparent 12px); }
.matrix tr.leadrow td:first-child { font-weight: 800; }
.cellbox { border-radius: 8px; padding: 4px 6px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 700; }
.cellbox small { display: block; font-weight: 500; opacity: .85; }

/* ---------- overlays ---------- */
#drawer-bg { position: fixed; inset: 0; background: rgba(8,12,24,.5); backdrop-filter: blur(2px); z-index: 40; opacity: 0; pointer-events: none; transition: .18s; }
#drawer-bg.open { opacity: 1; pointer-events: auto; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--card); z-index: 41; transform: translateX(105%); transition: transform .22s cubic-bezier(.2,.8,.2,1); box-shadow: -20px 0 50px rgba(0,0,0,.25); display: flex; flex-direction: column; }
#drawer.open { transform: none; }
#drawer .dh { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
#drawer .db { padding: 20px 22px; overflow-y: auto; flex: 1; }
#drawer .df { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: pop .2s; max-width: 90vw; }
.toast.err { background: #b91c1c; } .toast.ok { background: #15803d; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ---------- forms: tasks ---------- */
.taskrow { border: 1px solid var(--line); border-left: 4px solid var(--c, var(--good)); border-radius: 12px; padding: 12px; background: var(--card); display: grid; gap: 8px; }
.taskrow .r1 { display: grid; grid-template-columns: 1fr 84px 150px 32px; gap: 8px; }
.taskrow .r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.taskrow.p3 .r2 { grid-template-columns: 1fr 1fr 160px; }

/* ---------- auth ---------- */
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), radial-gradient(900px 500px at 100% 110%, rgba(124,58,237,.18), transparent), var(--bg); }
.authcard { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; }
.authcard .logo { width: 46px; height: 46px; border-radius: 14px; font-size: 22px; margin-bottom: 14px; }
.err-text { color: var(--bad); font-weight: 600; min-height: 20px; margin-top: 10px; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); } .empty .big { font-size: 38px; }
.tree-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; } .tree-row:hover { background: var(--soft); }
.tree-kids { margin-left: 22px; border-left: 2px solid var(--line); padding-left: 8px; }
.permgrid { display: grid; grid-template-columns: 1fr repeat(var(--n), 110px); gap: 0; align-items: center; }
.permgrid > div { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.permgrid .hd { font-weight: 800; font-size: 12px; text-align: center; background: var(--soft); }
.kbd { font-family: ui-monospace, monospace; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
.ring { --p: 0; width: 86px; height: 86px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--soft) 0); display: grid; place-items: center; flex: none; }
.ring::after { content: attr(data-t); width: 66px; height: 66px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--c, var(--brand)); border-radius: 99px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 18px; } .hero .row.wrap > .row.wrap { width: 100%; } .hero input[type=date] { flex: 1; }
  .sidebar { position: fixed; z-index: 30; left: 0; width: 280px; transform: translateX(-105%); transition: .2s; box-shadow: 10px 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .main { padding: 18px 14px 80px; }
  .g4, .g5 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr; } .g2 { grid-template-columns: 1fr; }
  .taskrow .r1 { grid-template-columns: 1fr 70px; } .taskrow .r1 .stsel { grid-column: 1 / 3; }
  .taskrow .r2, .taskrow.p3 .r2 { grid-template-columns: 1fr; }
  .permgrid { --cols: 1; }
}
@media print { .sidebar, .topbar .btn, .mobilebar { display: none !important; } .shell { display: block; } }
