/* =============================================================================
   Audit Safe Vault — Layout System
   App Shell · Sidebar · Topbar · Page Structure · Section Blocks
   =============================================================================
   Depends on: design-system.css (for CSS variables and primitives)
   Import order: <link> design-system.css, then this file.
   ============================================================================= */

/* ============================================================
   1. APP SHELL — root grid
   Sidebar (240px fixed) | Main column (flexible)
   ============================================================ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  transition: grid-template-columns .18s ease;
}

/* ── Collapsible sidebar — icon rail at 64px ─────────────────────
   Toggle: chevron in the sidebar head collapses; clicking the logo expands.
   Sub-items (Setting catalogs) and the client picker need the full rail,
   so they hide until expanded; nav icons keep title tooltips. */
.app.sb-collapsed { grid-template-columns: 64px 1fr; }
.sb-toggle { margin-left: auto; width: 24px; height: 24px; flex-shrink: 0; }
.app.sb-collapsed .sidebar-head { justify-content: center; padding: 14px 0; }
.app.sb-collapsed .brand-block,
.app.sb-collapsed .sb-toggle,
.app.sb-collapsed .nav-section,
.app.sb-collapsed .nav-group-head,
.app.sb-collapsed .nav-subitem,
.app.sb-collapsed .nav-item .count,
.app.sb-collapsed .sidebar-foot .foot-meta,
.app.sb-collapsed .sidebar-foot .icon-btn { display: none; }
.app.sb-collapsed .nav-item {
  justify-content: center; gap: 0;
  font-size: 0;          /* hides the bare text node; the SVG keeps its own size */
  padding: 10px 0;
}
.app.sb-collapsed .sidebar-foot { justify-content: center; padding: 12px 0; }

/* Density compact modifier — applied via JS class on .app */
.app.density-compact .tbl td      { padding: 8px 12px; }
.app.density-compact .tbl th      { padding: 7px 12px; }
.app.density-compact .page-head   { padding: 16px 24px 12px; }
.app.density-compact .sec-body    { padding: 14px; }
.app.density-compact .page-body   { padding: 16px; }
.app.density-compact .card-body   { padding: 14px; }
.app.density-compact .sbadge      { padding: 2px 7px 2px 5px; font-size: 11px; }

/* ============================================================
   2. SIDEBAR
   ============================================================ */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar header — brand (height must match .top for aligned borders) */
.sidebar-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-weight: 700; font-size: 10.5px;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 13px; line-height: 1.1; }
.brand-tag  { font-family: var(--mono); font-size: 10px; color: var(--muted); line-height: 1.1; margin-top: 2px; }

/* Sidebar navigation */
.nav {
  padding: 8px 8px 12px;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto;
  flex: 1;
}
.nav-section {
  font-family: var(--mono);
  font-size: 9.5px; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 12px 6px;
  font-weight: 600;
  display: flex; align-items: center; gap: 5px;
}
.nav-item {
  padding: 7px 11px;
  display: flex; align-items: center; gap: 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12.5px;
  text-decoration: none;
  border: none; background: transparent;
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); color: var(--ink); font-weight: 500; }
.nav-item.disabled { color: var(--muted-2); cursor: not-allowed; opacity: .7; }
.nav-item.disabled:hover { background: transparent; }
.nav-item .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 10px;
  color: var(--muted-2);
}
.nav-item .count.amber { padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); }

/* Pinned projects — × appears on hover; sidebar can only jump or unpin */
.nav-item .pin-x {
  margin-left: auto;
  display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  color: var(--muted); flex-shrink: 0;
}
.nav-item:hover .pin-x { display: inline-flex; }
.nav-item .pin-x:hover { background: var(--panel-3); color: var(--ink); }
.app.sb-collapsed .nav-item .pinned-label,
.app.sb-collapsed .nav-item:hover .pin-x { display: none; }

/* Always-expanded parent group (e.g. Setting → Service Types / Company Categories).
   The parent is a visual header (non-interactive), sub-items sit below at an indent. */
