/* CFOP Studio · Admin Console
   Operate-mode interface: dense, calm, scannable. No external dependencies. */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f0f3f8;
  --border: #e3e8f0;
  --border-strong: #d3dae6;
  --text: #15203a;
  --text-2: #56657f;
  --text-3: #64718a;
  --brand: #3a5bd9;
  --brand-hover: #2f4dc0;
  --brand-soft: #edf1ff;
  --brand-ink: #2a45ad;
  --success: #12866b;
  --success-soft: #e6f5f0;
  --warn: #b8791a;
  --warn-soft: #fdf3e3;
  --danger: #d33f49;
  --danger-soft: #fcedee;
  --info: #2b6cb0;
  --info-soft: #e9f2fc;
  --violet: #7052c4;
  --violet-soft: #f0ebfc;
  --teal: #16839a;
  --teal-soft: #e5f4f7;

  --side-bg: #111a2c;
  --side-bg-2: #18233a;
  --side-text: #c3cde0;
  --side-text-dim: #7d8ba6;
  --side-active: #2b3d68;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 2px 6px rgba(16, 24, 40, .06), 0 14px 34px -14px rgba(16, 24, 40, .24);
  --shadow-drawer: -18px 0 48px -20px rgba(10, 18, 35, .38);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
  --side-w: 234px;
  --top-h: 60px;
}

html[data-theme="dark"] {
  --bg: #0d1421;
  --surface: #151e2f;
  --surface-2: #1a2437;
  --surface-3: #202c41;
  --border: #28344a;
  --border-strong: #36435c;
  --text: #e9eef8;
  --text-2: #a5b2c9;
  --text-3: #90a0bb;
  --brand: #7290ff;
  --brand-hover: #8aa3ff;
  --brand-soft: #212f55;
  --brand-ink: #a8baff;
  --success: #45c4a2;
  --success-soft: #16352e;
  --warn: #e5aa55;
  --warn-soft: #3a2d17;
  --danger: #f07880;
  --danger-soft: #3b2026;
  --info: #6aa8ec;
  --info-soft: #1b3049;
  --violet: #a58aee;
  --violet-soft: #2b2447;
  --teal: #55c0d4;
  --teal-soft: #14333a;
  --side-bg: #0a111e;
  --side-bg-2: #131d30;
  --side-text: #c0cbe0;
  --side-text-dim: #71809b;
  --side-active: #26365a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .32), 0 18px 40px -16px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* Theme changes take effect immediately instead of leaving form controls mid-transition */
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--brand);
}

::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); color: var(--text); }

input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

.num, td.num, th.num, .kpi-value, .metric-value, code, .mono {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
}
.mono, code { font-family: var(--mono); font-size: .94em; letter-spacing: -.01em; }

