:root {
    --page: #eef3f6;
    --page-deep: #dfe8ec;
    --ink: #14212a;
    --ink-soft: #425466;
    --muted: #6b7a88;
    --line: #d7e0e7;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --brand: #12343b;
    --brand-2: #1d6874;
    --teal: #5db7b4;
    --amber: #d99a2b;
    --green: #23845b;
    --red: #bd3b2f;
    --shadow: 0 18px 45px rgba(21, 44, 55, 0.12);
    --shadow-soft: 0 10px 26px rgba(21, 44, 55, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.006em;
}

h1, h2, h3 { letter-spacing: -0.018em; font-weight: 650; }

.num, .kpi-value, .pay-summary strong, td.num, th.num,
.totals-preview .tp-row, .doc-totals .t {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

a {
    color: var(--brand-2);
    text-decoration: none;
    font-weight: 700;
}

a:hover {
    color: var(--brand);
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 292px;
    padding: 22px 18px;
    background: var(--brand);
    color: #fff;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
    display: flex;
    gap: 13px;
    align-items: center;
    min-height: 58px;
    padding: 4px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
}

.brand strong {
    display: block;
    max-width: 190px;
    color: #fff;
    font-size: 14px;
    line-height: 1.2;
}

.brand span {
    display: block;
    margin-top: 3px;
    color: #a9c4ca;
    font-size: 12px;
    font-weight: 700;
}

.nav {
    display: grid;
    gap: 6px;
    margin-top: 22px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 0 11px;
    border-radius: 8px;
    color: #eaf4f5;
    font-size: 14px;
    font-weight: 600;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
}

.nav-icon {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.1);
    color: #f0c36b;
    font-size: 12px;
    font-weight: 680;
    flex: 0 0 auto;
}

.sidebar-footer {
    margin-top: auto;
    padding: 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer span {
    display: block;
    color: #a9c4ca;
    font-size: 12px;
    font-weight: 700;
}

.sidebar-footer strong {
    display: block;
    margin-top: 4px;
    color: #fff;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 22px 30px 46px;
}

.topbar {
    min-height: 64px;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(120px, 1fr);
    align-items: center;
    gap: 18px;
    padding: 12px 16px;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

.topbar strong {
    display: block;
    overflow-wrap: anywhere;
}

.topbar-center {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-weight: 600;
}

.topbar .button {
    justify-self: end;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 4px 0 0;
    font-size: clamp(22px, 2.4vw, 30px);
    font-weight: 650;
    line-height: 1.12;
    color: var(--ink);
}

.page-heading p {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.eyebrow {
    color: var(--brand-2);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 680;
    letter-spacing: 0;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    max-width: 100%;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 680;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(21, 44, 55, 0.06);
}

.button.primary {
    background: var(--brand-2);
    border-color: var(--brand-2);
    color: #fff;
}

.button.primary:hover {
    background: var(--brand);
    color: #fff;
}

.button.ghost {
    background: var(--surface-2);
}

.button.wide {
    width: 100%;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metric-card,
.panel,
.auth-card,
.auth-panel,
.dashboard-band {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.metric-card {
    position: relative;
    min-height: 128px;
    display: grid;
    align-content: space-between;
    gap: 12px;
    padding: 18px;
    overflow: hidden;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--teal);
}

.metric-card span {
    color: var(--ink-soft);
    font-weight: 680;
}

.metric-card strong {
    color: var(--ink);
    font-size: 30px;
    font-weight: 650;
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
    font-weight: 650;
}

.accent-card::before {
    background: var(--amber);
}

.warning-card::before {
    background: var(--red);
}

.link-card:hover {
    transform: translateY(-2px);
    border-color: #9fc4ca;
    box-shadow: var(--shadow);
}

.dashboard-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px;
}

.dashboard-band h2 {
    margin: 4px 0 0;
    font-size: 21px;
}

.band-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.band-items span {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
}

.module-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 20px;
}

.module-actions a,
.module-actions form {
    display: inline-flex;
}

.module-actions a,
.text-button {
    min-height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--brand-2);
    font: inherit;
    font-size: 13px;
    font-weight: 680;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(21, 44, 55, 0.05);
}

.module-actions a:hover,
.text-button:hover {
    border-color: #9fc4ca;
    color: var(--brand);
}

.text-button.danger {
    color: var(--red);
}

.compact-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.split-grid.two {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

.formset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}

.formset-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
}

.line-table {
    display: grid;
    gap: 8px;
}

.line-row {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) 110px 110px 120px 74px;
    gap: 8px;
    align-items: start;
}

.line-head {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 680;
    text-transform: uppercase;
}

.delete-cell {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-line {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--ink-soft);
    font-weight: 680;
}

.checkbox-line input {
    width: auto;
    min-height: auto;
}

.table-actions form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.table-actions input {
    min-width: 170px;
    min-height: 36px;
}

.panel {
    padding: 20px;
    overflow-x: auto;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 19px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 680px;
}

