:root {
    --bg: #f7f9fc;
    --panel: #ffffff;
    --panel-subtle: #fbfcfe;
    --text: #08162f;
    --muted: #5c6a80;
    --soft: #f2f6fb;
    --line: #d9e2ee;
    --line-strong: #c7d3e2;
    --primary: #123a82;
    --primary-dark: #0c2b62;
    --green: #169a51;
    --orange: #f36b16;
    --purple: #8b35df;
    --teal: #1e9cad;
    --red: #e23b24;
    --shadow: 0 10px 28px rgba(8, 22, 47, 0.06);
    --shadow-soft: 0 1px 2px rgba(8, 22, 47, 0.04);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

img {
    max-width: 100%;
    height: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 12px;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button:disabled,
a[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
}

.button.is-loading,
.excel-link.is-loading {
    gap: 10px;
}

.button.is-loading::before,
.excel-link.is-loading::before {
    animation: spin 0.8s linear infinite;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    content: "";
    height: 16px;
    width: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app-shell {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-height: 100vh;
    padding: 34px 20px 20px;
    position: sticky;
    top: 0;
}

.brand-lockup {
    align-items: center;
    display: flex;
    gap: 14px;
    padding: 0 10px;
    text-decoration: none;
    text-transform: uppercase;
}

.brand-lockup strong {
    display: block;
    font-size: 18px;
    letter-spacing: 0;
    line-height: 1;
}

.brand-lockup small {
    color: var(--text);
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin-top: 6px;
}

.brand-mark {
    align-items: center;
    background: var(--text);
    border-radius: 50%;
    display: inline-flex;
    gap: 3px;
    height: 48px;
    justify-content: center;
    width: 48px;
}

.brand-mark span {
    background: #fff;
    border-radius: 999px;
    display: block;
    width: 3px;
}

.brand-mark span:nth-child(1),
.brand-mark span:nth-child(4) {
    height: 16px;
}

.brand-mark span:nth-child(2) {
    height: 25px;
}

.brand-mark span:nth-child(3) {
    height: 32px;
}

.side-nav {
    display: grid;
    gap: 5px;
}

/* Group heading that splits the nav into Income / Fans / Projects / Admin. */
.nav-section-label {
    color: #8a98ad;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.07em;
    margin: 18px 0 2px;
    padding: 0 16px;
    text-transform: uppercase;
}

.side-nav > .nav-section-label:first-child {
    margin-top: 2px;
}

.side-nav a,
.side-nav .nav-item,
.nav-parent {
    align-items: center;
    border-radius: 7px;
    color: #42516c;
    display: flex;
    gap: 14px;
    min-height: 44px;
    padding: 0 16px;
    text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover {
    background: #f3f6fb;
    color: var(--primary);
}

.side-nav a.active {
    box-shadow: inset 3px 0 0 #9eb4d3;
    font-weight: 600;
}

.side-nav .nav-item {
    cursor: default;
}

.nav-group {
    display: grid;
    gap: 4px;
}

.nav-group.active .nav-parent {
    color: var(--primary);
    font-weight: 600;
}

.nav-children {
    border-left: 1px solid var(--line);
    display: grid;
    gap: 4px;
    margin-left: 28px;
    padding-left: 14px;
}

.nav-children a,
.nav-children .nav-item {
    font-size: 14px;
    min-height: 36px;
    padding: 0 14px;
}

.nav-children a.active {
    background: transparent;
    box-shadow: inset 2px 0 0 #9eb4d3;
}

.nav-children .nav-item {
    color: #75839a;
}

.nav-icon {
    align-items: center;
    border: 1px solid #b8c5d6;
    border-radius: 5px;
    color: #52627a;
    display: inline-flex;
    font-size: 11px;
    height: 20px;
    justify-content: center;
    line-height: 1;
    width: 20px;
}

.side-nav a.active .nav-icon,
.nav-group.active .nav-icon {
    border-color: #9fb2ce;
    color: var(--primary);
}

.sidebar-account {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    margin-top: auto;
    padding: 11px;
}

.avatar {
    align-items: center;
    background: #e8effc;
    border-radius: 50%;
    color: var(--primary);
    display: inline-flex;
    font-weight: 800;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.sidebar-account strong,
.sidebar-account small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-account small {
    color: var(--muted);
    font-size: 13px;
}

.sidebar-account form {
    margin: 0;
}

.sidebar-account button {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 8px;
}

.page-shell {
    min-width: 0;
    padding: 34px 34px 56px;
}

.auth-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
}

/* Mobile app bar + off-canvas drawer.
   Hidden on desktop; the <=820px media query activates them. */
.app-bar {
    display: none;
}

.nav-toggle {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.nav-toggle:focus-visible {
    outline: 2px solid #8fb3df;
    outline-offset: 2px;
}

.nav-toggle-bars {
    display: grid;
    gap: 4px;
}

.nav-toggle-bars span {
    background: currentColor;
    border-radius: 2px;
    display: block;
    height: 2px;
    width: 18px;
}

.app-bar-brand {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
    text-transform: uppercase;
}

.app-bar-brand .brand-mark {
    flex: 0 0 auto;
    height: 34px;
    width: 34px;
}

.app-bar-brand strong {
    display: block;
    font-size: 15px;
    line-height: 1;
}

.app-bar-brand small {
    color: var(--text);
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    margin-top: 3px;
}

.app-bar-spacer {
    flex: 1;
}

.app-bar-avatar {
    flex: 0 0 auto;
    font-size: 14px;
    height: 36px;
    width: 36px;
}

.nav-scrim {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar {
        transition: none;
    }
}

.content-header {
    align-items: flex-start;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.content-header h1 {
    font-size: clamp(30px, 2.7vw, 40px);
    letter-spacing: 0;
    line-height: 1.08;
    margin: 0 0 6px;
}

.content-header p {
    color: var(--muted);
    font-size: 16px;
    margin: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: flex-end;
}

.header-actions form {
    margin: 0;
}

.button,
.excel-link {
    align-items: center;
    background: var(--primary);
    border: 1px solid transparent;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(18, 58, 130, 0.12);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    background: var(--primary-dark);
}

.button.ghost,
.excel-link {
    background: #fff;
    border-color: var(--line-strong);
    box-shadow: none;
    color: var(--text);
}

.button.ghost:hover,
.excel-link:hover {
    background: var(--soft);
}

.row-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    font-weight: 800;
    padding: 0;
}

.link-button.danger {
    color: #b72b1c;
}

.link-button:hover {
    text-decoration: underline;
}

.invoice-row-actions {
    gap: 18px;
    justify-content: flex-start;
}

.row-action-link {
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    gap: 6px;
    line-height: 1.2;
    padding: 0;
    text-decoration: none;
}

.row-action-link.is-loading::before {
    animation: spin 0.8s linear infinite;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    content: "";
    height: 12px;
    width: 12px;
}

.row-action-link.danger {
    color: #b42318;
}

.row-action-link:hover {
    text-decoration: underline;
}

.notice,
.filter-card,
.panel,
.metric-card,
.empty-report {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.page-header {
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: clamp(24px, 2.2vw, 32px);
    letter-spacing: 0;
    line-height: 1.1;
    margin: 0 0 6px;
}

.page-header p:last-child {
    color: var(--muted);
    margin: 0;
}

.eyebrow {
    color: var(--primary);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.report-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 18px;
    padding: 22px;
}

.report-form.compact {
    align-items: end;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    margin-bottom: 24px;
}

.notice,
.validation {
    padding: 12px 14px;
}

.validation.validation-summary-valid {
    display: none;
}

.validation:empty {
    display: none;
}

.notice.error,
.validation {
    background: #fff4f2;
    color: #9a271b;
}

.notice.success {
    background: #edf9f2;
    border-color: #bfe7ce;
    color: #116239;
    font-weight: 700;
}

.notice.warning {
    background: #fdf6e3;
    border-color: #ecd9a0;
    color: #6b4e00;
    font-weight: 700;
}

.wide-field {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.wide-field span {
    color: #263755;
    font-size: 14px;
    font-weight: 700;
}

.wide-field textarea {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    min-height: 92px;
    padding: 12px 14px;
    resize: vertical;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
}

.status-badge.success {
    background: #dff7e8;
    color: #10723b;
}

.status-badge.warning {
    background: #fff2dd;
    color: #9a5700;
}

.status-badge.error {
    background: #ffe2dc;
    color: #a52212;
}

.details-grid {
    display: grid;
    gap: 12px 22px;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
}

.details-grid span {
    color: var(--muted);
}

.details-grid strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.filter-card {
    margin-bottom: 24px;
    padding: 22px;
}

.filter-grid {
    align-items: end;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(180px, 1.05fr) minmax(150px, 0.85fr) minmax(120px, 0.65fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
}

.transaction-filter-grid {
    align-items: end;
    display: grid;
    gap: 18px;
    /* Fields wrap to as many rows as needed instead of a fixed 6-column row.
       The fixed row's min-content (~1096px incl. the Search button) overflowed the
       content column in the 1200-1366px band when the full sidebar was present. */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.transaction-filter-grid.compact {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.8fr) minmax(160px, 0.8fr) auto;
}

.statement-filter-grid {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.statement-filter-card {
    padding: 22px;
}

.statement-filter-grid label {
    flex: 0 1 280px;
}

.statement-filter-grid .button {
    flex: 0 0 auto;
    min-width: 190px;
}

.payment-toolbar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 20px;
}

.payment-filter-grid {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.payment-filter-grid label {
    flex: 1 1 280px;
    max-width: 420px;
}

.payment-filter-grid .button {
    flex: 0 0 auto;
    min-width: 148px;
}

/* Available-to-request balance: one quiet data line, not a showcase band. */
.statements-balance {
    align-items: baseline;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.95rem;
    gap: 0.5rem;
    margin: 0 0 20px;
}

.statements-balance-label {
    color: var(--muted);
}

.statements-balance-amount {
    color: var(--text);
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.statements-balance-note {
    color: var(--muted);
}

.payment-highlight {
    align-items: center;
    background: linear-gradient(135deg, #f6fbff, #ffffff);
    border: 1px solid #b8d3f6;
    border-radius: 8px;
    display: flex;
    gap: 28px;
    justify-content: space-between;
    margin-bottom: 26px;
    padding: 28px;
}

/* Let the flex children shrink so a large clamp()-sized amount can't push the
   fixed-width meta column past the row and overflow the band above 820px. */
.payment-highlight > * {
    min-width: 0;
}

.payment-highlight span,
.payment-highlight small {
    color: var(--muted);
    display: block;
}

.payment-highlight span {
    color: #253858;
    font-weight: 800;
    margin-bottom: 8px;
}

.payment-highlight strong {
    display: block;
    font-size: clamp(36px, 5vw, 58px);
    line-height: 1;
    margin-bottom: 10px;
}

.payment-summary-meta {
    border-left: 1px solid var(--line);
    min-width: 220px;
    padding-left: 28px;
    text-align: right;
}

.payment-summary-meta strong {
    font-size: 28px;
}

.latest-row {
    background: #f3f8ff;
    font-weight: 800;
}

label span,
.date-field legend {
    color: #253858;
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 7px;
}

.field-hint {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.3;
    margin-top: 7px;
}

.channel-change-status {
    align-items: center;
    display: inline-flex;
    gap: 8px;
}

.channel-change-status[hidden] {
    display: none;
}

.channel-change-status::before {
    animation: spin 0.8s linear infinite;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    content: "";
    height: 13px;
    width: 13px;
}

input,
select {
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: var(--text);
    min-height: 44px;
    padding: 9px 13px;
    width: 100%;
    /* Cap single-line field width so dropdowns/text inputs don't stretch to
       the full column on wide screens (matches the 420px field convention
       used elsewhere). Fields stay fluid below this and fill narrow cells. */
    max-width: 420px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(11, 58, 146, 0.2);
    outline-offset: 2px;
}

.date-field {
    border: 0;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.date-field legend {
    padding: 0;
}

.date-field {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.date-field legend {
    grid-column: 1 / -1;
}

.date-field span {
    align-self: center;
    color: var(--muted);
    font-size: 13px;
}

.more-filters {
    min-width: 132px;
    position: relative;
}

.more-filters summary {
    color: var(--primary);
    cursor: pointer;
    font-weight: 800;
    list-style: none;
    min-height: 44px;
    padding-top: 12px;
}

.more-filters summary::-webkit-details-marker {
    display: none;
}

.more-filters[open] {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0 14px 12px;
    z-index: 2;
}

.more-filters label {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 8px;
    margin-top: 10px;
    white-space: nowrap;
}

.more-filters input {
    min-height: auto;
    width: auto;
}

.generate-button {
    min-width: 166px;
}

.import-form-grid {
    grid-template-columns: minmax(220px, 320px) minmax(260px, 420px);
}

.validation {
    margin-top: 18px;
}

.filter-help {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 13px;
    gap: 8px;
    margin-top: 10px;
    padding: 0;
}

.import-upload-card {
    display: grid;
    gap: 14px;
}

.import-upload-card .transaction-filter-grid.compact {
    align-items: start;
    grid-template-columns: minmax(220px, 320px) minmax(260px, 420px);
}

.import-upload-card .transaction-filter-grid.compact.royalty-import-form-grid {
    align-items: start;
    gap: 16px;
    grid-template-areas: "channel file notes submit";
    grid-template-columns: minmax(190px, 250px) minmax(320px, 1fr) minmax(220px, 280px) minmax(170px, max-content);
}

.import-channel-field {
    grid-area: channel;
}

.import-file-field {
    grid-area: file;
}

.import-notes-field {
    grid-area: notes;
}

.import-submit-cell {
    align-items: start;
    display: flex;
    grid-area: submit;
    justify-content: flex-end;
    padding-top: 24px;
}

.import-upload-card input[type="file"] {
    align-items: center;
    display: flex;
    padding: 8px 11px;
}

.import-upload-card textarea {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 13px;
    resize: vertical;
}

.import-upload-card .filter-help {
    margin-top: 0;
}

.import-upload-card .generate-button {
    min-height: 44px;
    padding-inline: 22px;
    white-space: nowrap;
}

.latest-import-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    margin: 0 0 24px;
    padding: 14px 16px 16px;
}

.latest-import-header {
    align-items: baseline;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.latest-import-header h2 {
    font-size: 16px;
    margin: 0;
}

.latest-import-header p {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}

.latest-import-grid {
    display: grid;
    gap: 10px;
}

.latest-import-card {
    align-items: center;
    background: var(--panel-subtle);
    border: 1px solid #e1e8f2;
    border-radius: 7px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 12px 14px;
}

.latest-import-card strong,
.latest-import-card small,
.latest-import-label,
.latest-import-meta span {
    display: block;
}

.latest-import-label {
    color: var(--primary);
    font-size: 11px;
    font-weight: 900;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.latest-import-card strong {
    font-size: 16px;
    line-height: 1.2;
}

.latest-import-card small,
.latest-import-meta span {
    color: var(--muted);
    font-size: 13px;
}

.latest-import-meta .latest-import-warning {
    color: #9a5700;
    font-weight: 800;
}

.latest-import-card small {
    margin-top: 4px;
}

.latest-import-meta {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-items: end;
    justify-content: flex-end;
    text-align: right;
}

.latest-import-meta .excel-link {
    min-height: 34px;
    padding: 0 12px;
}

.metric-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 24px;
}

.compact-metrics .metric-card {
    min-height: 112px;
    padding: 20px;
}

.compact-metrics .metric-card strong {
    font-size: 25px;
}

.details-grid .monospace {
    font-size: 13px;
}

.info-dot {
    align-items: center;
    border: 2px solid var(--primary);
    border-radius: 50%;
    color: var(--primary);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 900;
    height: 22px;
    justify-content: center;
    width: 22px;
}

.empty-report {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 540px;
    padding: 48px 24px;
    text-align: center;
}

.empty-report h2 {
    font-size: 26px;
    margin: 26px 0 8px;
}

.empty-report p {
    color: var(--muted);
    margin: 0;
    max-width: 440px;
}

.empty-illustration {
    background: radial-gradient(circle at center, #eef5ff 0 42%, transparent 43%);
    height: 210px;
    position: relative;
    width: 360px;
}

.empty-illustration span {
    position: absolute;
}

.window-bar,
.empty-illustration::before {
    background: #fff;
    border: 1px solid #d8e6f8;
    border-radius: 8px;
    box-shadow: var(--shadow);
    content: "";
    height: 120px;
    left: 72px;
    top: 34px;
    width: 216px;
}

.window-bar {
    background: linear-gradient(90deg, #8fb9f4, #6c9de8);
    border: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: none;
    height: 28px;
    z-index: 1;
}

.bar {
    background: #9dc3f8;
    bottom: 76px;
    border-radius: 3px 3px 0 0;
    width: 18px;
    z-index: 1;
}

.bar.one {
    height: 18px;
    left: 116px;
}

.bar.two {
    height: 34px;
    left: 144px;
}

.bar.three {
    height: 54px;
    left: 172px;
}

.donut {
    border: 18px solid #93bdf3;
    border-radius: 50%;
    height: 72px;
    left: 226px;
    top: 72px;
    width: 72px;
    z-index: 1;
}

.mini-card {
    background: #fff;
    border: 1px solid #d8e6f8;
    border-radius: 8px;
    box-shadow: var(--shadow);
    height: 74px;
    left: 214px;
    top: 122px;
    width: 148px;
    z-index: 2;
}

.summary-grid {
    align-items: start;
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 24px;
}

.metric-card {
    min-height: 128px;
    padding: 22px;
}

.metric-card.highlighted {
    background: #fbfdff;
    border-color: #c5d6ec;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
    display: block;
}

.metric-card span {
    color: #253858;
    font-weight: 700;
    margin-bottom: 8px;
}

.metric-card strong {
    display: block;
    font-size: 26px;
    line-height: 1.1;
    margin-bottom: 8px;
}

.metric-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    margin: 12px 0 0;
}

.metric-note strong {
    color: var(--text);
    display: inline;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
}

.metric-details-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
}

.metric-details-toggle:hover {
    color: var(--primary-dark);
}

.metric-details-toggle .chevron {
    border-bottom: 2px solid currentColor;
    border-right: 2px solid currentColor;
    height: 7px;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 160ms ease;
    width: 7px;
}

.metric-details-toggle[aria-expanded="true"] .chevron {
    transform: rotate(225deg) translateY(-1px);
}

.metric-breakdown {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 0 16px;
    grid-template-columns: minmax(140px, 1fr) minmax(150px, auto);
    margin: 16px 0 0;
    padding-top: 8px;
}

.metric-breakdown[hidden] {
    display: none;
}

/* Small phones: the two-column breakdown's floors (140 + 150 + gap ~ 306px)
   exceed the headline card's inner width, clipping the amount column and
   overflowing the page. Stack label over value instead. */
@media (max-width: 480px) {
    .metric-breakdown {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .metric-breakdown dt {
        border-bottom: 0;
        min-height: 0;
        padding-bottom: 0;
    }

    .metric-breakdown dd {
        justify-content: flex-start;
        padding-top: 2px;
        text-align: left;
    }
}

.metric-breakdown dt,
.metric-breakdown dd {
    font-size: 13px;
    line-height: 1.35;
    margin: 0;
    min-height: 34px;
    padding: 8px 0;
}

.metric-breakdown dt {
    color: var(--muted);
    border-bottom: 1px solid #edf2f8;
}

.metric-breakdown dd {
    align-items: baseline;
    border-bottom: 1px solid #edf2f8;
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    font-weight: 700;
    gap: 4px 12px;
    justify-content: flex-end;
    text-align: right;
}

.metric-breakdown dt:last-of-type,
.metric-breakdown dd:last-of-type {
    color: var(--primary);
    border-bottom: 0;
    padding-top: 10px;
}

.payment-metric-card {
    align-items: center;
    align-self: start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 128px;
}

.payment-metric-card .metric-action {
    flex: 0 0 auto;
    margin: 0;
}

.payment-metric-card .button {
    min-height: 44px;
    padding-inline: 18px;
}

.statement-preview,
.statement-output {
    display: grid;
    gap: 26px;
}

.statement-hero,
.statement-cover {
    align-items: center;
    background: #fbfdff;
    border-color: #c5d6ec;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 24px;
}

.statement-hero span,
.statement-hero p,
.statement-cover span,
.statement-cover p,
.statement-total span,
.statement-total small {
    color: var(--muted);
}

.statement-hero h2,
.statement-hero p,
.statement-cover h2,
.statement-cover p {
    margin: 0;
}

.statement-hero h2,
.statement-cover h2 {
    font-size: 27px;
    margin-top: 6px;
}

.statement-summary {
    margin-bottom: 0;
}

.statement-source-row {
    cursor: default;
}

.statement-breakdown {
    margin-bottom: 0;
}

.statement-total {
    text-align: right;
}

.statement-total strong {
    display: block;
    font-size: 32px;
    line-height: 1.1;
    margin: 6px 0;
}

.statement-print-body {
    background: #eef3f8;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
}

.print-toolbar {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin: 24px auto 14px;
    max-width: 1040px;
    padding: 0 18px;
}

.statement-document {
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(9, 30, 66, 0.16);
    margin: 0 auto 42px;
    max-width: 1040px;
    min-height: 1120px;
    padding: 48px;
}

.statement-document-header,
.statement-title-block {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
}

.statement-brand {
    align-items: center;
    display: flex;
    gap: 12px;
    text-transform: uppercase;
}

.statement-brand small,
.statement-meta span,
.statement-meta small,
.statement-title-block span,
.statement-title-block p,
.statement-footer {
    color: var(--muted);
}

.statement-meta,
.statement-document-total {
    text-align: right;
}

.statement-meta strong,
.statement-document-total strong {
    display: block;
}

.statement-title-block {
    border-bottom: 2px solid #d8e6f8;
    border-top: 2px solid #d8e6f8;
    margin: 34px 0;
    padding: 28px 0;
}

.statement-title-block h1 {
    font-size: 34px;
    margin: 4px 0 8px;
}

.statement-document-total strong {
    font-size: 34px;
}

.statement-section {
    break-inside: avoid;
    margin: 0 0 32px;
}

.statement-section h2 {
    font-size: 18px;
    margin: 0 0 14px;
}

.statement-table {
    border-collapse: collapse;
    min-width: 0;
    width: 100%;
}

.statement-table th,
.statement-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: right;
}

.statement-table th:first-child,
.statement-table td:first-child {
    text-align: left;
}

.statement-table tfoot th {
    color: var(--primary);
    font-size: 16px;
}

.statement-table.compact {
    max-width: 620px;
}

.statement-card-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.statement-detail-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.statement-detail-card h3 {
    font-size: 16px;
    margin: 0 0 12px;
}

.statement-detail-card dl {
    display: grid;
    gap: 8px 12px;
    grid-template-columns: minmax(120px, 1fr) auto;
    margin: 0;
}

.statement-detail-card dt {
    color: var(--muted);
}

.statement-detail-card dd {
    margin: 0;
    text-align: right;
}

.statement-footer {
    border-top: 1px solid var(--line);
    font-size: 12px;
    margin-top: 36px;
    padding-top: 16px;
}

.insights-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.98fr);
    margin-bottom: 24px;
}

.panel {
    overflow: hidden;
}

.panel-heading,
.section-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 18px 22px 0;
}

.panel-heading h2,
.section-heading h2 {
    font-size: 17px;
    margin: 0;
}

.panel-heading-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.detail-value {
    display: inline;
}

.detail-action {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--primary);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    gap: 5px;
    justify-content: center;
    line-height: 1.2;
    min-height: 0;
    padding: 0;
    text-decoration: none;
    transition: color 140ms ease, text-decoration-color 140ms ease;
    white-space: nowrap;
}

.detail-action.compact {
    font-size: 12px;
    margin-top: 0;
    min-height: 0;
    padding: 0;
}

.detail-action:hover,
.detail-action:focus-visible {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--primary-dark);
    outline: 2px solid rgba(18, 58, 130, 0.18);
    outline-offset: 3px;
    text-decoration: underline;
}

.detail-action:active {
    transform: none;
}

.detail-action .chevron {
    height: 6px;
    width: 6px;
}

.deduction-amount .detail-action {
    color: var(--primary);
}

.section-copy {
    color: var(--muted);
    font-size: 14px;
    margin: 6px 0 0;
}

.select-chip {
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    padding: 8px 12px;
}

.chart {
    height: 315px;
    padding: 8px 16px 18px;
}

.chart.fallback-chart {
    align-items: end;
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(5, minmax(74px, 1fr));
    overflow-x: auto;
    padding: 26px 24px 18px;
}

.fallback-bar {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-rows: auto 1fr auto;
    height: 260px;
    justify-items: center;
}

.fallback-track {
    align-items: end;
    border-bottom: 1px solid var(--line);
    display: flex;
    height: 180px;
    justify-content: center;
    width: 100%;
}

.fallback-fill {
    border-radius: 5px 5px 0 0;
    display: block;
    min-height: 0;
    width: 52px;
}

.fallback-fill.blue {
    background: #2b6cb0;
}

.fallback-fill.green {
    background: var(--green);
}

.fallback-fill.orange {
    background: var(--orange);
}

.fallback-fill.purple {
    background: var(--purple);
}

.fallback-fill.teal {
    background: var(--teal);
}

.fallback-value,
.fallback-label {
    color: #344563;
    font-size: 12px;
    text-align: center;
}

.source-list {
    padding: 12px 0;
}

.transaction-results {
    display: grid;
    gap: 26px;
}

.transaction-type-list {
    display: grid;
    gap: 14px;
    padding: 18px 24px 24px;
}

.transaction-type-bar {
    align-items: center;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(210px, 0.8fr) minmax(160px, 1fr) minmax(110px, auto);
    min-height: 48px;
}

.transaction-type-meta {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
}

.transaction-type-meta strong,
.transaction-type-meta small,
.transaction-type-amount strong,
.transaction-type-amount small {
    display: block;
}

.transaction-type-meta small,
.transaction-type-amount small {
    color: var(--muted);
    margin-top: 2px;
}

.transaction-type-track {
    background: #edf2f8;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.transaction-type-fill {
    background: var(--primary);
    border-radius: inherit;
    display: block;
    height: 100%;
}

.transaction-type-fill.green {
    background: var(--green);
}

.transaction-type-fill.orange {
    background: var(--orange);
}

.transaction-type-fill.purple {
    background: var(--purple);
}

.transaction-type-fill.teal {
    background: var(--teal);
}

.transaction-type-amount {
    text-align: right;
}

/* Phone: the three-column type bar (meta | track | amount) has a ~516px minimum
   and no reflow, so on a narrow viewport the amount is pushed off-screen behind
   the panel edge. Stack it - label and amount share the top row, the progress
   track spans full width beneath - so the money is always visible. Matches the
   <=600px point where the transaction table itself collapses to cards. */
@media (max-width: 600px) {
    .transaction-type-bar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "meta amount"
            "track track";
        gap: 4px 14px;
    }

    .transaction-type-meta {
        grid-area: meta;
    }

    .transaction-type-amount {
        grid-area: amount;
    }

    .transaction-type-track {
        grid-area: track;
    }
}

.source-row {
    align-items: center;
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-left: 0;
    border-right: 0;
    border-top: 0;
    color: inherit;
    cursor: default;
    display: grid;
    gap: 14px;
    grid-template-columns: 48px minmax(0, 1fr) auto minmax(138px, auto);
    min-height: 68px;
    padding: 0 20px;
    text-align: left;
    width: 100%;
}

.source-row:last-child {
    border-bottom: 0;
}

button.source-row {
    cursor: pointer;
}

button.source-row:hover {
    background: #f7fbff;
}

button.source-row[aria-expanded="true"] {
    background: #f1f7ff;
}

.source-action {
    align-items: center;
    color: var(--primary);
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 8px;
    justify-content: flex-end;
    white-space: nowrap;
}

.source-action.muted {
    color: #5c6a80;
}

.chevron {
    border-bottom: 2px solid currentColor;
    border-right: 2px solid currentColor;
    display: inline-block;
    height: 8px;
    transform: rotate(-45deg);
    transition: transform 160ms ease;
    width: 8px;
}

button.source-row[aria-expanded="true"] .chevron {
    transform: rotate(45deg);
}

.source-row strong,
.source-row small {
    display: block;
}

.source-row small {
    color: var(--muted);
    font-size: 13px;
}

.source-icon {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    height: 40px;
    justify-content: center;
    width: 40px;
}

.source-icon.blue {
    background: #e7f0ff;
    color: var(--primary);
}

.source-icon.green {
    background: #e8f8ee;
    color: var(--green);
}

.source-icon.orange {
    background: #fff0e7;
    color: var(--orange);
}

.source-icon.purple {
    background: #f3e9ff;
    color: var(--purple);
}

.source-icon.teal {
    background: #e7f8fa;
    color: var(--teal);
}

.source-total {
    text-align: right;
}

.breakdown-panel {
    animation: reveal-panel 180ms ease-out;
    margin-bottom: 26px;
}

.breakdown-panel[hidden] {
    display: none;
}

.breakdown-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 18px 22px 22px;
}

.breakdown-grid.compact {
    grid-template-columns: minmax(260px, 420px);
}

.breakdown-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.breakdown-card h3 {
    font-size: 17px;
    margin: 0 0 14px;
}

.breakdown-card dl {
    display: grid;
    gap: 9px 14px;
    grid-template-columns: minmax(130px, 1fr) auto;
    margin: 0;
}

.breakdown-card dt {
    color: var(--muted);
}

.breakdown-card dd {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    justify-content: flex-end;
    margin: 0;
    text-align: right;
}

.deduction-amount {
    color: var(--red);
}

.breakdown-reconciliation {
    align-items: center;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1fr);
    margin: 0 22px 22px;
    padding-top: 20px;
}

.breakdown-reconciliation h3 {
    font-size: 17px;
    margin: 0 0 6px;
}

.breakdown-reconciliation p {
    color: var(--muted);
    margin: 0;
}

.breakdown-reconciliation dl {
    background: #fbfcff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px 16px;
    grid-template-columns: minmax(180px, 1fr) auto;
    margin: 0;
    padding: 16px;
}

.breakdown-reconciliation dt {
    color: var(--muted);
}

.breakdown-reconciliation dd {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    justify-content: flex-end;
    margin: 0;
    text-align: right;
}

.breakdown-reconciliation dd .detail-action {
    margin-top: 0;
}

.breakdown-reconciliation dt:last-of-type,
.breakdown-reconciliation dd:last-of-type {
    border-top: 1px solid var(--line);
    color: var(--text);
    padding-top: 12px;
}

/* The two-column reconciliation needs ~522px, but the sidebar already narrows at
   1180px. Collapse to one column from there (mirroring .insights-grid) so the
   amount column isn't clipped inside the overflow:hidden panel in the 821-1180
   band when the calculation is expanded. */
@media (max-width: 1180px) {
    .breakdown-reconciliation {
        grid-template-columns: 1fr;
    }
}

.breakdown-empty {
    align-items: center;
    display: flex;
    gap: 18px;
    padding: 22px 24px 26px;
}

.breakdown-empty h3 {
    font-size: 18px;
    margin: 0 0 6px;
}

.breakdown-empty p {
    color: var(--muted);
    margin: 0;
    max-width: 720px;
}

.breakdown-table-wrap {
    border-top: 1px solid var(--line);
    margin: 0 24px 24px;
    overflow-x: auto;
}

.breakdown-table {
    border-collapse: collapse;
    min-width: 0;
    width: 100%;
}

.breakdown-table th,
.breakdown-table td {
    border-bottom: 1px solid var(--line);
    padding: 13px 0;
    text-align: left;
}

.breakdown-table th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.breakdown-table th:last-child,
.breakdown-table td:last-child {
    text-align: right;
}

@keyframes reveal-panel {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.data-panel {
    margin-bottom: 24px;
    overflow-x: auto;
}

.tabs {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 8px;
    min-width: 780px;
    padding: 0 8px;
}

.tabs button {
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: #344563;
    cursor: pointer;
    min-height: 58px;
    padding: 0 20px;
}

.tabs button.active {
    border-bottom-color: var(--primary);
    color: var(--text);
    font-weight: 800;
}

.tabs button:disabled {
    color: #7d8ca4;
}

.excel-link {
    min-height: 38px;
    padding: 0 15px;
}

.empty {
    color: var(--muted);
    margin: 0;
    padding: 20px 22px;
}

.table-wrap,
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Phone & tablet: collapse a wide data table into one card per row. Each cell
   becomes a labeled key/value line (label from the column header via
   data-label), so financial detail stays readable without a horizontal scroll.
   The breakpoint matches the sidebar/drawer collapse (820px) so the 601-819px
   tablet band gets cards instead of an 880px-min table scrolling sideways.
   Scoped to .dyn-grid so other tables are unaffected. */
@media (max-width: 820px) {
    .table-wrap:has(> .dyn-grid) {
        overflow-x: visible;
    }

    table.dyn-grid {
        display: block;
        min-width: 0;
        width: 100%;
    }

    table.dyn-grid thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    table.dyn-grid tbody,
    table.dyn-grid tfoot {
        display: block;
    }

    table.dyn-grid tbody tr,
    table.dyn-grid tfoot tr {
        display: block;
        background: var(--panel, #fff);
        border: 1px solid var(--line, #d9e3ef);
        border-radius: 12px;
        padding: 6px 14px;
        margin-bottom: 10px;
    }

    /* The totals footer stands out from the per-row cards. */
    table.dyn-grid tfoot tr {
        background: var(--soft, #f2f6fb);
        font-weight: 700;
    }

    table.dyn-grid tbody td,
    table.dyn-grid tfoot td,
    table.dyn-grid tfoot th {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 16px;
        padding: 7px 0;
        border: 0;
        text-align: right;
        min-width: 0;
        /* Values wrap in cards even if the wide-table layout set nowrap. */
        white-space: normal;
    }

    table.dyn-grid tbody td + td,
    table.dyn-grid tfoot th + th,
    table.dyn-grid tfoot td + td {
        border-top: 1px solid var(--line, #edf1f6);
    }

    table.dyn-grid tbody td::before,
    table.dyn-grid tfoot td::before,
    table.dyn-grid tfoot th::before {
        content: attr(data-label);
        flex: 0 0 42%;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--muted, #62748b);
    }

    /* Empty cells collapse away so cards stay compact. */
    table.dyn-grid tbody td:empty,
    table.dyn-grid tfoot th:empty,
    table.dyn-grid tfoot td:empty {
        display: none;
    }
}

table {
    border-collapse: collapse;
    min-width: 880px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 14px 22px;
    text-align: left;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

th {
    color: #4d5c72;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

td {
    color: #1c2f4f;
    font-size: 15px;
}

tbody tr:hover {
    background: #f8fbff;
}

tfoot th {
    color: var(--text);
}

.login-shell {
    display: flex;
    flex-direction: column;
    gap: 22px;
    width: 100%;
    max-width: 384px;
}

.logo {
    max-width: 100%;
}

/* Login: the exact left-nav brand lockup, centred inside the card as a header
   band with a hairline divider beneath it. */
.login-brand {
    align-self: stretch;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    justify-content: center;
    margin-bottom: 4px;
    padding: 0 0 18px;
}

.login-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 6px 22px rgba(8, 22, 47, 0.06);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 30px 28px 28px;
}

.login-form .field {
    display: grid;
    gap: 7px;
}

.login-form .field span {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.login-form .field input {
    background: var(--panel-subtle);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    box-sizing: border-box;
    color: var(--text);
    font-size: 15px;
    padding: 11px 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.login-form .field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    outline: none;
}

.login-submit {
    justify-content: center;
    margin-top: 4px;
    width: 100%;
}

.login-foot {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 12px;
    gap: 6px;
    justify-content: center;
    margin: 0;
    text-align: center;
}

.login-lock {
    font-size: 12px;
    opacity: 0.8;
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 232px minmax(0, 1fr);
    }

    .filter-grid,
    .transaction-filter-grid,
    .transaction-filter-grid.compact,
    .import-upload-card .transaction-filter-grid.compact,
    .statement-filter-grid,
    .summary-grid,
    .metric-grid,
    .insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .more-filters,
    .generate-button {
        width: 100%;
    }

    .import-upload-card .transaction-filter-grid.compact.royalty-import-form-grid {
        grid-template-areas:
            "channel file"
            "notes submit";
        grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1fr);
    }

    .import-submit-cell {
        align-items: end;
    }
}

/* Tablet + narrow-desktop band (≤1180px): keep the statement insight panels
   stacked in a single column. The two-column layout squeezes the "Statement
   Calculation" breakdown panel so narrow that its money column (Artist Net)
   scrolls out of view behind the panel edge; at the 1180px sidebar-narrowing
   breakpoint the two columns also overrun the content width by ~16px. Stacking
   gives the breakdown table the full content width so every amount stays
   visible and nothing overflows. Splits to two columns only once the wide
   sidebar layout gives genuine room (>1180px). */
@media (max-width: 1180px) {
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .app-bar {
        align-items: center;
        background: var(--panel);
        border-bottom: 1px solid var(--line);
        display: flex;
        gap: 12px;
        height: 58px;
        padding: 0 14px;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .sidebar {
        bottom: 0;
        box-shadow: 0 24px 60px rgba(8, 22, 47, 0.28);
        gap: 22px;
        left: 0;
        max-width: 86vw;
        min-height: 100vh;
        overflow-y: auto;
        padding: 22px 16px;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform 240ms ease;
        width: 290px;
        z-index: 70;
    }

    body.nav-open .sidebar {
        transform: none;
    }

    body.nav-open {
        overflow: hidden;
    }

    .nav-scrim {
        background: rgba(9, 17, 30, 0.44);
        border: 0;
        display: block;
        inset: 0;
        position: fixed;
        z-index: 60;
    }

    .nav-scrim[hidden] {
        display: none;
    }

    .page-shell,
    .auth-shell {
        padding: 24px 16px 42px;
    }

    .content-header {
        display: block;
    }

    .header-actions {
        justify-content: flex-start;
        margin-top: 18px;
    }

    .filter-card {
        padding: 18px;
    }

    .filter-grid,
    .transaction-filter-grid,
    .transaction-filter-grid.compact,
    .import-upload-card .transaction-filter-grid.compact,
    .statement-filter-grid,
    .summary-grid,
    .metric-grid,
    .insights-grid,
    .breakdown-grid,
    .breakdown-reconciliation,
    .report-form.compact,
    .login-shell {
        grid-template-columns: 1fr;
    }

    .payment-highlight {
        align-items: stretch;
        flex-direction: column;
    }

    .latest-import-card {
        align-items: stretch;
        flex-direction: column;
    }

    .latest-import-meta {
        align-items: flex-start;
        justify-content: flex-start;
        text-align: left;
    }

    .payment-summary-meta {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding-left: 0;
        padding-top: 20px;
        text-align: left;
    }

    .statement-hero,
    .statement-document-header,
    .statement-title-block {
        align-items: flex-start;
        flex-direction: column;
    }

    .statement-total,
    .statement-meta,
    .statement-document-total {
        text-align: left;
    }

    .statement-card-grid {
        grid-template-columns: 1fr;
    }

    .statement-document {
        padding: 28px 18px;
    }

    .date-field {
        grid-template-columns: 1fr;
    }

    .import-upload-card .transaction-filter-grid.compact.royalty-import-form-grid {
        grid-template-areas:
            "channel"
            "file"
            "notes"
            "submit";
        grid-template-columns: 1fr;
    }

    .import-upload-card .generate-button {
        justify-self: stretch;
        width: 100%;
    }

    .latest-import-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .date-field span {
        display: none;
    }

    .detail-action {
        width: auto;
    }

    .panel-heading-actions {
        align-items: stretch;
    }

    .empty-report {
        min-height: 430px;
    }

    .empty-illustration {
        transform: scale(0.78);
        transform-origin: center;
    }
}

@media (max-width: 520px) {
    .brand-lockup strong {
        font-size: 16px;
    }

    .content-header h1 {
        font-size: 30px;
    }

    .header-actions,
    .header-actions form,
    .content-header .button {
        width: 100%;
    }

    .metric-card {
        min-height: 118px;
        padding: 20px;
    }

    .payment-metric-card {
        align-items: stretch;
        flex-direction: column;
    }

    .payment-metric-card .metric-action,
    .payment-metric-card .button {
        width: 100%;
    }

    .source-row {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .source-total,
    .source-action {
        grid-column: 2;
        text-align: left;
        justify-content: flex-start;
    }

    .panel-heading,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-heading-actions {
        justify-content: flex-start;
    }
}

@media print {
    @page {
        margin: 0.45in;
        size: letter;
    }

    body,
    body.statement-print-body {
        background: #ffffff;
    }

    .sidebar,
    .statement-filter-card,
    .statement-print-action,
    .print-toolbar {
        display: none;
    }

    .app-shell {
        display: block;
    }

    .page-shell {
        padding: 0;
    }

    .content-header {
        margin-bottom: 18px;
    }

    .content-header h1 {
        font-size: 26px;
    }

    .content-header p {
        display: none;
    }

    .panel,
    .metric-card {
        box-shadow: none;
    }

    .chart {
        min-height: 240px;
    }

    .statement-cover,
    .statement-breakdown,
    .insights-grid,
    .statement-summary {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .statement-document {
        box-shadow: none;
        margin: 0;
        max-width: none;
        min-height: 0;
        padding: 0;
    }

    .statement-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .statement-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .statement-detail-card,
    .statement-table th,
    .statement-table td {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* ------------------------------------------------------------------ *
 * Project workspace chrome — the compact header + section button bar
 * shared by a project's pages (Project Details / Budget / Project
 * Experience). Buttons, not tabs: each is a link to its own page, with
 * the current one highlighted. Wraps cleanly on narrow viewports.
 * ------------------------------------------------------------------ */
.pj-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.pj-back { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted);
    font-size: 18px; line-height: 1; text-decoration: none; flex: 0 0 auto; }
.pj-back:hover { color: var(--primary); border-color: var(--primary); }
.pj-cover { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 16px; flex: 0 0 auto;
    background: linear-gradient(150deg, var(--primary), #2e6fd0); }
.pj-name { margin: 0; font-size: 20px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em;
    color: var(--text); min-width: 0; word-break: break-word; }
.pj-artist { color: var(--muted); font-weight: 600; font-size: 14px; }
.pj-artist::before { content: "· "; color: var(--muted); }
.pj-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
    padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.pj-status.live { color: #0f7a3d; background: #e7f9ee; }
.pj-status.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #16a34a; }

.pj-tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    border-bottom: 1px solid var(--line); padding: 0 0 14px; margin: 0 0 20px; }
/* Friendly, tab-like pills with a leading icon. Active tab reads in the brand
   blue (softer than the old near-black), inactive tabs are quiet until hovered. */
.pj-tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted); font-weight: 700;
    font-size: 13.5px; text-decoration: none; white-space: nowrap; transition: border-color .12s, color .12s, background .12s; }
.pj-tab-ic { width: 15px; height: 15px; flex: 0 0 auto; }
.pj-tab:hover:not(.on) { border-color: var(--primary); color: var(--primary); background: var(--panel-subtle); }
.pj-tab.on { background: #eef3fb; border-color: var(--primary); color: var(--primary); }
.pj-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
