:root {
    --bg: #f3f7fb;
    --surface: #ffffff;
    --surface-alt: #eef4ff;
    --text: #14213d;
    --muted: #52607a;
    --line: #d7e0ef;
    --primary: #0f6fff;
    --primary-soft: #dcebff;
    --danger: #cf334d;
    --danger-soft: #ffe2e8;
    --sidebar-bg: #0f172a;
    --sidebar-text: #e5eefc;
    --font-family: Inter, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background:
        radial-gradient(circle at top left, rgba(15, 111, 255, 0.12) 0, transparent 28%),
        radial-gradient(circle at bottom right, rgba(15, 111, 255, 0.08) 0, transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

button,
.button {
    border: 0;
    border-radius: 999px;
    padding: 0.85rem 1.25rem;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button.secondary {
    background: var(--surface-alt);
    color: var(--text);
}

img {
    max-width: 100%;
    display: block;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    font: inherit;
    color: var(--text);
}

label span {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
    color: var(--muted);
}

small {
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem 0.8rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-card,
.card,
.stat-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(215, 224, 239, 0.9);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(460px, 100%);
    padding: 2rem;
    border-radius: 28px;
    display: grid;
    gap: 1.5rem;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-lockup-logo-only {
    justify-content: center;
    position: relative;
}

.brand-lockup-logo-only::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5.75rem;
    height: 5.75rem;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.14);
    z-index: 0;
}

.brand-lockup-logo-only .brand-logo,
.brand-lockup-logo-only .brand-mark {
    width: 5.75rem;
    height: 5.75rem;
    position: relative;
    z-index: 1;
}

.brand-lockup-logo-only .brand-logo {
    padding: 0.45rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: none;
    border-radius: 999px;
    overflow: hidden;
}

.compact-brand.brand-lockup-logo-only .brand-logo,
.compact-brand.brand-lockup-logo-only .brand-mark {
    width: 4.5rem;
    height: 4.5rem;
}

.compact-brand.brand-lockup-logo-only::before {
    width: 4.5rem;
    height: 4.5rem;
}

.brand-mark {
    width: 3rem;
    height: 3rem;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, #63a4ff 100%);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-mark.is-empty::after {
    content: '';
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    display: block;
}

.brand-logo {
    width: 3.25rem;
    height: 3.25rem;
    object-fit: contain;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.35rem;
}

.compact-brand .brand-logo,
.compact-brand .brand-mark {
    width: 2.4rem;
    height: 2.4rem;
}

.layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 2rem 1.2rem;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    margin-bottom: 1.6rem;
}

.sidebar nav {
    display: grid;
    gap: 0.6rem;
    margin-top: 2rem;
}

.sidebar a {
    color: rgba(229, 238, 252, 0.82);
    padding: 0.8rem 1rem;
    border-radius: 14px;
}

.sidebar a.active,
.sidebar a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.content {
    padding: 2rem;
    display: grid;
    gap: 1.5rem;
}

.page-header,
.section-heading,
.header-actions,
.grid-two,
.stats-grid,
.stack-md {
    display: grid;
    gap: 1rem;
}

.section-heading-inline {
    grid-template-columns: 1fr auto;
    align-items: end;
}

.page-header {
    grid-template-columns: 1fr auto;
    align-items: end;
}

.header-actions {
    grid-auto-flow: column;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.profit-summary-grid,
.profit-breakdown {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.profit-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1rem;
}

.grid-two {
    grid-template-columns: 1.4fr 0.8fr;
}

.vendor-overview-grid {
    align-items: start;
}

.vendor-summary-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    height: var(--vendor-summary-card-height, auto);
}

.vendor-summary-card {
    overflow: hidden;
}

.vendor-total-card {
    display: grid;
    align-content: start;
}

.card {
    padding: 1.4rem;
    border-radius: 26px;
}

.stat-card {
    padding: 1.2rem;
    border-radius: 22px;
}

.stat-card span,
.eyebrow,
.table-subtitle,
.muted-box,
.total-chip {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 0.5rem;
    font-size: 1.8rem;
}

.eyebrow {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
}

.muted-box {
    padding: 1rem;
    border-radius: 18px;
    background: var(--surface-alt);
}

.info-card {
    padding: 1rem 1.1rem;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--surface-alt) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 1px solid var(--line);
}

.field-help {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.file-upload-field {
    display: grid;
    gap: 0.65rem;
    align-content: start;
}

.file-upload-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0.1px;
    height: 0.1px;
}

.file-upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0.9rem 1.1rem;
    border-radius: 18px;
    border: 1px dashed var(--line);
    background: linear-gradient(135deg, var(--surface-alt) 0%, rgba(255, 255, 255, 0.96) 100%);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.file-upload-field:hover .file-upload-button {
    transform: translateY(-1px);
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(15, 111, 255, 0.14);
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 16px;
}

