/* DSP Suite — design system v2 component layer (issue #28)
   Loaded after styles.css. Builds only on the tokens defined at the top of styles.css.
   Selectors are prefixed with :root so they win over both the base rules and the
   legacy [data-theme="dark"] overrides without !important. */

/* ─── Base ─── */
:root body {
    font-family: var(--font, 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
    font-size: var(--fs-base);
    font-feature-settings: 'cv11' 1;
    -webkit-font-smoothing: antialiased;
}
:root .mono,
:root .issue-seq-prefix,
:root .kanban-card-seq,
:root .pivot-cell-val,
:root .kanban-card-footer {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}
:root :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* ─── Main navbar: light, 48px ─── */
:root .main-nav {
    height: var(--nav-h);
    background: var(--bg-surface);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 0 14px;
}
:root .nav-brand { color: var(--text-muted); font-size: var(--fs-sm); letter-spacing: 0; }
:root .workspace-selector-btn {
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--fs-base);
    font-weight: 500;
}
:root .workspace-selector-btn:hover,
:root .workspace-selector.open .workspace-selector-btn {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text);
}
:root .workspace-selector-btn:focus { box-shadow: 0 0 0 3px var(--focus-ring); border-color: var(--focus); }
:root .workspace-selector-dropdown { border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); padding: 6px; }
:root .workspace-selector-item { border-radius: var(--radius); }
:root .workspace-selector-item:hover { background: var(--bg-muted); }
:root .workspace-selector-item.active { background: var(--bg-muted); color: var(--text); }
:root .workspace-selector-item-code,
:root .workspace-selector-add-icon { color: var(--text); }
:root .workspace-selector-divider { background: var(--border); }
:root .nav-modules { gap: 2px; margin-left: 4px; }
:root .nav-module {
    height: 32px;
    gap: 7px;
    padding: 0 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: var(--fs-base);
    font-weight: 500;
}
:root .nav-module:hover { background: var(--bg-hover); color: var(--text); }
:root .nav-module.active { background: var(--bg-muted); color: var(--text); }
:root .nav-search-trigger {
    height: 32px;
    min-width: 200px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-faint);
    font-size: var(--fs-base);
}
:root .nav-search-trigger:hover { border-color: var(--text-faint); background: var(--bg-surface); }
:root .nav-search-kbd { margin-left: auto; }
:root .nav-search-kbd kbd {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-faint);
}
:root .nav-theme-toggle,
:root .notification-bell-btn,
:root .nav-user-btn {
    color: var(--text-muted);
    border-radius: var(--radius);
}
:root .nav-theme-toggle:hover,
:root .notification-bell-btn:hover,
:root .nav-user-btn:hover { background: var(--bg-hover); color: var(--text); }
:root .nav-user-name { color: var(--text); }
:root .nav-user-dropdown,
:root .notification-dropdown { border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text); }

/* ─── Sub-navigation: underline tabs, neutral ─── */
:root .sub-nav { height: 40px; padding: 0 14px; }
:root .sub-nav-tab,
:root .sub-nav-dropdown-btn {
    padding: 0 12px;
    color: var(--text-faint);
    font-weight: 500;
}
:root .sub-nav-tab:hover,
:root .sub-nav-dropdown-btn:hover { background: transparent; color: var(--text); }
:root .sub-nav-tab.active,
:root .sub-nav-dropdown.active .sub-nav-dropdown-btn {
    color: var(--text);
    font-weight: 600;
    border-bottom-color: var(--accent);
}
:root .sub-nav-dropdown-menu { border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); padding: 6px; border: 1px solid var(--border); }
:root .sub-nav-dropdown-item { border-radius: var(--radius); padding: 7px 10px; }
:root .sub-nav-dropdown-item:hover { background: var(--bg-muted); }
:root .sub-nav-dropdown-item.active { color: var(--text); background: var(--bg-muted); }

/* ─── Content & headings ─── */
:root .main { padding: 16px 20px; }
:root .view-header h1 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.2px; }

/* ─── Buttons ─── */
:root .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--control-h);
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text);
    font-size: var(--fs-base);
    font-weight: 500;
    transition: background var(--ease), border-color var(--ease), color var(--ease);
}
:root .btn:hover { background: var(--bg-hover); border-color: var(--text-faint); }
:root .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}
:root .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
:root .btn-sm { height: 28px; padding: 0 9px; font-size: var(--fs-sm); }
:root .btn-danger { color: var(--danger); }
:root .btn-danger:hover { background: var(--danger-bg); border-color: var(--danger-fill); }
:root .btn-icon { border-radius: var(--radius); opacity: 0.6; }
:root .btn-icon:hover { opacity: 1; background: var(--bg-hover); }

