:root {
    --bg: #090b08;
    --card: #141811;
    --card-2: #191f15;
    --card-3: #0f130d;
    --text: #f4f7ef;
    --muted: rgba(244, 247, 239, 0.62);
    --border: rgba(212, 255, 120, 0.13);
    --accent: #a9f10f;
    --accent-strong: #c4ff3e;
    --accent-soft: rgba(169, 241, 15, 0.16);
    --danger: #ff6b6f;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.bg {
    position: fixed;
    inset: 0;
    background-color: var(--bg);
    background-image:
        linear-gradient(135deg, rgba(169, 241, 15, 0.12), transparent 32%),
        linear-gradient(315deg, rgba(255, 255, 255, 0.06), transparent 28%),
        radial-gradient(circle at 1px 1px, rgba(169, 241, 15, 0.12) 1px, transparent 1px);
    background-size: auto, auto, 24px 24px;
}

.login-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.panel,
.metric,
.sidebar,
.topbar {
    border: 1px solid var(--border);
    background: rgba(20, 24, 17, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    border-radius: 8px;
}

.login-panel {
    width: min(380px, 100%);
    padding: 22px;
    display: grid;
    gap: 14px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 26px;
    line-height: 1.05;
}

h2 {
    font-size: 17px;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    background: rgba(10, 12, 9, 0.84);
    color: var(--text);
    outline: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

input:focus {
    border-color: rgba(47, 159, 0, 0.55);
    box-shadow: 0 0 0 3px rgba(169, 241, 15, 0.24);
}

select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(10, 12, 9, 0.84);
    color: var(--text);
    outline: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

select {
    min-height: 42px;
}

textarea {
    min-height: 88px;
    resize: vertical;
}

select:focus,
textarea:focus {
    border-color: rgba(47, 159, 0, 0.55);
    box-shadow: 0 0 0 3px rgba(169, 241, 15, 0.24);
}

.btn,
.nav-btn,
.tab {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 38px;
    padding: 0 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-weight: 800;
    isolation: isolate;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        box-shadow 160ms ease,
        filter 160ms ease,
        transform 120ms ease;
}

.btn::before,
.nav-btn::before,
.tab::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    opacity: 0;
    transform: translateX(-45%);
    transition:
        opacity 180ms ease,
        transform 420ms ease;
}

.btn:hover,
.nav-btn:hover,
.tab:hover {
    border-color: rgba(196, 255, 62, 0.42);
    background: rgba(169, 241, 15, 0.11);
    box-shadow: 0 0 0 3px rgba(169, 241, 15, 0.08);
}

.btn:hover::before,
.nav-btn:hover::before,
.tab:hover::before {
    opacity: 1;
    transform: translateX(45%);
}

.btn:active,
.nav-btn:active,
.tab:active {
    transform: translateY(1px);
    filter: brightness(1.12);
}

.btn.primary,
.nav-btn.active,
.tab.active {
    border-color: rgba(47, 159, 0, 0.24);
    background: var(--accent);
    color: #11120f;
    box-shadow: 0 10px 26px rgba(169, 241, 15, 0.18);
}

.btn.ghost {
    background: transparent;
}

.btn.danger {
    border-color: rgba(229, 72, 77, 0.28);
    color: var(--danger);
}

.app {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
}

.sidebar {
    position: sticky;
    top: 18px;
    height: calc(100vh - 36px);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    font-size: 25px;
    line-height: 1;
    align-self: center;
}

.brand > div {
    display: grid;
    align-items: center;
    min-height: 32px;
}

.brand strong,
.brand span {
    display: block;
}

.brand div span {
    color: var(--muted);
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 8px;
}

.settings-form {
    display: grid;
    gap: 14px;
    max-width: 760px;
    padding: 18px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.partner-shares-block {
    display: grid;
    gap: 12px;
}

.partner-shares-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.partner-shares-list {
    display: grid;
    gap: 10px;
}

.partner-share-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) auto;
    gap: 10px;
    align-items: center;
}

