/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.info-tip:hover .info-tip-popup { display: block !important; }

/* ── Light theme (default) ── */
:root {
  --bg:      #ffffff;
  --surface: #f7f7fb;
  --s2:      #ededf5;
  --border:  #e0dff0;
  --accent:  #6B3FA0;
  --text:    #1D1D3C;
  --muted:   #7b7b9e;
  --green:   #16a34a;
  --red:     #dc2626;
  --r:       6px;
  --grid:    #e8e8f0;
  --tick:    #7b7b9e;
  --chart-bg:#ffffff;
  /* Fluid side padding: stays ~3vw up to 1900px, then grows to keep content centered; max 200px */
  --side-pad: clamp(16px, calc(3vw + max(0px, calc((100vw - 1900px) / 2))), 200px);
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg:      #0d0d1a;
  --surface: #13132a;
  --s2:      #1e1e38;
  --border:  #2a2a50;
  --accent:  #8b5fd0;
  --text:    #e4e4f0;
  --muted:   #8888aa;
  --green:   #4ade80;
  --red:     #f87171;
  --grid:    #1e1e38;
  --tick:    #6666aa;
  --chart-bg:#13132a;
}

body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; transition: background .2s, color .2s; }

/* ── Gate ── */
#gate { display:flex; align-items:center; justify-content:center; min-height:100vh; padding:24px; background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(107,63,160,.06) 0%, transparent 70%), var(--bg); }
[data-theme="dark"] #gate { background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(139,95,208,.1) 0%, transparent 70%), var(--bg); }
.gate-card { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:40px; max-width:460px; width:100%; box-shadow:0 4px 24px rgba(29,29,60,.07); }
[data-theme="dark"] .gate-card { box-shadow:0 4px 32px rgba(0,0,0,.4); }
.gate-logo { margin-bottom:22px; }
.ln-wordmark { display:flex; align-items:center; gap:10px; }
.ln-icon { width:36px; height:36px; background:var(--accent); border-radius:6px; display:flex; align-items:center; justify-content:center; }
.ln-icon svg { width:20px; height:20px; fill:#fff; }
.ln-name { font-size:20px; font-weight:700; letter-spacing:-.03em; color:var(--text); }
.ln-name span { color:var(--accent); }
.gate-divider { border:none; border-top:1px solid var(--border); margin:18px 0; }
.gate-subtitle { font-size:13px; color:var(--muted); margin-bottom:18px; line-height:1.55; font-weight:400; }
.info-box { background:rgba(107,63,160,.05); border:1px solid rgba(107,63,160,.2); border-radius:6px; padding:12px 14px; font-size:12px; color:var(--accent); margin-bottom:18px; line-height:1.6; }
[data-theme="dark"] .info-box { background:rgba(139,95,208,.08); border-color:rgba(139,95,208,.25); }
.info-box a { color:var(--accent); }
#gate-err { background:rgba(220,38,38,.06); border:1px solid rgba(220,38,38,.3); border-radius:6px; padding:10px 14px; font-size:13px; color:var(--red); margin-bottom:14px; display:none; }
.inp-wrap { position:relative; margin-bottom:12px; }
.inp-wrap input { width:100%; background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:11px 40px 11px 13px; color:var(--text); font-size:13px; font-family:monospace; outline:none; transition:border-color .2s; }
.inp-wrap input:focus { border-color:var(--accent); }
.inp-wrap .eye { position:absolute; right:11px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; color:var(--muted); }
.remember { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); margin-bottom:16px; cursor:pointer; }
.remember input { accent-color:var(--accent); }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; background:var(--accent); color:#fff; border:none; border-radius:6px; padding:11px 22px; font-size:13px; font-weight:600; cursor:pointer; transition:background .15s; width:100%; letter-spacing:.01em; }
.btn:hover { filter:brightness(1.1); } .btn:disabled { opacity:.4; cursor:not-allowed; }
.btn.ghost { background:transparent; color:var(--text); border:1px solid var(--border); }
.btn.ghost:hover { background:var(--s2); }
.btn.sm { padding:6px 13px; font-size:12px; width:auto; border-radius:5px; }
.gate-note { margin-top:13px; font-size:11px; color:var(--muted); text-align:center; }

