:root {
    --bg: #f2f5f6;
    --surface: #ffffff;
    --surface-muted: #f5f5f5;
    --border: #e3e9eb;
    --text: #0b0f12;
    --text-soft: #2e3a40;
    --muted: #718e9c;
    --label: #8aa0aa;
    --primary: #1f3893;
    --primary-hover: #172b73;
    --brand-green: #27f47a;
    --positive: #007f62;
    --danger: #d6336c;
    --radius-card: 16px;
    --radius-control: 12px;
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.06);
    --font: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-figures: 'Oxanium', var(--font);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

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

[hidden] {
    display: none !important;
}

button {
    font: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius-control);
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition:
        background-color 0.15s ease,
        opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-light {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-soft);
}

.btn-light:hover {
    background: #fafbfb;
}

.btn-block {
    width: 100%;
    padding: 20px 14px;
    font-size: 18px;
}

/* ---------- Auth pages ---------- */

.auth-body {
    background: var(--surface);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 32px;
}

.site-logo img {
    display: block;
    height: 30px;
    width: auto;
}

.site-header-link {
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--text);
    color: #ffffff;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1fr minmax(320px, 480px);
    align-items: center;
    gap: 48px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 48px 32px 80px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    border: 2px solid #9be7b8;
    border-radius: 999px;
    font-size: 20px;
    font-weight: 500;
}

.pill svg {
    width: 26px;
    height: 26px;
}

.hero-title {
    margin: 32px 0 0;
    font-size: clamp(56px, 9vw, 112px);
    line-height: 0.98;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.hero-title .dot {
    color: var(--brand-green);
}

.auth-card {
    background: var(--surface);
    border: 1px solid #e6e6e6;
    border-radius: 28px;
    padding: 36px 34px 30px;
}

.auth-title {
    margin: 0 0 24px;
    font-size: 40px;
    font-weight: 500;
    letter-spacing: -0.03em;
}

.auth-text {
    margin: -8px 0 24px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field-label {
    display: block;
    margin-bottom: 12px;
    font-size: 16px;
}

.field input {
    width: 100%;
    height: 54px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: var(--surface-muted);
    font: 500 16px var(--font);
    color: var(--text);
    outline: none;
}

.field input:focus {
    border-color: var(--primary);
    background: var(--surface);
}

.password-input {
    position: relative;
    display: block;
}

.password-input input {
    padding-right: 56px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #555;
    cursor: pointer;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
}

.forgot-link {
    display: block;
    margin: -6px 0 28px;
    text-align: right;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 16px;
}

.forgot-link:hover {
    text-decoration: underline;
}

.captcha {
    display: flex;
    justify-content: center;
    min-height: 65px;
    margin-bottom: 22px;
}

.form-error,
.notice {
    margin: 0 0 18px;
    padding: 12px 16px;
    border-radius: var(--radius-control);
    font-size: 15px;
    line-height: 1.4;
}

.form-error {
    background: #ffe8ef;
    color: #9c1c45;
}

.notice {
    background: #e7f8ee;
    color: #0f5a3b;
}

.auth-footer {
    margin: 26px 0 0;
    text-align: center;
    font-size: 17px;
    color: var(--text-soft);
}

.auth-footer a {
    font-weight: 600;
    text-decoration: none;
}

.password-rules {
    margin: -6px 0 22px;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
    font-size: 14px;
    color: var(--muted);
}

.password-rules li::before {
    content: '○';
    display: inline-block;
    width: 20px;
}

.password-rules li.is-met {
    color: var(--positive);
}

.password-rules li.is-met::before {
    content: '✓';
}

/* ---------- Panel ---------- */

.loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #d7e0e3;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    min-height: 100vh;
    padding: 20px 24px 20px 20px;
}

.sidebar {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    width: 220px;
    height: calc(100vh - 40px);
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius-card);
    transition: width 0.25s ease;
}

.sidebar-logo {
    display: flex;
    justify-content: center;
    margin: 6px 0 32px;
}

.sidebar-logo .logo-full {
    width: 140px;
    height: auto;
}

