.invoice-attachments-page {
    display: grid;
    gap: 0.8rem;
    color: var(--page-text);
    --invoice-card-bg: color-mix(in srgb, var(--surface-bg) 96%, transparent);
    --invoice-card-border: var(--surface-border);
    --invoice-card-shadow: var(--surface-shadow);
    --invoice-muted: var(--nav-muted);
    --invoice-table-header-bg: var(--header-bg);
    --invoice-table-header-text: var(--header-text);
    --invoice-row-border: var(--surface-border);
    --invoice-row-alt-bg: var(--surface-soft);
    --invoice-row-highlight-bg: var(--surface-alt);
    --invoice-link: var(--link-color);
    --invoice-empty-bg: var(--surface-soft);
    --invoice-empty-text: var(--nav-muted);
    --invoice-error-bg: rgba(127, 29, 29, 0.12);
    --invoice-error-border: rgba(239, 68, 68, 0.24);
    --invoice-error-text: #b91c1c;
    --invoice-control-bg: var(--surface-bg);
    --invoice-control-text: var(--page-text);
    --invoice-control-placeholder: var(--nav-muted);
    --invoice-control-focus: var(--nav-accent);
}

.invoice-attachments-hero,
.invoice-attachments-card {
    border: 1px solid var(--invoice-card-border);
    border-radius: 1rem;
    background: var(--invoice-card-bg);
    box-shadow: var(--invoice-card-shadow);
}

.invoice-attachments-hero {
    padding: clamp(0.85rem, 1.5vw, 1.15rem);
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--nav-accent) 18%, transparent), transparent 34rem),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-bg) 92%, var(--surface-soft)) 0%, var(--surface-bg) 100%);
}

.invoice-attachments-hero-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.invoice-attachments-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--nav-accent);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    font-weight: 800;
}

.invoice-attachments-hero h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.2vw, 2rem);
    line-height: 1.05;
}

.invoice-attachments-hero p {
    margin: 0.4rem 0 0;
    color: var(--invoice-muted);
    max-width: 68ch;
    line-height: 1.45;
}

.invoice-attachments-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.55rem;
    margin-top: 0.9rem;
}

.invoice-attachments-stat {
    display: grid;
    gap: 0.1rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.85rem;
    border: 1px solid var(--invoice-card-border);
    background: var(--surface-soft);
}

.invoice-attachments-stat span {
    color: var(--invoice-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.invoice-attachments-stat strong {
    font-size: 1rem;
    line-height: 1.1;
}

.invoice-attachments-card {
    padding: clamp(0.75rem, 1.2vw, 1rem);
}

.invoice-attachments-company-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.invoice-attachments-company-meta {
    display: grid;
    gap: 0.15rem;
}

.invoice-attachments-company-meta h2 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.2;
}

.invoice-attachments-company-meta span {
    color: var(--invoice-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.invoice-attachments-filters {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.35fr) auto;
    gap: 0.7rem;
    align-items: end;
}

.invoice-attachments-field {
    display: grid;
    gap: 0.3rem;
}

.invoice-attachments-field-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--invoice-muted);
}

.invoice-control {
    width: 100%;
    min-height: 2.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.8rem;
    border: 1px solid var(--invoice-card-border);
    background: var(--invoice-control-bg);
    color: var(--invoice-control-text);
    font: inherit;
    box-sizing: border-box;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.invoice-control.e-input-group,
.invoice-control.e-control-wrapper,
.invoice-control.e-ddl,
.invoice-control.e-multi-select-wrapper {
    width: 100%;
}

.invoice-control::placeholder {
    color: var(--invoice-control-placeholder);
}

.invoice-control:focus,
.invoice-control:focus-visible {
    outline: none;
    border-color: var(--invoice-control-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--invoice-control-focus) 24%, transparent);
}