/* ─── Badges: soft, 4px radius, 20px high ─── */
:root .badge,
:root .badge-outline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}
:root .badge { background: var(--bg-muted); color: var(--text-muted); }
:root .badge-grey { background: var(--bg-muted); color: var(--text-muted); }
:root .badge-blue { background: var(--info-bg); color: var(--info); }
:root .badge-green { background: var(--success-bg); color: var(--success); }
:root .badge-yellow { background: var(--warning-bg); color: var(--warning); }
:root .badge-red { background: var(--danger-bg); color: var(--danger); }
:root .badge-purple { background: var(--vi-bg); color: var(--vi); }

/* ─── Forms ─── */
:root .form-group label { color: var(--text-muted); font-weight: 500; }
:root .form-group input:not([type="checkbox"]):not([type="radio"]),
:root .form-group select,
:root .form-group textarea {
    min-height: var(--control-h);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    transition: border-color var(--ease), box-shadow var(--ease);
}
:root .form-group input:focus,
:root .form-group select:focus,
:root .form-group textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ─── Modal ─── */
:root .modal-overlay { background: rgba(16, 24, 40, 0.38); z-index: var(--z-modal); }
:root .modal {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
}
:root .modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); }
:root .modal-header h3 { font-size: var(--fs-md); font-weight: 600; }
:root .modal-body { padding: 16px 18px; }

/* ─── Tables: list view + legacy data table ─── */
:root .list-view table,
:root .data-table { font-size: var(--fs-base); }
:root .list-view th,
:root .data-table th {
    height: var(--head-h);
    padding: 0 12px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border);
}
:root .list-view th:hover { color: var(--text); }
:root .list-view td,
:root .data-table td {
    height: var(--row-h);
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
}
:root .list-view tbody tr:hover td { background: var(--bg-subtle); }
:root .list-view tbody tr:hover { background: transparent; }
:root .list-view tr.list-view-group-header td,
:root tr.group-row td {
    height: var(--row-h-group);
    background: var(--bg-group);
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text);
}
:root .list-view tr.editing td { background: var(--info-bg); }
:root .list-view tr.row-closed td { color: var(--text-faint); }
:root th.sortable .sort-indicator::after { content: ''; }
:root th.sorted-asc .sort-indicator::after { content: '↑'; opacity: 0.8; margin-left: 4px; }
:root th.sorted-desc .sort-indicator::after { content: '↓'; opacity: 0.8; margin-left: 4px; }

/* ─── Cards & panels ─── */
:root .card { border-radius: var(--radius-lg); border-color: var(--border); box-shadow: none; }

/* ─── Empty & loading ─── */
:root .empty-state { color: var(--text-faint); }
:root .loading { color: var(--text-faint); }

