/*
 * claana — Shared Component Styles
 * Imported by base.html, inherited by all pages.
 * Page-specific overrides go in each template's <style> block.
 */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;700&display=swap');

/* ── Design tokens ──────────────────────────────────────────── */
:root {
    --bg:           #f0f2f5;
    --surface:      #ffffff;
    --surface2:     #f7f8fa;
    --border:       #e2e5e9;
    --border2:      #cdd1d6;
    --accent:       #714b67;
    --accent2:      #017e84;
    --accent-light: #f5f0f4;
    --success:      #28a745;
    --error:        #dc3545;
    --warning:      #f0ad4e;
    --ndc:          #017e84;
    --text:         #1a1f25;
    --text-dim:     #5a6370;
    --text-muted:   #98a1ad;
    --mono:         'IBM Plex Mono', monospace;
    --font:         'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Sidebar */
    --sidebar-bg:    #1e2a2e;
    --sidebar-hover: #2a3a3e;
    --sidebar-text:  #a0b0b8;
    --sidebar-active:#714b67;
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 52px;
}

/* ── Reset ──────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App layout — sidebar + main ────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.2s ease;
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    background: var(--bg);
    transition: margin-left 0.2s ease;
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-width));
}

.container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* ── Sidebar brand ──────────────────────────────────────────── */
.sidebar-brand {
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand-icon {
    width: 28px;
    height: 28px;
    background: var(--accent2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
}
.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: #e8edf2;
    letter-spacing: -0.02em;
}

/* ── Sidebar nav ────────────────────────────────────────────── */
.sidebar-section {
    padding: 14px 0 6px;
}
.sidebar-section-label {
    padding: 0 18px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
}
.sidebar-nav {
    list-style: none;
    padding: 0;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.12s;
}
.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #dce4ea;
}
.sidebar-nav a.active {
    background: rgba(113,75,103,0.15);
    color: #c9a0c1;
    border-left-color: var(--accent2);
    font-weight: 600;
}
.sidebar-nav .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    opacity: 0.7;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }

/* ── Sidebar user ───────────────────────────────────────────── */
.sidebar-user {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--sidebar-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--sidebar-text);
}
.sidebar-user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    color: #dce4ea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.sidebar-logout {
    font-size: 11px;
    color: var(--sidebar-text);
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.sidebar-logout:hover { opacity: 1; color: var(--error); }

/* ── Sidebar submenu (flyout) ──────────────────────────────── */
.sidebar-submenu {
    display: none;
    position: fixed;
    min-width: 180px;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    box-shadow: 4px 4px 16px rgba(0,0,0,0.25);
    list-style: none;
    padding: 6px 0;
    z-index: 300;
}
.sidebar-submenu.visible {
    display: block;
}
.sidebar-submenu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.12s;
    border-left: none !important;
}
.sidebar-submenu li a:hover {
    background: var(--sidebar-hover);
    color: #dce4ea;
}

/* ── Sidebar toggle button ─────────────────────────────────── */
.sidebar-toggle {
    position: absolute;
    top: 18px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--sidebar-text);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: all 0.15s;
}
.sidebar-toggle:hover {
    background: var(--accent2);
    color: #fff;
}

/* ── Sidebar collapsed state ───────────────────────────────── */
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}
.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .sidebar-logout {
    display: none;
}
.app-sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 0 14px;
}
.app-sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 0;
    font-size: 0;
    gap: 0;
}
.app-sidebar.collapsed .sidebar-nav .nav-icon {
    width: auto;
    font-size: 16px;
}
.app-sidebar.collapsed .sidebar-submenu {
    font-size: 12px;
}
.app-sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 14px 0;
}
.app-sidebar.collapsed .sidebar-toggle {
    right: -12px;
}
.app-sidebar.collapsed + .app-main {
    margin-left: var(--sidebar-collapsed-width);
    max-width: calc(100vw - var(--sidebar-collapsed-width));
}

/* ── Page wrapper base ──────────────────────────────────────── */
.page-wrap {
    font-family: var(--font);
    background: var(--bg);
    min-height: 100vh;
    padding: 10px 10px 10px 10px;
    color: var(--text);
}