th,
td {
    text-align: left;
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

tr:last-child td {
    border-bottom: 0;
}

td {
    color: var(--ink-soft);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    background: #e8f3f0;
    color: var(--green);
    font-size: 12px;
    font-weight: 680;
    white-space: nowrap;
}

.warning {
    color: var(--red);
    font-weight: 680;
}

.muted,
small {
    color: var(--muted);
}

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.message {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
}

.message.success {
    border-color: #a8d8c4;
    color: var(--green);
}

.message.error {
    border-color: #efb2ac;
    color: var(--red);
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(18, 52, 59, 0.92), rgba(29, 104, 116, 0.82)),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 18px),
        #12343b;
}

.auth-page .app-shell {
    display: block;
}

.auth-main {
    min-height: 100vh;
    width: 100%;
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-layout {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: minmax(320px, 1.12fr) minmax(330px, 440px);
    gap: 22px;
    align-items: stretch;
}

.auth-layout.compact {
    width: min(480px, 100%);
    grid-template-columns: 1fr;
}

.auth-panel {
    min-height: 560px;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 251, 251, 0.95)),
        var(--surface);
}

.auth-brand {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.auth-brand.column {
    flex-direction: column;
    gap: 20px;
}

.auth-logo {
    width: min(190px, 58%);
    height: auto;
    display: block;
}

.doc-statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -6px 0 18px;
}

.doc-statusbar .lbl {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-right: 2px;
}

.auth-brand.mini {
    margin-bottom: 24px;
}

.auth-brand h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1.03;
}

.auth-brand h2,
.auth-card h2 {
    margin: 5px 0 0;
    font-size: 30px;
    line-height: 1.12;
}