.nav-group-head {
  padding: 7px 11px 4px;
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: default;
}
.nav-group-head .group-ico { color: var(--muted-2); }
.nav-subitem {
  padding: 6px 11px 6px 36px;   /* 11 + 15 indent (icon-width-ish) + 10 gap */
  font-size: 12px;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none; background: transparent;
  text-align: left; width: 100%;
}
.nav-subitem::before {
  content: ""; width: 4px; height: 4px;
  border-radius: 50%; background: var(--muted-dim);
  flex-shrink: 0; margin-right: 2px;
}
.nav-subitem:hover  { background: var(--panel-2); color: var(--ink-2); }
.nav-subitem.active { background: var(--panel-2); color: var(--ink); font-weight: 500; }
.nav-subitem.active::before { background: var(--ink); }
.nav-subitem .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 10px;
  color: var(--muted-2);
}

/* Entity picker — "Active client" switcher below brand */
.ent-picker { padding: 10px 12px; }
.ent-picker-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--panel-3); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; text-align: left;
}
.ent-picker-btn:hover { border-color: var(--line-2); background: #fff; }
.ent-avatar {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 10px;
  flex-shrink: 0;
}
.ent-avatar.alt1 { background: oklch(0.65 0.15 25); }
.ent-avatar.alt2 { background: oklch(0.55 0.12 180); }
.ent-avatar.alt3 { background: oklch(0.45 0.18 290); }
.ent-avatar.alt4 { background: oklch(0.60 0.14 145); }
.ent-name { font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ent-sub  { font-family: var(--mono); font-size: 10px; color: var(--muted); line-height: 1.2; margin-top: 2px; }

/* Context block — "Currently viewing" entity/project in sidebar */
.ctx-block { padding: 4px 8px 4px; }
.ctx-ent {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  border-radius: var(--radius);
  cursor: pointer; text-align: left;
}
.ctx-ent:hover { background: #fff; border-color: var(--line-2); }
.ctx-name { font-size: 12px; font-weight: 600; line-height: 1.25; }
.ctx-sub  { font-size: 10px; color: var(--muted); margin-top: 3px; }
.ctx-proj {
  margin-top: 8px; padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.ctx-proj-name { font-size: 11.5px; font-weight: 600; line-height: 1.3; }
.ctx-tabs {
  display: flex; flex-direction: column; gap: 1px;
  margin-top: 10px;
  padding-left: 8px;
  border-left: 1px dashed var(--line);
  margin-left: 12px;
}
.ctx-tab {
  padding: 5px 10px;
  font-size: 11.5px; color: var(--muted);
  background: transparent; border: 0;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.ctx-tab:hover { background: var(--panel-2); color: var(--ink-2); }
.ctx-tab.active { color: var(--ink); font-weight: 500; background: var(--panel-2); }
.ctx-tab .lock { color: var(--warn-ink); }

/* Entity-detail tabs nested inside ent-picker — drop the dashed-rail indent
   because the picker already provides the visual container. */
.ent-picker .ctx-tabs.ent-picker-tabs {
  margin-left: 0;
  margin-top: 8px;
  padding-left: 0;
  border-left: 0;
}
.ent-picker .ctx-tabs.ent-picker-tabs .ctx-tab {
  padding: 6px 10px;
}

/* Sidebar footer — user info */
.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-3);
}

/* ============================================================
   3. MAIN COLUMN
   ============================================================ */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* Topbar — breadcrumbs left, search right */
.top {
  display: flex; align-items: center; gap: 10px;
  min-height: 57px;            /* match .sidebar-head so bottom borders align */
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky; top: 0; z-index: 30;
}
.top-search { flex: 1; max-width: 320px; margin-left: auto; }

/* Breadcrumbs in topbar */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--muted-2); }
.crumbs .cur { color: var(--ink); font-weight: 500; }

/* Page container */
.page { flex: 1; min-width: 0; }

/* Split-pane layout (entities list view) */
.split { display: grid; grid-template-columns: 320px 1fr; min-height: calc(100vh - 130px); }
.split-left  { border-right: 1px solid var(--line); background: var(--panel-3); display: flex; flex-direction: column; }
.split-right { display: flex; flex-direction: column; min-width: 0; }

/* Entity list */
.ent-list-head    { padding: 14px 16px 10px; }
.ent-list-filters { display: flex; gap: 4px; padding: 0 16px 10px; flex-wrap: wrap; }
.ent-list         { overflow-y: auto; flex: 1; }
.ent-item { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; cursor: pointer; position: relative; }
.ent-item:hover  { background: #fff; }
.ent-item.active { background: #fff; }
.ent-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ink); }
.ent-avatar-md { width: 40px; height: 40px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 11px; flex-shrink: 0; }
.ent-avatar-md.alt1 { background: oklch(0.65 0.15 25); }
.ent-avatar-md.alt2 { background: oklch(0.55 0.12 180); }
.ent-avatar-md.alt3 { background: oklch(0.45 0.18 290); }
.ent-avatar-md.alt4 { background: oklch(0.60 0.14 145); }
.ent-avatar-md.alt5 { background: oklch(0.50 0.15 50); }

/* ============================================================
   4. PAGE STRUCTURE
   ============================================================ */

/* Breadcrumb bar */
.crumbbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.crumbbar a { color: var(--muted); text-decoration: none; cursor: pointer; }
.crumbbar a:hover { color: var(--ink); }
.crumbbar .sep { color: var(--muted-2); }
.crumbbar .cur { color: var(--ink); font-weight: 500; }

/* Page header */
.page-head { padding: 22px 24px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.page-head.tight { padding-bottom: 0; border-bottom: 0; }
.page-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 760px; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Tab bar (below page header) */
.tabbar {
  display: flex; align-items: center; gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
  scrollbar-width: thin; /* visible hint that the strip scrolls when tabs overflow */
}
.tab {
  padding: 12px 18px 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap; flex-shrink: 0; /* keep tabs whole — a partially visible tab signals overflow */
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  border-left: 0; border-right: 0; border-top: 0;
  background: transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tab .lock  { color: var(--warn-ink); }
.tab .badge-count {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
  font-weight: 500;
}
.tab.active .badge-count { background: var(--ink); color: #fff; }
.tab .badge-count.amber  { background: var(--warn-soft); color: var(--warn-ink); }

/* Page body */
.page-body       { padding: 24px; min-width: 0; flex: 1; }
.page-body.flush { padding: 0; }

/* ============================================================
   5. SECTION BLOCKS (card-like content sections)
   ============================================================ */
.sec {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.sec-head {
  padding: 13px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.sec-head .sec-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sec-head .sec-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sec-body       { padding: 18px; }
.sec-body.flush { padding: 0; }

/* ============================================================
   6. FORM PAGE (full-width form layout)
   ============================================================ */
.formpage { max-width: 760px; margin: 0 auto; padding: 24px 24px 80px; }
.formpage h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.formpage > .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.formfoot {
  position: sticky; bottom: 0;
  padding: 14px 24px;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  z-index: 5; margin-top: 18px;
}
.formfoot .lead { color: var(--muted); font-size: 12px; }

/* Approval action bar (sticky bottom) */
.actionbar {
  position: sticky; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 10px;
  z-index: 5;
  box-shadow: 0 -6px 14px rgba(0,0,0,.03);
}

/* ============================================================
   7. STATS / COUNT PILLS
   ============================================================ */
.cnt {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-width: 120px;
  flex: 1 1 0; /* share the row evenly — avoids a lone card wrapping to its own line */
}
.cnt .val { font-family: var(--mono); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.cnt .lbl { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* ============================================================
   8. TWEAKS PANEL (floating debug/prototype panel)
   ============================================================ */
.tweaks {
  position: fixed; right: 20px; bottom: 20px;
  width: 300px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 30px rgba(0,0,0,.10);
  padding: 14px 16px;
  z-index: 150;
}
.tweaks.hidden { display: none; }
.tweaks h4 { margin: 0 0 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.tweaks .field { margin-bottom: 12px; }
.tweaks .field label { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; font-weight: 600; }
.tweaks .seg { display: flex; background: var(--panel-2); border-radius: var(--radius); padding: 2px; gap: 2px; }
.tweaks .seg button { flex: 1; border: 0; background: transparent; padding: 5px 6px; font-size: 11px; border-radius: 4px; color: var(--muted); font-weight: 500; cursor: pointer; }
.tweaks .seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 0 rgba(0,0,0,.05); }

/* ============================================================
   9. ACTIVITY / AUDIT TRAIL LAYOUT
   ============================================================ */
.trust-strip {
  padding: 10px 24px;
  background: linear-gradient(90deg, var(--ok-soft), transparent 80%);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--ok-ink);
}

.act-toolbar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.act-stat {
  display: flex; gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-3);
  flex-wrap: wrap;
}
.act-stat .stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 110px;
  flex: 1 1 0; /* share the row evenly so 5–6 cards sit on one line instead of wrapping 4+1 */
}
.act-stat .stat-val { font-size: 18px; font-weight: 600; font-family: var(--mono); letter-spacing: -.01em; }
.act-stat .stat-lbl { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* Activity split view */
.act-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: calc(100vh - 380px);
  flex: 1;
}
.act-list { border-right: 1px solid var(--line); min-width: 0; background: #fff; overflow-x: auto; }
.act-row  { cursor: pointer; }
.act-row:hover    { background: var(--panel-3); }
.act-row.selected { background: var(--accent-soft); }
.act-row .time { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.act-row .time b { display: block; color: var(--ink-2); font-weight: 500; font-size: 12px; }

.action-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius); font-size: 11px; font-weight: 500; }
.action-tag.upload  { background: var(--accent-soft); color: var(--accent-ink); }
.action-tag.edit    { background: var(--panel-2);     color: var(--ink-2); }
.action-tag.sign    { background: var(--ok-soft);     color: var(--ok-ink); }
.action-tag.return  { background: var(--warn-soft);   color: var(--warn-ink); }
.action-tag.delete  { background: var(--danger-soft); color: var(--danger-ink); }
.action-tag.perm    { background: oklch(0.95 0.03 290); color: oklch(0.40 0.14 290); }
.action-tag.login   { background: var(--panel-2);     color: var(--muted); }
.action-tag.view    { background: var(--panel-2);     color: var(--muted); }

.act-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; background: var(--panel-3);
}

/* Activity timeline view */
.tl-list { padding: 20px 24px; position: relative; }
.tl-list::before {
  content: ""; position: absolute;
  left: 42px; top: 30px; bottom: 30px;
  width: 2px; background: var(--line);
}
.tl-day { margin-bottom: 24px; }
.tl-day-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  padding-left: 24px;
  position: relative;
}
.tl-day-head::before {
  content: ""; position: absolute;
  left: 18px; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink); border: 3px solid var(--bg);
}
.tl-day-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.tl-day-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tl-card {
  position: relative;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  margin-left: 36px;
}
.tl-card:hover { border-color: var(--line-2); }
.tl-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-card::before {
  content: ""; position: absolute;
  left: -22px; top: 18px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-2);
}
.tl-card.critical::before { background: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.tl-card.signoff::before  { background: var(--ok);     box-shadow: 0 0 0 1px var(--ok); }
.tl-card.upload::before   { background: var(--accent);  box-shadow: 0 0 0 1px var(--accent); }
.tl-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.tl-card-body { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.tl-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); flex-wrap: wrap; }

/* Activity detail drawer */
.act-drawer {
  background: var(--panel-3);
  padding: 20px 22px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  min-width: 0;
}
.act-drawer .dfield { margin-bottom: 14px; }
.act-drawer .dfield label {
  display: block;
  font-family: var(--mono); font-size: 10px;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 5px; font-weight: 600;
}
.act-drawer .dval { font-size: 12.5px; color: var(--ink); }

.hash-box {
  padding: 10px 12px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  word-break: break-all; line-height: 1.5;
}
.hash-box .hchip {
  padding: 2px 6px;
  background: var(--ok-soft); color: var(--ok-ink);
  border-radius: 3px;
  font-weight: 600; font-size: 9px;
  letter-spacing: .04em; text-transform: uppercase;
  flex-shrink: 0;
}

.seg-wrap .seg {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px; gap: 2px;
}
.seg-wrap .seg button {
  border: 0; background: transparent;
  padding: 5px 10px; font-size: 11.5px;
  border-radius: 4px; color: var(--muted); font-weight: 500; cursor: pointer;
}
.seg-wrap .seg button.active {
  background: #fff; color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
}

/* ============================================================
   10. SOP TEMPLATES LAYOUT
   ============================================================ */
/* Template tab bar */
.tpl-tabbar .tab { padding: 11px 14px 12px; font-size: 12.5px; }
.tpl-tabbar .tab .badge,
.tpl-tabbar .tab .mono { margin-left: 2px; }

/* Template summary card */
.tpl-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 28px;
  align-items: center;
  padding: 18px 22px;
  margin-bottom: 14px;
}
.tpl-summary-main { min-width: 0; }
.tpl-summary-main > div:first-child { font-size: 16px; font-weight: 600; text-wrap: pretty; }
.tpl-summary-cell { display: flex; flex-direction: column; min-width: 0; }
.tpl-stat { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.tpl-summary-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 1100px) {
  .tpl-summary { grid-template-columns: 1fr 1fr; gap: 18px 22px; }
  .tpl-summary-main { grid-column: 1 / -1; }
  .tpl-summary-actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 2px; }
}

