/* =============================================================
   IT Task Management System - App styles
   Built on Bootstrap 5.3; light/dark via [data-bs-theme]
   ============================================================= */

:root {
    --app-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 60px;
    --bottom-nav-h: 64px;
    --radius: 10px;

    --app-bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f8;
    --border: #e6e8ef;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #4f46e5;
    --accent-soft: #eef0ff;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);

    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
    --bs-body-font-family: var(--app-font);

    /* Chart series (validated for CVD + contrast against --surface) */
    --chart-1: #2a78d6;
    --chart-2: #eb6834;
    --chart-closed: #b8bec9;
    --chart-critical: #d03b3b;
    --chart-grid: #eceef3;
}

[data-bs-theme="dark"] {
    --app-bg: #0b0f19;
    --surface: #121826;
    --surface-2: #1a2132;
    --border: #232b3d;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --accent: #818cf8;
    --accent-soft: rgba(129, 140, 248, .14);
    --shadow: none;

    --bs-body-bg: #0b0f19;
    --bs-body-color: #e5e7eb;
    --bs-border-color: #232b3d;
    --bs-primary: #6366f1;
    --bs-primary-rgb: 99, 102, 241;
    --bs-link-color: #a5b4fc;
    --bs-link-color-rgb: 165, 180, 252;
    --bs-link-hover-color: #c7d2fe;
    --bs-secondary-color: #94a3b8;

    --chart-1: #3987e5;
    --chart-2: #d95926;
    --chart-closed: #3a4458;
    --chart-critical: #f07070;
    --chart-grid: #1f2738;
}