.invoice-attachments-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.invoice-attachments-filter-note {
    margin-top: 0.55rem;
    color: var(--invoice-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.invoice-button {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    min-height: 2.65rem;
    padding: 0.5rem 0.85rem;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.invoice-button:hover {
    transform: translateY(-1px);
}

.invoice-button:focus,
.invoice-button:focus-visible {
    outline: none;
    transform: none;
}

.invoice-button-primary {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.invoice-button-primary:disabled {
    opacity: 0.65;
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

.invoice-button-secondary {
    color: var(--page-text);
    background: linear-gradient(180deg, var(--surface-bg), var(--surface-soft));
    border-color: var(--invoice-card-border);
}

.invoice-button-secondary:disabled {
    opacity: 0.65;
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

.invoice-attachment-detail-page {
    display: grid;
    gap: 0.8rem;
    color: var(--page-text);
}

.invoice-attachment-detail-card {
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--surface-bg) 96%, transparent);
    box-shadow: var(--surface-shadow);
    padding: clamp(0.75rem, 1.2vw, 1rem);
}

.invoice-attachment-detail-toolbar-card {
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--nav-accent) 16%, transparent), transparent 28rem),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-bg) 94%, var(--surface-soft)) 0%, var(--surface-bg) 100%);
}

.invoice-attachment-detail-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.invoice-attachment-detail-title-block {
    display: grid;
    gap: 0.2rem;
}

.invoice-attachment-detail-toolbar-actions {
    display: flex;
    justify-content: flex-start;
}

.invoice-attachment-detail-toolbar h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 1.85rem);
    line-height: 1.08;
}

.invoice-attachment-detail-empty,
.invoice-attachment-detail-error {
    border-radius: 0.95rem;
    padding: 0.9rem 1rem;
}

.invoice-attachment-detail-empty {
    background: var(--surface-soft);
    color: var(--nav-muted);
}

.invoice-attachment-detail-error {
    background: rgba(127, 29, 29, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.24);
    color: #b91c1c;
}

.invoice-attachment-detail-grid .e-toolbar {
    padding: 0.25rem 0.35rem;
    min-height: 2.35rem;
}

.invoice-attachment-detail-grid .e-toolbar .e-input-group,
.invoice-attachment-detail-grid .e-toolbar .e-search,
.invoice-attachment-detail-grid .e-toolbar input {
    min-height: 2rem;
}

.invoice-attachment-detail-grid .e-gridheader th,
.invoice-attachment-detail-grid .e-gridcontent td {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0.82rem;
}

.invoice-attachments-scroll {
    overflow-x: auto;
    border-radius: 0.85rem;
    border: 1px solid var(--invoice-card-border);
    background: var(--surface-bg);
    scrollbar-color: var(--nav-muted) transparent;
}

.invoice-attachments-grid {
    width: 100%;
    min-width: 0;
}

.invoice-grid-shell {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    scrollbar-color: var(--nav-muted) transparent;
}

.invoice-grid-shell .e-grid {
    width: 100%;
}

.invoice-attachments-grid-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.55rem;
}

.invoice-attachments-grid .e-toolbar {
    padding: 0.25rem 0.35rem;
    min-height: 2.35rem;
}

.invoice-attachments-grid .e-toolbar .e-input-group,
.invoice-attachments-grid .e-toolbar .e-search,
.invoice-attachments-grid .e-toolbar input {
    min-height: 2rem;
}

.invoice-attachments-grid .e-gridheader th,
.invoice-attachments-grid .e-gridcontent td {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0.82rem;
}

.invoice-attachments-grid .e-gridheader th.invoice-attachments-month,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-month,
.invoice-attachments-grid .e-gridheader th.invoice-attachments-count,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-count {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.invoice-attachments-grid .e-gridheader th.invoice-attachments-year,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-year {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    background: color-mix(in srgb, var(--invoice-row-highlight-bg) 60%, transparent);
}

.invoice-attachments-grid .e-gridheader th.invoice-attachments-month,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-month {
    min-width: 52px;
    font-weight: 800;
}

.invoice-attachments-grid .e-gridheader th.invoice-attachments-highlight,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-highlight {
    background: var(--invoice-row-highlight-bg);
}

.invoice-attachments-grid .e-gridheader th.invoice-attachments-year-end,
.invoice-attachments-grid .e-gridcontent td.invoice-attachments-year-end {
    border-right: 2px solid var(--invoice-row-border);
}

.invoice-attachments-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: separate;
    border-spacing: 0;
}

