/*
 * Invoice System UI, built from the Figma "Invoice System" frames.
 * Colors were sampled from the frames and darkened where needed to reach WCAG AA contrast:
 *   design lilac #AF91EB -> --primary #7C5CD6 (white text 4.8:1)
 *   design paid #63AF7D -> --success #2B7A41, design unpaid #EF928F -> --danger #B5382F
 */
:root {
    --navy: #0e123e;
    --bg: #f4f7fd;
    --surface: #ffffff;
    --primary: #7c5cd6;
    --primary-hover: #6a48c9;
    --primary-text: #6a48c9;
    --primary-soft: #eee8fa;
    --success: #2b7a41;
    --success-soft: #dffde3;
    --danger: #b5382f;
    --danger-on-soft: #a93630;
    --danger-soft: #ffd9d7;
    --text: #2e3137;
    --text-muted: #5b6170;
    --placeholder: #6b7180;
    --field-disabled: #eaf0f7;
    --border: #d9deea;
    --shadow: 0 1px 2px rgba(14, 18, 62, 0.06), 0 2px 8px rgba(14, 18, 62, 0.05);
    --radius: 8px;
    --radius-lg: 24px;
    --focus: 0 0 0 3px rgba(124, 92, 214, 0.45);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--navy);
    font-size: 15px;
    line-height: 1.45;

[hidden] { display: none !important; }
}

a { color: var(--primary-text); }

:focus-visible { outline: none; box-shadow: var(--focus); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute; left: 12px; top: -48px;
    background: var(--surface); color: var(--text);
    padding: 8px 14px; border-radius: var(--radius); z-index: 20;
}
.skip-link:focus { top: 12px; }

.icon {
    width: 20px; height: 20px;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
    flex: none;
}

/* Shell */

.shell {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    min-height: 100vh;
    padding: 12px 12px 12px 0;
}

.sidebar {
    color: #fff;
    padding: 28px 16px;
    display: flex; flex-direction: column; gap: 56px;
}
.sidebar { padding-top: 22vh; }

.brand {
    display: flex; align-items: center; gap: 10px;
    color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.brand-mark {
    display: grid; place-items: center;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); font-weight: 700; font-size: 16px;
}

.nav { display: flex; flex-direction: column; gap: 14px; }
.nav-link {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 20px; border-radius: var(--radius);
    color: #fff; text-decoration: none; font-size: 15px;
}
.nav-link .icon { fill: currentColor; stroke: none; }
.nav-link:hover { background: rgba(255, 255, 255, 0.08); }
.nav-link.is-active { background: var(--primary); }

.panel {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 28px 28px 32px;
    min-width: 0;
}
.panel:focus { outline: none; }

.breadcrumb ol { list-style: none; display: flex; gap: 6px; margin: 0 0 6px; padding: 0; font-size: 12px; }
.breadcrumb li + li::before { content: ">"; margin-right: 6px; color: var(--text-muted); }
.breadcrumb a { color: var(--text); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--primary-text); }

.page-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 28px;
}
.page-title { margin: 0; font-size: 34px; line-height: 1.2; font-weight: 700; color: var(--text); }
.page-actions { display: flex; align-items: center; gap: 16px; }

/* Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 8px 20px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-weight: 600; text-decoration: none;
    cursor: pointer; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:disabled { cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 10px rgba(124, 92, 214, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { background: #d5d4dd; color: #5b6170; box-shadow: none; }

.btn-outline { background: var(--surface); color: var(--primary-text); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }

.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger-on-soft); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #22663a; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: 6px; background: transparent;
    color: var(--primary-text); cursor: pointer;
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn-success { color: var(--success); }
.icon-btn-success:hover { background: var(--success-soft); }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger-soft); }

/* Inputs */