/* Nested folder tree */
.tpl-folder-tree { padding: 6px 6px 10px; min-height: 120px; }
.tpl-folder {
  display: flex; align-items: center; gap: 2px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--ink-2);
  padding: 2px 6px;
  position: relative;
}
.tpl-folder:hover  { background: var(--panel-2); }
.tpl-folder.active { background: var(--panel-2); color: var(--ink); }
.tpl-folder.active .tpl-folder-body { font-weight: 600; }
.tpl-folder-chev {
  flex-shrink: 0; width: 18px; height: 24px;
  display: grid; place-items: center;
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted);
}
.tpl-folder-chev:hover { color: var(--ink); }
.tpl-folder-body {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 5px 4px;
  border: 0; background: transparent;
  cursor: pointer; text-align: left;
  color: inherit; font: inherit; min-width: 0;
}
.tpl-folder-count { font-size: 10px; color: var(--muted-2); padding: 0 2px; }
.tpl-folder-actions { display: none; align-items: center; gap: 2px; padding-right: 2px; }
.tpl-folder:hover .tpl-folder-actions  { display: inline-flex; }
.tpl-folder.active .tpl-folder-actions { display: inline-flex; }

/* Template builder split layout */
.tpl-builder {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .tpl-builder { grid-template-columns: 1fr; } }

