:root {
  --bg: #0B1020; --side: #0E1526; --card: #121A2B; --sunk: #0E1526; --line: #1E2940; --line-soft: #1A2338;
  --text: #E6EAF2; --text-2: #CBD3E1; --muted: #A3AEC2; --faint: #8A96AD;
  --teal: #2DD4BF; --teal-text: #5EEAD4; --violet: #A78BFA; --amber: #F5A524; --coral: #F27A5E; --green: #34D399;
  --head: 'Space Grotesk', Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--teal-text); }
a:hover { color: #99F6E4; }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Animations ---------- */
@keyframes grow { from { transform: scaleY(0); } }
@keyframes growx { from { transform: scaleX(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes arc { from { stroke-dasharray: 0 400; } }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
.grow { transform-origin: bottom; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.growx { transform-origin: left; animation: growx 1.1s cubic-bezier(.2,.8,.2,1) both; }
.draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw 1.8s ease-out both; }
.arc { animation: arc 1.3s cubic-bezier(.2,.8,.2,1) both; }
.fade { animation: fade .6s ease-out both; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Shell ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 232px; max-width: 100%; padding: 24px 16px; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 28px; }
.content { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); text-decoration: none;
  font-family: var(--head); font-weight: 700; font-size: 18px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--teal); display: flex; align-items: center; justify-content: center; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 44px; border-radius: 10px;
  color: var(--muted); text-decoration: none; }
.nav a:hover { background: #131C31; color: var(--text); }
.nav a.on { background: #16213A; color: var(--text); font-weight: 600; }
.nav a.on svg { stroke: var(--teal-text); }
.nav .badge { margin-left: auto; background: var(--coral); color: #1A0B06; font-size: 12px; font-weight: 600; padding: 0 8px; border-radius: 999px; }
.nav .hint { margin-left: auto; color: var(--faint); font-size: 12px; }
.side-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; padding: 0 8px 6px; }
.org-list { display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.org-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.org-row .src { margin-left: auto; color: var(--faint); font-size: 12px; }
.sq { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.status-box { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.4; }
.logout { display: flex; }
.logout button { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.logout button:hover { color: var(--text); border-color: var(--faint); }

/* ---------- Common ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { color: var(--faint); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .span2 { grid-column: auto; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--faint); color: var(--text); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #0B1020; font-weight: 600; }
.btn.primary:hover { background: #5EEAD4; color: #0B1020; }
.btn.outline { background: transparent; border-color: var(--teal); color: var(--teal-text); font-weight: 600; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.danger { background: transparent; border-color: #3A1F17; color: #FCA58F; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.icon-btn:hover { color: var(--teal-text); border-color: var(--teal); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; background: var(--card); color: var(--text-2); border: 1px solid var(--line); text-decoration: none; }
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip.on { background: var(--text); color: #0B1020; border-color: var(--text); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--sunk); color: var(--text-2); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice { padding: 12px 16px; border-radius: 12px; background: #10302B; color: #99F6E4; border: 1px solid #134E48; }
.notice.warn { background: #3A2A0C; color: #FBCB6B; border-color: #5A410F; }
.notice a { color: inherit; font-weight: 600; }
.empty { color: var(--faint); padding: 24px 0; text-align: center; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; min-height: 44px; color: var(--faint); }
.search input { background: transparent; border: 0; outline: none; color: var(--text); width: 220px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--faint); }
.field input, .field select { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); color: var(--text); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.kpi-value { font-family: var(--head); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.kpi-value .unit { font-size: 20px; color: var(--faint); margin-left: 2px; }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 40px; }
.spark span { width: 7px; border-radius: 2px; }

/* ---------- Timeline ---------- */
.tl-scroll { overflow-x: auto; }
.tl { min-width: 980px; }
.tl-ticks { position: relative; height: 18px; margin-left: 88px; color: var(--faint); font-size: 11px; }
.tl-ticks span { position: absolute; transform: translateX(-50%); }
.tl-body { display: flex; gap: 8px; }
.tl-lanes { width: 80px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); }
.tl-lanes div { height: 52px; display: flex; align-items: center; }
.tl-track { position: relative; flex: 1; height: 112px; border-radius: 10px; background: var(--sunk); }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-block { position: absolute; height: 48px; border-radius: 8px; padding: 6px 8px; overflow: hidden; transition: opacity .3s; text-decoration: none; }
.tl-block b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block span { font-size: 11px; opacity: .85; white-space: nowrap; }
.tl-now { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--coral); }
.tl-now i { position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- Donut & bars ---------- */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { position: relative; width: 160px; height: 160px; flex: none; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center b { font-family: var(--head); font-size: 24px; font-weight: 600; }
.donut-center span { font-size: 11px; color: var(--faint); }
.donut circle { transition: opacity .3s; }
.bars { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 120px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; transition: opacity .3s; }
.bar-row .lbl { display: flex; justify-content: space-between; font-size: 13px; }
.track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.track > div { height: 100%; border-radius: 3px; }

/* ---------- Lists ---------- */
.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.score { width: 40px; flex: none; text-align: center; font-family: var(--head); font-weight: 600; font-size: 16px; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--faint); }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: #0B1020; }
.briefing { margin: 0; color: var(--text-2); line-height: 1.65; }
.ai-mark { width: 30px; height: 30px; border-radius: 8px; background: #2A2350; display: flex; align-items: center; justify-content: center; flex: none; }

/* ---------- Inbox ---------- */
.inbox { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.inbox-nav { flex: 1 1 200px; max-width: 260px; display: flex; flex-direction: column; gap: 20px; }
.inbox-nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; }
.inbox-nav a:hover { background: #131C31; color: var(--text); }
.inbox-nav a.on { background: #16213A; color: var(--text); }
.inbox-nav a .n { margin-left: auto; color: var(--faint); }
.msg-list { flex: 3 1 420px; min-width: 0; padding: 0; overflow: hidden; }
.msg { display: flex; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); color: inherit; text-decoration: none; }
.msg:hover { background: #141E33; color: inherit; }
.msg.on { background: #1A2440; }
.msg.unread .from, .msg.unread .subj { font-weight: 600; }
.msg .scorecol { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 40px; flex: none; }
.mini-track { width: 28px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; display: block; }
.mini-track span { display: block; height: 100%; }
.detail { flex: 3 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 18px; padding: 24px; }
.ai-box { background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ai-box .ttl { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #C4B5FD; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid; flex: none; }

/* ---------- Tasks ---------- */
.stack { display: flex; height: 20px; border-radius: 6px; overflow: hidden; gap: 3px; background: var(--sunk); }
.stack div { height: 100%; transition: opacity .3s; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--head); font-size: 22px; }
.add-task { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.add-task .grow-field { flex: 1 1 280px; }
.board-scroll { overflow-x: auto; }
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 16px; min-width: 1040px; }
.col { background: var(--sunk); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 420px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; }
.col-head h2 { font-size: 15px; }
.count-pill { font-size: 12px; color: var(--faint); background: var(--card); border-radius: 999px; padding: 0 10px; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.tcard.done { opacity: .7; }
.tcard.done .ttl { text-decoration: line-through; }
.tcard-top { display: flex; gap: 10px; align-items: flex-start; }
.tick { width: 44px; height: 44px; margin: -10px 0 -10px -10px; flex: none; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.tick span { width: 20px; height: 20px; border-radius: 6px; border: 2px solid; display: flex; align-items: center; justify-content: center; }
.tick:hover span { box-shadow: 0 0 0 3px #ffffff14; }
.due-urgent { background: #3A1F17; color: #FCA58F; }
.due-done { background: #0F2E28; color: #6EE7B7; }

/* ---------- Accounts ---------- */
.acct { display: flex; flex-direction: column; gap: 14px; }
.acct-head { display: flex; gap: 12px; align-items: center; }
.acct-badge { width: 44px; height: 44px; border-radius: 12px; background: var(--sunk); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--head); font-weight: 700; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 48px; }
.hist span { flex: 1; border-radius: 2px; }
.stat2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-size: 12px; }
.stat2 > div { background: var(--sunk); border-radius: 10px; padding: 8px 10px; }
.stat2 b { display: block; font-weight: 600; }
.label-form { display: flex; gap: 8px; }
.label-form input { flex: 1; min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--sunk); color: var(--text); font-size: 13px; }
.capture { display: flex; align-items: center; gap: 10px; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.capture code { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-item { display: flex; gap: 10px; align-items: flex-start; }
.error-text { color: #FCA58F; font-size: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .error { color: #FCA58F; background: #3A1F17; padding: 10px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- Timesheets ---------- */
a.ts-org { text-decoration: none; color: inherit; transition: border-color .2s, transform .2s; }
a.ts-org:hover { border-color: var(--faint); transform: translateY(-2px); color: inherit; }
.ts-chart { display: flex; align-items: stretch; gap: 4px; height: 190px; }
.ts-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; border-radius: 6px; padding: 4px 0; }
.ts-col.weekend { background: #0E1526; }
.ts-col.today { outline: 1px dashed var(--coral); outline-offset: -1px; }
.ts-bar-wrap { flex: 1; width: 70%; display: flex; align-items: flex-end; }
.ts-bar-wrap span { width: 100%; border-radius: 3px 3px 1px 1px; }
.ts-day { font-size: 10px; color: var(--faint); }
.ts-row { gap: 10px; }
.ts-edit { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ts-edit .ts-title { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); }
.ts-edit .ts-title:hover, .ts-edit .ts-title:focus { border-color: var(--line); background: var(--sunk); }
.ts-edit .ts-hours { width: 76px; min-height: 36px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--sunk); color: var(--text); text-align: right; }

/* ---------- PIN screen ---------- */
.pin-card { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 32px 28px; }
.pin-card h1 { font-size: 24px; }
.pin-card form { width: 100%; }
.lock-icon { width: 56px; height: 56px; border-radius: 16px; background: #10302B; color: var(--teal-text); display: flex; align-items: center; justify-content: center; }
.lock-icon.locked { background: #3A1F17; color: #FCA58F; }
.pin-input { width: 100%; min-height: 64px; text-align: center; font-family: var(--head); font-size: 32px; letter-spacing: .6em;
  padding-left: .6em; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); color: var(--text); }
.pin-input::placeholder { color: #3A4766; }