/* ── App shell ── */
#app { display:block; }
#gate { display:none; }
header { background:var(--bg); border-bottom:1px solid var(--border); padding:0 var(--side-pad); height:54px; display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:100; box-shadow:0 1px 0 var(--border); transition:background .2s, border-color .2s; }
.h-left { display:flex; align-items:center; gap:14px; }
.h-wordmark { display:flex; align-items:center; }
.h-sep { width:1px; height:18px; background:var(--border); }
.h-subtitle { font-size:12px; color:var(--muted); font-weight:500; }
.h-right { display:flex; align-items:center; gap:10px; }

/* ── User menu ── */
.user-menu { position:relative; }
.user-menu-btn { width:30px; height:30px; border-radius:50%; background:var(--s2); border:1px solid var(--border); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--muted); transition:background .15s, color .15s; flex-shrink:0; }
.user-menu-btn:hover { background:var(--border); color:var(--text); }
.user-menu-drop { display:none; position:absolute; right:0; top:calc(100% + 8px); background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:12px 14px; min-width:220px; box-shadow:0 4px 20px rgba(0,0,0,.13); z-index:300; }
.user-menu-drop.open { display:block; }
.user-menu-email { display:block; font-size:12px; color:var(--text); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:240px; padding-bottom:10px; border-bottom:1px solid var(--border); }