.sidebar-logo .logo-mark {
    display: none;
    width: 40px;
    height: 40px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.nav-item img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover,
.nav-item.is-active {
    background: var(--bg);
}

.collapse-btn {
    margin-top: auto;
    align-self: flex-end;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    color: var(--text);
}

.collapse-btn:hover {
    background: var(--bg);
}

.collapse-btn svg {
    width: 22px;
    height: 22px;
    transition: transform 0.25s ease;
}

.app.is-collapsed .sidebar {
    width: 88px;
}

.app.is-collapsed .logo-full,
.app.is-collapsed .nav-item span {
    display: none;
}

.app.is-collapsed .logo-mark {
    display: block;
}

.app.is-collapsed .nav-item {
    justify-content: center;
}

.app.is-collapsed .collapse-btn {
    align-self: center;
}

.app.is-collapsed .collapse-btn svg {
    transform: rotate(180deg);
}

.main {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 21px 4px 28px;
}

.welcome {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.welcome-sub {
    margin: 0 0 4px;
    font-size: 14px;
    color: #757575;
}

.welcome-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    gap: 16px;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.icon-btn:hover {
    box-shadow: var(--shadow-soft);
}

.icon-btn img {
    width: 22px;
    height: 22px;
}

.banner {
    margin: 0 0 20px;
    padding: 14px 18px;
    border-radius: var(--radius-card);
    background: #e8eeff;
    color: #1d2f6f;
    font-size: 15px;
    line-height: 1.45;
}

.ops-view-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 0 0 20px;
    padding: 12px 18px;
    border: 1px solid #f0c36a;
    border-radius: var(--radius-card);
    background: #fff4d6;
    color: #6b4a00;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
}

.ops-view-banner a {
    color: inherit;
    white-space: nowrap;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tabs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border-bottom: 2px solid #dde4e6;
}

.tab {
    margin-bottom: -2px;
    padding: 10px 14px 14px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    font-size: 22px;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
}

.tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tabs-note {
    margin: 0 0 14px auto;
    font-size: 13px;
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 24px 28px;
}

.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.card-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.card-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1.15fr repeat(3, 1fr);
    gap: 12px;
}

.stat {
    display: flex;
    flex-direction: column;
    min-height: 168px;
    padding: 22px 24px;
}

.stat-hero {
    grid-row: span 2;
    justify-content: space-between;
}

.stat-label {
    margin: 0;
    font-size: 17px;
    font-weight: 500;
    color: var(--text-soft);
}

.stat-value {
    margin: auto 0;
    padding-top: 12px;
    text-align: center;
    font-size: clamp(34px, 3.4vw, 52px);
    font-weight: 600;
    letter-spacing: -0.03em;
}