/* ---------- Shell ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
  transition: width .22s cubic-bezier(.2,.8,.2,1), flex-basis .22s cubic-bezier(.2,.8,.2,1);
  position: relative;
  z-index: 30;
}

.brand {
  height: var(--top-h);
  flex: 0 0 var(--top-h);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}
.brand-mark {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1.5px;
  transform: rotate(-8deg);
}
.brand-mark span { border-radius: 1.5px; background: var(--side-text-dim); }
.brand-mark span:nth-child(1), .brand-mark span:nth-child(5), .brand-mark span:nth-child(9) { background: #e8b552; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(6) { background: #5b7ce0; }
.brand-mark span:nth-child(3), .brand-mark span:nth-child(7) { background: #d5dbeb; }
.brand-mark span:nth-child(4), .brand-mark span:nth-child(8) { background: #4aa58a; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; min-width: 0; }
.brand-text strong { font-size: 14px; font-weight: 650; color: #f1f5ff; letter-spacing: -.01em; }
.brand-text small { font-size: 11px; color: var(--side-text-dim); letter-spacing: .04em; }

.sidebar-toggle {
  margin-left: auto;
  width: 24px; height: 24px;
  flex: 0 0 24px;
  border: 0; background: transparent; border-radius: 5px;
  display: grid; place-items: center;
  color: var(--side-text-dim);
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.sidebar:hover .sidebar-toggle, .sidebar-toggle:focus-visible { opacity: 1; }
.sidebar-toggle:hover { background: rgba(255,255,255,.09); color: #fff; }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 10px 18px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: #33405a; background-clip: padding-box; }

.nav-group { margin-bottom: 16px; }
.nav-group-label {
  font-size: 11px;
  letter-spacing: .1em;
  color: #8b99b4;
  padding: 0 10px 7px;
  white-space: nowrap;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 8px 10px;
  margin: 1px 0;
  border: 0; border-radius: 7px;
  background: transparent;
  color: var(--side-text);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  position: relative;
  transition: background .14s, color .14s;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; stroke-width: 1.7; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; font-weight: 550; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: #7b98ff;
}
.nav-item .nav-count {
  margin-left: auto; font-size: 11px; padding: 1px 6px;
  border-radius: 9px; background: rgba(255,255,255,.1); color: #c9d5ec;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { background: rgba(123,152,255,.28); color: #dbe5ff; }

.sidebar-foot { padding: 10px 12px 12px; border-top: 1px solid rgba(255,255,255,.07); }
.side-status { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--side-text-dim); padding: 2px 4px 10px; white-space: nowrap; }
.side-status-meta { margin-left: auto; font-family: var(--mono); font-size: 11px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #3fbf8f; box-shadow: 0 0 0 3px rgba(63,191,143,.16); flex: 0 0 7px; }
.side-account { display: flex; align-items: center; gap: 9px; padding: 8px 6px 2px; border-top: 1px solid rgba(255,255,255,.07); }
.side-account-text { display: flex; flex-direction: column; line-height: 1.3; white-space: nowrap; min-width: 0; }
.side-account-text strong { font-size: 12.5px; color: #eaf0ff; font-weight: 600; }
.side-account-text small { font-size: 11px; color: var(--side-text-dim); }
.side-account .icon-btn { margin-left: auto; color: var(--side-text-dim); }
.side-account .icon-btn:hover { background: rgba(255,255,255,.09); color: #fff; }

.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
  color: #fff;
  background: #5b6c9c;
  user-select: none;
}
.avatar-admin { background: linear-gradient(140deg, #4a63c8, #7a54b8); }
.avatar-sm { width: 26px; height: 26px; flex-basis: 26px; border-radius: 7px; font-size: 11px; }

/* collapsed */
.sidebar.collapsed { --side-w: 66px; }
.sidebar.collapsed .brand { padding: 0 20px; }
.sidebar.collapsed .brand-text, .sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-item span.nav-label, .sidebar.collapsed .nav-item .nav-count,
.sidebar.collapsed .side-status span:not(.pulse-dot), .sidebar.collapsed .side-account-text,
.sidebar.collapsed .side-account .icon-btn { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item.active::before { left: -10px; }
.sidebar.collapsed .side-status { justify-content: center; padding-bottom: 8px; }
.sidebar.collapsed .side-account { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-toggle { position: absolute; left: 20px; top: 70px; opacity: 0; }
.sidebar.collapsed:hover .sidebar-toggle { opacity: 1; }

.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--top-h); flex: 0 0 var(--top-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px 0 26px;
  gap: 16px;
  position: relative; z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { gap: 8px; }
.crumb { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.crumb-root { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.crumb-sep { color: var(--text-3); font-size: 12px; }
.crumb-current { font-size: 14.5px; font-weight: 640; letter-spacing: -.015em; white-space: nowrap; }

.icon-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-2);
  transition: background .14s, color .14s, border-color .14s;
}
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.7; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.subtle { border: 0; }
.icon-btn.is-active { background: var(--brand-soft); color: var(--brand); }
.mobile-menu { display: none; }

.global-search { position: relative; width: 258px; }
.global-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none;
}
.global-search .search-icon svg { width: 15px; height: 15px; stroke-width: 1.8; }
.global-search input {
  width: 100%; height: 34px;
  padding: 0 46px 0 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.global-search input::placeholder { color: var(--text-3); }
.global-search input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.global-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px;
  background: var(--surface); pointer-events: none;
}
.search-results {
  position: absolute; top: 40px; left: 0; right: 0;
  min-width: 340px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--shadow-2);
  padding: 6px; z-index: 60; max-height: 380px; overflow-y: auto;
}
.search-group { font-size: 11px; color: var(--text-3); padding: 7px 9px 4px; letter-spacing: .06em; text-transform: uppercase; }
.search-hit { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.search-hit:hover, .search-hit:focus-visible { background: var(--surface-3); }
.search-hit strong { font-size: 12.5px; font-weight: 560; }
.search-hit small { color: var(--text-3); font-size: 11.5px; margin-left: auto; }
.search-empty { padding: 20px 10px; text-align: center; color: var(--text-3); font-size: 12px; }

.data-stamp {
  font-size: 11px; color: var(--text-3); white-space: nowrap;
  padding: 5px 9px; border-radius: 6px; background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-variant-numeric: tabular-nums;
}
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 17px; height: 17px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
  border: 2px solid var(--surface); box-sizing: content-box;
}
.topbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.topbar-account { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 3px 6px 3px 3px; border-radius: 8px; font-size: 12.5px; font-weight: 560; }
.topbar-account:hover { background: var(--surface-3); }
.topbar-account .avatar { width: 28px; height: 28px; flex-basis: 28px; }