.nav-btn {
    width: 100%;
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar .btn {
    margin-top: auto;
}

.workspace {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 18px;
}

.topbar {
    position: sticky;
    top: 18px;
    z-index: 2;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.view {
    display: none;
}

.view.active {
    display: grid;
    gap: 18px;
}

.panel {
    padding: 14px;
    overflow: hidden;
}

.panel-head {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-note {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.panel-note-danger {
    color: var(--danger);
}

.stats-tables {
    display: grid;
    gap: 16px;
}

.stats-panel {
    padding: 0;
}

.stats-panel .panel-head {
    margin: 0;
    padding: 16px 16px 0;
}

.stats-table-wrap {
    overflow-x: auto;
    padding: 16px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.stats-table th,
.stats-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.stats-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    vertical-align: top;
}

.stats-table td {
    color: var(--text);
    font-size: 18px;
    font-weight: 900;
}

.stats-period-title,
.stats-period-label {
    display: block;
}

.stats-period-label {
    margin-top: 6px;
    color: rgba(244, 247, 239, 0.56);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    text-transform: none;
    white-space: normal;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-table tfoot td {
    padding: 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 15px;
    font-weight: 900;
}

.finance-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    padding: 16px;
    display: grid;
    gap: 8px;
}

.metric-value {
    font-size: 28px;
    line-height: 1;
    font-weight: 900;
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.portal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
    gap: 18px;
}

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

.finance-summary-panel {
    flex: 1 1 320px;
}

.finance-table-panel {
    padding: 0;
}

.finance-table {
    width: max-content;
    min-width: max(1180px, 100%);
    table-layout: auto;
}

.finance-table td,
.finance-table th {
    white-space: nowrap;
}

.finance-total-row td {
    font-weight: 900;
}

.referral-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
    width: 100%;
    gap: 12px 18px;
}

.referral-stats {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
}

.summary-chip {
    min-width: 96px;
    padding: 10px 12px;
    border: 1px solid rgba(169, 241, 15, 0.14);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
        rgba(169, 241, 15, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.summary-chip strong,
.summary-chip span {
    display: block;
}

.summary-chip strong {
    font-size: 21px;
    line-height: 1;
    font-weight: 900;
    color: var(--text);
}

.summary-chip span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.referral-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
    gap: 10px;
    flex-wrap: wrap;
}

.referral-create-btn {
    width: auto;
    min-width: 176px;
    padding-inline: 16px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-plus {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(17, 18, 15, 0.12);
    font-size: 18px;
    line-height: 1;
    font-weight: 900;
}

.referrals-panel {
    padding-top: 14px;
}

.payouts-history-panel {
    padding-top: 14px;
}

.payout-toolbar-note {
    margin: 0;
    text-align: right;
}

.blogger-link-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    font-size: 15px;
    line-height: 1.5;
}

.blogger-link-label {
    color: var(--text);
    font-weight: 900;
}

.blogger-link-anchor {
    color: var(--accent-strong);
    text-decoration: none;
    word-break: break-all;
}

.blogger-link-anchor:hover {
    text-decoration: underline;
}

.chart-panel {
    min-width: 0;
}

.chart-shell {
    position: relative;
    height: 280px;
}

.chart-shell canvas {
    width: 100% !important;
    height: 100% !important;
}

.access-card {
    padding: 14px;
    border: 1px solid rgba(169, 241, 15, 0.14);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
        rgba(169, 241, 15, 0.045);
}

.access-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.access-card-head .btn {
    width: auto;
    min-width: 168px;
}

.access-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.access-item {
    padding: 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.access-item-secret {
    grid-column: 1 / -1;
}

.access-item span,
.access-item strong {
    display: block;
}

.access-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.access-item strong {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.payout-row {
    align-items: flex-start;
}

.payout-main {
    min-width: 0;
}

.payout-actions {
    min-width: min(320px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
}

.payout-status-select,
.payout-note-input {
    min-width: 220px;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.7fr) auto;
    gap: 10px;
}

#userSearch {
    grid-template-columns: minmax(180px, 1fr) auto;
}

.list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
}

.row:hover {
    border-color: rgba(196, 255, 62, 0.28);
    background: rgba(169, 241, 15, 0.065);
}

.row-title {
    font-weight: 900;
    overflow-wrap: anywhere;
}

.row-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.user-main {
    min-width: 0;
}

.user-tariffs-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.plan-assign {
    min-height: 56px;
    padding: 10px 12px;
    display: grid;
    justify-items: start;
    align-content: center;
    gap: 4px;
    text-align: left;
}

.plan-assign-name {
    font-size: 14px;
    font-weight: 900;
    line-height: 1.1;
}

.plan-assign-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.15;
}

.plan-assign.active-plan {
    border-color: rgba(169, 241, 15, 0.32);
    background: rgba(169, 241, 15, 0.12);
    color: var(--accent-strong);
    box-shadow: 0 0 0 3px rgba(169, 241, 15, 0.06);
    cursor: default;
}

.plan-assign.active-plan .plan-assign-meta {
    color: var(--accent-strong);
}

.user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.user-revoke {
    width: auto;
    min-width: 140px;
}

.user-open-modal {
    width: auto;
    min-width: 160px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.56);
    backdrop-filter: blur(8px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(20, 24, 17, 0.96);
    box-shadow: var(--shadow);
    display: grid;
    gap: 16px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-close {
    width: auto;
    min-width: 110px;
}

.modal-tariffs-grid {
    margin-top: 0;
}

.modal-form {
    display: grid;
    gap: 14px;
}

.referral-edit-btn {
    width: auto;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(169, 241, 15, 0.18);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
}

.pill-danger {
    background: rgba(255, 107, 111, 0.16);
    color: #ff8d92;
}

.toggle-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    user-select: none;
}

.toggle-chip {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
}

.toggle-chip:hover {
    border-color: rgba(196, 255, 62, 0.36);
    background: rgba(169, 241, 15, 0.08);
    box-shadow: 0 0 0 3px rgba(169, 241, 15, 0.06);
}

.toggle-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.error {
    min-height: 18px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100vw - 36px));
    padding: 12px 14px;
    border-radius: 8px;
    background: #11120f;
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow);
}

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

    .sidebar {
        position: relative;
        top: auto;
        height: auto;
    }

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

    .topbar {
        position: relative;
        top: auto;
        align-items: flex-start;
        flex-direction: column;
    }

    .referral-toolbar {
        align-items: flex-start;
    }

    .referral-stats {
        width: 100%;
    }

    .summary-chip {
        flex: 1 1 120px;
    }

    .referral-toolbar-actions {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
    }

    .referral-create-btn {
        min-width: 164px;
    }

    .access-card-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .access-card-head .btn {
        width: 100%;
    }

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

    .access-item-secret {
        grid-column: auto;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

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

    .partner-share-row {
        grid-template-columns: 1fr;
    }

    .metrics-grid,
    .portal-grid {
        grid-template-columns: 1fr;
    }

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

    .row-actions {
        justify-content: flex-start;
    }

    .payout-actions {
        min-width: 0;
        width: 100%;
    }

    .user-row {
        grid-template-columns: 1fr;
    }

    .user-tariffs-grid {
        grid-template-columns: 1fr;
    }

    .user-actions {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .user-revoke {
        width: 100%;
    }

    .user-open-modal {
        width: 100%;
    }

    .modal {
        padding: 10px;
    }

    .modal-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .modal-close {
        width: 100%;
    }
}