html, body { height: 100%; }
body {
    font-family: var(--app-font);
    background: var(--app-bg);
    color: var(--text);
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
.min-w-0 { min-width: 0; }

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: #4338ca;
    --bs-btn-hover-border-color: #4338ca;
    --bs-btn-active-bg: #3730a3;
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}
.form-control, .form-select { border-color: var(--border); border-radius: 8px; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.dropdown-menu {
    border-color: var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    font-size: .9rem;
}
[data-bs-theme="dark"] .text-bg-light { background: var(--surface-2) !important; color: var(--text) !important; }

.btn-icon {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 0;
    color: var(--text-muted); background: transparent;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: width .2s ease, transform .25s ease;
}
.sidebar-header {
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; min-width: 0; }
.brand-text { overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
    width: 34px; height: 34px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bs-primary); color: #fff;
    border-radius: 9px; font-size: 1rem;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.nav-section {
    font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted);
    padding: 18px 10px 6px;
    white-space: nowrap;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; margin-bottom: 2px;
    border-radius: 8px;
    color: var(--text-muted); font-weight: 500;
    white-space: nowrap; overflow: hidden;
    text-align: left;
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .seg-icon { color: var(--seg-color); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.app-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .2s ease;
}

.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--app-bg) 85%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { position: relative; align-items: center; flex: 1; max-width: 380px; }
.topbar-search i { position: absolute; left: 12px; color: var(--text-muted); font-size: .9rem; }
.topbar-search .form-control { padding-left: 34px; background: var(--surface); height: 38px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 0; color: var(--text); }
.user-btn:hover { background: var(--surface-2); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: .75rem; font-weight: 600;
}
.notif-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }
.notif-menu { width: 340px; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); color: var(--text); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread .small:first-child { font-weight: 500; }
.notif-icon {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--accent);
}
.notif-badge {
    position: absolute; top: 6px; left: calc(50% + 4px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
    background: #ef4444; color: #fff; font-size: .62rem; font-weight: 600; line-height: 16px;
}

.app-content { flex: 1; padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }

/* Collapsed sidebar (desktop) */
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-item span { display: none; }
.sidebar-collapsed .nav-section { font-size: 0; padding: 12px 0 4px; border-top: 1px solid var(--border); margin: 8px 6px 0; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed #sidebarCollapse i { transform: scaleX(-1); }

/* ---------- Page elements ---------- */
.page-header {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 12px; margin-bottom: 20px;
}
.page-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 2px; }
.page-subtitle { color: var(--text-muted); margin: 0; font-size: .875rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h3, .card-header-lite h3 { font-size: .95rem; font-weight: 600; margin: 0; }
.card-header-lite { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }

.kpi-card .card-body { padding: 18px; }
.kpi-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kpi-label { color: var(--text-muted); font-size: .825rem; margin-top: 2px; }
.tone-primary { background: rgba(79, 70, 229, .12);  color: #4f46e5; }
.tone-warning { background: rgba(245, 158, 11, .14); color: #d97706; }
.tone-danger  { background: rgba(239, 68, 68, .12);  color: #dc2626; }
.tone-success { background: rgba(34, 197, 94, .13);  color: #16a34a; }
[data-bs-theme="dark"] .tone-primary { color: #a5b4fc; }
[data-bs-theme="dark"] .tone-warning { color: #fbbf24; }
[data-bs-theme="dark"] .tone-danger  { color: #f87171; }
[data-bs-theme="dark"] .tone-success { color: #4ade80; }

.seg-card { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.seg-card:hover { border-color: var(--seg-color); transform: translateY(-1px); color: inherit; }
.seg-card .card-body { padding: 16px; }
.seg-badge, .seg-badge-lg {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: var(--seg-color);
    background: color-mix(in srgb, var(--seg-color) 14%, transparent);
    border-radius: 9px;
}
.seg-badge { width: 34px; height: 34px; }
.seg-badge-lg { width: 46px; height: 46px; font-size: 1.3rem; border-radius: 12px; }
.seg-stats { display: flex; gap: 16px; margin: 14px 0 10px; font-size: .8rem; color: var(--text-muted); }
.seg-stats strong { display: block; font-size: 1.15rem; color: var(--text); font-weight: 600; }
.seg-stats .is-overdue strong { color: #ef4444; }
.stack-bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.stack-bar span { display: block; height: 100%; }

.list-lite { list-style: none; margin: 0; padding: 0 0 8px; }
.list-lite > li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}
.list-lite > li:first-child { border-top: 0; }
.list-lite > li:has(.stretched-link) { position: relative; }
.list-lite > li:has(.stretched-link):hover { background: var(--surface-2); }

.status-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status-pill, .status-dot-label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .78rem; font-weight: 500;
    padding: 4px 10px; border-radius: 99px;
    color: var(--status-color);
    background: color-mix(in srgb, var(--status-color) 13%, transparent);
    white-space: nowrap;
}

.progress-row + .progress-row { margin-top: 14px; }
.progress-row .progress { height: 8px; border-radius: 99px; background: var(--surface-2); }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-align: center; color: var(--text-muted);
    padding: 40px 16px;
}
.empty-state > i { font-size: 1.8rem; opacity: .6; }
.empty-inline { color: var(--text-muted); font-size: .85rem; padding: 14px 16px; }

/* ---------- Charts ---------- */
.chart-tools { display: flex; align-items: center; gap: 6px; }
.chart-tools .form-select { width: auto; background-color: var(--surface); }
.chart-card [data-table-toggle].active { background: var(--accent-soft); color: var(--accent); }
.chart-box { position: relative; }
.chart-legend { display: flex; gap: 16px; font-size: .8rem; color: var(--text-muted); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 3px; border-radius: 2px; }
.stat-figure { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.tabular { font-variant-numeric: tabular-nums; }
.chart-table .table { --bs-table-bg: transparent; color: var(--text); }
.chart-table th { color: var(--text-muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Segment builder ---------- */
.drag-handle { cursor: grab; color: var(--text-muted); padding: 4px 2px; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .4; background: var(--accent-soft); }
.list-lite > li.is-archived .seg-badge,
.list-lite > li.is-archived a > div:first-child { opacity: .55; }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.icon-choice {
    height: 38px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-size: 1rem;
}
.icon-choice:hover { color: var(--text); background: var(--surface-2); }
.icon-choice.active {
    color: var(--seg-color, var(--accent));
    border-color: var(--seg-color, var(--accent));
    background: color-mix(in srgb, var(--seg-color, var(--accent)) 12%, transparent);
}
.color-swatch {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--surface); background: var(--swatch);
    box-shadow: 0 0 0 1px var(--border);
}
.color-swatch.active { box-shadow: 0 0 0 2px var(--swatch); }
.form-control-color { width: 40px; height: 32px; padding: 3px; }

.tab-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.tab-scroll::-webkit-scrollbar { display: none; }
.tab-scroll .nav-link { white-space: nowrap; color: var(--text-muted); font-weight: 500; }
.tab-scroll .nav-link.active { color: var(--accent); }

.feature-switch { padding-top: 10px; padding-bottom: 10px; border-top: 1px solid var(--border); margin: 0; }
.feature-switch:first-child { border-top: 0; }
.form-switch .form-check-input { cursor: pointer; }

.sticky-save {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; justify-content: flex-end;
    margin-top: 16px; padding: 12px 0;
    background: linear-gradient(to top, var(--app-bg) 70%, transparent);
}

.rules-head, .rule-row {
    display: grid; align-items: center; gap: 8px;
    grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr) minmax(0, 1.3fr) 38px;
    padding: 6px 16px;
}
.rules-head { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 12px; }
.rule-row + .rule-row { border-top: 1px dashed var(--border); }

/* ---------- Items ---------- */
.chip-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    padding: 5px 12px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-size: .8rem; font-weight: 500; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color); }
.chip-count { color: var(--text-muted); font-weight: 400; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip.active .chip-count { color: inherit; opacity: .7; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.toolbar-search .form-control { padding-left: 30px; background: var(--surface); }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-filters .form-select { width: auto; background-color: var(--surface); }

.items-table { font-size: .875rem; }
.items-table thead th {
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); background: var(--surface); border-bottom-color: var(--border);
    white-space: nowrap; padding: 12px;
}
.items-table td { padding: 10px 12px; border-color: var(--border); background: transparent; max-width: 260px; }
.items-table tbody tr { cursor: pointer; }
.items-table .col-code { width: 1%; white-space: nowrap; }
.items-table .col-title { min-width: 220px; max-width: 420px; }
.items-table .item-link { color: var(--text); }
.items-table .item-link:hover { color: var(--accent); }
.th-sort { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; white-space: nowrap; }
.th-sort i { font-size: .75rem; opacity: .5; }
.th-sort.active { color: var(--text); }
.th-sort.active i { opacity: 1; }
.is-loading { opacity: .5; transition: opacity .15s; }

.item-cards { display: flex; flex-direction: column; }
.item-card {
    display: block; width: 100%; text-align: left;
    padding: 14px 16px; border: 0; border-top: 1px solid var(--border);
    background: none; color: var(--text);
}
.item-card:first-child { border-top: 0; }
.item-card:active { background: var(--surface-2); }

.list-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); }
.list-footer:empty { display: none; }

.priority-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.priority-badge i { color: var(--p-color); font-size: .7rem; }
.avatar-sm { width: 24px; height: 24px; font-size: .62rem; flex-shrink: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); font-size: .78rem; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.mini-progress { display: flex; align-items: center; gap: 8px; min-width: 110px; font-size: .78rem; color: var(--text-muted); }
.mini-progress .progress { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); }

.item-drawer { --bs-offcanvas-width: 520px; background: var(--surface); }
.item-drawer .offcanvas-header { border-bottom: 1px solid var(--border); gap: 12px; }
.status-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px; border-radius: 99px; font-size: .85rem; font-weight: 500;
    color: var(--status-color); border: 0;
    background: color-mix(in srgb, var(--status-color) 14%, transparent);
}
.status-btn:hover, .status-btn.show { color: var(--status-color); background: color-mix(in srgb, var(--status-color) 22%, transparent); }
.dropdown-item .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.props { display: grid; grid-template-columns: 1fr; gap: 2px; }
.prop { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: center; padding: 6px 0; font-size: .875rem; }
.prop-label { color: var(--text-muted); font-size: .8rem; }
.drawer-section {
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); margin: 22px 0 8px;
}
.timeline { list-style: none; padding: 0 0 0 14px; margin: 0; border-left: 2px solid var(--border); font-size: .82rem; }
.timeline li { position: relative; padding: 0 0 12px 8px; }
.timeline li::before {
    content: ''; position: absolute; left: -20px; top: 6px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent);
}
.check-pills { display: flex; flex-wrap: wrap; gap: 6px; }

.item-counts { display: inline-flex; gap: 8px; margin-left: 8px; font-size: .75rem; color: var(--text-muted); white-space: nowrap; vertical-align: middle; }
.item-counts i { font-size: .75rem; }

/* ---------- Board ---------- */
.board {
    display: flex; gap: 12px; align-items: flex-start;
    overflow-x: auto; padding-bottom: 12px;
    scroll-snap-type: x proximity;
    min-height: 60vh;
}
.board-col {
    flex: 0 0 280px; max-height: calc(100vh - 230px);
    display: flex; flex-direction: column;
    background: var(--surface-2); border-radius: var(--radius);
    border: 1px solid transparent;
    scroll-snap-align: start;
    transition: border-color .15s, opacity .15s, background .15s;
}
.board-col-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; font-size: .85rem;
    border-top: 3px solid var(--status-color); border-radius: var(--radius) var(--radius) 0 0;
}
.board-col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-color); flex-shrink: 0; }
.board-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.board-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; cursor: grab; box-shadow: var(--shadow);
    font-size: .85rem;
}
.board-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.board-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.board-card-title { font-weight: 500; line-height: 1.35; word-break: break-word; }
.board-card .item-counts { margin-left: 0; }
.board-ghost { opacity: .35; }
.board-chosen { box-shadow: 0 8px 24px rgba(15, 23, 42, .18); }
.board-more, .board-empty { padding: 4px 12px 12px; }
.board-list:not(:empty) + .board-more + .board-empty, .board-list:not(:empty) ~ .board-empty { display: none; }
.board-col.drop-ok { border-color: var(--status-color); background: color-mix(in srgb, var(--status-color) 8%, var(--surface-2)); }
.board-col.drop-no { opacity: .4; }

