/* Invoice Claude — application theme (on top of Tabler). Design "B": dark side panel. */
:root {
    --app-accent: #3b5bdb;
    --app-accent-600: #2f4ab8;
    --app-accent-50: #eef2ff;
    --app-bg: #f4f5f8;
    --app-surface: #ffffff;
    --app-border: #e5e7eb;
    --app-border-soft: #f0f1f4;
    --app-text: #111827;
    --app-muted: #6b7280;
    --app-sidebar: #111827;
    --app-sidebar-active: #1f2a3d;
    --app-sidebar-text: #c9ced8;
    --app-sidebar-muted: #8d95a5;
    --app-sidebar-w: 248px;
    --app-radius: 12px;
    --tone-neutral: #9ca3af; --tone-neutral-text: #4b5563;
    --tone-blue: #3b5bdb;    --tone-blue-text: #1e40af;
    --tone-green: #16a34a;   --tone-green-text: #166534;
    --tone-amber: #f59e0b;   --tone-amber-text: #92400e;
    --tone-red: #e53935;     --tone-red-text: #b91c1c;
    --bs-primary: var(--app-accent);
    --bs-primary-rgb: 59, 91, 219;
    --bs-link-color: var(--app-accent);
    --bs-link-color-rgb: 59, 91, 219;
    --bs-link-hover-color: var(--app-accent-600);
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);
    --bs-font-sans-serif: "Inter", "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --tblr-primary: var(--app-accent);
    --tblr-primary-rgb: 59, 91, 219;
    --tblr-body-bg: var(--app-bg);
    --tblr-font-sans-serif: var(--bs-font-sans-serif);
}

body { background: var(--app-bg); color: var(--app-text); font-family: var(--bs-font-sans-serif); font-size: .9375rem; }
a { text-decoration: none; }

.btn { border-radius: 8px; font-weight: 500; }
.btn-primary {
    --bs-btn-bg: var(--app-accent); --bs-btn-border-color: var(--app-accent);
    --bs-btn-hover-bg: var(--app-accent-600); --bs-btn-hover-border-color: var(--app-accent-600);
    --bs-btn-active-bg: var(--app-accent-600); --bs-btn-active-border-color: var(--app-accent-600);
    --bs-btn-disabled-bg: var(--app-accent); --bs-btn-disabled-border-color: var(--app-accent);
    --tblr-btn-bg: var(--app-accent); --tblr-btn-hover-bg: var(--app-accent-600);
    font-weight: 600;
}
.btn-outline-primary {
    --bs-btn-color: var(--app-accent); --bs-btn-border-color: #c7d2fe;
    --bs-btn-hover-bg: var(--app-accent-50); --bs-btn-hover-color: var(--app-accent-600); --bs-btn-hover-border-color: #a5b4fc;
    --bs-btn-active-bg: var(--app-accent-50); --bs-btn-active-color: var(--app-accent-600);
}
.btn-outline-secondary {
    --bs-btn-color: var(--app-text); --bs-btn-border-color: #d1d5db; --bs-btn-bg: #fff;
    --bs-btn-hover-bg: #f9fafb; --bs-btn-hover-color: var(--app-text); --bs-btn-hover-border-color: #d1d5db;
    --bs-btn-active-bg: #f3f4f6; --bs-btn-active-color: var(--app-text);
}
.text-bg-primary { background-color: var(--app-accent) !important; }
.form-control, .form-select { border-radius: 8px; border-color: #d1d5db; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(59, 91, 219, .15);
}
.form-check-input:checked { background-color: var(--app-accent); border-color: var(--app-accent); }
:focus-visible { outline: 3px solid rgba(59, 91, 219, .45); outline-offset: 2px; }
.skip-link { position: absolute; left: 1rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .375rem; }

