:root {
    --navy: #1a2744;
    --navy-deep: #122038;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #d8dee9;
    --soft: #f4f6fa;
    --page: #eef1f6;
    --white: #ffffff;
    --accent: #1f6feb;
    --green: #1a7f4b;
    --danger: #c0392b;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(18, 32, 56, 0.08);
    --font: "DM Sans", system-ui, sans-serif;
    --display: "Instrument Sans", "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(ellipse at top left, rgba(31, 111, 235, 0.08), transparent 40%),
        linear-gradient(180deg, #f7f8fb 0%, var(--page) 100%);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(26, 39, 68, 0.08);
}
.nav-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-family: var(--display);
    font-weight: 700;
    letter-spacing: -0.02em;
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, var(--navy), #2d4a7c);
    color: white;
    font-size: 0.95rem;
}
.brand-text { font-size: 1.1rem; color: var(--navy); }
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.nav-links a {
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.95rem;
}
.nav-links a:hover,
.nav-links a.active {
    color: var(--navy);
    background: rgba(26, 39, 68, 0.06);
}
.nav-cta {
    background: var(--navy) !important;
    color: white !important;
    margin-left: 0.35rem;
}
.nav-cta:hover { background: var(--navy-deep) !important; }
.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}
.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--navy);
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-header h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(1.5rem, 2vw, 1.9rem);
    letter-spacing: -0.03em;
    color: var(--navy);
}
.page-header p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s ease;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-secondary { background: white; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--soft); }
.btn-danger { background: #fff5f5; color: var(--danger); border-color: #f5c6c2; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.875rem; }

.card {
    background: white;
    border: 1px solid rgba(26,39,68,0.08);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: white;
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    border: 1px solid rgba(26,39,68,0.08);
    box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.4rem; }
.stat .value {
    font-family: var(--display);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.02em;
}

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
}
table.data th, table.data td {
    text-align: left;
    padding: 0.85rem 0.7rem;
    border-bottom: 1px solid #eef1f6;
    vertical-align: middle;
}
table.data th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
table.data tr:hover td { background: #fafbfd; }

.badge {
    display: inline-flex;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-unpaid { background: #fff1f0; color: #b42318; }
.badge-partial { background: #fff8eb; color: #b54708; }
.badge-paid { background: #ecfdf3; color: #027a48; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
.form-control {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    background: white;
    color: var(--ink);
}
.form-control:focus {
    outline: none;
    border-color: #8eb6ff;
    box-shadow: 0 0 0 3px rgba(31,111,235,0.15);
}
textarea.form-control { min-height: 96px; resize: vertical; }
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.alert-success { background: #ecfdf3; color: #027a48; border: 1px solid #abefc6; }
.alert-error { background: #fef3f2; color: #b42318; border: 1px solid #fecdca; }
.alert ul { margin: 0; padding-left: 1.1rem; }

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filters .form-control { width: auto; min-width: 160px; }

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}

/* Invoice editor — matches attached design */
.invoice-shell {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(26,39,68,0.08);
    padding: 1.5rem;
}
.invoice-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.invoice-paper {
    border: 1px solid #e6ebf2;
    border-radius: 12px;
    padding: 1.5rem;
    background: #fff;
}
.inv-top {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.inv-logo-wrap {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.inv-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 8px;
}
.inv-logo-fallback {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: linear-gradient(145deg, #14345c, #0d6e9c);
    color: white;
    display: grid;
    place-items: center;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 0.4rem;
}
.inv-title-block { text-align: right; }
.inv-title {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(2rem, 4vw, 2.8rem);
    letter-spacing: 0.04em;
    color: #5b6475;
    font-weight: 700;
}
.inv-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
}
.inv-title-hint {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}
.inv-title-select {
    display: block;
    width: auto;
    min-width: 11ch;
    max-width: 280px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-family: var(--display);
    font-size: clamp(1.7rem, 3.6vw, 2.5rem);
    letter-spacing: 0.04em;
    color: #5b6475;
    font-weight: 700;
    text-align: right;
    padding: 0.1rem 0.2rem;
    cursor: pointer;
}
.inv-title-select:hover,
.inv-title-select:focus {
    outline: none;
    border-color: #cfd7e4;
    background: #fff;
}
.inv-number-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
    color: var(--muted);
}
.inv-number-row input {
    width: 110px;
    text-align: right;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
}

.inv-meta {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}
.inv-left-col, .inv-right-col { display: flex; flex-direction: column; gap: 0.85rem; }
.field-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
    font-weight: 500;
}
.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.field-add {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--navy);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.field-add:hover {
    background: var(--navy);
    border-color: var(--navy);
    color: white;
}

.combo {
    position: relative;
    width: 100%;
}
.combo-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}
.combo-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #cfd7e4;
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
    background: white;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.combo-trigger:hover { border-color: #aebbd0; }
.combo.is-open .combo-trigger {
    border-color: #aebbd0;
}
.combo.is-invalid .combo-trigger {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}
.combo-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.combo-text.is-empty { color: #9aa5b7; }
.combo-caret {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.combo-panel {
    display: none;
    position: absolute;
    z-index: 55;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    padding: 0.45rem;
    background: white;
    border: 1px solid rgba(26, 39, 68, 0.1);
    border-radius: 10px;
    box-shadow: 0 14px 32px rgba(18, 32, 56, 0.16);
}
.combo.is-open .combo-panel { display: block; }
.combo-search-wrap {
    position: relative;
    margin-bottom: 0.4rem;
}
.combo-search-icon {
    position: absolute;
    left: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
    pointer-events: none;
}
.combo-search {
    width: 100%;
    border: 1px solid #dfe5ee;
    border-radius: 6px;
    padding: 0.45rem 0.55rem 0.45rem 1.9rem;
}
.combo-search:focus {
    outline: none;
    border-color: #aebbd0;
}
.combo-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 210px;
    overflow-y: auto;
}
.combo-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--ink);
}
.combo-option.is-active { background: var(--soft); }
.combo-option.is-selected { font-weight: 600; }
.combo-option.is-selected::after {
    content: "✓";
    color: var(--green);
    font-size: 0.9rem;
}
.combo-option mark {
    background: rgba(31, 111, 235, 0.14);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
    font-weight: 600;
}
.combo-empty {
    padding: 0.5rem 0.55rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 32, 56, 0.45);
    backdrop-filter: blur(2px);
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(18, 32, 56, 0.28);
    overflow: hidden;
}
/* The form holds the scrolling body and the footer, so it has to stretch too. */
.modal-card form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex: none;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid #eef1f6;
}
.modal-head h3 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.1rem;
    color: var(--navy);
}
.modal-close {
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.15rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex: none;
    padding: 0.9rem 1.15rem;
    border-top: 1px solid #eef1f6;
    background: #fafbfd;
}
.modal-error {
    margin-bottom: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: rgba(192, 57, 43, 0.08);
    color: var(--danger);
    font-size: 0.92rem;
}
.field-error {
    display: block;
    margin-top: 0.25rem;
    color: var(--danger);
    font-size: 0.85rem;
}
body.modal-open { overflow: hidden; }

.inv-input,
.inv-textarea {
    width: 100%;
    border: 1px solid #cfd7e4;
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
    background: #fff;
}
.inv-textarea { min-height: 78px; resize: vertical; }
#billTo,
#shipTo {
    overflow: hidden;
    resize: none;
    min-height: 78px;
}
.bill-ship {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}
.meta-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.6rem;
    align-items: center;
}
.meta-row label {
    text-align: right;
    color: var(--muted);
    font-size: 0.9rem;
}