@media (prefers-reduced-motion: reduce) {
    :root * { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ─── Semantic values (js/shared/semantic.js) ─── */
:root .si { flex: none; vertical-align: -3px; }
:root .sem { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text); }
:root .person { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
:root .av,
:root .tg-owner-avatar,
:root .tg-group-avatar,
:root .org-avatar {
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 6px rgba(0, 0, 0, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
:root .av { display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* Status stepper (issue / meeting / scope / scenario detail) — neutral, icon + label */
:root .status-pip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
}
:root .status-pip-btn:not(.active):hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-faint); }
:root .status-pip-btn.active,
:root .status-pip-btn.active[class*="status-pip-"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    opacity: 1;
}

/* ─── Org chart (legacy layout until the centred tree lands) ─── */
:root .org-card-ext { border-left: 1px solid var(--border); }
:root .org-card { border-radius: var(--radius-lg); }
:root .org-badge-ext { background: var(--bg-muted); color: var(--text-muted); border-radius: var(--radius-sm); }

/* ─── Org chart: centred top-down tree (resources.js renderTreeView) ─── */
:root .org-chart:has(.ot-wrap) { max-width: none; padding: 0; }
:root .ot-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
:root .ot-grp, :root .ot-zoom { display: inline-flex; gap: 4px; }
:root .ot-zoom { margin-left: auto; }
:root .ot-ib { width: 32px; padding: 0; }
:root .ot-ib:disabled { opacity: 0.4; cursor: default; }
:root .ot-search { display: inline-flex; align-items: center; gap: 8px; height: var(--control-h); width: 240px; max-width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--input-bg); color: var(--text-faint); }
:root .ot-search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; flex: 1; min-width: 0; }
:root .ot-wrap { overflow: auto; max-height: calc(100vh - 230px); padding: 24px 12px 32px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
:root .ot-tree { display: flex; justify-content: center; min-width: max-content; margin: 0 auto; }
:root .ot-tree ul { display: flex; justify-content: center; margin: 0; padding: 22px 0 0; position: relative; }
:root .ot-tree > ul { padding-top: 0; }
:root .ot-tree li { list-style: none; position: relative; padding: 22px 6px 0; display: flex; flex-direction: column; align-items: center; }
:root .ot-tree > ul > li { padding-top: 0; }
:root .ot-tree li::before, :root .ot-tree li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 22px; border-top: 1px solid var(--border-strong); }
:root .ot-tree li::after { right: auto; left: 50%; border-left: 1px solid var(--border-strong); }
:root .ot-tree li:only-child::before { display: none; }
:root .ot-tree li:only-child::after { border-top: 0; width: 0; }
:root .ot-tree li:first-child::before, :root .ot-tree li:last-child::after { border: 0; }
:root .ot-tree li:last-child::before { border-right: 1px solid var(--border-strong); border-radius: 0 8px 0 0; }
:root .ot-tree li:first-child::after { border-radius: 8px 0 0 0; }
:root .ot-tree > ul > li::before, :root .ot-tree > ul > li::after { display: none; }
:root .ot-tree ul ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 22px; border-left: 1px solid var(--border-strong); }
:root .ot-tree ul.ot-stack { flex-direction: column; align-items: center; gap: 8px; }
:root .ot-tree ul.ot-stack::after { content: ""; position: absolute; left: 50%; top: 22px; bottom: 30px; border-left: 1px solid var(--border-strong); }
:root .ot-tree ul.ot-stack > li { padding: 0; }
:root .ot-tree ul.ot-stack > li::before, :root .ot-tree ul.ot-stack > li::after { display: none; }
:root .ot-tree ul.ot-stack > li:first-child { padding-top: 22px; }
:root .ot-node { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; width: 224px; padding: 10px 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-surface); box-shadow: var(--shadow-sm); text-align: left; }
:root .ot-node.hit { border-color: var(--warning-fill); box-shadow: 0 0 0 3px var(--warning-bg); }
:root .ot-tx { display: flex; flex-direction: column; min-width: 0; }
:root .ot-tx b { font-size: var(--fs-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root .ot-tx span { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root .ot-dp { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; }
:root .ot-dp i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
:root .ot-tog { position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%); min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; }
:root .ot-tog:hover { border-color: var(--accent); color: var(--text); }
:root .ot-outside { margin-top: 16px; padding: 14px 16px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
:root .ot-outside-h { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 10px; }
:root .ot-outside-h span, :root .ot-xh span { color: var(--text-faint); font-weight: 500; margin-left: 4px; }
:root .ot-xgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
:root .ot-xcol { display: flex; flex-direction: column; gap: 6px; }
:root .ot-xh { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
:root .ot-xcol .ot-node { box-shadow: none; width: auto; }

/* ─── Budget tracking: Ledger (budgets.js renderTracking) ─── */
:root .bt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px; }
:root .bt-kpis > div { display: flex; flex-direction: column; gap: 3px; padding: 14px 18px; border-left: 1px solid var(--border); margin-left: -1px; }
:root .bt-kpis span { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
:root .bt-kpis b { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }
:root .bt-kpis small { font-size: var(--fs-sm); color: var(--text-faint); }
:root .bt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
:root .bt-seg { display: inline-flex; padding: 2px; border-radius: 7px; background: var(--bg-muted); border: 1px solid var(--border); }
:root .bt-seg button { height: 28px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font: 500 var(--fs-base) var(--font); cursor: pointer; white-space: nowrap; }
:root .bt-seg button.on { background: var(--bg-surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root .bt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
:root .bt-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-muted); font: 500 var(--fs-base) var(--font); cursor: pointer; white-space: nowrap; }
:root .bt-chip b { font-weight: 500; color: var(--text-faint); font-variant-numeric: tabular-nums; }
:root .bt-chip.on { background: var(--bg-muted); border-color: var(--text-faint); color: var(--text); }
:root .bt-dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; flex: none; }
:root .bt-search { margin-left: auto; }
:root .bt-search input { height: 30px; width: 200px; max-width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--input-bg); color: var(--text); font: inherit; }
:root .bt-table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
:root .bt-table { width: 100%; min-width: 1040px; border-collapse: collapse; font-size: var(--fs-base); }
:root .bt-table th { height: var(--head-h); padding: 0 12px; text-align: left; font-size: 12.5px; font-weight: 500; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-surface); position: sticky; top: 0; z-index: 1; }
:root .bt-table td { height: var(--row-h); padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
:root .bt-table .bt-n { text-align: right; font-variant-numeric: tabular-nums; }
:root .bt-rn { width: 52px; text-align: center !important; color: var(--text-faint); font-size: var(--fs-sm); border-right: 1px solid var(--border); padding: 0 4px !important; }
:root .bt-wbs { width: 60px; color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
:root .bt-lbl { max-width: 460px; overflow: hidden; text-overflow: ellipsis; }
:root .bt-lbl .bt-tog { vertical-align: middle; margin: -2px 6px 0 -4px; }
:root .bt-sup td { height: 48px; border-top: 1px solid var(--border-strong); }
:root .bt-sup .bt-wbs { color: var(--text); font-weight: 700; }
:root .bt-supname { font-size: var(--fs-lg); font-weight: 700; margin-right: 10px; }
:root .bt-ref { color: var(--text-faint); font-size: var(--fs-sm); margin-right: 10px; }
:root .bt-cat td { height: var(--row-h-group); background: var(--bg-group); font-weight: 600; }
:root .bt-line .bt-lbl { padding-left: 32px; color: var(--text); }
:root .bt-line .bt-wbs { font-weight: 400; }
:root .bt-tot td { font-weight: 700; background: var(--bg-group); border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
:root .bt-grand td { font-weight: 700; background: var(--bg-muted); border-top: 2px solid var(--accent); }
:root .bt-tog { width: 24px; height: 24px; border: 0; border-radius: 5px; background: transparent; color: var(--text-faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
:root .bt-tog:hover { background: var(--bg-muted); color: var(--text); }
:root .bt-tog svg { transition: transform var(--ease); }
:root .bt-tog.open svg { transform: rotate(90deg); }
:root .bt-fold { display: inline-flex; gap: 2px; }
:root .bt-fold button { width: 22px; height: 22px; padding: 0; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--bg-surface); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
:root .bt-fold button:hover:not(:disabled) { border-color: var(--text-faint); color: var(--text); }
:root .bt-fold button:disabled { opacity: 0.35; cursor: default; }
:root .bt-neg { color: var(--danger); }
:root .bt-mut { color: var(--text-faint); }
:root .bt-ahead { color: var(--info); }
:root .bt-behind { color: var(--warning); }
:root .bt-planc { color: var(--te); }
:root .bt-capwrap { display: inline-flex; align-items: center; gap: 8px; }
:root .bt-cap { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 120px; height: 22px; border: 1px solid var(--cs); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-surface); }
:root .bt-cap i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--cb); }
:root .bt-cap .bt-plan { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--te); }
:root .bt-cap span { position: relative; font-size: var(--fs-sm); font-weight: 600; color: var(--ct); font-variant-numeric: tabular-nums; }
:root .bt-c-ok { --cs: var(--border-strong); --cb: var(--bg-muted); --ct: var(--text-muted); }
:root .bt-c-wa { --cs: var(--warning-fill); --cb: var(--warning-bg); --ct: var(--warning); }
:root .bt-c-full { --cs: var(--g400); --cb: var(--g100); --ct: var(--text-muted); }
:root .bt-c-er { --cs: var(--danger-fill); --cb: var(--danger-bg); --ct: var(--danger); }
:root .bt-c-idle { --cs: var(--border); --cb: transparent; --ct: var(--text-faint); }
:root .bt-over { font-size: 11.5px; font-weight: 600; color: var(--danger); font-variant-numeric: tabular-nums; }
:root .bt-empty { text-align: center; color: var(--text-faint); padding: 28px !important; }
:root .bt-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: var(--fs-sm); color: var(--text-muted); }
:root .bt-legend > span { display: inline-flex; align-items: center; gap: 6px; }
:root .bt-legend-plan { display: inline-block; width: 2px; height: 12px; background: var(--te); }

/* ─── Issue chip (semantic.js issueChip) ─── */
:root .issue-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 340px; height: 26px; padding: 0 8px 0 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-surface); color: var(--text); text-decoration: none; font-size: var(--fs-base); white-space: nowrap; transition: border-color var(--ease), background var(--ease); }
:root .issue-chip:hover { border-color: var(--border-strong); background: var(--bg-hover); }
:root .issue-chip:hover .ic-name { text-decoration: underline; text-underline-offset: 2px; }
:root .ic-code { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
:root .ic-code i { width: 8px; height: 8px; border-radius: 2px; }
:root .ic-seq { color: var(--text-faint); font-weight: 500; font-variant-numeric: tabular-nums; }
:root .ic-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ─── Project tag + label dot ─── */
:root .pj-tag { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 7px 0 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); font-size: 11.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
:root .pj-tag i { width: 8px; height: 8px; border-radius: 2px; }
:root .dot-tag { width: 8px; height: 8px; border-radius: 4px; flex: none; }

/* ─── Checkboxes (app-wide) ─── */
:root input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    flex: none;
    display: inline-grid;
    place-content: center;
    vertical-align: middle;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease);
}
:root input[type="checkbox"]:hover { border-color: var(--text-faint); }
:root input[type="checkbox"]::after {
    content: "";
    width: 10px;
    height: 10px;
    background: var(--on-accent);
    transform: scale(0);
    transition: transform var(--ease);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
:root input[type="checkbox"]:checked,
:root input[type="checkbox"]:indeterminate { background: var(--accent); border-color: var(--accent); }
:root input[type="checkbox"]:checked::after { transform: scale(1); }
:root input[type="checkbox"]:indeterminate::after {
    transform: scale(1);
    -webkit-mask: none; mask: none;
    width: 8px; height: 2px; border-radius: 1px;
}
:root input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); border-color: var(--focus); }
:root input[type="checkbox"]:disabled { opacity: 0.45; cursor: default; }
/* list-view selection column: centred, fixed width */
:root .list-view th:first-child:has(> input[type="checkbox"]),
:root .list-view td:first-child:has(> input[type="checkbox"]) { width: 40px; padding: 0; text-align: center; }