.auth-brand p {
    max-width: 520px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.logo-mark {
    width: 54px;
    height: 54px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(18, 52, 59, 0.18);
    flex: 0 0 auto;
}

.logo-mark img {
    width: 54px;
    height: 54px;
    display: block;
    border-radius: 12px;
}

.auth-signal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.auth-signal-grid div {
    min-height: 118px;
    padding: 16px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.auth-signal-grid strong {
    display: block;
    color: var(--brand);
    font-size: 22px;
}

.auth-signal-grid span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.auth-card {
    min-height: 560px;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
}

.auth-layout.compact .auth-card {
    min-height: auto;
}

.auth-footnote {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-weight: 700;
}

.form,
.form-grid {
    display: grid;
    gap: 14px;
}

.form label,
.form-grid label {
    display: grid;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 680;
}

.form-grid p {
    margin: 0;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(20, 33, 42, 0.02);
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(29, 104, 116, 0.14);
}

.errorlist {
    margin: 4px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff1ef;
    color: var(--red);
    list-style: none;
    font-size: 13px;
    font-weight: 600;
}

/* ============================================================
   Zoho-grade overhaul additions
   ============================================================ */

.ico {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sidebar nav active + dividers */
.nav a {
    position: relative;
    color: #cfe0e3;
}

.nav a .ico {
    color: #8fb6bd;
}

.nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav a.active::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--teal);
}

.nav a.active .ico {
    color: #f0c36b;
}

/* Pending-approval notification dot on sidebar tabs */
.nav-dot {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
    border-radius: 999px; background: #ef4444; color: #fff;
    font-size: 10.5px; font-weight: 800; line-height: 1;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.nav-divider {
    margin: 14px 6px 4px;
    color: #88a7ad;
    font-size: 10px;
    font-weight: 680;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.topbar .button .ico {
    color: var(--ink-soft);
}

/* Secondary navigation (section tabs) */
.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: -6px 0 22px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

.subnav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
}

.subnav a .ico {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.subnav a:hover {
    background: var(--surface-2);
    color: var(--brand);
}

.subnav a.on {
    background: var(--brand);
    color: #fff;
}

.subnav a.on .ico {
    color: #f0c36b;
}

/* Pending-count notification badge on section tabs */
.tab-dot {
    display: inline-grid; place-items: center;
    min-width: 17px; height: 17px; padding: 0 5px; margin-left: 2px;
    border-radius: 999px; background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 800; line-height: 1;
}

.subnav a.on .tab-dot {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* Breadcrumb + page actions */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
}

.breadcrumb a {
    color: var(--muted);
    font-weight: 600;
}

.breadcrumb a:hover {
    color: var(--brand-2);
}

.breadcrumb span {
    color: var(--line);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.button .ico {
    width: 16px;
    height: 16px;
}

.button.sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.button.success {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.button.danger-solid {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

/* KPI cards with accent + delta */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.kpi {
    position: relative;
    padding: 18px 18px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--brand-2);
}

.kpi.green::before { background: var(--green); }
.kpi.amber::before { background: var(--amber); }
.kpi.red::before { background: var(--red); }
.kpi.teal::before { background: var(--teal); }

.kpi-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 680;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.kpi-head .ico {
    width: 16px;
    height: 16px;
    color: var(--brand-2);
}

.kpi-value {
    margin-top: 10px;
    color: var(--ink);
    font-size: 25px;
    font-weight: 650;
    line-height: 1.05;
}

.kpi-value .cur {
    font-size: 16px;
    font-weight: 600;
    color: var(--muted);
    margin-right: 2px;
}

.kpi-sub {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
}

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    padding: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h2 {
    margin: 0;
    font-size: 16px;
}

.card-head .hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.chart {
    width: 100%;
    overflow: visible;
}

.chart .grid-line {
    stroke: var(--line);
    stroke-width: 1;
}

.chart .axis-label {
    fill: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.chart .bar {
    transition: opacity 0.15s;
}

.chart .bar:hover {
    opacity: 0.82;
}

.chart .line-path {
    fill: none;
    stroke-width: 2.4;
}

.chart .area-path {
    opacity: 0.12;
}

.chart .dot {
    stroke: #fff;
    stroke-width: 1.5;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
}

.legend i {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    display: inline-block;
}

.donut-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
}

.donut-legend {
    display: grid;
    gap: 8px;
    flex: 1;
}

.donut-legend div {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
}

.donut-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: 0 0 auto;
}

.donut-legend b {
    margin-left: auto;
    color: var(--ink);
}

/* Status variants */
.status {
    background: #eef2f5;
    color: var(--ink-soft);
}

.status.is-pending { background: #fbf0d8; color: #9a6a12; }
.status.is-paid,
.status.is-complete,
.status.is-approved { background: #e3f3ec; color: var(--green); }
.status.is-rejected { background: #fbe6e3; color: var(--red); }
.status.is-draft { background: #eef2f5; color: var(--muted); }
.status.is-info { background: #e4eef6; color: #25618f; }

.dot-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
}

.dot-label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Table card + toolbar + numeric */
.tablecard {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.tablecard .table-scroll {
    overflow-x: auto;
}

.tablecard table {
    min-width: 720px;
}

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: var(--surface-2);
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}

.list-toolbar form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.list-toolbar select,
.list-toolbar input {
    min-height: 38px;
    min-width: 150px;
}

.cell-strong {
    color: var(--ink);
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
}

.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn:hover { border-color: #9fc4ca; color: var(--brand); }
.icon-btn.danger:hover { border-color: #efb2ac; color: var(--red); }
.icon-btn.go:hover { border-color: var(--brand-2); color: var(--brand-2); }

/* Empty states */
.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--muted);
}

.empty .ico {
    width: 34px;
    height: 34px;
    color: var(--line);
    margin-bottom: 8px;
}

.empty strong {
    display: block;
    color: var(--ink-soft);
    font-size: 15px;
}

/* Form sections */
.form-section {
    margin-bottom: 18px;
}

.form-section > h3 {
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--brand);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field-grid .full { grid-column: 1 / -1; }

.field-grid label,
.stack label {
    display: grid;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.helptext { color: var(--muted); font-size: 11.5px; font-weight: 600; }

/* Line items editor with running totals */
.li-table { display: grid; gap: 8px; }

.li-head,
.li-row {
    display: grid;
    grid-template-columns: minmax(150px, 1.1fr) minmax(150px, 1.3fr) 92px 90px 110px 120px 40px;
    gap: 8px;
    align-items: center;
}

.li-head {
    padding: 8px 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 680;
    text-transform: uppercase;
}

.li-row .li-amount {
    text-align: right;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.li-del {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.li-del:hover { color: var(--red); border-color: #efb2ac; }
.li-row input[type=checkbox] { display: none; }

.totals-preview {
    margin-top: 16px;
    margin-left: auto;
    width: min(340px, 100%);
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.totals-preview .tp-row {
    display: flex;
    justify-content: space-between;
    color: var(--ink-soft);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.totals-preview .tp-row.grand {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-size: 18px;
    font-weight: 680;
}

.bill-warning {
    display: none;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fbf0d8;
    color: #9a6a12;
    font-weight: 600;
    font-size: 13px;
}

/* ----- Printable document paper ----- */
.doc-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.doc-paper {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 38px 40px;
}

.doc-top {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 3px solid var(--brand);
}

.doc-top .co img {
    height: 54px;
    margin-bottom: 8px;
}

.doc-top .co strong {
    display: block;
    font-size: 19px;
    color: var(--brand);
}

.doc-top .co p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre-line;
}

.doc-title {
    text-align: right;
}

.doc-title h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 650;
    color: var(--brand);
    letter-spacing: 0.02em;
}

.doc-meta {
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 10px;
    justify-content: end;
}

.doc-meta dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-align: right;
}

.doc-meta dd {
    margin: 0;
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.doc-parties {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 22px 0;
}

.doc-parties.cols-2 { grid-template-columns: repeat(2, 1fr); }
.doc-parties.cols-3 { grid-template-columns: repeat(3, 1fr); }

.doc-parties .box {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.doc-parties h4 {
    margin: 0 0 6px;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand-2);
}

.doc-parties p {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-soft);
    line-height: 1.5;
    white-space: pre-line;
}

.doc-parties .name {
    color: var(--ink);
    font-weight: 680;
    font-size: 13.5px;
}

table.doc-lines {
    min-width: 0;
    margin-top: 4px;
}

table.doc-lines thead th {
    background: var(--brand);
    color: #fff;
    text-transform: none;
    font-size: 12px;
}

table.doc-lines tbody tr:hover { background: transparent; }

.doc-foot {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.9fr);
    gap: 22px;
    margin-top: 18px;
}

.doc-foot .words {
    padding: 12px 14px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 12.5px;
}

.doc-foot h4 {
    margin: 14px 0 4px;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand-2);
}

.doc-foot .small {
    color: var(--ink-soft);
    font-size: 12px;
    white-space: pre-line;
    line-height: 1.5;
    margin: 0;
}

.doc-totals {
    align-self: start;
    display: grid;
    gap: 6px;
}

.doc-totals .t {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.doc-totals .t.grand {
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 16px;
    font-weight: 680;
}

.doc-sign {
    margin-top: 38px;
    text-align: right;
    color: var(--ink-soft);
    font-size: 12.5px;
}

/* Chart series filter */
.chart-filter {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9px;
}

.chart-filter button {
    min-height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.chart-filter button:hover { color: var(--brand); }
.chart-filter button.on { background: var(--brand); color: #fff; }

/* Status: partial */
.status.is-partial { background: #e4eef6; color: #25618f; }

/* Payments panel */
.pay-panel { margin-bottom: 22px; }

.pay-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.pay-summary div {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.pay-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.pay-summary strong { font-size: 19px; font-weight: 650; color: var(--ink); }
.ship-helpers { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.pay-summary strong.ok { color: var(--green); }
.pay-summary strong.due { color: var(--red); }

.pay-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.pay-form label {
    display: grid;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
}

.pay-form input,
.pay-form select { min-height: 40px; min-width: 120px; }
.pay-form input[name="amount"] { min-width: 130px; }
.pay-form button { align-self: end; }

@media (max-width: 720px) {
    .pay-summary { grid-template-columns: 1fr; }
    .pay-form { flex-direction: column; align-items: stretch; }
    .pay-form label { width: 100%; }
}

@media print {
    .sidebar, .topbar, .subnav, .breadcrumb, .doc-toolbar, .doc-statusbar, .messages, .page-actions, .pay-panel { display: none !important; }
    .app-shell, .main { display: block; padding: 0; }
    .doc-paper { border: 0; box-shadow: none; max-width: none; padding: 0; }
    body { background: #fff; }
}

@media (max-width: 980px) {
    .chart-grid { grid-template-columns: 1fr; }
    .field-grid { grid-template-columns: 1fr; }
    .doc-parties { grid-template-columns: 1fr; }
    .doc-foot { grid-template-columns: 1fr; }
    .li-head { display: none; }
    .li-row { grid-template-columns: 1fr 1fr; }
    .li-row .li-amount { grid-column: 1 / -1; text-align: left; }
}

@media (max-width: 980px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-panel,
    .auth-card {
        min-height: auto;
    }

    .auth-signal-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        grid-template-columns: 1fr;
    }

    .topbar-center,
    .topbar .button {
        justify-self: stretch;
    }

    .split-grid,
    .split-grid.two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    .sidebar-footer {
        display: none;
    }

    .nav {
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    }

    .main {
        padding: 18px;
    }

    .page-heading,
    .dashboard-band {
        align-items: flex-start;
        flex-direction: column;
    }

    .band-items {
        justify-content: flex-start;
    }

    .compact-form {
        grid-template-columns: 1fr;
    }

    .line-row {
        grid-template-columns: 1fr;
    }

    .line-head {
        display: none;
    }
}

@media (max-width: 540px) {
    .auth-main {
        padding: 16px;
    }

    .auth-panel,
    .auth-card {
        padding: 22px;
    }

    .auth-brand {
        flex-direction: column;
    }

    .auth-footnote {
        align-items: flex-start;
        flex-direction: column;
    }

    .button {
        width: 100%;
        white-space: normal;
        text-align: center;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }
}

/* Finance dashboard: FY selector + alerts */
.fy-select { display: inline-flex; align-items: center; }
.fy-select label {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.fy-select select { min-height: 40px; min-width: 120px; }

.alert-row { display: grid; gap: 10px; margin-bottom: 20px; }
@media (min-width: 760px) { .alert-row:has(.alert + .alert) { grid-template-columns: 1fr 1fr; } }

.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 10px;
    font-size: 13.5px; font-weight: 600;
    border: 1px solid var(--line); background: var(--surface);
}
.alert .ico { width: 18px; height: 18px; flex: 0 0 auto; }
.alert span { flex: 1; }
.alert a { white-space: nowrap; }
.alert.danger { background: #fbe9e7; border-color: #efb2ac; color: #a3352a; }
.alert.danger .ico, .alert.danger a { color: #a3352a; }
.alert.warn { background: #fbf3df; border-color: #ecd9a6; color: #8a6516; }
.alert.warn .ico, .alert.warn a { color: #8a6516; }

/* Receivables ageing widget */
.aging-card { padding: 20px 22px; margin-bottom: 22px; }
.aging-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.aging-head span { color: var(--muted); font-size: 13px; font-weight: 600; }
.aging-head strong { color: var(--ink); font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.aging-bar {
    display: flex; height: 12px; border-radius: 7px; overflow: hidden;
    background: #eef2f5; margin-bottom: 16px;
}
.aging-bar .seg { display: block; height: 100%; }
.aging-bar .s-cur { background: #f59e0b; }
.aging-bar .s-1 { background: #ea7c1c; }
.aging-bar .s-2 { background: #db5f10; }
.aging-bar .s-3 { background: #c53d0c; }
.aging-bar .s-4 { background: #dc2626; }
.aging-buckets {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
    border-top: 1px solid var(--line); padding-top: 14px;
}
.aging-buckets > div { display: flex; flex-direction: column; gap: 2px; padding-right: 12px; border-right: 1px solid var(--line); }
.aging-buckets > div:last-child { border-right: 0; }
.aging-buckets .cur { }
.aging-buckets span { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.aging-buckets .cur span { color: var(--brand-2); }
.aging-buckets .ov { color: var(--red); }
.aging-buckets strong { font-size: 19px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.aging-buckets small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
@media (max-width: 860px) { .aging-buckets { grid-template-columns: 1fr 1fr; } }

/* Sales & Expenses: chart + totals sidebar */
.sales-exp { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 8px; align-items: center; }
.sales-exp-totals { display: grid; gap: 14px; padding-left: 22px; border-left: 1px solid var(--line); }
.sales-exp-totals div { display: flex; flex-direction: column; gap: 3px; }
.sales-exp-totals span { font-size: 13px; font-weight: 700; }
.sales-exp-totals .t-sales { color: var(--brand-2); }
.sales-exp-totals .t-rec { color: var(--green); }
.sales-exp-totals .t-exp { color: var(--red); }
.sales-exp-totals strong { font-size: 21px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
    .sales-exp { grid-template-columns: 1fr; }
    .sales-exp-totals { grid-template-columns: repeat(3, 1fr); padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
}

/* Ensure chart SVGs always have a visible height */
.chart { width: 100%; height: 300px; display: block; overflow: visible; }

/* Net Profit basis selector */
.profit-mode {
    min-height: 26px; margin-left: auto; padding: 2px 6px;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); color: var(--ink-soft);
    font: inherit; font-size: 11px; font-weight: 700;
}
.kpi-head { display: flex; align-items: center; gap: 8px; }

/* Clickable Net Profit card (toggles Actual / Ideal) */
.kpi-clickable { cursor: pointer; user-select: none; transition: box-shadow .15s, transform .15s; }
.kpi-clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-clickable:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.kpi-head { display: flex; align-items: center; gap: 8px; }

/* Interactive chart series legend (bottom-left, multi-select) */
.series-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.series-legend .chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface, #fff); color: var(--ink-soft);
    font-size: 12px; font-weight: 700; cursor: pointer; transition: opacity .15s, background .15s;
}
.series-legend .chip i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.series-legend .chip:hover { background: var(--wash, #f4f6f8); }
.series-legend .chip.off { opacity: 0.35; }
.legend-hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.chart { height: 300px; }

/* Searchable select combobox */
.ss-wrap { position: relative; }
.ss-control {
    width: 100%; text-align: left; cursor: pointer;
    padding: 9px 30px 9px 12px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
    font: inherit; color: var(--ink); line-height: 1.3;
}
.ss-control.ss-empty { color: var(--muted); }
.ss-panel {
    position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 8px; max-height: 280px; overflow: auto;
}
.ss-search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; margin-bottom: 6px; }
.ss-list { display: flex; flex-direction: column; }
.ss-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.ss-item:hover { background: var(--wash, #f4f6f8); }
.ss-item.sel { background: var(--brand, #12343b); color: #fff; }
.ss-add { padding: 9px 10px; margin-top: 4px; border-top: 1px solid var(--line); color: var(--brand, #12343b); font-weight: 700; cursor: pointer; }
.ss-add:hover { background: var(--wash, #f4f6f8); }
.ss-none { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* List search bars */
.list-search { display: flex; gap: 8px; margin: 0 0 16px; }
.list-search input { flex: 1; max-width: 460px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.button.ghost { background: transparent; }

/* Ledger table */
.ledger-table td.debit { color: #b3391f; }
.ledger-table td.credit { color: #18794e; }
.ledger-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.ledger-net { font-size: 18px; font-weight: 700; }

/* Assets UI: age grid, type chips, clickable rows, detail grid */
.age-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.age-cell { border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-align: center; background: var(--surface, #fff); }
.age-cell strong { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.age-cell span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.age-cell.danger { border-color: #f0b9b0; background: #fdf3f1; }
.age-cell.danger strong { color: #c53d0c; }
@media (max-width: 860px) { .age-grid { grid-template-columns: repeat(3, 1fr); } }

.chip-type { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
    background: #eef3f5; color: #2b5560; border: 1px solid #dbe6ea; white-space: nowrap; }
.t-fixed { background:#eef2ff; color:#3730a3; border-color:#dfe4ff; }
.t-mechanical { background:#f1f5f9; color:#334155; border-color:#e2e8f0; }
.t-enclosure { background:#f5f3ff; color:#5b21b6; border-color:#ece7fb; }
.t-elec_passive { background:#ecfeff; color:#0e7490; border-color:#cff1f5; }
.t-elec_active { background:#fff7ed; color:#c2410c; border-color:#fde3cf; }
.t-elec_ic { background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.t-elec_connector { background:#f0fdf4; color:#15803d; border-color:#d5f0dc; }
.t-packaging { background:#fefce8; color:#a16207; border-color:#f7ecc0; }
.t-sub_assembly { background:#fdf4ff; color:#a21caf; border-color:#f3ddf6; }
.t-finished { background:#ecfdf5; color:#047857; border-color:#c9efdd; }

tr.row-link { cursor: pointer; }
tr.row-link:hover { background: var(--wash, #f4f6f8); }
.table-scroll.scroll-10 { max-height: 420px; overflow-y: auto; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 22px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; }
.detail-grid span { font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.detail-grid strong { font-size: 15px; color: var(--ink); font-weight: 650; }

/* BoQ line table */
.boq-table .li-head, .boq-table .li-row { grid-template-columns: 1fr 140px 44px; }

/* DC + packing line tables */
.dc-table .li-head, .dc-table .li-row { grid-template-columns: 1fr 140px 44px; }

.box-table .li-head, .box-table .li-row { grid-template-columns: 90px 1fr 1fr 1fr 1fr 44px; }
.content-table .li-head, .content-table .li-row { grid-template-columns: 90px 1fr 130px 44px; }
.overdue-row { background: #fdf3f1; }
.detail-lbl { font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }

.chip-type.t-sales { background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.chip-type.t-purchase { background:#fef2f2; color:#b91c1c; border-color:#fee2e2; }
.chip-type.t-proforma { background:#f5f3ff; color:#6d28d9; border-color:#ede9fe; }

/* Cash-flow matrix */
.cashflow-table th, .cashflow-table td { white-space: nowrap; }
.cashflow-table .cf-lbl { text-align: left; }
.cashflow-table td:first-child { text-align: left; }
.cashflow-table .cf-group td { font-weight: 700; background: var(--wash, #f4f6f8); }
.cashflow-table .cf-group.receipts td:first-child { color: #16a34a; }
.cashflow-table .cf-group.expenses td:first-child { color: #d97706; }
.cashflow-table .cf-group.purchases td:first-child { color: #dc2626; }
.cashflow-table .cf-group.fixed td:first-child { color: #7c3aed; }
.cashflow-table .cf-group.salaries td:first-child { color: #2563eb; }
.cashflow-table .cf-sub td { color: var(--ink-soft); font-size: 13px; }
.cashflow-table .cf-net td { font-weight: 800; border-top: 2px solid var(--line); font-size: 15px; }
.cashflow-table td.cf-pos { color: #15803d; }
.cashflow-table td.cf-neg { color: #b91c1c; }

/* Cash-flow matrix — polished spreadsheet look (v6) */
.cashflow-table { border-collapse: separate; border-spacing: 0; min-width: 720px; }
.cashflow-table th, .cashflow-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.cashflow-table thead th { position: sticky; top: 0; background: var(--brand, #12343b); color: #fff; font-size: 12px; z-index: 2; }
.cashflow-table thead th.cf-lbl { text-align: left; }
.cashflow-table td:first-child, .cashflow-table th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; box-shadow: 1px 0 0 var(--line); }
.cashflow-table .cf-group td { font-weight: 700; }
.cashflow-table .cf-group td:first-child { background: #f4f6f8; }
.cashflow-table tr.cf-group.receipts td { background: #edfaf1; }
.cashflow-table tr.cf-group.receipts td:first-child { color: #15803d; background: #dcf5e3; }
.cashflow-table tr.cf-group.expenses td { background: #fff7ed; }
.cashflow-table tr.cf-group.expenses td:first-child { color: #b45309; background: #fdecd3; }
.cashflow-table tr.cf-group.purchases td { background: #fef2f2; }
.cashflow-table tr.cf-group.purchases td:first-child { color: #b91c1c; background: #fde2e2; }
.cashflow-table tr.cf-group.fixed td { background: #f5f3ff; }
.cashflow-table tr.cf-group.fixed td:first-child { color: #6d28d9; background: #ede9fe; }
.cashflow-table tr.cf-group.salaries td { background: #eff6ff; }
.cashflow-table tr.cf-group.salaries td:first-child { color: #1d4ed8; background: #dbeafe; }
.cashflow-table .cf-sub td { color: var(--ink-soft); font-size: 13px; }
.cashflow-table .cf-sub td:first-child { padding-left: 22px; }
.cashflow-table .cf-sub:hover td { background: #fafcfd; }
.cashflow-table tfoot .cf-net td { font-weight: 800; font-size: 15px; background: var(--surface-2); color: var(--ink); border-top: 2px solid var(--brand); }
.cashflow-table tfoot .cf-net td:first-child { background: var(--surface-2); color: var(--ink); }
/* Profit green / loss red — high specificity so the footer colour never wins. */
.cashflow-table td.cf-pos, .cashflow-table tfoot .cf-net td.cf-pos { color: #15803d !important; }
.cashflow-table td.cf-neg, .cashflow-table tfoot .cf-net td.cf-neg { color: #dc2626 !important; }

/* Cash-flow header: keep the dark band (the generic sticky-header rule above
   was washing out its background while the text stayed white). */
.tablecard .table-scroll .cashflow-table thead th,
.cashflow-table thead th {
    background: var(--brand) !important;
    color: #fff !important;
    box-shadow: none;
}

/* Advanced filter bar (invoices etc.) */
.filter-bar { padding: 14px 16px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filter-grid label { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.filter-grid input, .filter-grid select { min-height: 38px; }

/* Ledger polish */
.ledger-filter label { align-self: center; font-size: 13px; color: var(--ink-soft); }
.ledger-table tfoot .lt-total td { border-top: 2px solid var(--line); background: var(--wash, #f4f6f8); font-weight: 700; }
.ledger-table tfoot .lt-net td { background: #0f2a30; color: #fff; font-weight: 800; }
.ledger-table tfoot .lt-net .ledger-net { color: #fff; }
.ledger-table td.debit { color: #b3391f; }
.ledger-table td.credit { color: #18794e; }
.ledger-table tbody tr:hover td { background: #fafcfd; }

.chip-type.t-asset { background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.chip-type.t-inventory { background:#ecfdf5; color:#047857; border-color:#c9efdd; }

/* ============================================================
   Professional table overhaul (all Accounts + Assets tables)
   ============================================================ */

/* Sticky headers inside any scrollable table card */
.tablecard .table-scroll thead th,
.table-scroll.scroll-10 thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    box-shadow: inset 0 -1px 0 var(--line);
}

/* Denser, cleaner cells + zebra striping */
.tablecard th { padding: 11px 14px; font-weight: 700; letter-spacing: 0.04em; }
.tablecard td { padding: 11px 14px; font-size: 13.5px; }
.tablecard tbody tr:nth-child(even) { background: #fbfcfd; }
.tablecard tbody tr:hover { background: #f2f7f8; }
.tablecard tbody tr.row-link:hover { background: #edf5f6; }
.tablecard tbody td { border-bottom: 1px solid #e9eef2; }
.tablecard tbody tr:last-child td { border-bottom: 0; }

.nowrap { white-space: nowrap; }
.cell-wrap { min-width: 160px; }

/* Toolbar refinements: count badge + quick filter */
.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 20px; padding: 0 7px; margin-left: 6px;
    border-radius: 999px; background: var(--brand-2); color: #fff;
    font-size: 11px; font-weight: 700; vertical-align: 1px;
}
.toolbar-tools { display: flex; gap: 8px; align-items: center; }
.table-filter {
    min-height: 34px; min-width: 170px; max-width: 220px;
    padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; font-size: 13px; background: #fff;
}
.table-filter:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29,104,116,.12); outline: none; }

/* Zero / negative quantity flag */
.qty-zero {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    background: #fbe6e3; color: var(--red); font-weight: 700;
}

/* Movement chips */
.chip-move {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
    background: #eef2f5; color: var(--ink-soft); border: 1px solid #dbe3e8;
}
.chip-move.mv-in { background: #e3f3ec; color: #15803d; border-color: #c9efdd; }
.chip-move.mv-out { background: #fbe6e3; color: #b91c1c; border-color: #f5cbc5; }
.chip-move.mv-adjust { background: #e4eef6; color: #25618f; border-color: #cfe0ef; }
.chip-move.mv-consume { background: #fff7ed; color: #c2410c; border-color: #fde3cf; }

/* Sortable column headers (wired up by tables.js) */
table.sortable th[data-sortable],
.tablecard th[data-sortable] {
    cursor: pointer; user-select: none; transition: color .12s;
}
th[data-sortable]:hover { color: var(--brand); }
th[data-sortable]::after {
    content: "↕"; margin-left: 6px; font-size: 10px; opacity: .35;
}
th[data-sortable].sort-asc::after { content: "↑"; opacity: 1; color: var(--brand-2); }
th[data-sortable].sort-desc::after { content: "↓"; opacity: 1; color: var(--brand-2); }

/* Keep filter usable on small screens */
@media (max-width: 640px) {
    .toolbar-tools { width: 100%; }
    .table-filter { flex: 1; max-width: none; }
}

/* Stacked dashboard sections (asset table above, movements below) */
.stack-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }

/* Locations & Box IDs cards */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 640px) { .loc-grid { grid-template-columns: 1fr; } }
.loc-card .list-toolbar { align-items: center; }
.loc-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.loc-title strong { display: block; font-size: 15px; }
.loc-title small { display: block; margin-top: 1px; font-weight: 600; }
.loc-ico {
    width: 34px; height: 34px; padding: 8px; flex: 0 0 auto;
    border-radius: 9px; background: #e4eef6; color: #25618f;
}
.box-ico { width: 14px; height: 14px; margin-right: 7px; color: var(--brand-2); vertical-align: -2px; }
.loc-notes { padding: 10px 16px 0; margin: 0; font-size: 12.5px; }

/* BoQ detail table */
.boq-detail tfoot td { border-top: 2px solid var(--line); background: var(--surface-2); padding: 12px 14px; }
.boq-card .list-toolbar .muted { font-size: 12.5px; font-weight: 600; }

/* Asset parameters */
.param-table .li-head, .param-table .li-row { grid-template-columns: 1fr 1fr 44px; }

/* Register hover popover — the "?" badge. The pop is position:fixed and
   placed by tables.js so it is never clipped by the table's scroll box. */
.param-badge {
    display: inline-grid; place-items: center;
    width: 20px; height: 20px; margin-left: 7px; border-radius: 50%;
    background: #e4eef6; color: #25618f; border: 1px solid #cfe0ef;
    font-size: 12px; font-weight: 800; line-height: 1;
    cursor: help; vertical-align: -4px;
}
.param-badge:hover, .param-badge:focus { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.param-pop {
    display: none; position: fixed; z-index: 90;
    min-width: 240px; max-width: 320px; padding: 12px 14px; border-radius: 10px;
    background: #fff; border: 1px solid var(--line);
    box-shadow: 0 14px 34px rgba(21, 44, 55, 0.22);
    font-size: 12.5px; font-weight: 500; color: var(--ink-soft);
    white-space: normal; text-align: left; cursor: default;
}
.param-badge:hover .param-pop, .param-badge:focus .param-pop, .param-pop.pop-open { display: block; }
.param-pop .pp-title {
    display: block; margin-bottom: 8px; padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
    color: var(--brand); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.param-pop .pp-row { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; }
.param-pop .pp-row b { color: var(--ink-soft); font-weight: 650; }
.param-pop .pp-row i { font-style: normal; color: var(--ink); font-weight: 600; }

/* Asset classes list on the Asset Type page */
.class-list { display: grid; gap: 8px; }
.class-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2);
}
.class-row:hover { border-color: #9fc4ca; }
.class-info { min-width: 0; }
.class-info strong { display: block; font-size: 14px; color: var(--ink); }
.class-info small { display: block; margin-top: 2px; font-weight: 600; overflow-wrap: anywhere; }

/* HR: leave calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-head-row { margin-bottom: 8px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 0; }
.cal-dow.wknd { color: #c3aa88; }
.cal-cell {
    min-height: 88px; padding: 8px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.cal-out { opacity: .38; background: var(--surface-2); }
.cal-today { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(29,104,116,.15); }
.cal-multi { background: #fff9f0; border-color: #ecd9a6; }
.cal-date { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.cal-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--amber); color: #fff; font-size: 11px; }
.cal-leave {
    display: block; padding: 2px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 650; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: #64748b;
}
.cal-leave.lv-casual { background: #3b82f6; }
.cal-leave.lv-sick { background: #ef4444; }
.cal-leave.lv-annual { background: #8b5cf6; }
.cal-leave.lv-comp_off { background: #10b981; }
@media (max-width: 860px) { .cal-cell { min-height: 60px; } .cal-leave { font-size: 10px; } }

/* HR: attendance card */
.att-card { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; }
.att-status p { margin: 8px 0 0; color: var(--ink-soft); }
.att-card .helptext { flex-basis: 100%; margin: 0; }
.att-modes { display: flex; flex-wrap: wrap; gap: 14px; }
.approve-form { display: inline-flex; gap: 6px; align-items: center; }

/* Detail page parameter chips */
.param-strip { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.param-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.param-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border-radius: 999px;
    background: var(--surface-2); border: 1px solid var(--line);
    font-size: 12.5px; font-weight: 600; color: var(--ink);
}
.param-chip b { color: var(--brand-2); font-weight: 700; }

/* ---- Polished tables (.pretty) + export panel + button variants ---- */
table.pretty { border-collapse: separate; border-spacing: 0; width: 100%; }
table.pretty thead th {
    background: var(--surface-2);
    color: var(--ink-soft, #425466);
    font-size: 12px; letter-spacing: .02em; text-transform: uppercase;
    font-weight: 700; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 1;
}
table.pretty tbody td { border-bottom: 1px solid var(--line); }
table.pretty tbody tr:nth-child(even) td { background: rgba(18, 52, 59, 0.025); }
table.pretty tbody tr:hover td { background: rgba(29, 104, 116, 0.08); }
table.pretty tbody tr.row-link { cursor: pointer; }

.export-card { padding: 14px 16px; margin-bottom: 16px; }
.export-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.export-row .export-lbl { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--brand, #12343b); }
.export-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft, #425466); }
.export-row select, .export-row input[type=date] { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); }

.button.danger { background: var(--red); border-color: var(--red); color: #fff; }
.button.warn { background: var(--amber, #f59e0b); border-color: var(--amber, #f59e0b); color: #fff; }
.chip-move { display:inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip-move.mv-out, .chip-move.mv-consume { background: #fde8e8; color: #b42318; }