/* ---- Shell -------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--app-sidebar-w); flex: 0 0 var(--app-sidebar-w);
    background: var(--app-sidebar); color: var(--app-sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 1.25rem .875rem;
}
.app-brand { display: flex; align-items: center; gap: .65rem; padding: 0 .5rem 1.25rem; }
.app-brand-text { min-width: 0; line-height: 1.25; }
.app-brand-sub { color: var(--app-sidebar-muted); }
.app-brand-mark {
    width: 34px; height: 34px; border-radius: 9px; background: var(--app-accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 34px;
}
.auth-brand .app-brand-mark { width: 44px; height: 44px; font-size: 1.25rem; display: flex; margin: 0 auto; }
.app-brand-logo { display: block; max-height: 34px; max-width: 120px; object-fit: contain; flex: none; border-radius: 6px; }
.auth-brand .app-brand-logo { max-height: 56px; max-width: 200px; margin: 0 auto; }
.logo-preview { width: 180px; height: 90px; flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.app-nav { display: flex; flex-direction: column; gap: 2px; }
.app-nav-section { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--app-sidebar-muted); padding: .9rem .65rem .35rem; font-weight: 600; }
.app-nav-section:first-child { padding-top: .25rem; }
.app-nav-link {
    display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: 8px;
    color: var(--app-sidebar-text); font-size: .9rem;
}
.app-nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.app-nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.app-nav-link.active { background: var(--app-sidebar-active); color: #fff; font-weight: 600; }
.app-nav-bottom { margin-top: auto; padding-top: 1rem; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.75rem 0 3rem; outline: none; }
.app-content > .container-xl { padding-inline: 2rem; max-width: 1360px; }
.app-topbar {
    height: 60px; display: flex; align-items: center; gap: .75rem; padding: 0 2rem; background: var(--app-surface);
    border-bottom: 1px solid var(--app-border); position: sticky; top: 0; z-index: 1020;
}
.app-topbar-title { font-weight: 600; }
.app-topbar-end { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.lang-switch { gap: 2px; background: var(--app-bg); border-radius: 8px; padding: 3px; }
.lang-switch a { padding: .2rem .55rem; border-radius: 6px; font-size: .8rem; font-weight: 600; color: var(--app-muted); }
.lang-switch a.active { background: #fff; color: var(--app-text); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; padding: .25rem .4rem; border-radius: 8px; color: var(--app-text); max-width: 260px; font-size: .9rem; }
.btn-user:hover { background: var(--app-bg); }
.avatar-circle {
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: #e0e7ff; color: var(--app-accent);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem;
}
.btn-icon { border: 0; background: transparent; width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: inherit; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: 0; top: 0; z-index: 1045; transform: translateX(-100%); transition: transform .2s ease; }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 1040; }
    .app-topbar { padding: 0 .5rem 0 .25rem; background: var(--app-sidebar); color: #fff; border-bottom: 0; }
    .app-topbar .btn-user { color: #fff; }
    .app-topbar .btn-user:hover { background: var(--app-sidebar-active); }
    .app-topbar .lang-switch { background: var(--app-sidebar-active); }
    .app-topbar .lang-switch a { color: var(--app-sidebar-text); }
    .app-topbar .lang-switch a.active { background: #fff; color: var(--app-text); }
    .app-content { padding-top: 1.25rem; }
    .app-content > .container-xl { padding-inline: 1rem; }
}

/* ---- Page elements -------------------------------------------------------- */
.page-head { margin-bottom: 1.5rem !important; }
.page-pretitle { font-size: .8125rem; color: var(--app-muted); margin-bottom: .2rem; }
.page-pretitle a { color: var(--app-muted); }
.page-pretitle a:hover { color: var(--app-text); }
.page-title { font-weight: 700; letter-spacing: -.01em; font-size: 1.625rem; }
.card { border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); padding: .9rem 1.25rem; flex-wrap: wrap; gap: .25rem 1rem; }
.card-title { font-weight: 600; font-size: 1rem; margin-bottom: 0; }
.card-body { padding: 1.25rem; }
.card-footer { background: #fafbfc; border-top: 1px solid var(--app-border); padding: .9rem 1.25rem; flex-wrap: wrap; gap: .75rem; }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .3rem; }
.form-text { font-size: .8rem; color: var(--app-muted); }
.req::after { content: " *"; color: #b42318; }
.text-money, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.alert { border-radius: 10px; }

/* Tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .8rem 1.25rem; border-bottom-color: var(--app-border-soft); }
.table thead th { font-size: .8125rem; color: var(--app-muted); font-weight: 500; background: transparent; border-bottom: 1px solid var(--app-border); white-space: nowrap; text-transform: none; letter-spacing: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f9fafb; }
.table-hover tbody tr[data-href] { cursor: pointer; }

/* Status: coloured dot + text */
.state { display: inline-flex; align-items: center; gap: .45rem; font-size: .875rem; font-weight: 500; white-space: nowrap; color: var(--tone-neutral-text); }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone-neutral); flex: 0 0 8px; }
.state-blue { color: var(--tone-blue-text); } .state-blue .state-dot { background: var(--tone-blue); }
.state-green { color: var(--tone-green-text); } .state-green .state-dot { background: var(--tone-green); }
.state-amber { color: var(--tone-amber-text); } .state-amber .state-dot { background: var(--tone-amber); }
.state-red { color: var(--tone-red-text); } .state-red .state-dot { background: var(--tone-red); }
.state-note { display: block; font-size: .8125rem; color: var(--app-muted); font-weight: 400; margin-top: 1px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 .5rem; border-radius: 6px; background: #f3f4f6; color: #374151; font-size: .75rem; font-weight: 600; }
.tag-amber { background: #fef3c7; color: #92400e; }

/* Avatar (initials) for customers */
.avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .75rem; }
.avatar-0 { background: #fef3c7; color: #92400e; } .avatar-1 { background: #dbeafe; color: #1e40af; }
.avatar-2 { background: #e0e7ff; color: #3730a3; } .avatar-3 { background: #dcfce7; color: #166534; }
.avatar-4 { background: #fce7f3; color: #9d174d; } .avatar-5 { background: #e0f2fe; color: #075985; }
.cell-customer { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.cell-customer .name { font-weight: 600; color: var(--app-text); }
.cell-customer .sub { display: block; font-size: .8125rem; color: var(--app-muted); }

/* KPI strip */
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fff; border: 1px solid var(--app-border); border-radius: var(--app-radius); margin-bottom: 1.25rem; }
.kpi-strip .kpi { padding: 1.1rem 1.4rem; border-right: 1px solid var(--app-border); }
.kpi-strip .kpi:last-child { border-right: 0; }
.kpi-label { font-size: .8125rem; color: var(--app-muted); }
.kpi-value { font-size: 1.375rem; font-weight: 700; letter-spacing: -.01em; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--app-muted); }
.kpi-danger .kpi-value { color: var(--tone-red-text); }

/* Tabs on top of a list card */
.list-tabs { display: flex; gap: 1.5rem; padding: 0 1.25rem; border-bottom: 1px solid var(--app-border); overflow-x: auto; scrollbar-width: none; }
.list-tabs::-webkit-scrollbar { display: none; }
.list-tab { border: 0; background: transparent; padding: .9rem 0; color: var(--app-muted); font-weight: 500; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.list-tab:hover { color: var(--app-text); }
.page-tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--app-border); overflow-x: auto; scrollbar-width: none; }
.page-tabs::-webkit-scrollbar { display: none; }
.list-tab[aria-current="page"], .list-tab[aria-selected="true"] { color: var(--app-text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--app-accent); }
.list-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--app-border); }
.list-toolbar .search { position: relative; flex: 1 1 260px; max-width: 360px; }
.list-toolbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--app-muted); }
.list-toolbar .search input { padding-left: 2.2rem; background: var(--app-bg); border-color: transparent; }
.list-toolbar .search input:focus { background: #fff; }
.list-toolbar .period { display: flex; gap: .5rem; align-items: center; }
.list-toolbar .period input { width: 150px; }

/* Mobile summary header (invoice list) */
.list-hero { display: none; }
@media (max-width: 991.98px) {
    .kpi-strip { display: none; }
    .list-hero { display: block; background: var(--app-sidebar); color: #fff; border-radius: var(--app-radius); padding: 1.1rem 1.1rem 1rem; margin-bottom: 1rem; }
    .list-hero .label { font-size: .8125rem; color: #a3abba; }
    .list-hero .value { font-size: 1.875rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
    .list-hero .sub { font-size: .8125rem; color: #fca5a5; }
    .page-head .btn-head-primary { display: none !important; }
}

/* Page actions: wrap on phones, main action full width */
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 575.98px) {
    .page-head { flex-direction: column; align-items: stretch !important; }
    .page-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); width: 100%; }
    .page-actions > .dropdown > .btn { width: 100%; height: 100%; }
    .page-actions .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* Document detail (invoice / credit note) */
.doc-head { margin-bottom: 1.25rem; }
.doc-head-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title actions" "states actions"; align-items: center; gap: .6rem 1rem; }
.doc-head-row .page-title { grid-area: title; }
.doc-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.doc-states { grid-area: states; display: flex; flex-wrap: wrap; gap: .4rem; }
/* Status pills (document header, list rows) */
:is(.doc-states, .pills, table.dt-rows td.c-status) .state { padding: .2rem .65rem; border-radius: 999px; background: #f2f4f7; font-size: .8125rem; font-weight: 600; }
:is(.pills, table.dt-rows td.c-status) .state { padding: .1rem .55rem; font-size: .75rem; }
:is(.pills, table.dt-rows td.c-status) .state .state-dot { display: none; }
:is(.doc-states, .pills, table.dt-rows td.c-status) .state-red { background: #fef3f2; } :is(.doc-states, .pills, table.dt-rows td.c-status) .state-green { background: #ecfdf3; }
:is(.doc-states, .pills, table.dt-rows td.c-status) .state-blue { background: #eef2ff; } :is(.doc-states, .pills, table.dt-rows td.c-status) .state-amber { background: #fffaeb; }
.doc-card .card-body { padding: 1.25rem; }
.doc-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); }
.doc-bill { background: #f6f8fc; border-radius: .625rem; padding: .85rem 1rem; }
.doc-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .85rem 1rem; margin: 1rem 0 .5rem; }
.doc-facts > div > div:last-child { font-weight: 600; margin-top: 1px; }
.doc-facts .doc-facts-wide { grid-column: 1 / -1; }
.doc-line { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--app-border-soft); }
.doc-line-main { min-width: 0; }
.doc-line-desc { font-size: .8125rem; color: var(--app-muted); white-space: pre-line; }
.doc-line-meta { font-size: .8125rem; color: var(--app-muted); margin-top: .15rem; }
.doc-line-meta .sep { margin: 0 .2rem; }
.doc-line-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-sum { border-top: 1px solid var(--app-border); padding-top: .5rem; margin-left: auto; max-width: 420px; font-variant-numeric: tabular-nums; }
.doc-sum-row { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.doc-sum-row.muted { color: var(--app-muted); font-size: .8125rem; }
.doc-sum-total { display: flex; justify-content: space-between; background: var(--app-accent); color: #fff; border-radius: .5rem; padding: .55rem .8rem; font-weight: 700; margin-top: .5rem; }
@media (max-width: 575.98px) {
    .doc-head-row { grid-template-columns: 1fr; grid-template-areas: "title" "states" "actions"; }
    .doc-actions { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); width: 100%; }
    .doc-actions .doc-action-main { grid-column: 1 / -1; }
    .doc-actions .btn, .doc-actions .dropdown > .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; width: 100%; white-space: nowrap; padding-left: .25rem; padding-right: .25rem; }
    .doc-sum { max-width: none; }
}

/* Empty states */
.empty-state { text-align: center; padding: 3.5rem 1rem; }
.empty-state .empty-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--app-accent-50); color: var(--app-accent);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; margin-bottom: 1rem; }

/* ---- Invoice editor --------------------------------------------------------------- */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.totals-panel { position: sticky; top: 1rem; }
.totals-panel .row-line { display: flex; justify-content: space-between; padding: .3rem 0; font-variant-numeric: tabular-nums; }
.totals-panel .grand { border-top: 2px solid var(--app-text); margin-top: .4rem; padding-top: .6rem; font-size: 1.25rem; font-weight: 700; }
.lines-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }
.tool-group { display: flex; align-items: center; gap: .6rem; }
.tool-label { font-size: .8125rem; color: var(--app-muted); font-weight: 500; }
@media (max-width: 575.98px) {
    .lines-toolbar { flex-direction: column; align-items: stretch; }
    .tool-group { flex-direction: column; align-items: stretch; gap: .35rem; }
    .tool-group .qty-mode { display: flex; }
    .tool-group .qty-mode-opt { flex: 1; text-align: center; padding: .45rem .5rem; }
}
/* Quantity label: segmented control */
.pay-seg { display: flex; background: #eef1f6; border-radius: .6rem; padding: 3px; gap: 2px; }
.pay-seg-opt { flex: 1; border: 0; background: transparent; border-radius: .45rem; padding: .5rem .25rem; font-size: .875rem; color: #475467; }
.pay-seg-opt:hover:not(:disabled) { color: var(--app-text); }
.pay-seg-opt:disabled:not(.is-active) { opacity: .45; }
.pay-seg-opt.is-active { background: #fff; color: var(--app-text); font-weight: 700; box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.pay-seg-opt.is-active[value="paid"] { color: #067647; }
.pay-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; border-top: 1px solid var(--app-border-soft); font-size: .9rem; }
.qty-mode { display: inline-flex; background: #eef1f6; border-radius: .5rem; padding: 3px; gap: 2px; }
.qty-mode-opt { padding: .3rem .8rem; border-radius: .375rem; font-size: .8125rem; color: #475467; cursor: pointer; white-space: nowrap; margin: 0; }
.qty-mode .btn-check:checked + .qty-mode-opt { background: #fff; color: var(--app-text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.qty-mode .btn-check:focus-visible + .qty-mode-opt { outline: 2px solid var(--app-accent); }
/* Lines as cards */
.lines-list { display: flex; flex-direction: column; gap: .75rem; }
.line-row { background: #f6f8fc; border: 1px solid #dfe5ef; border-radius: .75rem; padding: .6rem .75rem .75rem; }
.line-row.is-new { animation: flash-row 1.2s ease; }
.line-head { display: flex; align-items: center; gap: .375rem; margin-bottom: .5rem; }
.line-num { font-size: .75rem; font-weight: 700; color: var(--app-accent); background: var(--app-accent-50); border-radius: .375rem; padding: .15rem .45rem; min-width: 1.6rem; text-align: center; }
.btn-line { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d0d5dd; border-radius: .5rem; background: #fff; color: #475467; padding: 0; font-size: .85rem; }
.btn-line:hover { color: var(--app-text); border-color: #98a2b3; }
.btn-line-del { color: #d92d20; border-color: #f3c5c0; }
.btn-line-del:hover { color: #b42318; border-color: #e7a59f; background: #fef3f2; }
.line-total { margin-left: auto; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line-body { display: grid; gap: .5rem; }
.line-row .line-title { font-weight: 600; }
.line-row .line-desc { margin-top: .375rem; font-size: .8125rem; color: var(--app-muted); min-height: 34px; resize: vertical; }
.lc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.lc-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); margin-bottom: .2rem; }
.qty-stepper { display: flex; }
.qty-stepper .num-input { flex: 1 1 auto; width: auto; min-width: 0; padding-left: .25rem; padding-right: .25rem; text-align: center; border-radius: 0; }
.qty-step { flex: 0 0 30px; border: 1px solid var(--tblr-border-color, #d0d5dd); background: #fff; color: #475467; display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: .8rem; }
.qty-step:hover { background: #f2f4f7; color: var(--app-text); }
.qty-step[data-step="-1"] { border-right: 0; border-radius: .5rem 0 0 .5rem; }
.qty-step[data-step="1"] { border-left: 0; border-radius: 0 .5rem .5rem 0; }
.lc-fields .form-select { padding-right: 1.6rem; background-position: right .45rem center; }
.btn-add-line { display: block; width: 100%; margin-top: .75rem; border: 1.5px dashed #9aa4ff; color: var(--app-accent); background: #f7f8ff; border-radius: .625rem; padding: .6rem; font-weight: 600; }
.btn-add-line:hover { background: var(--app-accent-50); }
@media (min-width: 992px) {
    /* Desktop: item on the left, quantity / rate / VAT next to it */
    .line-body { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; gap: .75rem; }
}
.doc-foot { border-top: 1px solid var(--app-border); padding-top: .5rem; }
.doc-totals .row-line { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .4rem 0; font-variant-numeric: tabular-nums; }
.doc-totals .row-line + .row-line { border-top: 1px solid var(--app-border); }
.doc-totals .discount-input { max-width: 170px; margin-left: auto; }
.doc-totals .discount-input .form-select { flex: 0 0 64px; max-width: 64px; padding-right: 1.6rem; background-position: right .4rem center; }
.doc-totals .discount-line > span { min-width: 90px; text-align: right; }
.doc-totals #t-taxes .row-line { border-top: 0; font-size: .875rem; }
.doc-totals .grand { border-top: 2px solid var(--app-text) !important; font-size: 1.15rem; font-weight: 700; }
@keyframes flash-row { from { background: var(--app-accent-50); } to { background: transparent; } }
.num-input { text-align: right; font-variant-numeric: tabular-nums; }
.autocomplete { position: relative; }
.autocomplete-menu {
    position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px); background: #fff;
    border: 1px solid var(--app-border); border-radius: .5rem; box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    max-height: 280px; overflow-y: auto; padding: .25rem;
}
.autocomplete-item { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border: 0; background: transparent; border-radius: .375rem; }
.autocomplete-item:hover, .autocomplete-item[aria-selected="true"] { background: var(--app-accent-50); }
.autocomplete-item small { color: var(--app-muted); }
.save-indicator { font-size: .8rem; color: var(--app-muted); }

@media (max-width: 1599.98px) {
    .editor-grid { grid-template-columns: 1fr; }
    .totals-panel { position: static; }
    .totals-panel .card { max-width: 440px; margin-left: auto; }
}
/* Document detail */

/* Auth */
.auth-body { background: #111827; min-height: 100vh; }
.onboarding-body { background: var(--app-bg); min-height: 100vh; }
.brand-chip { display: inline-flex; align-items: center; background: #111827; border-radius: 10px; padding: .4rem .6rem; }
.auth-tagline { color: #9ca3af; font-size: .9rem; }
.auth-foot { color: #6b7280; }
.auth-link { color: #9ca3af; text-decoration: none; } .auth-link:hover { color: #fff; }
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 3.5rem 1rem 2rem; }
.auth-card { border-radius: 1rem; }

/* Onboarding */
.stepper { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stepper .step { display: flex; align-items: center; gap: .45rem; font-size: .875rem; color: var(--app-muted); }
.stepper .step-num { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--app-border); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; background: #fff; }
.stepper .step.done .step-num { background: var(--app-accent); border-color: var(--app-accent); color: #fff; }
.stepper .step.current { color: var(--app-text); font-weight: 600; }
.stepper .step.current .step-num { border-color: var(--app-accent); color: var(--app-accent); }
.stepper .sep { flex: 0 0 24px; height: 2px; background: var(--app-border); align-self: center; }

/* ---- DataTables -------------------------------------------------------------- */
div.dt-container { font-size: .9375rem; }
div.dt-container > .row { margin: 0 !important; }
div.dt-container > .row > * { padding: 0; }
div.dt-container > .row:not(.dt-layout-table) { padding: .75rem 1.25rem; border-top: 1px solid var(--app-border-soft); display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; }
div.dt-container > .row:not(.dt-layout-table) > * { display: flex !important; align-items: center; width: auto; flex: 0 0 auto; margin: 0 !important; }
div.dt-container .dt-info { color: var(--app-muted); font-size: .8125rem; padding: 0 !important; }
div.dt-container .dt-paging { display: flex; }
div.dt-container .dt-paging .pagination { margin: 0; gap: .5rem; }
div.dt-container .dt-paging .page-link { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d1d5db; border-radius: 8px !important; color: var(--app-text); background: #fff; }
div.dt-container .dt-paging .page-item.disabled .page-link { color: #c0c5cd; }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--app-accent); border-color: var(--app-accent); color: #fff; }
div.dt-container .dt-processing { box-shadow: none; border: 1px solid var(--app-border); border-radius: 8px; }
table.dataTable { margin: 0 !important; border-collapse: collapse !important; }
table.dataTable > tbody > tr { cursor: pointer; }
table.dataTable > tbody > tr:hover > * { background: #f9fafb; }
table.dataTable td.dt-type-numeric, table.dataTable th.dt-type-numeric { text-align: right; }
table.dataTable > thead > tr > th, table.dataTable > thead > tr > td { border-bottom: 1px solid var(--app-border) !important; }
table.dataTable td.col-number { white-space: nowrap; font-weight: 500; }
.dt-empty { padding: 2.5rem 1rem !important; color: var(--app-muted); }

/* Phones: list rows become compact two-line items (generic: label/value pairs) */
@media (max-width: 767.98px) {
    table.dt-cards thead { display: none; }
    table.dt-cards, table.dt-cards tbody, table.dt-cards tr, table.dt-cards td { display: block; width: 100% !important; }
    table.dt-cards tr { padding: .75rem 1rem; border-bottom: 1px solid var(--app-border-soft); }
    table.dt-cards td { padding: .1rem 0 !important; border: 0 !important; display: flex; justify-content: space-between; gap: 1rem; text-align: right !important; }
    table.dt-cards td::before { content: attr(data-label); color: var(--app-muted); font-size: .8125rem; text-align: left; }
    table.dt-cards td:first-child { display: block; text-align: left !important; font-weight: 600; font-size: 1rem; margin-bottom: .35rem; }
    table.dt-cards td:first-child::before { content: none; }
    table.dt-cards td.dt-empty { display: block; text-align: center !important; }
    table.dt-cards td.dt-empty::before { content: none; }

    /* Invoice rows: avatar · customer / number · date ........ amount / status */
    table.dt-rows tr { display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "av name amount" "av meta status"; column-gap: .75rem; row-gap: 2px; align-items: center; }
    table.dt-rows td::before { content: none !important; }
    table.dt-rows td { display: block !important; text-align: left !important; }
    table.dt-rows td.c-customer { display: contents !important; }
    table.dt-rows td.c-customer .avatar { grid-area: av; width: 40px; height: 40px; }
    table.dt-rows td.c-customer .name { grid-area: name; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    table.dt-rows td.c-customer .sub { grid-area: meta; }
    table.dt-rows td.c-customer .cell-customer { display: contents; }
    table.dt-rows td.c-customer .cell-customer > span:not(.avatar) { display: contents; }
    table.dt-rows td.c-number, table.dt-rows td.c-date, table.dt-rows td.c-balance, table.dt-rows td.c-hide-sm { display: none !important; }
    table.dt-rows td.c-total { grid-area: amount; text-align: right !important; font-weight: 600; }
    table.dt-rows td.c-status { grid-area: status; text-align: right !important; }
    table.dt-rows td.c-status .state { font-size: .8125rem; }
    table.dt-rows td.c-status .state-note { display: none; }
}

@media print {
    .app-sidebar, .app-topbar, .btn { display: none !important; }
}
table.dataTable > tbody > tr > td { vertical-align: middle; }
table.dataTable > tbody > tr > td.sorting_1, table.dataTable > tbody > tr > td.dt-ordering-asc, table.dataTable > tbody > tr > td.dt-ordering-desc { box-shadow: none !important; }

/* ---- Dashboard, customers, reports (design A) -------------------------------------- */
.page-head-stack { margin-bottom: 1rem; }
.text-accent { color: var(--app-accent) !important; }
.period-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.seg { display: inline-flex; background: #e9edf3; border-radius: .6rem; padding: 3px; gap: 2px; }
.seg-opt { padding: .38rem .95rem; border-radius: .45rem; font-size: .875rem; color: #475467; text-decoration: none; white-space: nowrap; }
.seg-opt:hover { color: var(--app-text); }
.seg-opt[aria-current="page"] { background: #fff; color: var(--app-text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.period-step { display: inline-flex; align-items: center; gap: .25rem; }
.period-step .btn-icon { width: 36px; height: 36px; font-size: 1rem; color: var(--app-muted); }
.period-label { font-weight: 600; min-width: 8.5rem; text-align: center; }
.kpi-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.kpi-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 640px; }
.kpi-tile .kpi-value.kpi-value-text { font-size: 1.05rem; overflow-wrap: normal; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--app-border); border-radius: var(--app-radius); }
.switch-row .form-check-input { width: 2.6em; height: 1.4em; margin: 0; flex: none; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.kpi-tile { background: #fff; border: 1px solid var(--app-border); border-radius: var(--app-radius); padding: .9rem 1rem; min-width: 0; }
.kpi-tile .kpi-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.kpi-tile .kpi-value { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.kpi-tile.kpi-danger { border-color: #f6c7c2; background: #fffbfa; }
.list-rows { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 1.25rem; border-top: 1px solid var(--app-border-soft); color: inherit; text-decoration: none; }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #f9fafb; }
.list-row .cell-customer { min-width: 0; }
.list-row .cell-customer .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-end { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex: none; }
.list-row-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.report-big { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: .5rem; height: 120px; margin-top: 1rem; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: .3rem; }
.bar-col .bar { background: #dfe3ff; border-radius: .35rem .35rem .15rem .15rem; }
.bar-col .bar.on { background: var(--app-accent); }
.bar-col span { font-size: .7rem; color: var(--app-muted); text-align: center; }
.report-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--app-border-soft); }
.report-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); font-weight: 500; border-bottom-color: var(--app-border-soft); }
.report-table td { border-bottom-color: var(--app-border-soft); padding-top: .5rem; padding-bottom: .5rem; }
.aging-row { padding: .45rem 0; }
.hbar { height: 8px; border-radius: 999px; background: #eef0f3; margin-top: .35rem; overflow: hidden; }
.hbar > div { height: 100%; border-radius: 999px; }
.impersonate-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; padding: .6rem .6rem .6rem 1rem; border-radius: var(--app-radius); background: #b54708; color: #fff; font-weight: 600; font-size: .875rem; }
.avatar-lg { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 14px; font-size: 1.05rem; font-weight: 700; }
.min-w-0 { min-width: 0; } .flex-none { flex: none; }
.kpi-tile.kpi-warn { border-color: #fedf89; background: #fffcf5; } .kpi-warn .kpi-value { color: #b54708; }
.section-head { display: flex; align-items: center; gap: .75rem; }
.section-icon { width: 32px; height: 32px; flex: none; border-radius: 9px; background: #eef0ff; color: var(--app-accent); display: inline-flex; align-items: center; justify-content: center; }
.info-list { margin: 0; }
.info-row { display: flex; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--app-border-soft); font-size: .9rem; }
.info-row:first-child { border-top: 0; }
.info-row dt { width: 8rem; flex: none; font-weight: 400; color: var(--app-muted); }
.info-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.edit-grid { display: grid; gap: 1rem; grid-template-areas: "login" "company" "limits"; }
.ga-login { grid-area: login; } .ga-company { grid-area: company; } .ga-limits { grid-area: limits; }
@media (min-width: 1200px) { .edit-grid { grid-template-columns: 1.45fr 1fr; grid-template-areas: "company login" "company limits"; grid-template-rows: auto 1fr; align-items: start; } .ga-company { align-self: start; } }
.sticky-actions { position: sticky; bottom: 0; z-index: 1020; display: flex; gap: .5rem; margin: 1rem -1rem 0; padding: .75rem 1rem; background: #fff; border-top: 1px solid var(--app-border); }
.sticky-actions .btn { flex: 1; min-height: 46px; } .sticky-actions .btn-primary { flex: 2; }
.fab { position: fixed; right: 1rem; bottom: 1rem; width: 56px; height: 56px; border-radius: 18px; background: var(--app-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; box-shadow: 0 8px 20px rgba(79, 91, 213, .4); z-index: 1030; }
.fab:hover { color: #fff; filter: brightness(1.05); }
.btn-lg-touch { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
@media (max-width: 991.98px) {
    .kpi-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-tiles-3 > :first-child { grid-column: 1 / -1; }
    .kpi-tiles-fixed.kpi-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi-tiles-fixed.kpi-tiles-3 > :first-child { grid-column: auto; }
}
@media (max-width: 575.98px) {
    .period-bar { flex-direction: column; align-items: stretch; }
    .seg { display: flex; } .seg-opt { flex: 1; text-align: center; }
    .period-step { justify-content: space-between; }
    .kpi-tile .kpi-value { font-size: 1.15rem; }
    .list-row { padding: .7rem 1rem; }
    .form-actions { flex-direction: column-reverse; }
    .w-100-sm { width: 100%; }
    .kpi-tiles-fixed .kpi-tile { padding: .7rem .75rem; }
    .form-actions .btn { width: 100%; min-height: 46px; }
    .report-stats { grid-template-columns: 1fr 1fr; }
    .report-stats > :last-child { grid-column: 1 / -1; }
    .fab-spacer { height: 4.5rem; }
}