/* ── Theme toggle ── */
.theme-toggle { position:relative; display:inline-flex; align-items:center; cursor:pointer; }
.theme-toggle input { position:absolute; opacity:0; width:0; height:0; }
.toggle-track { width:40px; height:22px; background:var(--s2); border:1px solid var(--border); border-radius:11px; transition:background .2s, border-color .2s; position:relative; }
.theme-toggle input:checked ~ .toggle-track { background:var(--accent); border-color:var(--accent); }
.toggle-thumb { position:absolute; top:2px; left:2px; width:16px; height:16px; background:var(--muted); border-radius:50%; transition:transform .2s, background .2s; display:flex; align-items:center; justify-content:center; font-size:9px; line-height:1; }
.theme-toggle input:checked ~ .toggle-track .toggle-thumb { transform:translateX(18px); background:#fff; }
.toggle-icon { font-size:10px; line-height:1; }

main { padding:clamp(14px, 2vw, 20px) var(--side-pad); max-width:100%; margin:0 auto; }

/* ── Loading bar ── */
.loading-bar { height:3px; background:transparent; position:relative; overflow:hidden; }
.loading-bar.active { background:var(--s2); }
.loading-bar.active::after {
  content:''; position:absolute; top:0; left:0; height:100%; width:30%;
  background:var(--accent);
  animation:loadSlide 1.2s ease-in-out infinite;
}
@keyframes loadSlide { 0%{left:-30%} 100%{left:100%} }

/* ── Controls ── */
.controls { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; margin-bottom:20px; background:var(--bg); border:1px solid var(--border); border-radius:var(--r); padding:14px 18px; }
.cg { display:flex; flex-direction:column; gap:4px; }
.cg label { font-size:11px; color:var(--muted); font-weight:500; text-transform:uppercase; letter-spacing:.06em; }
.cg input, .cg select { background:var(--bg); border:1px solid var(--border); border-radius:5px; padding:7px 10px; color:var(--text); font-size:13px; outline:none; transition:border-color .2s; font-family:'Inter',sans-serif; }
.cg input:focus, .cg select:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(107,63,160,.1); }
.cg select option { background:var(--bg); color:var(--text); }
.presets { display:flex; gap:5px; }
.preset { background:var(--bg); border:1px solid var(--border); border-radius:5px; padding:5px 11px; font-size:12px; color:var(--muted); cursor:pointer; transition:all .15s; font-family:'Inter',sans-serif; }
.preset:hover { border-color:var(--accent); color:var(--accent); }
.preset.active { border-color:var(--accent); color:#fff; background:var(--accent); font-weight:600; }
.spacer { flex:1; min-width:20px; }

/* ── Error banner ── */
.err { background:rgba(220,38,38,.05); border:1px solid rgba(220,38,38,.3); border-radius:var(--r); padding:12px 16px; color:var(--red); margin-bottom:16px; display:none; font-size:13px; }

/* ── Tabs ── */
.tabs { display:flex; gap:0; margin-bottom:20px; border-bottom:1px solid var(--border); overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.tabs::-webkit-scrollbar { display:none; }
.tab { padding:9px 18px; font-size:13px; font-weight:500; color:var(--muted); background:none; border:none; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:all .15s; white-space:nowrap; font-family:'Inter',sans-serif; }
.tab:hover { color:var(--text); }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
/* Sub-tabs: pill style, visually subordinate to main tabs */
.tabs-sub { display:flex; gap:6px; flex-wrap:wrap; margin:4px 0 16px; overflow-x:auto; scrollbar-width:none; }
.tabs-sub::-webkit-scrollbar { display:none; }
.tabs-sub .tab { padding:5px 14px; font-size:12px; border-radius:20px; border:1px solid var(--border); color:var(--muted); font-weight:500; margin-bottom:0; }
.tabs-sub .tab:hover { color:var(--text); border-color:var(--muted); }
.tabs-sub .tab.active { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:600; }
.panel { display:none; }
.panel.active { display:block; }

/* ── Stat cards ── */
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; margin-bottom:18px; }
.stat { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:16px 18px; position:relative; overflow:hidden; }
.stat::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background:var(--border); }
.ca::before { background:var(--accent); }
.cp::before { background:#9b6cd0; }
.cg2::before { background:var(--green); }
.cb::before { background:var(--accent); }
.cm::before { background:#0891b2; }
.stat-lbl { font-size:11px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.07em; margin-bottom:8px; }
.stat-val { font-size:clamp(22px, 2.2vw, 28px); font-weight:700; letter-spacing:-.03em; line-height:1; color:var(--text); }
.stat-sub { font-size:12px; color:var(--muted); margin-top:6px; }
.ca .stat-val { color:var(--accent); }
.cp .stat-val { color:#9b6cd0; }
.cg2 .stat-val { color:var(--green); }
.cb .stat-val { color:var(--accent); }
.cm .stat-val { color:#0891b2; }

/* ── Gauge cards ── */
.gauge-row { display:flex; flex-wrap:wrap; gap:14px; justify-content:center; }
.gauge-stat { display:flex; flex-direction:column; align-items:center; min-width:140px; flex:1; padding:16px 10px 12px; }
.gauge-wrap { position:relative; width:120px; height:70px; }
.gauge-wrap svg { width:100%; height:100%; }
.gauge-bg { fill:none; stroke:var(--border); stroke-width:8; stroke-linecap:round; }
.gauge-fill { fill:none; stroke-width:8; stroke-linecap:round; transition:stroke-dashoffset .6s ease; }
.gauge-pct { position:absolute; bottom:2px; left:50%; transform:translateX(-50%); font-size:clamp(16px, 1.6vw, 22px); font-weight:800; color:var(--text); }
.gauge-label { font-size:13px; font-weight:600; color:var(--text); margin-top:6px; text-align:center; }
.gauge-sub { font-size:12px; color:var(--muted); margin-top:2px; text-align:center; }

/* ── DAU cards ── */
.dau-row { display:flex; flex-wrap:wrap; gap:14px; }
.dau-card { display:flex; flex-direction:column; min-width:160px; flex:1; padding:16px; }
.dau-val { font-size:clamp(22px, 2.5vw, 32px); font-weight:800; margin:4px 0 2px; }
.dau-meta { font-size:12px; color:var(--muted); margin-bottom:8px; }
.dau-spark { width:100%; height:32px; display:block; margin-bottom:8px; }
.dau-trend { font-size:12px; font-weight:600; padding:3px 8px; border-radius:4px; display:inline-block; }
.dau-trend.up { color:#4ade80; background:rgba(74,222,128,.1); }
.dau-trend.down { color:#f87171; background:rgba(248,113,113,.1); }
.dau-trend.flat { color:var(--muted); background:var(--s2); }

/* ── App metric cards ── */
.app-metric { display:flex; flex-direction:column; min-width:180px; flex:1; padding:16px 18px 14px; border-left:3px solid var(--border); }
.app-metric .app-metric-name { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; margin-bottom:10px; }
.app-metric .app-metric-row { display:flex; gap:20px; margin-bottom:8px; }
.app-metric .app-metric-col { display:flex; flex-direction:column; gap:2px; }
.app-metric .app-metric-label { font-size:10px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.app-metric .app-metric-num { font-size:clamp(18px, 2vw, 24px); font-weight:800; line-height:1.1; }
.app-metric .app-metric-sub { font-size:11px; color:var(--muted); margin-bottom:6px; }
.app-metric .dau-spark { width:100%; height:28px; display:block; }

/* ── Compact heatmap table ── */
.heatmap-compact table { font-size:12px; }
.heatmap-compact th { padding:0 8px 6px; font-size:10px; }
.heatmap-compact td { padding:5px 8px; }

/* ── Chart cards ── */
.row2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
.row3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; margin-bottom:14px; }
@media(max-width:900px){ .row2,.row3{ grid-template-columns:1fr; } }

/* ── Cramped laptops (≤1280px) ── */
@media(max-width:1280px){
  .stats { grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); }
  .gauge-stat { min-width:110px; }
  .gauge-wrap { width:clamp(80px,8vw,120px); height:clamp(48px,5vw,70px); }
  .dau-card { min-width:130px; }
  .app-metric { min-width:150px; }
  .ch { height:190px; }
}

/* ── Wide monitors (≥1800px) ── */
@media(min-width:1800px){
  .ch { height:300px; }
  .row3 { grid-template-columns:repeat(3,1fr); }
  .stats { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); }
}
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r); padding:18px 20px; margin-bottom:14px; transition:background .2s, border-color .2s; }
.card:last-child { margin-bottom:0; }
.card-head { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:14px; }
.card-title { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.card-sub { font-size:13px; color:var(--muted); margin-top:3px; font-weight:400; text-transform:none; letter-spacing:0; }
.ch { position:relative; height:230px; overflow:hidden; }
.ch canvas { display:block; max-width:100%; }

/* ── Tables ── */
.tbl-wrap { overflow-x:auto; max-height:80vh; overflow-y:auto; }
.tbl-wrap thead th { position:sticky; top:0; background:var(--surface); z-index:2; box-shadow:0 1px 0 var(--border); }
#tbl-users th, #tbl-projects th, #tbl-skills th, #tbl-connectors th, #tbl-office th, #tbl-claudecode th, #tbl-cowork th { padding:0 6px 10px; }
#tbl-users td, #tbl-projects td, #tbl-skills td, #tbl-connectors td, #tbl-office td, #tbl-claudecode td, #tbl-cowork td { padding:10px 6px; }
table { width:100%; border-collapse:separate; border-spacing:0; font-size:13px; }
th { text-align:left; color:var(--muted); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.06em; padding:0 12px 10px; border-bottom:2px solid var(--border); white-space:nowrap; }
td { padding:10px 12px; border-bottom:1px solid var(--border); color:var(--text); }
tr:last-child td { border-bottom:none; }
tr:hover td { background:var(--s2); }
.tr { text-align:right; font-family:monospace; }
.tm { color:var(--muted); }
.avatar { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:4px; background:linear-gradient(135deg, rgba(107,63,160,.8), rgba(29,29,60,.5)); font-size:11px; font-weight:700; color:#fff; flex-shrink:0; }
.user-cell { display:flex; align-items:center; gap:9px; }
/* ── Sticky first column ── */
.tbl-wrap table th:first-child,
.tbl-wrap table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 2px 0 4px -1px rgba(0,0,0,0.08);
}
.tbl-wrap thead th:first-child { z-index: 3; }
.tbl-wrap table td:first-child { min-width: 180px; max-width: 260px; }
.tbl-wrap table td:first-child .user-cell > div:last-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px;
}
tr:hover td:first-child { background: var(--s2); }
.pill { display:inline-block; background:var(--s2); border:1px solid var(--border); border-radius:3px; padding:1px 6px; font-size:11px; }

/* ── Loading / empty ── */
.loading { text-align:center; padding:50px 20px; color:var(--muted); }
.spinner { width:26px; height:26px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin .7s linear infinite; margin:0 auto 13px; }
@keyframes spin { to { transform:rotate(360deg); } }
.empty { text-align:center; padding:40px; color:var(--muted); font-size:13px; }

/* ── Bar within table ── */
.bar-wrap { display:flex; align-items:center; gap:8px; min-width:80px; }
.bar-bg { flex:1; height:4px; background:var(--border); border-radius:2px; overflow:hidden; }
.bar-fill { height:100%; border-radius:2px; background:var(--accent); transition:width .3s; }

/* ── Sortable headers ── */
th.sortable { cursor:pointer; user-select:none; }
th.sortable:hover { color:var(--text); }
.arr { font-size:9px; margin-left:3px; opacity:.3; }
.arr.on { opacity:1; color:var(--accent); }

/* ── User search ── */
.search-wrap { position:relative; }
.search-wrap input { background:var(--bg); border:1px solid var(--border); border-radius:5px; padding:6px 10px 6px 28px; color:var(--text); font-size:13px; outline:none; width:220px; transition:border-color .2s; font-family:'Inter',sans-serif; }
.search-wrap input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(107,63,160,.1); }
.search-wrap .si { position:absolute; left:9px; top:50%; transform:translateY(-50%); color:var(--muted); font-size:12px; pointer-events:none; }
.card-head-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.card-head-row .card-title { flex:1; }

/* ── Modals (shared) ── */
.modal-overlay { display:none; position:fixed; inset:0; z-index:1000; background:rgba(0,0,0,.55); backdrop-filter:blur(3px); padding:24px; overflow:auto; }
.modal-box { background:var(--surface); border:1px solid var(--border); border-radius:10px; max-width:960px; margin:0 auto; display:flex; flex-direction:column; max-height:calc(100vh - 48px); box-shadow:0 8px 40px rgba(0,0,0,.18); }
.modal-box.narrow { max-width:520px; }
.modal-box.wide { max-width:800px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--border); flex-shrink:0; }
.modal-header-title { font-size:14px; font-weight:700; color:var(--text); }
.modal-header-sub { font-size:11px; color:var(--muted); margin-top:2px; }
.modal-close { background:none; border:none; color:var(--muted); cursor:pointer; font-size:18px; line-height:1; padding:2px 6px; }
.modal-body { flex:1; overflow-y:auto; padding:18px 20px; }
.modal-footer { padding:16px 24px; display:flex; justify-content:flex-end; border-top:1px solid var(--border); }

/* ── Settings sections ── */
.settings-section { padding:20px 24px; border-bottom:1px solid var(--border); }
.settings-section:last-child { border-bottom:none; }
.section-title { font-size:12px; font-weight:700; color:var(--text); text-transform:uppercase; letter-spacing:.08em; margin-bottom:4px; }
.section-desc { font-size:12px; color:var(--muted); margin-bottom:14px; line-height:1.5; }
.input-field { width:100%; background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:9px 12px; color:var(--text); font-size:13px; font-family:monospace; outline:none; box-sizing:border-box; }
.input-field:focus { border-color:var(--accent); }
.input-label { font-size:11px; color:var(--muted); font-weight:500; text-transform:uppercase; letter-spacing:.06em; display:block; margin-bottom:4px; }

/* ── Status banners ── */
.status-success { background:rgba(40,167,69,.06); border:1px solid rgba(40,167,69,.3); border-radius:6px; padding:8px 12px; font-size:12px; color:#28A745; }
.status-error { background:rgba(220,38,38,.06); border:1px solid rgba(220,38,38,.3); border-radius:6px; padding:8px 12px; font-size:12px; color:var(--red); }