/* ---------- Attachments & comments ---------- */
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 16px; margin-bottom: 8px;
    border: 1.5px dashed var(--border); border-radius: var(--radius);
    text-align: center; font-size: .85rem; cursor: pointer;
    color: var(--text); background: var(--surface);
    transition: border-color .15s, background .15s;
}
.dropzone > i { font-size: 1.4rem; color: var(--text-muted); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .progress { height: 4px; }
.file-list, .comment-list { list-style: none; padding: 0; margin: 0; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.file-thumb {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--text-muted); font-size: 1.2rem;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.comment-list li { display: flex; gap: 10px; padding: 8px 0; }
.comment-body { font-size: .875rem; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment-form { margin-top: 8px; }

/* ---------- Calendar ---------- */
.calendar-card .fc {
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--surface);
    --fc-neutral-bg-color: var(--surface-2);
    --fc-list-event-hover-bg-color: var(--surface-2);
    --fc-today-bg-color: var(--accent-soft);
    --fc-button-bg-color: var(--surface);
    --fc-button-border-color: var(--border);
    --fc-button-text-color: var(--text);
    --fc-button-hover-bg-color: var(--surface-2);
    --fc-button-hover-border-color: var(--border);
    --fc-button-active-bg-color: var(--accent-soft);
    --fc-button-active-border-color: var(--accent);
    --fc-event-border-color: transparent;
    --fc-now-indicator-color: #ef4444;
    font-size: .85rem;
}
.calendar-card .fc .fc-button { font-size: .8rem; font-weight: 500; padding: 4px 10px; box-shadow: none !important; text-transform: none; }
.calendar-card .fc .fc-button-active { color: var(--accent); }
.calendar-card .fc .fc-toolbar-title { font-size: 1.05rem; font-weight: 600; }
.calendar-card .fc .fc-col-header-cell-cushion { font-size: .72rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); padding: 8px 4px; }
.calendar-card .fc a { color: inherit; }
.calendar-card .fc .fc-daygrid-day-number { font-size: .8rem; color: var(--text-muted); padding: 6px 8px; }
.calendar-card .fc .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 700; }
.calendar-card .fc .fc-daygrid-event { border-radius: 5px; padding: 1px 4px; font-size: .78rem; font-weight: 500; }
.calendar-card .fc .fc-daygrid-dot-event { background: none; }
.calendar-card .fc .fc-daygrid-dot-event:hover { background: var(--surface-2); }
.calendar-card .fc .fc-daygrid-day.fc-day-other { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
.calendar-card .fc .fc-daygrid-day:hover { cursor: pointer; }
.fc .is-done { opacity: .5; }
.fc .is-done .fc-event-title { text-decoration: line-through; }
.fc .is-overdue { box-shadow: inset 3px 0 0 #ef4444; }
.fc .is-overdue.fc-daygrid-dot-event .fc-event-title { color: #ef4444; }
.fc .fc-bg-event.ev-holiday { background: #ef4444; opacity: .12; }
.fc .fc-bg-event.ev-holiday .fc-event-title { color: #b91c1c; font-size: .7rem; font-style: normal; font-weight: 600; opacity: 1; }
.fc .ev-event { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.18) 6px 12px); }
.fc .fc-list-event.ev-event { background-image: none; }.cal-seg .form-check-input:checked { background-color: var(--seg-color); border-color: var(--seg-color); }
.cal-seg { margin-bottom: 6px; }
.cal-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cal-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-overdue { background: var(--surface-2); box-shadow: inset 3px 0 0 #ef4444; }
.lg-done { background: #94a3b8; opacity: .5; }
.lg-event { background: #64748b repeating-linear-gradient(135deg, transparent 0 3px, rgba(255,255,255,.35) 3px 6px); }
.lg-holiday { background: rgba(239, 68, 68, .2); }
@media (max-width: 767.98px) {
    .calendar-card .fc .fc-toolbar { gap: 6px; }
    .calendar-card .fc .fc-toolbar-title { font-size: .95rem; }
}

.holiday-form { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.holiday-date {
    width: 44px; flex-shrink: 0; text-align: center; line-height: 1.1;
    border: 1px solid var(--border); border-radius: 8px; padding: 4px 0;
    font-size: .68rem; text-transform: uppercase; color: #ef4444;
}
.holiday-date b { display: block; font-size: 1.05rem; color: var(--text); }

/* ---------- Feature panels (purchasing, lines, renewals, units) ---------- */
.milestones { list-style: none; padding: 0; margin: 0 0 8px; position: relative; }
.milestones li, .renewal-list li { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0 10px; position: relative; }
.milestones li:not(:last-child)::after, .renewal-list li:not(:last-child)::after {
    content: ''; position: absolute; left: 11px; top: 28px; bottom: 0; width: 2px; background: var(--border);
}
.ms-dot {
    width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--text-muted); font-size: .7rem;
}
.milestones li.done .ms-dot { background: #22c55e; color: #fff; }
.milestones li:not(.done) .fw-medium { color: var(--text-muted); }
.renewal-list { list-style: none; padding: 0; margin: 0; }
.renewal-list .ms-dot.current { background: var(--accent); color: #fff; }
.lines-table { font-size: .82rem; --bs-table-bg: transparent; color: var(--text); }
.lines-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.lines-table tbody tr[role="button"]:hover td { background: var(--surface-2); }
.lines-table tfoot td { border-bottom: 0; }
.units-progress { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.units-progress .progress { height: 8px; background: var(--surface); }
.units-figure { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.unit-list { list-style: none; padding: 0; margin: 0; }
.unit-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.unit-list li:last-child { border-bottom: 0; }
.unit-status { width: auto; font-size: .78rem; color: var(--status-color); font-weight: 500; padding-top: 2px; padding-bottom: 2px; }

/* ---------- Reports ---------- */
.report-types { display: flex; flex-direction: column; gap: 6px; }
.report-type {
    display: flex; gap: 12px; align-items: flex-start; text-align: left;
    padding: 12px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.report-type > i { font-size: 1.1rem; color: var(--text-muted); margin-top: 1px; }
.report-type:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.report-type.active { border-color: var(--accent); background: var(--accent-soft); }
.report-type.active > i { color: var(--accent); }
.report-filters { display: flex; flex-wrap: wrap; gap: 12px; }
.report-filters > div { min-width: 150px; flex: 1 1 150px; max-width: 220px; }
.report-filters .form-label { margin-bottom: 4px; }
.report-head { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.report-summary { display: flex; flex-wrap: wrap; gap: 8px 28px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.report-stat-value { font-size: 1.25rem; font-weight: 700; }
.report-table-wrap { overflow: auto; max-height: 70vh; }
.report-table { font-size: .82rem; --bs-table-bg: transparent; color: var(--text); }
.report-table thead th {
    position: sticky; top: 0; z-index: 1; background: var(--surface);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
    white-space: nowrap; padding: 10px 12px; border-bottom-color: var(--border);
}
.report-table td { padding: 8px 12px; border-color: var(--border); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.print-only { display: none; }

@media (max-width: 991.98px) {
    .report-types { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
    .report-types::-webkit-scrollbar { display: none; }
    .report-type { flex: 0 0 auto; padding: 8px 12px; }
    .report-type .small { display: none !important; }
}
@media (max-width: 575.98px) {
    .report-filters > div { max-width: none; flex-basis: calc(50% - 6px); min-width: 0; }
}

/* Printing a report = PDF export: only the report, landscape, no app chrome */
@media print {
    @page { size: landscape; margin: 12mm; }
    .sidebar, .topbar, .bottom-nav, .toast-container, .sidebar-backdrop { display: none !important; }
    .app-main { margin: 0 !important; }
    .app-content { padding: 0 !important; max-width: none; }
    body, .card { background: #fff !important; color: #000 !important; box-shadow: none !important; }
    .card { border: 0 !important; }
    .print-only { display: block; }
    .report-table-wrap { max-height: none; overflow: visible; }
    .report-table { font-size: 9pt; width: 100%; }
    .report-table.is-wide { font-size: 7.5pt; }
    .print-only.d-none { display: none !important; }
    .report-table td, .report-table th { white-space: normal !important; max-width: none; padding: 4px 4px !important; }
    .report-table.is-wide thead th { letter-spacing: 0; }
    .report-table thead th { position: static; color: #444 !important; }
    .report-table .th-sort { white-space: normal; text-align: left; }
    .report-table thead { display: table-header-group; }
    .report-table tr { break-inside: avoid; }
    .col-lg-9 { width: 100% !important; flex: 0 0 100% !important; max-width: 100% !important; }
    [data-bs-theme="dark"] * { color: #000 !important; }
}

/* ---------- Inventory ---------- */
.age-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.age-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 10px 12px; border-radius: var(--radius); text-align: left;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.age-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.age-card.active { border-color: var(--accent); background: var(--accent-soft); }
.age-card-value { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.age-card-label { font-size: .75rem; color: var(--text-muted); }
.age-card.tone-mid .age-card-value { color: #d97706; }
.age-card.tone-old .age-card-value { color: #dc2626; }
.age-card.tone-muted .age-card-value { color: var(--text-muted); }
[data-bs-theme="dark"] .age-card.tone-mid .age-card-value { color: #fbbf24; }
[data-bs-theme="dark"] .age-card.tone-old .age-card-value { color: #f87171; }
.age-badge { font-size: .8rem; font-weight: 500; white-space: nowrap; }
.age-badge.age-mid { color: #d97706; }
.age-badge.age-old { color: #dc2626; }
.age-badge.age-old::before { content: '\25CF'; font-size: .6rem; margin-right: 4px; vertical-align: 1px; }
[data-bs-theme="dark"] .age-badge.age-mid { color: #fbbf24; }
[data-bs-theme="dark"] .age-badge.age-old { color: #f87171; }
.task-chip {
    display: inline-flex; align-items: center; gap: 4px; margin-left: 6px;
    font-size: .72rem; font-weight: 500; padding: 1px 7px; border-radius: 99px;
    background: rgba(245, 158, 11, .14); color: #b45309; vertical-align: middle;
}
.task-chip.closed { background: var(--surface-2); color: var(--text-muted); }
[data-bs-theme="dark"] .task-chip { color: #fbbf24; }
.items-table tr.is-disposed td { opacity: .55; }
.selection-bar { display: flex; align-items: center; gap: 8px; }
.device-checklist { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.device-check { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.device-check:hover { background: var(--surface-2); }
.import-preview { max-height: 45vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.import-preview thead th { position: sticky; top: 0; background: var(--surface); }
.revealed-key { background: var(--accent-soft); padding: 2px 6px; border-radius: 4px; user-select: all; }
@media (max-width: 767.98px) {
    .age-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .selection-bar { width: 100%; }
}

/* Global search results */
.search-results { width: 100%; max-height: 420px; overflow-y: auto; padding: 4px; }
.search-results .dropdown-item { display: flex; align-items: center; gap: 10px; border-radius: 6px; padding: 8px 10px; white-space: normal; }

/* ---------- Auth page ---------- */
.auth-page { background: var(--app-bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 32px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, .06);
}
.auth-brand { display: flex; align-items: center; gap: 12px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none;
    color: var(--text-muted);
    font-size: .7rem; font-weight: 500;
    min-height: 44px;
}
.bottom-nav i { font-size: 1.2rem; }
.bottom-nav .active { color: var(--accent); }
.notif-sheet { height: auto !important; max-height: 70vh; border-radius: 16px 16px 0 0; }

.sidebar-backdrop { display: none; }

/* ---------- Responsive ---------- */

/* Desktop: the page title lives in the page header, so hide the duplicate in the top bar */
@media (min-width: 992px) {
    .topbar-title { display: none; }
}

/* Tablet: icon-only sidebar by default */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app:not(.sidebar-expanded) .sidebar { width: var(--sidebar-w-collapsed); }
    .app:not(.sidebar-expanded) .app-main { margin-left: var(--sidebar-w-collapsed); }
    .app:not(.sidebar-expanded) .brand-text,
    .app:not(.sidebar-expanded) .nav-item span { display: none; }
    .app:not(.sidebar-expanded) .nav-section { font-size: 0; padding: 12px 0 4px; border-top: 1px solid var(--border); margin: 8px 6px 0; }
    .app:not(.sidebar-expanded) .nav-item { justify-content: center; padding: 10px 0; }
}

/* Mobile & small tablet: off-canvas sidebar + bottom nav */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: min(var(--sidebar-w), 85vw); box-shadow: none; }
    .sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
    .sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1035;
        background: rgba(15, 23, 42, .45);
    }
    .app-main { margin-left: 0 !important; }
    .topbar { padding: 0 12px; }
    .app-content { padding: 16px 16px calc(var(--bottom-nav-h) + 24px); }
    .nav-item { padding: 11px 10px; }    /* larger touch targets */
    .sticky-save { bottom: var(--bottom-nav-h); }
    .sticky-save .btn { width: 100%; }
}

/* Filters collapse behind a button on phones */
@media (max-width: 767.98px) {
    .toolbar-search { max-width: none; }
    .toolbar-filters { display: none; width: 100%; }
    .toolbar-filters.show { display: grid; grid-template-columns: 1fr 1fr; }
    .toolbar-filters .form-select { width: 100%; }
    .prop { grid-template-columns: 110px minmax(0, 1fr); }
    .board { margin: 0 -16px; padding: 0 16px 12px; scroll-snap-type: x mandatory; scroll-padding-left: 16px; }
    .board-col { flex-basis: calc(100vw - 56px); max-height: calc(100vh - 280px); }
}

/* Workflow rules stack on small screens */
@media (max-width: 767.98px) {
    .rule-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px; padding: 12px 16px; }
    .rule-row > div { grid-column: 1 / 3; }
}

@media (max-width: 575.98px) {
    .page-title { font-size: 1.2rem; }
    .kpi-value { font-size: 1.4rem; }
    .kpi-card .card-body { padding: 14px; }
    .auth-card { padding: 24px 20px; }
    .toast-container { left: 0; right: 0; }
}
