/* TimeTracking interface. Solid colors only: no gradients anywhere. */

:root {
    --canvas: #F5F7FA;
    --surface: #FFFFFF;
    --surface-subtle: #F9FAFC;
    --ink: #182638;
    --ink-2: #33455A;
    --muted: #536477;
    --faint: #8A97A6;
    --line: #DCE3EB;
    --line-soft: #EAEFF4;
    --control-line: #C8D1DC;

    --action: #2457D6;
    --action-hover: #1C45AE;
    --action-pressed: #173A94;
    --action-soft: #EDF2FF;
    --action-ink: #1D48B5;

    --success: #1F7A4D;
    --success-soft: #E6F4EC;
    --success-line: #BFE0CD;
    --warning: #8A5A00;
    --warning-soft: #FFF4D6;
    --warning-line: #EBD39C;
    --danger: #B42332;
    --danger-soft: #FDECEE;
    --danger-line: #F1C3C9;
    --neutral-soft: #EEF1F5;

    --radius-control: 6px;
    --radius-surface: 10px;
    --shadow-pop: 0 12px 32px rgba(24, 38, 56, .16), 0 2px 6px rgba(24, 38, 56, .08);
    --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 240px;

    --bs-body-font-family: var(--font);
    --bs-body-font-size: 14px;
    --bs-body-line-height: 1.5;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--canvas);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-heading-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-primary: #2457D6;
    --bs-primary-rgb: 36, 87, 214;
    --bs-link-color: var(--action);
    --bs-link-color-rgb: 36, 87, 214;
    --bs-link-hover-color: var(--action-hover);
    --bs-link-hover-color-rgb: 28, 69, 174;
    --bs-focus-ring-color: rgba(36, 87, 214, .25);
    --bs-border-radius: var(--radius-control);
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 600; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; line-height: 1.35; }
h3 { font-size: 14px; font-weight: 600; }
p { margin-bottom: .75rem; }
a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-hover); }
small, .small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