/* Sub-tabs inside template detail */
.sub-tabs {
  display: flex; gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.sub-tab {
  padding: 8px 16px;
  border: 0; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
}
.sub-tab:hover  { color: var(--ink-2); }
.sub-tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

.tpl-impact-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel-3);
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
}

/* ============================================================
   11. PROJECT STRUCTURE — 3-panel layout
   ============================================================ */
.struct {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  min-height: calc(100vh - 200px);
}

/* Folder tree */
.tree { padding: 0 8px 10px; overflow-y: auto; }
.tree-head {
  padding: 8px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.tree-node {
  padding: 5px 8px;
  display: flex; align-items: center; gap: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px; color: var(--ink-2);
}
.tree-node:hover  { background: var(--panel-2); }
.tree-node.active { background: var(--panel-2); color: var(--ink); font-weight: 500; }
.tree-node .chev  { width: 14px; display: inline-block; color: var(--muted-2); transition: transform .15s; }
.tree-node.open .chev { transform: rotate(90deg); }
.tree-kids {
  margin-left: 14px;
  border-left: 1px dashed var(--line);
  padding-left: 6px;
}

/* ============================================================
   15. HOME (My Workspace) — personal pulse dashboard
   ============================================================ */
/* 2-column shell: main + right sidebar (sidebar drops below on narrow screens) */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.home-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.home-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 70px; }
@media (max-width: 1100px) {
  .home-grid  { grid-template-columns: 1fr; }
  .home-side  { position: static; }
}