/* ─── Inline issue refs, kanban, sidebars, mentions ─── */
:root .issue-inline { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; color: var(--text); text-decoration: none; }
:root .issue-inline .ic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root a.issue-inline:hover .ic-name { text-decoration: underline; text-underline-offset: 2px; }
:root .issue-parent-banner .issue-inline { margin-left: 6px; }
:root .kanban-card-header { display: flex; align-items: center; gap: 6px; }
:root .kanban-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
:root .kanban-card-meta .sem { font-size: var(--fs-sm); color: var(--text-muted); }
:root .kanban-prio { display: inline-flex; }
:root .kanban-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); color: var(--text-faint); }
:root .kanban-card-footer .person { color: var(--text-muted); }
:root .kanban-card-footer .av { width: 18px !important; height: 18px !important; font-size: 8px !important; }
:root .kanban-card { border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--bg-surface); }
:root .gantt-sidebar-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
:root .gantt-sidebar-label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root .activity-actor { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
:root .comment-author .person { font-weight: 600; }
:root .participant-name .person { font-weight: 500; }
:root td.resource .person { gap: 8px; }
:root .m2o-item, :root .m2o-modal-item { display: flex; align-items: center; gap: 8px; }
:root .m2o-item-project, :root .m2o-modal-item-project { margin-left: auto; }

/* ─── Workload chips: neutral until it matters ─── */
:root .gantt-sidebar-badge { border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; font-weight: 600; }
:root .gantt-sidebar-badge.workload-ok,
:root .gantt-sidebar-badge.workload-empty { background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); }
:root .gantt-sidebar-badge.workload-warn { background: var(--warning-bg); color: var(--warning); border: 1px solid transparent; }
:root .gantt-sidebar-badge.workload-over { background: var(--danger-bg); color: var(--danger); border: 1px solid transparent; }
:root .kanban-card-footer > span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
:root .kanban-card-footer .person { min-width: 0; overflow: hidden; }
:root .kanban-card-footer .person > span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* ─── Avatar stack ─── */
:root .av-stack { display: inline-flex; align-items: center; vertical-align: middle; }
:root .av-stack-item { display: inline-flex; margin-left: -6px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg-surface); }
:root .av-stack-item:first-child { margin-left: 0; }
:root .av-stack-item.is-optional { opacity: 0.55; }
:root .av-stack-more { display: inline-flex; align-items: center; justify-content: center; margin-left: -6px; padding: 0 5px; border-radius: 11px; background: var(--bg-muted); color: var(--text-muted); font-size: 10.5px; font-weight: 600; box-shadow: 0 0 0 2px var(--bg-surface); font-variant-numeric: tabular-nums; }
:root tr:hover .av-stack-item, :root tr:hover .av-stack-more { box-shadow: 0 0 0 2px var(--bg-subtle); }