/* ── Gradient header ────────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Data table ─────────────────────────────────────────────── */
.data-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--font);
}
.data-tbl th {
    position: sticky;
    top: 0;
    background: var(--surface2);
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    z-index: 2;
}
.data-tbl td {
    padding: 4px 12px;
    border-bottom: 1px solid var(--surface2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    font-family: var(--mono);
    font-size: inherit;
    color: var(--text);
}
.data-tbl tr { cursor: pointer; transition: background 0.08s; }
.data-tbl tr:hover td { background: var(--accent-light); }
.data-tbl tr.active-row td { background: #ede5eb; }

/* ── Pills ──────────────────────────────────────────────────── */
.pill {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 16px;
    vertical-align: middle;
}
/* Generic */
.pill-cs   { background: #d4edda; color: #155724; }
.pill-ps   { background: #cce5ff; color: #004085; }
.pill-void { background: #f8d7da; color: #721c24; }
.pill-ndc  { background: #d1ecf1; color: #0c5460; }
.pill-gds  { background: #e8e0ec; color: #714b67; }
.pill-def  { background: var(--surface2); color: var(--text-dim); }
/* CRM stage */
.pill-new       { background: #cce5ff; color: #004085; }
.pill-quoted    { background: #d4edda; color: #155724; }
.pill-followup  { background: #e8e0ec; color: #714b67; }
.pill-confirmed { background: #c3e6cb; color: #155724; }
.pill-ticketed  { background: #28a745; color: #fff; }
.pill-lost      { background: #f8d7da; color: #721c24; }
/* CRM priority */
.pill-low    { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.pill-medium { background: #e8e0ec; color: #714b67; }
.pill-high   { background: #ffeeba; color: #856404; }
.pill-urgent { background: #f8d7da; color: #721c24; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-sm {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 0 10px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.12s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.success { color: var(--success); border-color: rgba(40,167,69,0.3); }
.btn-sm.success:hover { background: rgba(40,167,69,0.06); border-color: var(--success); }
.btn-sm.danger  { color: var(--error); border-color: rgba(220,53,69,0.3); }
.btn-sm.danger:hover  { background: rgba(220,53,69,0.06); border-color: var(--error); }
.btn-sm.warn    { color: var(--warning); border-color: rgba(240,173,78,0.3); }
.btn-sm.warn:hover    { background: rgba(240,173,78,0.06); border-color: var(--warning); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 0 14px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent2); }

.btn-add {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: var(--surface);
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-add:hover { background: var(--accent); color: #fff; }

/* ── Inputs ─────────────────────────────────────────────────── */
.inp {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 7px 11px;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(113,75,103,0.1); }
.inp.mono { font-family: var(--mono); font-size: 12px; }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ── Chips ──────────────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 5px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text-dim);
    user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: #e8e0ec; color: var(--accent); border-color: var(--accent); }
.chip .chip-sub { font-size: 9px; color: var(--text-muted); font-weight: 400; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Sub-nav ────────────────────────────────────────────────── */
.subnav {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.subnav a {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.12s;
}
.subnav a:hover { background: var(--surface); color: var(--text); }
.subnav a.active { background: var(--accent); color: #fff; }

/* ── Badge ──────────────────────────────────────────────────── */
.badge {
    font-family: var(--mono);
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 4px;
    font-weight: 700;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

/* ── Field label ────────────────────────────────────────────── */
.field-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* ── Info grid (detail panels) ──────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.info-cell .lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.info-cell .val {
    font-size: 12px;
    color: var(--text);
    font-family: var(--mono);
    word-break: break-word;
}
.info-cell.full { grid-column: span 2; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Data-view topbar ──────────────────────────────────────── */
.view-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.view-topbar h1 {
    font-size: 16px;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.view-topbar .count {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
}
.view-topbar .spacer { flex: 1; }

/* ── Data-view wrapper ─────────────────────────────────────── */
.view-wrap {
    padding: 6px 10px;
}

/* ── Sub-nav pills ─────────────────────────────────────────── */
.view-subnav {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 4px;
}
.view-subnav a {
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 5px;
    transition: background 0.12s, color 0.12s;
}
.view-subnav a:hover { background: var(--surface2); color: var(--text); }
.view-subnav a.active { background: var(--accent); color: #fff; }

/* ── Search box ────────────────────────────────────────────── */
.view-search {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    width: 180px;
    outline: none;
}
.view-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(113,75,103,0.1); }

/* ── Data-view table ───────────────────────────────────────── */
.view-tbl-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.view-tbl-wrap {
    overflow-x: auto;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}
.view-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--font);
}
.view-table thead th {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    padding: 4px 12px;
    text-align: left;
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.view-table thead th.chk-col { width: 28px; padding: 6px 10px; }
.view-table tbody tr { border-bottom: 1px solid var(--surface2); cursor: pointer; transition: background 0.08s; }
.view-table tbody tr:hover { background: var(--accent-light); }
.view-table tbody tr.active-row { background: #ede5eb; }
.view-table td {
    padding: 4px 12px;
    color: var(--text);
    vertical-align: middle;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--mono);
    font-size: inherit;
}
.view-table td.chk-col { padding: 4px 10px; }

/* ── Data-view body (table + detail split) ─────────────────── */
.view-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
    transition: grid-template-columns 0.2s;
}
.view-body.detail-open { grid-template-columns: 1fr 440px; }

/* ── Detail side panel ─────────────────────────────────────── */
.view-detail {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}
.view-detail.open { display: block; }
.view-detail-hdr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.view-detail-hdr-title { font-size: 12px; font-weight: 700; color: var(--text); font-family: var(--mono); }
.view-detail-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; line-height: 1; }
.view-detail-close:hover { color: var(--text); }
.view-detail-body { padding: 12px 14px; }
.view-detail-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 4px 0; border-bottom: 1px solid var(--surface2); font-size: 11px; gap: 12px; }
.view-detail-row:last-child { border-bottom: none; }
.view-detail-label { color: var(--text-dim); font-weight: 600; white-space: nowrap; min-width: 100px; }
.view-detail-value { color: var(--text); text-align: right; word-break: break-all; font-family: var(--mono); font-size: 11px; }

/* ── Pagination bar ────────────────────────────────────────── */
.paging-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    font-size: 11px;
    color: var(--text-dim);
}
.paging-info {
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
}
.paging-btns {
    display: flex;
    align-items: center;
    gap: 4px;
}
.paging-btns button {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 10px;
    height: 24px;
    font-size: 13px;
    font-weight: 400;
    font-family: var(--font);
    color: var(--text);
    cursor: pointer;
    transition: all 0.12s;
}
.paging-btns button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}
.paging-btns button:disabled {
    opacity: 0.35;
    cursor: default;
}
.paging-btns .page-num {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 400;
    padding: 0 6px;
    color: var(--text);
}
.page-size-select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
    height: 24px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    cursor: pointer;
    outline: none;
}
.page-size-select:focus { border-color: var(--accent); }

/* ── Sheet table (Google Sheets-like) ──────────────────────── */
.sheet-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
    max-width: 100%;
    width: 100%;
}
.sheet-scroll::-webkit-scrollbar { height: 10px; width: 10px; }
.sheet-scroll::-webkit-scrollbar-track { background: var(--surface2); border-radius: 6px; }
.sheet-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 6px; }
.sheet-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.sheet-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    font-family: var(--font);
    table-layout: fixed;
}
.sheet-table th {
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: capitalize;
    color: var(--text-dim);
    padding: 4px 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 4;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}
.sheet-table th .sort-arrow { font-size: 0.8em; color: var(--text-muted); margin-left: 2px; }
.sheet-table th .sort-arrow.active { color: var(--accent); }
.sheet-table th .col-resize {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
}
.sheet-table th .col-resize:hover,
.sheet-table th .col-resize.dragging { background: var(--accent); }
.sheet-table td {
    padding: 1px 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: calc(1em + 13px);
    max-height: calc(1em + 13px);
    line-height: calc(1em + 9px);
}
.sheet-table tr:hover td { background: #fafafa; }
.sheet-table tr.row-dirty td { background: #fff8e1; }
.sheet-table tr.row-new td { background: #e8f5e9; }
.sheet-table tr.row-inactive { opacity: 0.5; }
.sheet-table td.readonly { padding: 2px 6px; font-size: inherit; color: var(--text-dim); }
.sheet-table td.mono { font-family: var(--mono); }
.sheet-table th.col-frozen,
.sheet-table td.col-frozen {
    position: sticky;
    right: 0;
    z-index: 3;
    background: var(--surface2);
    border-left: 2px solid var(--border2) !important;
}
.sheet-table th.col-frozen { z-index: 5; }
.sheet-table td.col-frozen { background: var(--surface); }
.sheet-table tr:hover td.col-frozen { background: #fafafa; }
.sheet-table tr.row-dirty td.col-frozen { background: #fff8e1; }
.sheet-table tr.row-new td.col-frozen { background: #e8f5e9; }
.sheet-table th.col-cb,
.sheet-table td.col-cb {
    width: 28px;
    text-align: center;
    padding: 0;
    vertical-align: middle;
}
.sheet-table th.col-cb input,
.sheet-table td.col-cb input { vertical-align: middle; margin: 0; }
.sheet-table td.actions { padding: 0 4px; white-space: nowrap; text-align: left; }
.sheet-table input.cell,
.sheet-table select.cell {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    padding: 2px 6px;
    font-family: inherit;
    font-size: inherit;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sheet-table .cell-mono { font-family: var(--mono); }
.sheet-table input.cell:focus,
.sheet-table select.cell:focus {
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.sheet-table td.actions .btn-icon { padding: 2px 5px; font-size: 11px; border: none; background: none; cursor: pointer; color: var(--text-dim); }
.sheet-table td.actions .btn-icon:hover { background: var(--surface2); color: var(--accent); }
.sheet-table tr.group-header td {
    background: #f5f0f4;
    font-weight: 700; font-size: 10px;
    letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--accent); padding: 6px 10px;
    border-top: 1px solid var(--border);
    cursor: pointer; user-select: none;
}
.sheet-table tr.group-header td:hover { background: #ece3ea; }
.sheet-table tr.group-header .group-count { font-family: var(--mono); font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.sheet-table tr.group-header .group-toggle { display: inline-block; width: 12px; margin-right: 4px; color: var(--text-muted); }
.sheet-table tr.group-collapsed { display: none; }

/* ── Form labels (side panel) ──────────────────────────────── */
.frm-lbl { font-size: 13px; font-weight: 600; color: var(--text-dim); letter-spacing: normal; text-transform: none; }
.frm-inp { font-size: 13px; font-family: var(--font); padding: 5px 8px; }
.frm-mono { font-family: var(--mono); }

/* ── Toolbar header bar ────────────────────────────────────── */
.st-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.st-card-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* ── Toolbar control normalization ─────────────────────────── */
.st-card-header input,
.st-card-header select,
.st-card-header .btn-sm,
.st-card-header .btn-primary {
    font-family: var(--font);
    vertical-align: middle;
    box-sizing: border-box;
}

/* ── Filter dropdown panel ─────────────────────────────────── */
.filter-wrap { position: relative; display: inline-block; }
.filter-wrap > button {
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-weight: 400;
    cursor: pointer;
    height: auto;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6370'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 22px;
}
.filter-dropdown {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 10px 14px;
    z-index: 200;
    min-width: 260px;
    max-height: 70vh;
    overflow-y: auto;
}
.filter-dropdown.open { display: block; }
.filter-dropdown .filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.filter-dropdown .filter-row:last-child { margin-bottom: 0; }
.filter-dropdown .filter-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    font-family: var(--font);
    min-width: 70px;
    white-space: nowrap;
}
.filter-dropdown select,
.filter-dropdown input {
    flex: 1;
    padding: 3px 6px;
    font-size: 13px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.filter-dropdown select:focus,
.filter-dropdown input:focus { border-color: var(--accent); }
.filter-badge {
    font-size: 9px;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 14px;
    text-align: center;
    margin-left: 4px;
}

/* ── Column toggle dropdown ────────────────────────────────── */
.col-toggle-wrap {
    position: relative;
    display: inline-block;
}
.col-toggle-dropdown {
    display: none;
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 8px 0;
    z-index: 200;
    min-width: 180px;
    max-height: 70vh;
    overflow-y: auto;
}
.col-toggle-dropdown.open { display: block; }
.col-toggle-dropdown label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
}
.col-toggle-dropdown label:hover { background: var(--surface2); }
.col-toggle-dropdown input[type="checkbox"] { accent-color: var(--accent); }

/* ── Font-size control ─────────────────────────────────────── */
.font-size-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
    background: var(--surface);
}
.font-size-ctrl button {
    background: none;
    border: none;
    padding: 0 7px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    height: 100%;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1;
}
.font-size-ctrl button:hover { color: var(--accent); background: var(--surface2); }
.font-size-ctrl span {
    font-family: var(--font);
    font-size: 13px;
    padding: 0 5px;
    color: var(--text);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