/* Continue-where-you-left-off hero — single primary card */
.home-hero {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
}
.home-hero .h-mark {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--panel-2);
  display: grid; place-items: center;
  color: var(--ink-2);
  flex-shrink: 0;
}
.home-hero .h-body { flex: 1; min-width: 0; }
.home-hero .h-eyebrow {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 4px;
}
.home-hero .h-title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.home-hero .h-meta  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.home-hero .h-meta b { color: var(--ink-2); font-weight: 500; }

/* Recent-files row — compact list inside .sec */
.recent-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1.5fr) minmax(0, 1fr) 150px 70px;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: var(--panel-3); }
.recent-row .r-name  { font-size: 13px; color: var(--ink); font-weight: 500; }
.recent-row .r-path  { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.recent-row .r-when  { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.recent-row .r-when b { display: block; color: var(--ink-2); font-weight: 500; font-size: 11.5px; font-family: var(--mono); white-space: nowrap; }
.recent-row .r-act   { justify-self: end; }
@media (max-width: 900px) {
  .recent-row { grid-template-columns: 28px minmax(0, 1fr) 80px 60px; }
  .recent-row .r-when { display: none; }
}

/* To-do row — pending action across project */
.todo-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;  /* title gets the slack; entity + time hug content */
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.todo-row:last-child { border-bottom: 0; }
.todo-row:hover { background: var(--panel-3); }
.todo-row .t-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.todo-row .t-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.todo-row .t-sub .mono { font-family: var(--mono); }
.todo-row .t-proj  { font-size: 12px; color: var(--ink-2); }
.todo-row .t-proj .mono { font-family: var(--mono); font-size: 10.5px; color: var(--muted); display: block; }
.todo-row .t-when  { font-family: var(--mono); font-size: 11px; color: var(--muted); justify-self: end; }

/* Engagement chip — condensed Active engagements list */
.engagement-strip {
  display: flex; flex-direction: column; gap: 0;
}
.engagement-chip {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.engagement-chip:last-child { border-bottom: 0; }
.engagement-chip:hover { background: var(--panel-3); }
.engagement-chip .e-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.engagement-chip .e-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* Right-sidebar mini cards */
.side-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.side-card-head {
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.side-card-head .side-title {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0; text-transform: none;
  color: var(--ink);
  display: flex; align-items: center; gap: 7px;
}
.side-card-body { padding: 4px 0; }
.side-row {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.side-row:last-child { border-bottom: 0; }
.side-row:hover { background: var(--panel-3); }
.side-row .s-top { display: flex; align-items: center; gap: 7px; }
.side-row .s-name { font-size: 12.5px; color: var(--ink); font-weight: 500; flex: 1; min-width: 0; }
.side-row .s-meta { font-size: 11px; color: var(--muted); margin-top: 3px; font-family: var(--mono); }
.side-row .s-pill {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.side-row .s-pill.danger { background: var(--danger-soft); color: var(--danger-ink); }
.side-row .s-pill.warn   { background: var(--warn-soft);   color: var(--warn-ink); }
.side-row .s-pill.info   { background: var(--accent-soft); color: var(--accent-ink); }

/* Compact tabbar (inside a .sec head) for Home to-do switcher */
.tabbar-inline {
  display: flex; align-items: center; gap: 2px;
  margin-left: auto;
}
.tabbar-inline .tab {
  padding: 6px 11px 7px; font-size: 12px;
  border-bottom-width: 2px;
}