/* ─── Select menu (js/shared/select-menu.js): native <select> → trigger + icon menu ─── */
.sm { position: relative; display: inline-block; max-width: 100%; vertical-align: middle; }
.form-group .sm, .issue-meta-grid .sm { display: block; }
.sm-native {
    position: absolute !important; inset: 0; width: 100% !important; height: 100% !important;
    opacity: 0; pointer-events: none; margin: 0;
}
.sm-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; min-height: var(--control-h); padding: 0 8px 0 10px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--input-bg); color: var(--text);
    font: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer;
    transition: border-color var(--ease), box-shadow var(--ease);
}
.sm-trigger:hover:not(:disabled) { border-color: var(--text-faint); }
.sm-trigger:focus-visible, .sm.open .sm-trigger { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.sm-trigger:disabled { opacity: .55; cursor: not-allowed; }
.sm-value { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.sm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-placeholder .sm-label { color: var(--text-faint); }
.sm-chev { flex: none; color: var(--text-faint); transition: transform var(--ease); }
.sm.open .sm-chev { transform: rotate(180deg); }
.sm-pj { flex: none; width: 9px; height: 9px; border-radius: 2px; }
.sm-trigger .si, .sm-item .si, .sm-trigger .av, .sm-item .av { flex: none; }

.sm-menu {
    position: fixed; z-index: calc(var(--z-modal) + 50);
    display: flex; flex-direction: column; max-width: min(420px, calc(100vw - 16px));
    padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--bg-surface); color: var(--text); box-shadow: var(--shadow-pop);
    font-size: var(--fs-base);
}
.sm-filter {
    flex: none; height: 30px; margin: 2px 2px 4px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--input-bg); color: var(--text); font: inherit; outline: none;
}
.sm-filter:focus { border-color: var(--focus); }
.sm-list { overflow-y: auto; min-height: 0; }
.sm-item {
    display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 6px;
    border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
}
.sm-item.active { background: var(--bg-hover); }
.sm-item.selected { font-weight: 500; }
.sm-item.disabled { opacity: .45; cursor: default; }
.sm-check { flex: none; width: 14px; display: inline-flex; color: var(--text); }
.sm-empty { padding: 8px 10px; color: var(--text-faint); }