.alert.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert.success {
    background: #dff3e4;
    color: #1b5e20;
}

.total-chip {
    background: var(--primary-soft);
    padding: 0.8rem 1rem;
    border-radius: 999px;
    font-weight: 600;
}

.metric-stack {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.metric-label {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-value {
    font-size: clamp(1.15rem, 2vw, 1.6rem);
}

.profit-total {
    font-size: clamp(1.35rem, 2.4vw, 2rem);
}

.profit-stack {
    display: flex;
    overflow: hidden;
    min-height: 1rem;
    margin-top: 1rem;
    border-radius: 999px;
    background: rgba(215, 224, 239, 0.72);
}

.profit-segment {
    min-width: 0;
}

.profit-segment.is-tax {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.profit-segment.is-commission {
    background: linear-gradient(90deg, #0f6fff 0%, #63a4ff 100%);
}

.profit-segment.is-profit {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.profit-legend {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.profit-legend div {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.settlement-summary-grid {
    margin-bottom: 1rem;
}

.settlement-stack {
    display: flex;
    overflow: hidden;
    min-height: 1rem;
    margin-top: 1rem;
    border-radius: 999px;
    background: rgba(215, 224, 239, 0.72);
}

.settlement-segment {
    min-width: 0;
}

.settlement-segment.is-paid {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.settlement-segment.is-pending {
    background: linear-gradient(90deg, #0f6fff 0%, #63a4ff 100%);
}

.settlement-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.settlement-legend div {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.settlement-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.settlement-filter-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-alt);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.settlement-filter-link strong {
    font-size: 0.9rem;
}

.settlement-filter-link.is-active {
    background: linear-gradient(135deg, rgba(15, 111, 255, 0.12) 0%, rgba(15, 111, 255, 0.2) 100%);
    border-color: rgba(15, 111, 255, 0.3);
    color: #0f4db8;
}

.settlement-filter-caption {
    margin-bottom: 1rem;
}

.inline-link {
    color: #0f4db8;
    font-weight: 600;
    text-decoration: none;
}

.inline-link:hover {
    text-decoration: underline;
}

.pending-settlement-panel {
    margin-top: 1.5rem;
    padding: 1.1rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(244, 248, 255, 0.88) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.pending-settlement-total {
    font-size: 1.25rem;
    color: #0f4db8;
}

.pending-settlement-chart {
    display: grid;
    gap: 0.85rem;
}

.pending-settlement-item {
    display: grid;
    gap: 0.45rem;
}

.pending-settlement-actions {
    display: flex;
    justify-content: flex-end;
}

.pending-settlement-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.pending-settlement-meta strong {
    font-size: 0.96rem;
}

.pending-settlement-meta span {
    color: var(--muted);
    font-size: 0.92rem;
}

.pending-settlement-track {
    overflow: hidden;
    min-height: 0.85rem;
    border-radius: 999px;
    background: rgba(186, 204, 235, 0.36);
}

.pending-settlement-bar {
    display: block;
    min-inline-size: 0.85rem;
    block-size: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #0f6fff 0%, #63a4ff 100%);
}

.vendor-profit-list {
    display: grid;
    gap: 1rem;
}

.vendor-profit-item {
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(238, 244, 255, 0.96) 100%);
}

.vendor-profit-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.vendor-profit-amount {
    font-size: 1.2rem;
}

.vendor-profit-bar {
    margin-top: 0.85rem;
}

.vendor-profit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.legend-dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 999px;
    flex: 0 0 auto;
}

.legend-dot.is-tax {
    background: #f59e0b;
}

.legend-dot.is-commission {
    background: #0f6fff;
}

.legend-dot.is-profit {
    background: #10b981;
}

.scroll-panel {
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 111, 255, 0.45) rgba(220, 235, 255, 0.8);
}

.scroll-panel::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.scroll-panel::-webkit-scrollbar-track {
    background: rgba(220, 235, 255, 0.75);
    border-radius: 999px;
}

.scroll-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(15, 111, 255, 0.72) 0%, rgba(15, 111, 255, 0.42) 100%);
    border-radius: 999px;
    border: 2px solid rgba(220, 235, 255, 0.75);
}

.vendor-summary-card .monthly-summary-panel {
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0.35rem;
}

.vendor-summary-card .monthly-summary-panel table {
    table-layout: fixed;
    width: 100%;
    margin-right: 0.25rem;
}

.vendor-summary-card .monthly-summary-panel th,
.vendor-summary-card .monthly-summary-panel td {
    white-space: normal;
    word-break: break-word;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    align-items: end;
}

.dashboard-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.clients-filter-grid {
    grid-template-columns: 1.4fr 1fr 1fr auto;
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 56px;
}

.checkbox-field.top-aligned {
    align-items: flex-start;
    padding-top: 2rem;
}

.checkbox-field input {
    width: auto;
}

.logo-preview-card {
    display: grid;
    gap: 0.75rem;
    align-content: start;
    padding: 1rem;
    border-radius: 18px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.logo-preview-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.logo-preview-image {
    width: 6rem;
    height: 6rem;
    border-radius: 999px;
    padding: 0.55rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.actions-cell {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    margin: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-pill.is-active {
    background: #def7e8;
    color: #166534;
}

.status-pill.is-inactive {
    background: #e5e7eb;
    color: #475569;
}

.status-pill.is-paid {
    background: #dcfce7;
    color: #166534;
}

.status-pill.is-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-pill.is-period-production {
    background: rgba(15, 111, 255, 0.12);
    color: #0f4db8;
}

.status-pill.is-period-maintenance {
    background: rgba(16, 185, 129, 0.14);
    color: #0f766e;
}

.sales-period-match {
    background: linear-gradient(90deg, rgba(15, 111, 255, 0.08) 0%, rgba(255, 255, 255, 0.96) 22%);
}

.sales-period-match td:first-child {
    border-inline-start: 3px solid rgba(15, 111, 255, 0.45);
}

.period-flag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.mini-stat {
    padding: 1rem;
    border-radius: 18px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

.mini-stat.is-warning {
    background: linear-gradient(180deg, rgba(255, 226, 232, 0.85) 0%, rgba(255, 245, 247, 0.98) 100%);
    border-color: rgba(207, 51, 77, 0.28);
}

.mini-stat.is-warning span,
.mini-stat.is-warning strong {
    color: var(--danger);
}

.mini-stat span {
    color: var(--muted);
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.86rem;
}

.mini-stat strong {
    font-size: 1.35rem;
}

.align-end {
    align-self: end;
}

.actions-row {
    display: flex;
    gap: 0.65rem;
    margin-top: 0.4rem;
}

.settlement-grid {
    align-items: start;
}

.settings-grid {
    align-items: start;
}

.preview-card {
    position: sticky;
    top: 1rem;
}

.preview-shell {
    padding: 1rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(15, 111, 255, 0.08) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 1px solid var(--line);
}

.preview-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.preview-card-body {
    display: grid;
    gap: 0.8rem;
}

.preview-card h3 {
    margin: 0;
    font-size: 1.45rem;
}

.preview-warning {
    display: none;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(207, 51, 77, 0.18);
    margin-bottom: 1rem;
}

.preview-warning.is-visible {
    display: block;
}

.print-page {
    background: #eef3fb;
}

.print-sheet {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    gap: 1.25rem;
}

.print-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.print-actions {
    display: flex;
    gap: 0.75rem;
}

.print-card {
    background: #fff;
}

@media print {
    .no-print {
        display: none !important;
    }

    .print-page {
        background: #fff;
    }

    .print-sheet {
        max-width: none;
        padding: 0;
    }

    .card,
    .mini-stat {
        box-shadow: none;
    }
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
}

.link-button.danger {
    color: var(--danger);
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .sidebar {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 20;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sidebar nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        margin-top: 1rem;
        padding-bottom: 0.4rem;
    }

    .stats-grid,
    .grid-two,
    .profit-summary-grid,
    .profit-breakdown,
    .profit-legend,
    .settlement-legend,
    .page-header,
    .two-columns,
    .settings-grid,
    .filter-grid,
    .report-summary-grid,
    .section-heading-inline {
        grid-template-columns: 1fr;
    }

    .header-actions {
        grid-auto-flow: row;
    }

    .vendor-profit-head {
        flex-direction: column;
    }

    .content {
        padding: 1rem;
    }

    .vendor-summary-card,
    .vendor-total-card {
        height: auto;
    }

    .auth-page {
        padding: 1rem;
    }

    .auth-card,
    .card,
    .stat-card {
        border-radius: 22px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 0.9rem;
    }

    tr {
        padding: 0.95rem 1rem;
        border: 1px solid var(--line);
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.92);
    }

    td {
        border-bottom: 0;
        padding: 0.55rem 0;
        text-align: left;
        display: grid;
        grid-template-columns: minmax(110px, 42%) 1fr;
        gap: 0.8rem;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .actions-cell {
        justify-content: flex-start;
    }

    .actions-cell form {
        margin: 0;
    }

    .preview-card {
        position: static;
    }

    .brand-lockup {
        align-items: flex-start;
    }

    .page-header {
        align-items: start;
    }
}