.datepicker {
    position: relative;
    width: 100%;
}
.dp-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #cfd7e4;
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
    background: #fff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dp-trigger:hover { border-color: #aebbd0; }
.dp-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}
.datepicker.is-open .dp-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}
.datepicker.is-invalid .dp-trigger {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}
.dp-icon {
    width: 17px;
    height: 17px;
    flex: none;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.6;
    stroke-linecap: round;
}
.dp-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dp-text.is-empty { color: #9aa5b7; }
.dp-clear {
    display: none;
    line-height: 1;
    font-size: 1.15rem;
    color: #9aa5b7;
    padding: 0 0.15rem;
}
.dp-clear:hover { color: var(--danger); }
.datepicker.has-value .dp-clear { display: inline-block; }

.dp-popup {
    display: none;
    position: fixed;
    z-index: 60;
    top: 0;
    left: 0;
    width: 254px;
    padding: 0.6rem;
    background: white;
    border: 1px solid rgba(26, 39, 68, 0.1);
    border-radius: 12px;
    box-shadow: 0 16px 38px rgba(18, 32, 56, 0.18);
}
.datepicker.is-open .dp-popup { display: block; }
.dp-head {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.35rem;
}
.dp-nav {
    width: 27px;
    height: 27px;
    flex: none;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 6px;
    background: var(--navy);
    color: white;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}
.dp-nav:hover { background: var(--navy-deep); }
.dp-selects {
    flex: 1;
    display: flex;
    gap: 0.35rem;
}
.dp-selects select {
    flex: 1;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.25rem 0.2rem;
    background: transparent;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.dp-selects select:hover { background: var(--soft); }
.dp-selects select:focus { outline: none; border-color: var(--accent); }
.dp-weekdays,
.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.dp-grid {
    /* Six fixed rows keep the popup height identical for every month. */
    grid-template-rows: repeat(6, 30px);
    height: calc((30px * 6) + (3px * 5));
}
.dp-weekdays span {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--navy);
    padding: 0.25rem 0 0.3rem;
}
.dp-day {
    height: 30px;
    border: 1px solid #e6e9ef;
    border-radius: 4px;
    background: white;
    color: var(--ink);
    font-size: 0.85rem;
    cursor: pointer;
}
.dp-day:hover {
    background: var(--soft);
    border-color: #c3cddd;
}
.dp-blank {
    display: block;
    height: 30px;
}
.dp-day.is-today {
    font-weight: 700;
    color: var(--navy);
    border-color: #c3cddd;
}
.dp-day.is-selected {
    background: #fdf5c2;
    border-color: #ded073;
    color: var(--ink);
    font-weight: 700;
}
.dp-day.is-selected:hover { background: #fbefa6; }
.dp-foot {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid #eef1f6;
}
.dp-foot button {
    border: none;
    background: none;
    padding: 0.1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
}
.dp-foot .dp-reset { color: var(--muted); }
.dp-foot .dp-reset:hover { color: var(--danger); }

.items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.5rem;
}
.items-table thead th {
    background: var(--navy);
    color: white;
    font-weight: 600;
    padding: 0.7rem 0.75rem;
    text-align: left;
    font-size: 0.92rem;
}
.items-table thead th:first-child { border-radius: 6px 0 0 6px; }
.items-table thead th:last-child { border-radius: 0 6px 6px 0; text-align: right; }
.items-table thead th.num { text-align: right; }
.items-table tbody td {
    padding: 0.55rem 0.35rem;
    vertical-align: top;
    border-bottom: 1px solid #edf1f7;
}
.items-table .item-desc { width: 52%; }
.items-table .item-qty { width: 12%; }
.items-table .item-rate { width: 18%; }
.items-table .item-amount { width: 18%; text-align: right; color: var(--ink); padding-top: 0.85rem; white-space: nowrap; }
.items-table input {
    width: 100%;
    border: 1px solid #cfd7e4;
    border-radius: 4px;
    padding: 0.5rem 0.55rem;
}
.items-table .qty,
.items-table .rate {
    text-align: center;
    -moz-appearance: textfield;
}
.items-table .qty::-webkit-outer-spin-button,
.items-table .qty::-webkit-inner-spin-button,
.items-table .rate::-webkit-outer-spin-button,
.items-table .rate::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.rate-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.rate-wrap span { color: var(--muted); font-size: 0.85rem; }
.line-actions {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0 1.25rem;
}
.btn-line {
    flex: 1;
    border: 1px solid #d7dde8;
    background: #f3f5f8;
    color: #4b5567;
    border-radius: 6px;
    padding: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-line:hover { background: #e9edf4; }
.btn-remove-line {
    border: none;
    background: transparent;
    color: #98a2b3;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.4rem;
}
.btn-remove-line:hover { color: var(--danger); }

.inv-bottom {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 1.5rem;
    margin-top: 0.5rem;
}
.notes-block .field-label { margin-top: 0.75rem; }
.notes-block .field-label:first-child { margin-top: 0; }
.totals {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding-top: 0.25rem;
}
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    color: var(--ink);
}
.total-row.muted { color: var(--muted); }
.total-row.strong {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0.2rem;
}
.total-row.balance {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    margin-top: 0.35rem;
}
.total-divider {
    height: 1px;
    background: #e6ebf2;
    margin: 0.15rem 0;
}
.adj-links {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    padding: 0.15rem 0 0.25rem;
}
.adj-links button {
    border: none;
    background: none;
    color: var(--green);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}
.adj-field { display: none; }
.adj-field.visible {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 168px 20px;
    gap: 0.5rem;
    align-items: center;
}
.adj-label,
.adj-value {
    border: 1px solid #dfe5ee;
    border-radius: 7px;
    background: white;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.adj-label {
    width: 100%;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    color: var(--ink);
}
.adj-label:focus,
.adj-value:focus-within {
    outline: none;
    border-color: #14b88a;
    box-shadow: 0 0 0 3px rgba(20, 184, 138, 0.15);
}
.adj-value {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.3rem 0.3rem 0.55rem;
}
.adj-amount {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 0.2rem 0;
    text-align: center;
    background: transparent;
    color: var(--ink);
    -moz-appearance: textfield;
}
.adj-amount::-webkit-outer-spin-button,
.adj-amount::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.adj-prefix,
.adj-suffix {
    color: var(--muted);
    font-size: 0.9rem;
}
.adj-field[data-mode="percent"] .adj-prefix,
.adj-field[data-mode="flat"] .adj-suffix { display: none; }
.adj-toggle {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-left: 1px solid #eef1f6;
    background: none;
    color: #8b96a8;
    cursor: pointer;
}
.adj-toggle svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.adj-toggle:hover { color: #14b88a; }
.adj-remove {
    border: none;
    background: none;
    color: #9aa5b7;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.adj-field:hover .adj-remove,
.adj-field:focus-within .adj-remove { opacity: 1; }
.adj-remove:hover { color: var(--danger); }
.paid-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.paid-wrap input {
    width: 120px;
    border: 1px solid #cfd7e4;
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    text-align: center;
    -moz-appearance: textfield;
}
.paid-wrap input::-webkit-outer-spin-button,
.paid-wrap input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.invoice-view .inv-static {
    white-space: pre-line;
    line-height: 1.45;
}
.actions-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pagination { margin-top: 1rem; }
.pager {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.pager a, .pager span {
    display: inline-flex;
    min-width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    font-size: 0.9rem;
}
.pager a:hover { background: var(--soft); }
.pager-current {
    background: var(--navy) !important;
    color: white !important;
    border-color: var(--navy) !important;
}
.pager-disabled { opacity: 0.45; }

.nav-user {
    margin-left: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}
.logout-form { display: inline-flex; }

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}
.auth-shell {
    width: 100%;
    max-width: 440px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}
.auth-brand strong {
    display: block;
    font-family: var(--display);
    font-size: 1.25rem;
    color: var(--navy);
}
.auth-brand p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}
.auth-card {
    background: white;
    border: 1px solid rgba(26,39,68,0.08);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
}
.auth-card h1 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.6rem;
    color: var(--navy);
    letter-spacing: -0.02em;
}
.auth-subtitle {
    margin: 0.4rem 0 1.25rem;
    color: var(--muted);
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.auth-submit {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.75rem 1rem;
}
.remember {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.92rem;
}
.auth-switch {
    margin: 1.25rem 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
}
.auth-switch a {
    color: var(--navy);
    font-weight: 600;
}

@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .modal-grid { grid-template-columns: 1fr; }
    .inv-meta, .inv-bottom, .bill-ship, .form-grid { grid-template-columns: 1fr; }
    .meta-row { grid-template-columns: 1fr; }
    .meta-row label { text-align: left; }
    .inv-title-block { text-align: left; width: 100%; }
    .inv-number-row { justify-content: flex-start; }
    .items-table thead { display: none; }
    .items-table, .items-table tbody, .items-table tr, .items-table td {
        display: block;
        width: 100%;
    }
    .items-table tr {
        border: 1px solid #e6ebf2;
        border-radius: 8px;
        padding: 0.6rem;
        margin-bottom: 0.75rem;
    }
    .items-table td {
        border: none;
        padding: 0.35rem 0;
    }
    .items-table .item-amount { text-align: left; padding-top: 0.35rem; }
}

@media (max-width: 560px) {
    .modal { padding: 0.6rem; align-items: end; }
    .modal-card { max-height: calc(100dvh - 1.2rem); border-radius: 14px; }
    .modal-head { padding: 0.85rem 1rem; }
    .modal-body { padding: 1rem; }
    .modal-foot {
        flex-direction: column-reverse;
        padding: 0.8rem 1rem;
    }
    .modal-foot .btn { width: 100%; }
}

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        padding-top: 0.5rem;
    }
    .nav-links.open { display: flex; }
    .nav-inner { flex-wrap: wrap; }
    .nav-cta { margin-left: 0; text-align: center; }
    .stats { grid-template-columns: 1fr; }
}

@media print {
    .navbar, .invoice-toolbar, .no-print { display: none !important; }
    .dp-popup, .dp-clear, .dp-icon { display: none !important; }
    .dp-trigger { border: none; padding: 0; }
    body { background: white; }
    .page { max-width: none; padding: 0; }
    .invoice-shell, .invoice-paper { box-shadow: none; border: none; padding: 0; }
}