/* ═══ App shell: left sidebar + breadcrumb top bar (#42) ═══
   Sidebar 240px, collapses to a 52px icon rail ( [ ), drawer below 760px.
   Content scrolls inside .main, so the sidebar and top bar stay put. */
:root { --side-w: 240px; --rail-w: 52px; --bg-side: var(--g25); --bg-side-active: var(--g200); }
[data-theme="dark"] { --bg-side: #14181e; }

body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app-shell {
    flex: 1; min-height: 0;
    display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
    transition: grid-template-columns 140ms ease-out;
}
.app-shell.rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

/* ── Sidebar ── */
:where(.app-side, .app-top) button { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
:where(.app-side .side-head, .app-side .side-scroll, .app-side .side-foot, .app-top) > button { padding: 0; }
.app-side {
    display: flex; flex-direction: column; min-height: 0; min-width: 0;
    padding: 8px; background: var(--bg-side); border-right: 1px solid var(--border);
}
.side-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.side-foot { flex: none; display: flex; flex-direction: column; gap: 1px; padding-top: 8px; border-top: 1px solid var(--border); }
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.side-group-label { padding: 0 8px 4px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-faint); letter-spacing: .02em; }

/* client switcher */
:root .app-side .workspace-selector { flex: 1; min-width: 0; position: relative; }
:root .app-side .workspace-selector-btn {
    width: 100%; height: 40px; padding: 0 6px; gap: 8px; display: flex; align-items: center;
    border: 0; background: transparent; color: var(--text); justify-content: flex-start;
}
:root .app-side .workspace-selector-btn:hover,
:root .app-side .workspace-selector.open .workspace-selector-btn { background: var(--bg-hover); border-color: transparent; }
.workspace-selector-label { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.ws-logo {
    flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--data-2), var(--data-1)); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.ws-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; text-align: left; }
.ws-code { font-weight: 600; font-size: var(--fs-md); }
.ws-name { font-size: var(--fs-xs); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root .app-side .workspace-selector-dropdown { top: 100%; left: 0; min-width: 260px; z-index: calc(var(--z-modal) - 10); }
.side-collapse { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius); color: var(--text-faint); }
.side-collapse:hover { background: var(--bg-hover); color: var(--text); }

/* search */
:root .app-side .nav-search-trigger {
    width: 100%; min-width: 0; height: 32px; display: flex; align-items: center; gap: 8px; flex: none;
    border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-faint);
}
:root .app-side .nav-search-trigger:hover { border-color: var(--border-strong); }
.app-side .nav-search-label { flex: 1; text-align: left; }