.popover {
  position: fixed; z-index: 90;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--shadow-2);
  min-width: 260px; padding: 6px;
}
.popover-title { font-size: 11px; color: var(--text-3); padding: 8px 10px 6px; letter-spacing: .05em; text-transform: uppercase; }
.popover-item { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border-radius: 7px; }
.popover-item:hover { background: var(--surface-3); }
.popover-item .pi-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: 0 0 7px; }
.popover-item strong { display: block; font-size: 12.5px; font-weight: 560; }
.popover-item small { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; }
.popover-foot { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; }

/* ---------- View & page ---------- */
.view { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px 26px 48px; scroll-behavior: smooth; }
.page { max-width: 1500px; margin: 0 auto; animation: page-in .3s cubic-bezier(.16,.84,.3,1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } * { scroll-behavior: auto !important; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-head h1 { font-size: 21px; font-weight: 660; letter-spacing: -.028em; margin: 0 0 4px; line-height: 1.3; }
.page-head p { margin: 0; color: var(--text-2); font-size: 12.5px; max-width: 76ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 33px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: 12.5px; font-weight: 540; white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, transform .1s, box-shadow .14s;
}
.btn svg { width: 15px; height: 15px; stroke-width: 1.8; }
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(58,91,217,.24); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-danger { background: var(--surface); border-color: var(--border-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon-only { width: 32px; padding: 0; }
.link-btn { border: 0; background: transparent; color: var(--brand); padding: 0; font-size: 12.5px; font-weight: 540; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); }

.seg { display: inline-flex; padding: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font-size: 12px; padding: 5px 11px; border-radius: 6px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 570; box-shadow: var(--shadow-1); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-1); min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px 12px; }
.panel-head h2 { font-size: 14px; font-weight: 620; letter-spacing: -.012em; margin: 0 0 2px; }
.panel-head p { margin: 0; color: var(--text-3); font-size: 11.5px; }
.panel-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.panel-body { padding: 4px 18px 18px; }
.panel-foot { border-top: 1px solid var(--border); padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--text-3); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-grid { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.dash-grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* KPI strip — one shared surface, divided cells, not four hero cards */
.kpi-strip {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-1);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}
.kpi-cell { padding: 15px 17px 14px; min-width: 0; position: relative; }
.kpi-cell + .kpi-cell { border-left: 1px solid var(--border); }
.kpi-label { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.kpi-label svg { width: 14px; height: 14px; stroke-width: 1.8; color: var(--text-3); }
.kpi-value { font-size: 25px; font-weight: 660; letter-spacing: -.035em; line-height: 1.25; margin-top: 7px; display: flex; align-items: baseline; gap: 4px; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 580; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--danger); }      /* 增长用红：与中文语境「涨」一致 */
.delta.down { color: var(--success); }
.delta.flat { color: var(--text-3); }
.delta svg { width: 12px; height: 12px; stroke-width: 2; }
.kpi-foot .kpi-note { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-spark { width: 62px; height: 22px; flex: 0 0 62px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--text-3);
  letter-spacing: .03em; text-transform: uppercase;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th .sort-ind { display: inline-block; margin-left: 4px; opacity: .45; font-size: 11px; }
.data-table th.sorted .sort-ind { opacity: 1; color: var(--brand); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.selected { background: var(--brand-soft); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table td.nowrap, .data-table th.nowrap { white-space: nowrap; }
.data-table .cell-strong { font-weight: 570; color: var(--text); }
.data-table .cell-sub { color: var(--text-3); font-size: 11px; margin-top: 1px; }
.cell-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-user .cu-text { min-width: 0; }
.cell-user .cu-name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-user .cu-mail { color: var(--text-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.cell-actions .icon-btn { width: 27px; height: 27px; flex-basis: 27px; }
.cell-actions .icon-btn svg { width: 14px; height: 14px; }

.check { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; flex: 0 0 15px; border: 1.5px solid var(--border-strong); border-radius: 4px; background: var(--surface); position: relative; cursor: pointer; transition: background .12s, border-color .12s; }
.check:hover { border-color: var(--brand); }
.check:checked, .check:indeterminate { background: var(--brand); border-color: var(--brand); }
.check:checked::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(42deg); }
.check:indeterminate::after { content: ""; position: absolute; left: 3px; top: 6px; width: 7px; height: 2px; background: #fff; border-radius: 1px; }
.check:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 560; white-space: nowrap; line-height: 1.6; }
.badge .b-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.mod-tag { display: inline-grid; place-items: center; width: 21px; height: 21px; border-radius: 5px; font-size: 11px; font-weight: 700; font-family: var(--mono); }
.mod-C { background: var(--info-soft); color: var(--info); }
.mod-F { background: var(--success-soft); color: var(--success); }
.mod-O { background: var(--warn-soft); color: var(--warn); }
.mod-P { background: var(--violet-soft); color: var(--violet); }

/* ---------- Toolbar & forms ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.search-field { position: relative; width: 236px; min-width: 170px; }
.search-field .sf-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.search-field .sf-icon svg { width: 14px; height: 14px; stroke-width: 1.8; }
.field { height: 33px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 12.5px; transition: border-color .14s, box-shadow .14s; }
.field::placeholder { color: var(--text-3); }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.field:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
input.field, select.field { width: 100%; }
select.field { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b97ad' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
.search-field input { padding-left: 30px; }
.toolbar-spacer { flex: 1; }
.toolbar-count { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 9px 18px; background: var(--brand-soft); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--brand-ink); }
.bulk-bar strong { font-weight: 650; }

.filter-label { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-item.full { grid-column: 1 / -1; }
.form-item > label { font-size: 12px; font-weight: 560; color: var(--text-2); }
.form-item .hint { font-size: 11px; color: var(--text-3); }
.form-item textarea.field { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.55; }
.form-error { font-size: 11.5px; color: var(--danger); min-height: 15px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .sr-title { font-size: 12.5px; font-weight: 560; }
.switch-row .sr-desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; max-width: 60ch; }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 36px; height: 20px; flex: 0 0 36px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 12px; background: var(--border-strong); transition: background .18s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pg-info { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pg-buttons { display: flex; align-items: center; gap: 4px; }
.pg-btn { min-width: 28px; height: 28px; padding: 0 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pg-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pg-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Data viz ---------- */
.chart-svg { display: block; width: 100%; overflow: visible; }
.chart-svg text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; }
.chart-axis-text { fill: var(--text-3); font-size: 11px; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { opacity: .13; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-hover-line { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-bar { transition: opacity .14s; }
.chart-bar:hover { opacity: .78; }
.chart-tooltip {
  position: fixed; z-index: 120; pointer-events: none;
  background: var(--text); color: var(--surface);
  border-radius: 7px; padding: 8px 10px; font-size: 11.5px;
  box-shadow: var(--shadow-2); min-width: 120px;
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .chart-tooltip { background: #e9eef8; color: #101828; }
.chart-tooltip .tt-title { font-weight: 620; margin-bottom: 5px; font-size: 11px; opacity: .8; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.chart-tooltip .tt-row i { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 7px; }
.chart-tooltip .tt-row b { margin-left: auto; font-weight: 620; }
.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.legend-item i { width: 9px; height: 9px; border-radius: 3px; }
.legend-item.off { opacity: .38; }

.rank-list { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 64px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: 0; }
.rank-idx { font-size: 11px; color: var(--text-3); font-family: var(--mono); text-align: center; }
.rank-row:nth-child(-n+3) .rank-idx { color: var(--brand); font-weight: 700; }
.rank-name { min-width: 0; }
.rank-name .rn-top { display: flex; align-items: baseline; gap: 6px; }
.rank-name strong { font-size: 12.5px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-name small { color: var(--text-3); font-size: 11px; white-space: nowrap; }
.rank-name .rn-track { height: 4px; border-radius: 3px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.rank-name .rn-fill { height: 100%; border-radius: 3px; background: var(--brand); }
.rank-value { text-align: right; font-size: 12.5px; font-weight: 620; font-variant-numeric: tabular-nums; }
.rank-value small { display: block; font-size: 11px; color: var(--text-3); font-weight: 400; }

.stat-list { display: flex; flex-direction: column; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .sl { color: var(--text-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.stat-row .sv { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-row .sv small { color: var(--text-3); font-weight: 400; margin-left: 5px; }

.heatmap { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; min-width: 0; cursor: default; }
.heat-label { font-size: 11px; color: var(--text-3); text-align: right; padding-right: 5px; white-space: nowrap; }
.heat-hour { font-size: 11px; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }

.progress { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.progress > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-center-label { text-align: center; }
.donut-legend { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 9px; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-legend .dl-row i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.donut-legend .dl-row span { color: var(--text-2); }
.donut-legend .dl-row b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 620; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(12, 20, 36, .42); z-index: 70; animation: fade-in .2s ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--surface); z-index: 71; box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  animation: drawer-in .28s cubic-bezier(.16,.84,.3,1) both;
}
@keyframes drawer-in { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 14px; }
.drawer-head h2 { font-size: 16px; font-weight: 640; letter-spacing: -.02em; margin: 0 0 3px; }
.drawer-head p { margin: 0; color: var(--text-3); font-size: 11.5px; }
.drawer-head .icon-btn { margin-left: auto; flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 13px 22px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.drawer-section { margin-bottom: 24px; }
.drawer-section:last-child { margin-bottom: 0; }
.drawer-section h3 { font-size: 12px; font-weight: 620; color: var(--text-2); margin: 0 0 12px; letter-spacing: .02em; text-transform: uppercase; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.kv { min-width: 0; }
.kv .k { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.kv .v { font-size: 12.5px; font-weight: 540; word-break: break-word; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.profile-head .avatar { width: 52px; height: 52px; flex-basis: 52px; border-radius: 12px; font-size: 17px; }
.profile-head .ph-name { font-size: 17px; font-weight: 640; letter-spacing: -.02em; }
.profile-head .ph-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.profile-head .ph-tags { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 5px; bottom: 5px; width: 1px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.tl-item.warn::before { border-color: var(--warn); }
.tl-item.danger::before { border-color: var(--danger); }
.tl-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 12.5px; font-weight: 540; margin-top: 1px; }
.tl-desc { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); padding: 0 22px; }
.tabs button { border: 0; background: transparent; padding: 10px 0 11px; font-size: 12.5px; color: var(--text-2); position: relative; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); font-weight: 600; }
.tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px 2px 0 0; }

/* ---------- Modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 20, 36, .46); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade-in .18s ease both; }
.modal { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-2); animation: modal-in .22s cubic-bezier(.16,.84,.3,1) both; }
@keyframes modal-in { from { transform: translateY(10px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { width: min(620px, 100%); }
.modal-head { padding: 18px 20px 12px; }
.modal-head h2 { font-size: 15.5px; font-weight: 640; margin: 0 0 3px; letter-spacing: -.015em; }
.modal-head p { margin: 0; font-size: 12px; color: var(--text-2); }
.modal-body { padding: 4px 20px 18px; max-height: 62vh; overflow-y: auto; }
.modal-foot { border-top: 1px solid var(--border); padding: 13px 20px; display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.confirm-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); margin-bottom: 12px; }
.confirm-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 140; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 250px; max-width: 380px; padding: 11px 13px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-2); animation: toast-in .24s cubic-bezier(.16,.84,.3,1) both; }
@keyframes toast-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.out { animation: toast-out .2s ease both; }
@keyframes toast-out { to { transform: translateX(16px); opacity: 0; } }
.toast .t-icon { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.toast .t-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.toast.success .t-icon { color: var(--success); }
.toast.error .t-icon { color: var(--danger); }
.toast.info .t-icon { color: var(--brand); }
.toast.warn .t-icon { color: var(--warn); }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-size: 12.5px; font-weight: 600; }
.toast .t-desc { font-size: 11.5px; color: var(--text-2); margin-top: 2px; line-height: 1.5; }

.empty-state { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty-state svg { width: 30px; height: 30px; stroke-width: 1.4; margin-bottom: 10px; color: var(--border-strong); }
.empty-state .es-title { font-size: 13px; font-weight: 560; color: var(--text-2); }
.empty-state .es-desc { font-size: 11.5px; margin-top: 4px; }
.empty-state .btn { margin-top: 14px; }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: 5px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Misc ---------- */
.note { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); line-height: 1.6; }
.note svg { width: 15px; height: 15px; flex: 0 0 15px; stroke-width: 1.8; margin-top: 2px; color: var(--info); }
.note.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.note.warn svg { color: var(--warn); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--text-3); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 13px; font-weight: 620; margin: 0 0 10px; letter-spacing: -.01em; }
.matrix-table td, .matrix-table th { text-align: center; }
.matrix-table td:first-child, .matrix-table th:first-child { text-align: left; }
.perm-yes { color: var(--success); font-weight: 700; }
.perm-no { color: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1340px) {
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-cell:nth-child(4) { border-left: 0; border-top: 1px solid var(--border); }
  .kpi-cell:nth-child(5) { border-top: 1px solid var(--border); }
  .dash-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .global-search { width: 190px; }
  .data-stamp { display: none; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .mobile-menu { display: grid; }
  .grid-2, .grid-3, .dash-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-cell:nth-child(3), .kpi-cell:nth-child(5) { border-left: 0; }
  .kpi-cell:nth-child(3), .kpi-cell:nth-child(4), .kpi-cell:nth-child(5) { border-top: 1px solid var(--border); }
  .topbar { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 640px) {
  .view { padding: 16px 14px 36px; }
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .global-search { width: 40px; }
  .global-search input { padding-right: 8px; }
  .global-search input:focus { position: absolute; width: 230px; right: 0; z-index: 5; }
  .global-search kbd { display: none; }
  .search-results { left: auto; right: 0; min-width: 300px; }
  .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .kpi-cell + .kpi-cell { border-left: 0; border-top: 1px solid var(--border); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-account span, .topbar-divider { display: none; }
  .search-field { width: 100%; }
  .toolbar { padding: 12px 14px; }
}