.invoice-attachments-table th,
.invoice-attachments-table td {
    padding: 0.48rem 0.65rem;
    border-bottom: 1px solid var(--invoice-row-border);
    white-space: nowrap;
    font-size: 0.92rem;
}

.invoice-attachments-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--invoice-table-header-bg);
    color: var(--invoice-table-header-text);
    text-align: left;
}

.invoice-sort-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.invoice-sort-button:hover,
.invoice-sort-button:focus-visible {
    outline: none;
    color: var(--invoice-link);
}

.invoice-sort-state {
    color: var(--invoice-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.invoice-attachments-table thead tr:first-child th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.invoice-attachments-table thead th.invoice-attachments-month,
.invoice-attachments-table td.invoice-attachments-count {
    text-align: center;
    min-width: 58px;
    font-variant-numeric: tabular-nums;
}

.invoice-attachments-table tbody tr:nth-child(even) {
    background: var(--invoice-row-alt-bg);
}

.invoice-attachments-table tbody tr:hover {
    background: var(--invoice-row-highlight-bg);
}

.invoice-attachments-company {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
}

.invoice-attachments-company-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.invoice-attachments-company-header h2 {
    margin: 0;
    font-size: 0.98rem;
}

.invoice-attachments-pill {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--invoice-card-border);
    color: var(--invoice-muted);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.invoice-attachments-count-link {
    color: var(--invoice-link);
    font-weight: 800;
    text-decoration: none;
}

.invoice-attachments-count-link:hover {
    text-decoration: underline;
}

.invoice-attachments-highlight {
    background: var(--invoice-row-highlight-bg);
}

.invoice-attachments-year-end {
    border-right: 2px solid var(--invoice-row-border);
}

.invoice-attachments-empty,
.invoice-attachments-error {
    border-radius: 0.95rem;
    padding: 0.9rem 1rem;
}

.invoice-attachments-empty {
    background: var(--invoice-empty-bg);
    color: var(--invoice-empty-text);
}

.invoice-attachments-error {
    background: var(--invoice-error-bg);
    border: 1px solid var(--invoice-error-border);
    color: var(--invoice-error-text);
}

html[data-theme="dark"] .invoice-attachments-page {
    --invoice-card-bg: rgba(15, 23, 42, 0.9);
    --invoice-error-bg: rgba(127, 29, 29, 0.45);
    --invoice-error-border: rgba(248, 113, 113, 0.38);
    --invoice-error-text: #fecaca;
    --invoice-control-bg: rgba(15, 23, 42, 0.98);
    --invoice-control-placeholder: #94a3b8;
}

html[data-theme="dark"] .invoice-attachment-detail-page {
    color: var(--page-text);
}

html[data-theme="dark"] .invoice-attachment-detail-card {
    background: rgba(15, 23, 42, 0.9);
}

html[data-theme="dark"] .invoice-attachment-detail-error {
    background: rgba(127, 29, 29, 0.45);
    border-color: rgba(248, 113, 113, 0.38);
    color: #fecaca;
}

@media (max-width: 960px) {
    .invoice-attachments-filters {
        grid-template-columns: 1fr;
    }

    .invoice-attachments-actions {
        justify-content: flex-start;
    }

    .invoice-attachment-detail-toolbar {
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .invoice-attachments-card {
        padding: 0.95rem;
    }

    .invoice-attachments-company-header {
        align-items: flex-start;
    }

    .invoice-attachment-detail-card {
        padding: 0.95rem;
    }
}