/* module tree */
:root .app-side .nav-modules { display: flex; flex-direction: column; align-items: stretch; gap: 1px; margin: 0; overflow: visible; }
.nav-group { display: flex; flex-direction: column; }
:root .app-side .nav-module {
    position: relative; width: 100%; height: 30px; padding: 0 8px; gap: 9px;
    display: flex; align-items: center; justify-content: flex-start; border-radius: var(--radius); text-align: left;
    color: var(--text-muted); font-size: var(--fs-base); font-weight: 500; text-decoration: none; white-space: nowrap;
}
:root .app-side .nav-module:hover { background: var(--bg-hover); color: var(--text); }
:root .app-side .nav-group:not(.has-subs) > .nav-module.active { background: var(--bg-side-active); color: var(--text); }
:root .app-side .nav-group.has-subs > .nav-module.active { color: var(--text); }
.app-side .nav-icon { flex: none; display: inline-flex; }
.app-side .nav-icon svg { width: 16px; height: 16px; }
.nav-caret { flex: none; display: inline-flex; color: var(--text-faint); transition: transform 140ms ease-out; }
.nav-group.open > .nav-module .nav-caret { transform: rotate(90deg); }
.nav-subs { display: none; flex-direction: column; gap: 1px; margin: 2px 0 4px 15px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-group.open > .nav-subs { display: flex; }
.nav-sub-item {
    display: flex; align-items: center; height: 28px; padding: 0 8px; border-radius: var(--radius);
    color: var(--text-muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-sub-item.active { background: var(--bg-side-active); color: var(--text); font-weight: 500; }
.nav-sub-label { padding: 6px 8px 2px; font-size: var(--fs-xs); color: var(--text-faint); }
.nav-sub-nested { padding-left: 16px; }

/* recent */
.side-recent-list { display: flex; flex-direction: column; gap: 1px; }
.side-recent-item {
    display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: var(--radius);
    color: var(--text-muted); text-decoration: none;
}
.side-recent-item:hover { background: var(--bg-hover); color: var(--text); }
.side-recent-item.active { background: var(--bg-side-active); color: var(--text); }
.side-recent-icon { flex: none; display: inline-flex; }
.side-recent-ref { flex: none; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }

/* footer items */
:root .app-side .side-item {
    position: relative; width: 100%; height: 30px; padding: 0 8px; gap: 9px;
    display: flex; align-items: center; border: 0; border-radius: var(--radius);
    background: none; color: var(--text-muted); font-size: var(--fs-base); cursor: pointer;
}
:root .app-side .side-item:hover { background: var(--bg-hover); color: var(--text); }
.side-item svg { flex: none; }
.side-expand { display: none !important; }
:root .app-side .notification-bell { display: block; position: static; }
:root .app-side .notification-bell[style*="none"] { display: none !important; }
:root .app-side .notification-badge {
    position: absolute; top: 7px; right: 8px; left: auto; min-width: 18px; height: 16px; padding: 0 5px;
    background: var(--info-fill); font-weight: 600;
}
:root .app-side .notification-bell { position: relative; }
:root .app-side .notification-dropdown {
    position: fixed; top: auto; bottom: 12px; right: auto; left: calc(var(--side-w) + 8px); margin: 0;
    width: 340px; max-height: min(520px, calc(100vh - 24px)); overflow: auto; z-index: calc(var(--z-modal) - 10);
}
.app-shell.rail .app-side .notification-dropdown { left: calc(var(--rail-w) + 8px); }
:root .app-side .nav-user { display: block; position: relative; }
:root .app-side .nav-user[style*="none"] { display: none !important; }
:root .app-side .nav-user-btn { height: 36px; padding: 0 6px; color: var(--text); }
.nav-user-avatar { flex: none; display: inline-flex; }
:root .app-side .nav-user-dropdown { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; margin: 0; width: 228px; }

/* rail mode */
.app-shell.rail .app-side { padding-left: 6px; padding-right: 6px; }
.app-shell.rail .side-label, .app-shell.rail .ws-text, .app-shell.rail .workspace-selector-chevron,
.app-shell.rail .nav-search-label, .app-shell.rail .nav-search-kbd, .app-shell.rail .nav-caret,
.app-shell.rail .nav-subs, .app-shell.rail .side-recent, .app-shell.rail .side-collapse { display: none !important; }
.app-shell.rail .side-expand { display: flex !important; }
.app-shell.rail .side-head { justify-content: center; }
:root .app-shell.rail .app-side .workspace-selector-btn,
:root .app-shell.rail .app-side .nav-search-trigger,
:root .app-shell.rail .app-side .nav-module,
:root .app-shell.rail .app-side .side-item { justify-content: center; padding: 0; }
:root .app-shell.rail .app-side .nav-search-trigger { border-color: transparent; background: none; height: 30px; }
:root .app-shell.rail .app-side .nav-group.has-subs > .nav-module.active { background: var(--bg-side-active); }
:root .app-shell.rail .app-side .notification-badge { top: 3px; right: 6px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; }
.app-shell.rail [data-tip]:hover::after {
    content: attr(data-tip); position: fixed; left: calc(var(--rail-w) + 6px); transform: translateY(-50%); margin-top: 15px;
    padding: 4px 8px; border-radius: var(--radius-sm); background: var(--g900); color: var(--g0);
    font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; z-index: calc(var(--z-modal) - 5); pointer-events: none;
}
.app-shell.rail .app-side [data-tip] { position: relative; }

/* ── Main column ── */
.app-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.app-top {
    flex: none; height: var(--nav-h); display: flex; align-items: center; gap: 8px;
    padding: 0 16px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.app-menu-btn { display: none; flex: none; width: 30px; height: 30px; place-items: center; border-radius: var(--radius); color: var(--text-muted); }
.app-menu-btn:hover { background: var(--bg-hover); color: var(--text); }
:root .app-main .main { flex: 1; min-height: 0; overflow: auto; }
.app-main .search-bar { flex: none; }

/* breadcrumbs */
.breadcrumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; white-space: nowrap; }
.crumb {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px; min-width: 0; flex: none;
    border-radius: var(--radius); color: var(--text-muted); text-decoration: none; font-size: var(--fs-base);
}
a.crumb:hover, button.crumb:hover { background: var(--bg-hover); color: var(--text); }
.crumb-current { color: var(--text); font-weight: 500; flex: 0 1 auto; overflow: hidden; }
.crumb-text { overflow: hidden; text-overflow: ellipsis; }
.crumb-ref { flex: none; font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-faint); }
.crumb-icon { display: inline-flex; }
.crumb-icon svg { width: 14px; height: 14px; }
.crumb-sep { flex: none; display: inline-flex; color: var(--g300); }

/* the record crumb replaces the per-page "← Back" buttons */
.issue-back-btn { display: none !important; }

/* screens that used to sit below the 44px top bar */
:root .no-access-screen { top: 0; left: var(--side-w); }

/* ── Phone: sidebar becomes a drawer ── */
.app-scrim { display: none; }
@media (max-width: 760px) {
    .app-shell, .app-shell.rail { grid-template-columns: minmax(0, 1fr); }
    .app-side {
        position: fixed; z-index: calc(var(--z-modal) - 20); inset: 0 auto 0 0; width: min(84vw, 280px);
        transform: translateX(-102%); transition: transform 160ms ease-out; box-shadow: var(--shadow-pop);
    }
    .app-shell.drawer-open .app-side { transform: none; }
    .app-shell.drawer-open .app-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-modal) - 21); background: rgba(16, 24, 40, .38); }
    /* the drawer is always the full sidebar, never the rail */
    .app-shell.rail .side-label, .app-shell.rail .ws-text, .app-shell.rail .nav-search-label, .app-shell.rail .nav-caret { display: revert !important; }
    .app-shell.rail .nav-group.open > .nav-subs { display: flex !important; }
    .app-shell.rail .side-recent:not([hidden]) { display: block !important; }
    .side-collapse, .side-expand { display: none !important; }
    .app-menu-btn { display: grid; }
    .app-top { padding: 0 12px 0 8px; }
    .crumb-hide-sm, .crumb-hide-sm + .crumb-sep { display: none; }
    :root .app-side .notification-dropdown { left: 12px; right: 12px; width: auto; }
    :root .no-access-screen { left: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .app-shell, .app-side, .nav-caret { transition: none; }
}

/* ─── Person pickers (search inputs): avatar in the field + in the results ─── */
.m2o-person { position: relative; }
.m2o-person .m2o-lead { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); display: inline-flex; pointer-events: none; }
:root .m2o-person.has-lead .m2o-input { padding-left: 36px; }
.m2o-person-item { display: flex; align-items: center; gap: 8px; }
.m2o-person-item .av { flex: none; }

/* Issue / meeting chips inside detail-page lists (subtasks, related, linked issues) */
:root .subtask-item .issue-chip, :root .relation-item .issue-chip, :root .issue-parent-banner .issue-chip { max-width: 100%; min-width: 0; }
:root .relation-item { display: flex; align-items: center; gap: 8px; }
:root .relation-item .relation-label { flex: none; }
:root .meeting-chip .si + .si { margin-left: -2px; }