.stat-hero-value {
    margin: 0;
    text-align: center;
    font-family: var(--font-figures);
    font-size: clamp(48px, 5vw, 76px);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.stat-note {
    margin: 8px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

.hero-split {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.hero-split div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.hero-split dt {
    color: var(--muted);
}

.hero-split dd {
    margin: 0;
    font-weight: 600;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.table th {
    padding: 0 12px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--label);
    white-space: nowrap;
}

.table td {
    padding: 14px 12px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
}

.table .num {
    text-align: right;
}

.table tfoot td {
    font-weight: 700;
}

.chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    background: var(--bg);
    color: #5b7480;
}

.chip-review {
    background: #e8eeff;
    color: #1f3893;
}

.chip-hold {
    background: #eef2f4;
    color: #33474f;
}

.chip-payable {
    background: #dff7ea;
    color: #006b4f;
}

.chip-paid {
    background: #007f62;
    color: #ffffff;
}

.chip-rejected {
    background: #ffe8ef;
    color: #9c1c45;
}

.chart {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: end;
    gap: 10px;
    height: 220px;
    padding-top: 8px;
}

.chart-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    height: 100%;
}

.chart-track {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex: 1;
    width: 100%;
}

.chart-fill {
    width: 100%;
    max-width: 44px;
    min-height: 2px;
    border-radius: 8px 8px 3px 3px;
    background: var(--primary);
}

.chart-fill.is-empty {
    background: #dfe6e9;
}

.chart-label {
    font-size: 12px;
    color: var(--muted);
}

.empty {
    margin: 8px 0 0;
    padding: 36px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

.detail-list {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 2fr;
    margin: 0;
}

.detail-list dt,
.detail-list dd {
    margin: 0;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    font-size: 17px;
}

.detail-list dt {
    color: var(--muted);
}

.detail-list dd {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.terms-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 16px;
}

.terms-list li {
    padding: 16px 18px;
    border-radius: var(--radius-control);
    background: var(--bg);
    line-height: 1.55;
}

.terms-list strong {
    display: block;
    margin-bottom: 4px;
    font-size: 16px;
}

.big-title {
    margin: 8px 0 28px;
    font-size: clamp(30px, 3.2vw, 44px);
    font-weight: 600;
    letter-spacing: -0.03em;
}

.steps {
    margin: 0 0 8px;
    padding-left: 28px;
    display: grid;
    gap: 14px;
    font-size: 19px;
    line-height: 1.5;
}

.link-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 720px;
    padding: 14px 14px 14px 28px;
    border-radius: var(--radius-card);
    background: var(--bg);
}

.link-box span {
    font-size: 20px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.copy-status {
    margin: 12px 0 0;
    color: var(--positive);
    font-weight: 500;
}

.assets {
    margin: 0 0 8px;
    padding-left: 24px;
    display: grid;
    gap: 10px;
    font-size: 19px;
}

.assets a {
    font-weight: 500;
    text-decoration: none;
}

.payout-summary {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

.payout-summary .hero-split {
    align-content: center;
    padding: 0 0 0 24px;
    border-top: 0;
    border-left: 1px solid var(--border);
}

.payout-amount {
    margin: 8px 0 12px;
    font-family: var(--font-figures);
    font-size: clamp(44px, 4.6vw, 64px);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.payout-text {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
    font-size: 15px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
}

.error-view {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    text-align: center;
}

.error-view h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.error-view p {
    margin: 0 0 20px;
    color: var(--muted);
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-hero {
        grid-column: span 3;
        grid-row: auto;
        min-height: 0;
    }
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
        align-content: start;
        padding: 12px;
    }

    .sidebar {
        position: static;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        width: auto;
        height: auto;
        padding: 10px 12px;
        overflow-x: auto;
    }

    .sidebar-logo {
        margin: 0 8px 0 0;
    }

    .sidebar-logo .logo-full {
        display: none;
    }

    .sidebar-logo .logo-mark {
        display: block;
        width: 34px;
        height: 34px;
    }

    .nav {
        flex-direction: row;
        gap: 4px;
    }

    .collapse-btn {
        display: none;
    }

    .app.is-collapsed .sidebar {
        width: auto;
    }

    .app.is-collapsed .nav-item span {
        display: inline;
    }

    .topbar {
        padding: 16px 4px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-hero {
        grid-column: span 2;
    }

    .payout-summary {
        grid-template-columns: 1fr;
    }

    .payout-summary .hero-split {
        padding: 16px 0 0;
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .auth-layout {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 16px 20px 56px;
    }

    .hero-title {
        margin-top: 20px;
    }

    .site-header {
        padding: 20px;
    }
}

@media (max-width: 560px) {
    .sidebar {
        padding: 6px;
    }

    .sidebar-logo {
        display: none;
    }

    .nav {
        flex: 1;
    }

    .nav-item {
        flex: 1;
        flex-direction: column;
        gap: 4px;
        padding: 8px 4px;
        font-size: 11px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-hero {
        grid-column: auto;
    }

    /* Each table row becomes a small card: its first cells on top, the labelled cells as lines below. */
    .table-stack,
    .table-stack tbody,
    .table-stack tfoot {
        display: block;
    }

    .table-stack thead,
    .table-stack .cell-empty {
        display: none;
    }

    .table-stack tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px 12px;
        padding: 14px 0;
        border-top: 1px solid var(--border);
    }

    .table-stack td {
        padding: 0;
        border: 0;
    }

    .table-stack td:not(:first-child):not([data-label]) {
        text-align: right;
    }

    .table-stack td[data-label] {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        font-size: 14px;
    }

    .table-stack td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 400;
    }

    .table-stack td[colspan] {
        grid-column: 1 / -1;
    }

    .table-stack .cell-headline {
        grid-row: 1;
        grid-column: 2;
    }

    .stat {
        min-height: 0;
    }

    .card {
        padding: 20px;
    }

    .tab {
        font-size: 18px;
    }

    .tabs-note {
        display: none;
    }

    .detail-list {
        grid-template-columns: 1fr;
    }

    .detail-list dd {
        border-top: 0;
        padding-top: 0;
    }

    .chart {
        gap: 4px;
    }

    .chart-label {
        font-size: 10px;
    }

    .auth-card {
        padding: 28px 20px 24px;
    }

    .auth-title {
        font-size: 32px;
    }

    .link-box {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
}