.input {
    display: block; width: 100%;
    min-height: 44px; padding: 10px 14px;
    border: 1px solid transparent; border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow);
    font: inherit; color: var(--text);
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.input:disabled, .input[readonly], .input-readonly {
    background: var(--field-disabled); box-shadow: none; color: var(--text-muted);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
textarea.input { resize: none; }

.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-icon > .input { padding-left: 44px; }

/* Combobox (searchable dropdown) */

.combobox-button {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    text-align: left; cursor: pointer;
}
.combobox-button .combobox-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-button.is-placeholder .combobox-value { color: var(--placeholder); }
.combobox-button .icon { color: var(--text-muted); transition: transform .15s; }
.combobox-button[aria-expanded="true"] { border-color: var(--primary); }
.combobox-button[aria-expanded="true"] .icon { transform: rotate(180deg); }
.combobox-button:disabled { cursor: not-allowed; background: var(--field-disabled); box-shadow: none; color: var(--text-muted); }

.popover {
    position: fixed; z-index: 40;
    background: var(--surface); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(14, 18, 62, 0.18), 0 2px 6px rgba(14, 18, 62, 0.08);
}

.combobox-search { position: relative; padding: 8px; border-bottom: 1px solid var(--border); }
.combobox-search .icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.combobox-search .input { padding-left: 34px; box-shadow: none; border-color: var(--border); }
.combobox-search .input:focus { border-color: var(--primary); }

.combobox-list { list-style: none; margin: 0; padding: 6px; max-height: 260px; overflow-y: auto; }
.combobox-list:focus { outline: none; }
.combobox-option {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.combobox-option .icon { width: 18px; height: 18px; color: var(--primary-text); visibility: hidden; }
.combobox-option.is-active { background: var(--bg); }
.combobox-option[aria-selected="true"] { background: var(--primary-soft); font-weight: 600; }
.combobox-option[aria-selected="true"] .icon { visibility: visible; }
.combobox-option[aria-disabled="true"] { color: var(--text-muted); cursor: not-allowed; text-decoration: line-through; }
.combobox-empty { margin: 0; padding: 12px 16px; font-size: 14px; color: var(--text-muted); }

/* Date picker */

.date-field { position: relative; }
.date-field > .input { padding-right: 44px; }
.date-field-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 36px; height: 36px;
    border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer;
}
.date-field-toggle:hover { background: var(--primary-soft); color: var(--primary-text); }
.date-field-toggle[aria-expanded="true"] { color: var(--primary-text); }
.date-field-toggle:disabled { cursor: not-allowed; background: transparent; }
.date-field > .input-sm { padding-right: 36px; }
.date-field > .input-sm + .date-field-toggle { width: 30px; height: 30px; }
.date-field > .input-sm + .date-field-toggle .icon { width: 16px; height: 16px; }

.calendar { padding: 14px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-title { margin: 0; font-weight: 600; font-size: 15px; }
.calendar-title-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px; border: 0; border-radius: 6px; background: transparent;
    font-family: inherit; color: var(--text); cursor: pointer;
}
.calendar-title-btn .icon { width: 16px; height: 16px; color: var(--primary-text); }
.calendar-title-btn:hover { background: var(--primary-soft); }
.calendar-nav {
    display: grid; place-items: center; width: 32px; height: 32px;
    border: 0; border-radius: 6px; background: transparent; color: var(--primary-text); cursor: pointer;
}
.calendar-nav:hover { background: var(--primary-soft); }
.calendar-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar-grid th { padding: 4px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.calendar-grid td { padding: 1px; text-align: center; }
.calendar-day {
    width: 100%; height: 36px;
    border: 0; border-radius: 6px; background: transparent;
    font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
}
.calendar-day:hover:not(:disabled) { background: var(--bg); }
.calendar-day.is-outside { color: var(--text-muted); }
.calendar-day[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--primary); }
.calendar-day:disabled { color: #b9bccb; cursor: not-allowed; text-decoration: line-through; }
.calendar-grid td[aria-selected="true"] .calendar-day { background: var(--primary); color: #fff; font-weight: 600; }
.calendar-day:focus-visible { box-shadow: var(--focus); }
/* Month and year grids: 3 x 4, as tall as the 6-week day grid so the popover keeps its size. */
.calendar-picker { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: 6px; height: 252px; }
.calendar-option {
    border: 0; border-radius: 6px; background: transparent;
    font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
}
.calendar-option:hover:not(:disabled) { background: var(--bg); }
.calendar-option[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--primary); }
.calendar-option.is-selected { background: var(--primary); color: #fff; font-weight: 600; }
.calendar-option.is-selected:hover { background: var(--primary-hover); }
.calendar-option:disabled { color: #b9bccb; cursor: not-allowed; text-decoration: line-through; }
.calendar-option:focus-visible { box-shadow: var(--focus); }
.calendar-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > dt { font-size: 13px; color: var(--text); }
.field > dd { margin: 0; }
.field-error { margin: 0; min-height: 0; font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }

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

/* Cards and notices */

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

.notice {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 16px; margin-bottom: 18px; border-radius: var(--radius);
}
.notice p { margin: 0; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice-error { background: var(--danger-soft); color: var(--danger-on-soft); }
.notice-error:focus { outline: none; box-shadow: var(--focus); }
[data-role="form-error"] { display: block; }
.notice-title { font-weight: 600; }

.toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 30;
    background: var(--navy); color: #fff;
    padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow);
}

/* Invoice list */

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

/*
 * Viewport-fit pages (route meta.fitViewport, the invoice list): the shell is exactly one screen tall,
 * the table scrolls inside its own box under a sticky header, and the pagination footer never leaves the screen.
 */
.shell-fit { height: 100vh; height: 100dvh; }
.shell-fit .panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.invoice-index { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.invoice-index .table-scroll { flex: 1; min-height: 0; overflow: auto; }
.invoice-index .invoice-table thead { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.invoice-index .table-footer { flex: none; }
.invoice-index .page-head { margin-bottom: 16px; }

.invoice-table {
    width: 100%; min-width: 1040px;
    border-collapse: separate; border-spacing: 0 6px;
    font-size: 14px;
}
.invoice-table thead th {
    padding: 0 10px 2px; text-align: center; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.invoice-table .filters td { padding: 0 6px 6px; }
.invoice-table tbody tr { background: var(--surface); box-shadow: var(--shadow); }
.invoice-table tbody td { padding: 10px; text-align: center; }
.invoice-table tbody td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.invoice-table tbody td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.invoice-table .col-no { width: 44px; }
.invoice-table .col-subject { min-width: 200px; }
.invoice-table .col-strong { font-weight: 600; white-space: nowrap; }
.invoice-table .col-actions { white-space: nowrap; }
.invoice-table .col-actions .icon-btn { width: 28px; height: 28px; }
.invoice-table .state-row td { padding: 28px; color: var(--text-muted); text-align: center; }
.invoice-table .state-row .btn { margin-left: 8px; }
.link-code { color: var(--text); text-decoration: none; font-weight: 600; }
.link-code:hover { color: var(--primary-text); text-decoration: underline; }

.status-text { font-weight: 600; }
.status-text.is-paid { color: var(--success); }
.status-text.is-unpaid { color: var(--danger); }

.table-footer {
    display: flex; justify-content: flex-end; align-items: center; gap: 28px;
    flex-wrap: wrap; margin-top: 12px;
}
.table-count { margin: 0; font-size: 14px; }

.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
    min-width: 32px; height: 32px; padding: 0 8px;
    border: 0; border-radius: 6px; background: transparent;
    color: var(--primary-text); font: inherit; font-weight: 600; cursor: pointer;
}
.page-btn:hover:not(:disabled) { background: var(--primary-soft); }
.page-btn.is-current { background: var(--primary-soft); color: var(--primary-text); cursor: default; }
.page-btn-nav { display: inline-grid; place-items: center; background: var(--primary); color: #fff; }
.page-btn-nav:hover:not(:disabled) { background: var(--primary-hover); }
.page-btn-nav:disabled { background: #d5d4dd; color: var(--text-muted); cursor: not-allowed; }
.page-btn-nav .icon { width: 18px; height: 18px; }
.page-gap { padding: 0 4px; color: var(--text-muted); }

/* Invoice form and view */

.invoice-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 264px;
    gap: 56px;
    align-items: start;
}
.invoice-main { min-width: 0; }

.section { border: 0; margin: 0 0 26px; padding: 0; min-width: 0; }
.section-title { font-size: 18px; font-weight: 600; margin: 0 0 14px; padding: 0; }

.divider-dashed { border: 0; border-top: 2px dashed #c6cacf; margin: 6px 0 26px; }

.line-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.line {
    display: grid;
    grid-template-columns: minmax(160px, 2.2fr) minmax(80px, 0.6fr) minmax(110px, 1.4fr) minmax(110px, 1.4fr) 32px;
    gap: 18px; align-items: end;
}
.line .icon-btn { margin-bottom: 6px; }
.line output.input { display: flex; align-items: center; justify-content: flex-end; }
.btn-add-item { align-self: flex-start; }

.summary { position: sticky; top: 24px; }
.summary-title { font-size: 18px; font-weight: 600; margin: 0 0 14px; }
.summary-list { margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
/* A long amount moves whole to its own right-aligned line; only one wider than the card breaks between digits. */
.summary-list div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.summary-list dt { color: var(--text); white-space: nowrap; }
.summary-list dd { margin: 0 0 0 auto; min-width: 0; word-break: break-all; text-align: right; font-variant-numeric: tabular-nums; }
.summary-grand { align-items: baseline; margin-top: 4px; }
.summary-grand dd { font-size: 22px; font-weight: 700; }
.summary-note { margin: 18px 0 14px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--text-muted); }
.summary-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.summary-note + .summary-actions { margin-top: 0; }

/* Setting page */

.settings-card { max-width: 760px; padding: 28px; }
.settings-card .section { margin-bottom: 8px; }
.settings-note { margin: 0 0 20px; max-width: 62ch; font-size: 13px; color: var(--text-muted); }
.settings-actions { display: flex; justify-content: flex-end; }

.status-pill {
    display: inline-flex; align-items: center;
    min-height: 42px; padding: 8px 20px; border-radius: var(--radius);
    font-weight: 600;
}
.status-pill.is-paid { background: var(--success-soft); color: var(--success); }
.status-pill.is-unpaid { background: var(--danger-soft); color: var(--danger-on-soft); }

dd.input-readonly, span.input-readonly { display: flex; align-items: center; min-height: 44px; }
span.input-num { justify-content: flex-end; }

.lines-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
.lines-table th { text-align: left; font-weight: 400; font-size: 13px; padding: 0 9px 0 0; }
.lines-table td { padding: 0 9px 0 0; }
.lines-table td:first-child { width: 40%; }
.lines-table .col-num { text-align: right; }
.lines-table .state-row td { color: var(--text-muted); padding: 12px 0; }

/* Modals */

.modal {
    border: 0; border-radius: 16px; padding: 0;
    background: var(--bg); color: var(--text);
    box-shadow: 0 20px 50px rgba(14, 18, 62, 0.25);
    width: min(92vw, 420px);
}
.modal::backdrop { background: rgba(14, 18, 62, 0.7); }
.modal-body { padding: 36px 40px 32px; }
.modal-title { margin: 0 0 24px; text-align: center; font-size: 18px; font-weight: 600; }
.modal-message { margin: 0 0 28px; text-align: center; font-size: 17px; font-weight: 600; }
.modal-actions { display: flex; justify-content: center; gap: 16px; }
.modal-actions .btn { min-width: 150px; }
.modal-items { width: min(94vw, 560px); }
.modal-items .modal-body { padding: 36px 32px 30px; }

.field-search { margin-bottom: 20px; }

.items-picker { max-height: 320px; overflow-y: auto; margin-bottom: 28px; }
.picker-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.picker-table th { text-align: left; font-weight: 600; padding: 8px 10px; }
.picker-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); }
.picker-table tr.is-selected td { background: var(--primary-soft); }
.picker-table label { display: block; cursor: pointer; }
.picker-table .check { width: 44px; text-align: right; }
.picker-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.picker-state { margin: 0; padding: 16px 10px; color: var(--text-muted); }
.picker-state.error { color: var(--danger); }
.muted { color: var(--text-muted); }

.btn-count { gap: 12px; }
.btn-count-value { padding-right: 12px; border-right: 1px solid rgba(255, 255, 255, 0.7); }
.btn-primary:disabled .btn-count-value { border-color: var(--text-muted); }

/* Home */

.page-meta { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); }

.home { display: flex; flex-direction: column; gap: 20px; }
.home .page-head { margin-bottom: 8px; }
.home .notice { margin-bottom: 0; }

.stat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { border-top: 4px solid var(--primary); }
.stat.is-paid { border-top-color: var(--success); }
.stat.is-unpaid, .stat.is-overdue { border-top-color: var(--danger); }
.stat-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.stat-value { margin: 6px 0 2px; font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat.is-paid .stat-value { color: var(--success); }
.stat.is-unpaid .stat-value, .stat.is-overdue .stat-value { color: var(--danger); }
.stat-amount { margin: 0; font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .section-title { margin: 0; }
.card-meta { margin: 0; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.bar-chart {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px;
    height: 220px;
}
.bar-chart-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar-value { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar { display: block; width: 100%; height: calc(var(--ratio) * 100%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--primary); }
.bar-label { font-size: 12px; }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rank-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.rank-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rank-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-meta { margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.share-track { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--primary-soft); overflow: hidden; }
.share-bar { display: block; width: calc(var(--ratio) * 100%); height: 100%; background: var(--primary); }

.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.data-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 600; white-space: nowrap; }
.data-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .col-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .state-row td { padding: 20px; text-align: center; color: var(--text-muted); }

/* Responsive */

@media (max-width: 1100px) {
    .invoice-layout { grid-template-columns: 1fr; gap: 24px; }
    .summary { position: static; }
    .home-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; padding: 0; }
    .shell-fit { grid-template-rows: auto minmax(0, 1fr); }
    .sidebar { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; }
    .nav { flex-direction: row; gap: 4px; }
    .nav-link { padding: 8px 12px; gap: 8px; }
    .panel { border-radius: 20px 20px 0 0; padding: 20px 16px 28px; }
    .page-title { font-size: 26px; }
    .grid-2 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .line { grid-template-columns: 1fr 1fr; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
    .line .field-item { grid-column: 1 / -1; }
    .line .icon-btn { justify-self: end; grid-column: 2; }
    .table-footer { justify-content: space-between; }
}

@media (max-width: 480px) {
    .brand-name { display: none; }
    .modal-body { padding: 28px 20px 24px; }
    .modal-actions .btn { min-width: 0; flex: 1; }
    .stat-grid { grid-template-columns: 1fr; }
    .bar-value { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