.muted { color: var(--muted) !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-muted { color: var(--muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 2000; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: var(--radius-control); box-shadow: var(--shadow-pop); }
.skip-link:focus { top: 12px; }

/* ---------- Shell ---------- */
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1040; width: var(--sidebar-width); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: var(--ink); font-size: 17px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; }
.sidebar-brand:hover { color: var(--ink); }
.brand-mark { flex: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-group-label { margin: 0 10px 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.side-link { display: flex; align-items: center; gap: 12px; min-height: 34px; padding: 6px 10px; margin: 0; border-radius: var(--radius-control); color: var(--ink-2); text-decoration: none; }
.side-link i { width: 16px; text-align: center; color: var(--faint); font-size: 14px; }
.side-link:hover { background: var(--canvas); color: var(--ink); }
.side-link.is-active { background: var(--action-soft); color: var(--action-ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--action); }
.side-link.is-active i { color: var(--action); }
button.side-link { width: 100%; border: 0; background: none; text-align: left; }
button.side-link .spinner { flex: none; }
.sidebar-footer { padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.language-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 12px; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; }
.language-switch button { border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); padding: 5px 4px; font-size: 12px; font-weight: 500; }
.language-switch button:hover { color: var(--ink); }
.language-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.sidebar-account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-account-text { display: grid; min-width: 0; line-height: 1.35; }
.sidebar-account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.sidebar-account-text a { color: var(--muted); font-size: 12px; }

.app-main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 10px 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-trail { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 13px; }
.topbar-trail > * + *::before { content: "/"; margin-right: 8px; color: var(--faint); }
.topbar-trail a { color: var(--ink-2); text-decoration: none; }
.topbar-trail a:hover { color: var(--action); text-decoration: underline; }
.topbar-date { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.nav-toggle { display: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); }
.sidebar-scrim { position: fixed; inset: 0; z-index: 1035; background: rgba(24, 38, 56, .45); }
.app-content { width: 100%; max-width: 1440px; padding: 28px 32px 64px; outline: none; }

/* ---------- Page structure ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.page-header h1 { margin: 0; }
.page-lede { margin: 6px 0 0; max-width: 72ch; color: var(--muted); }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--action); }

.sheet { margin-bottom: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-surface); }
.sheet-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { margin: 0; }
.sheet-header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.sheet-body { padding: 20px; }
.sheet-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--surface-subtle); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-surface) var(--radius-surface); }
.sheet-footer .sheet-footer-note { margin-right: auto; color: var(--muted); font-size: 13px; }
.sheet-footer.is-sticky { position: sticky; bottom: 0; z-index: 5; }
.sheet > :last-child:not(.sheet-footer) { border-radius: 0 0 var(--radius-surface) var(--radius-surface); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.detail-grid > * { min-width: 0; }
.detail-aside { display: grid; gap: 24px; }
.detail-aside .sheet { margin-bottom: 0; }

.form-narrow { max-width: 760px; }
.form-section { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: 16px 40px; padding: 22px 20px; border-bottom: 1px solid var(--line-soft); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-intro h2 { margin: 0 0 4px; font-size: 15px; }
.form-section-intro p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Ledger totals and week grid ---------- */
.ledger-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-surface); }
.ledger-totals > div { padding: 14px 20px; border-left: 1px solid var(--line-soft); }
.ledger-totals > div:first-child { border-left: 0; }
.ledger-totals dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.ledger-totals dd { margin: 2px 0 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ledger-totals dd small { margin-left: 3px; color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: 0; }

.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav .week-range { min-width: 150px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
.week-ledger th.day, .week-ledger td.day { width: 9%; text-align: right; }
.week-ledger thead th.day { line-height: 1.2; }
.week-ledger .day-name { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.week-ledger .day-number { display: block; margin-top: 2px; color: var(--ink); font-size: 15px; font-weight: 600; }
.week-ledger .is-today { background: var(--action-soft) !important; }
.week-ledger .is-today .day-number, .week-ledger .is-today .day-name { color: var(--action-ink); }
.week-ledger .is-weekend { background: var(--surface-subtle); }
.week-ledger .hours-none { color: #A7B2BF; }
.week-ledger .row-total { border-left: 1px solid var(--line-soft); font-weight: 600; }
.data-table.week-ledger tfoot th, .data-table.week-ledger tfoot td { padding-top: 12px; padding-bottom: 12px; border-top: 2px solid var(--ink); font-weight: 600; background: var(--surface); }
.data-table.week-ledger tbody th { font-weight: 500; }
.data-table.week-ledger .row-total { font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.data-table thead th { padding: 10px 16px; background: var(--surface-subtle); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; vertical-align: bottom; }
.data-table td, .data-table tbody th, .data-table tfoot th { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); font-weight: 400; vertical-align: middle; text-align: left; }
.data-table thead th.num, .data-table td.num { text-align: right; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr:hover > * { background: #FAFBFD; }
.data-table .num { text-align: right; }
.data-table .row-title { color: var(--ink); font-weight: 600; text-decoration: none; }
.data-table a.row-title:hover { color: var(--action); text-decoration: underline; }
.row-meta { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; font-weight: 400; }
.row-note { display: block; max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.data-table .check-cell { width: 44px; }
.sheet > .table-wrap:last-child .data-table tbody tr:last-child > *:first-child { border-bottom-left-radius: var(--radius-surface); }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 7px; border-radius: 5px; background: var(--neutral-soft); color: var(--ink-2); font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill-plain::before { display: none; }
.pill-info { background: var(--action-soft); color: var(--action-ink); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: var(--neutral-soft); color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; margin: 0 4px 4px 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink-2); font-size: 12px; }

/* ---------- Facts ---------- */
.facts { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); margin: 0; }
.facts dt, .facts dd { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.facts dt { padding-right: 12px; color: var(--muted); font-weight: 400; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts > :nth-last-child(-n + 2) { border-bottom: 0; }
.sheet-body > .facts:first-child > :nth-child(-n + 2) { padding-top: 0; }
.facts-wide { grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); }

/* ---------- Forms ---------- */
.form-label { margin-bottom: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.form-label.required::after { content: " *"; color: var(--danger); }
.form-control, .form-select { padding: 8px 12px; border-color: var(--control-line); border-radius: var(--radius-control); background-color: var(--surface); color: var(--ink); font-size: 14px; }
.form-select { padding-right: 36px; }
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus { border-color: var(--action); box-shadow: 0 0 0 3px rgba(36, 87, 214, .18); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--canvas); color: var(--muted); }
.form-control-sm, .form-select-sm { padding-top: 5px; padding-bottom: 5px; font-size: 13px; }
.form-text { margin-top: 5px; color: var(--muted); font-size: 12px; }
.form-check-input { border-color: var(--control-line); }
.form-check-input:checked { background-color: var(--action); border-color: var(--action); }
.form-check-input:focus { border-color: var(--action); box-shadow: 0 0 0 3px rgba(36, 87, 214, .18); }
.form-check-label { color: var(--ink); }
.input-group-text { border-color: var(--control-line); background: var(--canvas); color: var(--muted); font-size: 13px; }
.field-validation-error, .invalid-feedback { display: block; margin-top: 5px; color: var(--danger); font-size: 12px; }
.input-validation-error { border-color: var(--danger) !important; }
.validation-summary-errors { padding: 12px 16px; margin-bottom: 20px; border: 1px solid var(--danger-line); border-radius: 8px; background: var(--danger-soft); color: #7F1D28; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none; }

/* ---------- Buttons ---------- */
.btn { --bs-btn-padding-y: 7px; --bs-btn-padding-x: 14px; --bs-btn-font-size: 14px; --bs-btn-font-weight: 500; --bs-btn-border-radius: var(--radius-control); --bs-btn-focus-box-shadow: 0 0 0 3px rgba(36, 87, 214, .3); display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn-sm { --bs-btn-padding-y: 4px; --bs-btn-padding-x: 10px; --bs-btn-font-size: 13px; gap: 6px; }
.btn-lg { --bs-btn-padding-y: 9px; --bs-btn-padding-x: 18px; --bs-btn-font-size: 15px; }
.btn-primary { --bs-btn-bg: var(--action); --bs-btn-border-color: var(--action); --bs-btn-hover-bg: var(--action-hover); --bs-btn-hover-border-color: var(--action-hover); --bs-btn-active-bg: var(--action-pressed); --bs-btn-active-border-color: var(--action-pressed); --bs-btn-disabled-bg: var(--action); --bs-btn-disabled-border-color: var(--action); }
.btn-secondary, .btn-outline-secondary { --bs-btn-color: var(--ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--control-line); --bs-btn-hover-color: var(--ink); --bs-btn-hover-bg: var(--canvas); --bs-btn-hover-border-color: #B6C1CE; --bs-btn-active-color: var(--ink); --bs-btn-active-bg: #E9EEF4; --bs-btn-active-border-color: #B6C1CE; --bs-btn-disabled-color: var(--muted); --bs-btn-disabled-bg: var(--surface); --bs-btn-disabled-border-color: var(--line); }
.btn-success { --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: #186240; --bs-btn-hover-border-color: #186240; --bs-btn-active-bg: #134F33; --bs-btn-active-border-color: #134F33; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); --bs-btn-hover-bg: #961C29; --bs-btn-hover-border-color: #961C29; --bs-btn-active-bg: #7F1722; --bs-btn-active-border-color: #7F1722; }
.btn-outline-danger { --bs-btn-color: var(--danger); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--danger-line); --bs-btn-hover-color: var(--danger); --bs-btn-hover-bg: var(--danger-soft); --bs-btn-hover-border-color: #E3A2AB; --bs-btn-active-color: var(--danger); --bs-btn-active-bg: #F9DADE; --bs-btn-active-border-color: #E3A2AB; }
.btn-ghost { --bs-btn-color: var(--muted); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--ink); --bs-btn-hover-bg: var(--canvas); --bs-btn-hover-border-color: transparent; --bs-btn-active-color: var(--ink); --bs-btn-active-bg: #E9EEF4; --bs-btn-active-border-color: transparent; }
.btn-ghost.text-danger:hover { background: var(--danger-soft); }
.btn-icon { --bs-btn-padding-x: 0; width: 32px; height: 32px; }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn .spinner, .side-link .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented .is-active, .segmented [aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.segmented .count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.filter-bar .field { flex: 1 1 170px; min-width: 0; }
.filter-bar .field-wide { flex-basis: 260px; }
.filter-bar .form-label { font-size: 12px; }
.filter-bar .filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Notices, empty states, meters ---------- */
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.notice > i { margin-top: 3px; }
.notice p { margin: 0; }
.notice .notice-title { margin-bottom: 2px; font-weight: 600; }
.notice-body { flex: 1; min-width: 0; }
.notice-danger { background: var(--danger-soft); border-color: var(--danger-line); color: #7F1D28; }
.notice-warning { background: var(--warning-soft); border-color: var(--warning-line); color: #6B4600; }
.notice-info { background: var(--action-soft); border-color: #C9D7FA; color: #1D3F99; }
.notice-success { background: var(--success-soft); border-color: var(--success-line); color: #155A38; }
.notice .quote { margin-top: 8px; padding: 8px 12px; border-left: 3px solid currentColor; background: rgba(255, 255, 255, .6); white-space: pre-wrap; }

.empty-state { padding: 44px 24px; text-align: center; }
.empty-state-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 12px; background: var(--canvas); color: var(--muted); font-size: 20px; }
.empty-state h2, .empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { max-width: 46ch; margin: 0 auto 16px; color: var(--muted); }
.empty-state p:last-child { margin-bottom: 0; }

.meter { height: 6px; overflow: hidden; border-radius: 3px; background: var(--line-soft); }
.meter > span { display: block; height: 100%; background: var(--action); }
.meter.is-over > span { background: var(--danger); }
.meter.is-near > span { background: #C98A12; }

.avatar { display: inline-grid; flex: none; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--action-soft); color: var(--action-ink); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-text { min-width: 0; }

/* ---------- Timeline and comments ---------- */
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; top: 30px; bottom: 2px; left: 13.5px; width: 1px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 11px; }
.timeline-icon.is-approved { border-color: var(--success-line); background: var(--success-soft); color: var(--success); }
.timeline-icon.is-rejected { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.timeline-text { padding-top: 4px; }
.timeline-text time, .timeline-text .row-meta { color: var(--muted); font-size: 12px; }

.comment { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.comment-head strong { font-weight: 600; }
.comment-head time { color: var(--muted); font-size: 12px; }
.comment-text { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 14px; }
.comment-actions button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.comment-actions button:hover { color: var(--action); }
.comment-replies { margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--line-soft); }
.comment-replies .comment { padding: 10px 0; }
.comment-form textarea { resize: vertical; min-height: 76px; }

/* ---------- Board ---------- */
.board { display: grid; grid-auto-columns: minmax(270px, 1fr); grid-auto-flow: column; gap: 16px; align-items: start; overflow-x: auto; padding-bottom: 12px; }
.board-column { display: flex; flex-direction: column; min-height: 240px; max-height: calc(100vh - 250px); border: 1px solid var(--line); border-radius: var(--radius-surface); background: #EEF2F6; }
.board-column-header { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; }
.board-column-header h2 { margin: 0; font-size: 14px; }
.board-column-header .count { margin-left: auto; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.board-column-body { display: grid; flex: 1; align-content: start; gap: 8px; min-height: 80px; padding: 0 10px 12px; overflow-y: auto; }
.board-column.is-drop-target { outline: 2px dashed var(--action); outline-offset: -3px; background: var(--action-soft); }
.board-card { position: relative; padding: 10px 12px 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: grab; }
.board-card::before { content: ""; position: absolute; top: 10px; bottom: 10px; left: 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--faint); }
.board-card.priority-2::before { background: var(--action); }
.board-card.priority-3::before { background: #C98A12; }
.board-card.priority-4::before { background: var(--danger); }
.board-card.is-dragging { opacity: .45; }
.board-card-title { display: block; margin: 0 28px 4px 0; color: var(--ink); font-weight: 600; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
.board-card-title:hover { color: var(--action); }
.board-card-project { color: var(--muted); font-size: 12px; }
.board-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.board-card-meta .is-overdue { color: var(--danger); font-weight: 500; }
.board-card-meta .avatar { margin-left: auto; }
.board-card .card-menu { position: absolute; top: 6px; right: 6px; }
.board-empty { padding: 16px 8px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Overlays ---------- */
.dropdown-menu { --bs-dropdown-font-size: 14px; --bs-dropdown-border-color: var(--line); --bs-dropdown-border-radius: 8px; --bs-dropdown-link-color: var(--ink); --bs-dropdown-link-hover-bg: var(--canvas); --bs-dropdown-link-active-bg: var(--action-soft); --bs-dropdown-link-active-color: var(--action-ink); --bs-dropdown-item-padding-y: 7px; --bs-dropdown-item-padding-x: 14px; --bs-dropdown-header-color: var(--muted); box-shadow: var(--shadow-pop); }
.dropdown-item { display: flex; align-items: center; gap: 10px; }
.dropdown-item i { width: 14px; color: var(--muted); text-align: center; }
.dropdown-item.text-danger i { color: inherit; }

.modal { --bs-modal-border-radius: 12px; --bs-modal-border-width: 0; --bs-modal-header-padding: 16px 22px; --bs-modal-padding: 22px; --bs-modal-footer-gap: 8px; }
.modal-content { box-shadow: var(--shadow-pop); }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-footer { padding: 14px 22px; background: var(--surface-subtle); border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.modal-backdrop { --bs-backdrop-bg: #182638; --bs-backdrop-opacity: .45; }

.app-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
.app-dialog::backdrop { background: rgba(24, 38, 56, .45); }
.app-dialog-body { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 14px; padding: 22px 22px 6px; }
.app-dialog-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--action-soft); color: var(--action); }
.app-dialog.tone-danger .app-dialog-icon { background: var(--danger-soft); color: var(--danger); }
.app-dialog.tone-success .app-dialog-icon { background: var(--success-soft); color: var(--success); }
.app-dialog h2 { margin: 6px 0 6px; font-size: 16px; }
.app-dialog p { margin: 0; color: var(--muted); white-space: pre-line; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 1090; display: grid; gap: 8px; width: min(380px, calc(100vw - 40px)); }
.app-toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 8px; background: var(--ink); color: #FFFFFF; box-shadow: var(--shadow-pop); animation: toast-in .18s ease-out; }
.app-toast > i { margin-top: 3px; color: #8FD6AE; }
.app-toast.is-error > i { color: #FFA3AD; }
.app-toast p { flex: 1; margin: 0; }
.app-toast button { padding: 0 4px; border: 0; background: none; color: #B9C4D1; }
.app-toast button:hover { color: #FFFFFF; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Tabs ---------- */
.nav-tabs { gap: 22px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.nav-tabs .nav-link { display: inline-flex; gap: 8px; min-height: 0; margin: 0 0 -1px; padding: 13px 0 11px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; box-shadow: none; color: var(--muted); font-weight: 500; }
.nav-tabs .nav-link:hover { background: none; color: var(--ink); }
.nav-tabs .nav-link.active { background: none; border-bottom-color: var(--action); color: var(--ink); }
.nav-tabs .count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- DataTables ---------- */
div.dt-container > .row { --bs-gutter-x: 0; margin: 0 !important; padding: 12px 20px; row-gap: 10px; }
div.dt-container > .row.dt-layout-table { padding: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
div.dt-container > .row:last-child { border-bottom: 0; }
div.dt-container > .row > div { gap: 10px 14px; flex-wrap: wrap; }
div.dt-container div.dt-layout-table > div { margin: 0; overflow-x: auto; }
table.dataTable.data-table th.dt-type-numeric:not(.num), table.dataTable.data-table td.dt-type-numeric:not(.num),
table.dataTable.data-table th.dt-type-date, table.dataTable.data-table td.dt-type-date { text-align: left; }
table.dataTable.data-table th.dt-type-numeric:not(.num) div.dt-column-header,
table.dataTable.data-table th.dt-type-date div.dt-column-header { flex-direction: row; }
div.dt-container .dt-search label, div.dt-container .dt-length label { color: var(--muted); font-size: 13px; }
div.dt-container .dt-search input { width: 240px; max-width: 100%; margin-left: 0 !important; padding: 7px 12px; border: 1px solid var(--control-line); border-radius: var(--radius-control); }
div.dt-container .dt-length select { width: auto; margin-right: 6px; padding: 4px 28px 4px 8px; border-color: var(--control-line); font-size: 13px; }
div.dt-container .dt-info { padding: 0 !important; color: var(--muted); font-size: 13px; }
div.dt-container .dt-paging .pagination { gap: 4px; margin: 0; }
div.dt-container .dt-paging .page-link { min-width: 32px; padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--radius-control) !important; background: var(--surface); color: var(--ink-2); font-size: 13px; text-align: center; }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--action); border-color: var(--action); color: #FFFFFF; }
div.dt-container .dt-paging .page-item.disabled .page-link { background: var(--surface); color: var(--faint); }
div.dt-container .dt-buttons { gap: 6px; }
div.dt-container .dt-buttons .btn { --bs-btn-padding-y: 4px; --bs-btn-padding-x: 10px; --bs-btn-font-size: 13px; border-radius: var(--radius-control) !important; }
div.dt-container .dt-buttons.btn-group { flex-wrap: wrap; }
table.dataTable.data-table { margin: 0 !important; }
table.dataTable.data-table > thead > tr > th { border-bottom: 1px solid var(--line); }
table.dataTable.data-table > tbody > tr:last-child > * { border-bottom: 0; }
table.dataTable > thead > tr > th.dt-orderable-asc:hover, table.dataTable > thead > tr > th.dt-orderable-desc:hover { outline: none; color: var(--ink); }
table.dataTable td.dt-empty { padding: 32px 16px; color: var(--muted); text-align: center; }
div.dt-button-info { border: 0 !important; border-radius: 10px; box-shadow: var(--shadow-pop) !important; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }

/* ---------- Sign in and errors ---------- */
.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 32px 16px; background: var(--canvas); }
.auth-shell { width: min(400px, 100%); }
.auth-brand { justify-content: center; margin-bottom: 20px; padding: 0; font-size: 19px; }
.auth-panel { padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.auth-panel h1 { margin: 0 0 6px; font-size: 22px; }
.auth-panel .auth-lede { margin-bottom: 22px; color: var(--muted); }
.auth-language { max-width: 220px; margin: 20px auto 0; }
.error-code { margin-bottom: 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- Overview ---------- */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.overview-grid > * { min-width: 0; }
.link-list { margin: 0; padding: 0; list-style: none; }
.link-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
.link-list li:last-child { border-bottom: 0; }
.link-list .link-list-main { flex: 1; min-width: 0; }
.link-list a.row-title { color: var(--ink); font-weight: 600; text-decoration: none; }
.link-list a.row-title:hover { color: var(--action); text-decoration: underline; }

/* ---------- Claims ---------- */
.claim-module > td { padding-top: 16px !important; background: var(--surface-subtle) !important; color: var(--ink); font-weight: 600; }
.form-switch .form-check-input { width: 2.2em; cursor: pointer; }
.form-switch .form-check-input:disabled { cursor: not-allowed; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .detail-grid, .overview-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
    .nav-open .app-sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-pop); }
    .nav-open { overflow: hidden; }
    .app-main { margin-left: 0; }
    .nav-toggle { display: inline-grid; place-items: center; }
    .app-topbar { padding: 10px 20px; }
    .app-content { padding: 22px 20px 56px; }
    .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 767.98px) {
    /* DataTables centers its controls on small screens; keep them aligned with the rest of the sheet. */
    div.dt-container div.dt-length, div.dt-container div.dt-search, div.dt-container div.dt-info, div.dt-container div.dt-paging { text-align: left; }
    div.dt-container div.dt-paging ul.pagination { justify-content: flex-start !important; flex-wrap: wrap; }
}

@media (max-width: 575.98px) {
    h1 { font-size: 22px; }
    .app-topbar { padding: 8px 16px; }
    .topbar-date { display: none; }
    .app-content { padding: 18px 16px 48px; }
    .page-header { align-items: stretch; flex-direction: column; }
    .ledger-totals { grid-template-columns: 1fr 1fr; }
    .ledger-totals > div:nth-child(odd) { border-left: 0; }
    .ledger-totals > div:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
    .sheet-header, .sheet-body, .filter-bar, .sheet-footer { padding-left: 16px; padding-right: 16px; }
    .filter-bar .field { flex-basis: calc(50% - 7px); }
    .facts { grid-template-columns: minmax(0, 1fr); }
    .facts dt { padding-bottom: 0; border-bottom: 0; font-size: 12px; }
    .facts dd { padding-top: 2px; }
    .facts > :nth-last-child(2) { border-bottom: 0; }
    div.dt-container > .row { padding: 12px 16px; }
    div.dt-container > .row > div.dt-layout-start, div.dt-container div.dt-search { width: 100%; }
    div.dt-container div.dt-search input { width: 100%; }
    .week-ledger { min-width: 680px; }
    .toast-stack { right: 16px; bottom: 16px; width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
    body { background: #FFFFFF; }
    .app-sidebar, .app-topbar, .page-actions, .toast-stack, .row-actions, .filter-bar, .dt-container > .row:not(.dt-layout-table), .btn { display: none !important; }
    .app-main { margin: 0; }
    .app-content { max-width: none; padding: 0; }
    .sheet, .ledger-totals { break-inside: avoid; border-color: #B8C2CC; }
}
