:root {
    --admin-navy-950: #030a18;
    --admin-navy-900: #071126;
    --admin-navy-850: #0a1730;
    --admin-navy-800: #0d1d3b;
    --admin-navy-750: #112448;
    --admin-orange: #ff6a1a;
    --admin-orange-light: #ff8b32;
    --admin-gold: #ffc928;
    --admin-gold-soft: #ffe28a;
    --admin-text: #edf3fb;
    --admin-muted: #9eacc4;
    --admin-line: rgba(255, 255, 255, .115);
    --admin-line-strong: rgba(255, 201, 40, .28);
    --admin-success: #46d693;
    --admin-danger: #ff7b72;
    --admin-warning: #ffbd66;
    --admin-shadow: 0 1.25rem 3.5rem rgba(0, 0, 0, .26);
    --admin-radius-sm: .7rem;
    --admin-radius: 1rem;
    --admin-radius-lg: 1.35rem;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
}

body {
    margin: 0;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 88% 2%, rgba(255, 106, 26, .13), transparent 29rem),
        radial-gradient(circle at 5% 45%, rgba(41, 91, 215, .18), transparent 35rem),
        var(--admin-navy-900);
    color: var(--admin-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: var(--admin-gold-soft);
    text-underline-offset: .2rem;
}

a:hover {
    color: #fff;
}

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

button,
.button {
    min-height: 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .65rem .95rem;
    border: 1px solid transparent;
    border-radius: .72rem;
    background: linear-gradient(135deg, var(--admin-orange), var(--admin-orange-light));
    color: #111827;
    font-weight: 850;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 .55rem 1.4rem rgba(255, 106, 26, .16);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    color: #111827;
    box-shadow: 0 .8rem 1.7rem rgba(255, 106, 26, .25);
}

button.secondary,
.button.secondary,
button.ghost,
.button.ghost {
    border-color: var(--admin-line);
    background: rgba(255, 255, 255, .06);
    color: var(--admin-text);
    box-shadow: none;
}

button.secondary:hover,
.button.secondary:hover,
button.ghost:hover,
.button.ghost:hover {
    border-color: rgba(255, 255, 255, .24);
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

button.danger,
.button.danger {
    border-color: rgba(255, 123, 114, .38);
    background: rgba(255, 70, 61, .13);
    color: #ffd5d2;
    box-shadow: none;
}

button.danger:hover,
.button.danger:hover {
    background: rgba(255, 70, 61, .2);
    color: #fff;
}

button:focus-visible,
.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--admin-gold);
    outline-offset: 3px;
}

.topbar,
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--admin-line);
    background: rgba(3, 10, 24, .9);
    box-shadow: 0 .8rem 2rem rgba(0, 0, 0, .17);
    backdrop-filter: blur(1rem);
}

.topbar-inner,
.shell,
.site-footer-inner {
    width: min(100% - 2rem, 86rem);
    margin-inline: auto;
}

.topbar-inner,
.nav {
    min-height: 5.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: .85rem;
    flex: 0 0 auto;
    color: #fff;
    font-size: 1.03rem;
    font-weight: 900;
    letter-spacing: -.025em;
    text-decoration: none;
    white-space: nowrap;
}

.brand img {
    width: 3.9rem;
    height: 3.9rem;
    flex: 0 0 auto;
    object-fit: contain;
    filter: drop-shadow(0 .4rem 1rem rgba(0, 0, 0, .35));
}

.brand-copy {
    min-width: 0;
}

.brand-copy small {
    display: block;
    color: var(--admin-gold);
    font-size: .64rem;
    font-weight: 850;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.menu-toggle {
    display: none;
    margin-left: auto;
}

.admin-nav {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .2rem;
    flex: 1;
}

.admin-nav a {
    position: relative;
    padding: .65rem .7rem;
    border-radius: .6rem;
    color: #bfcbe0;
    font-size: .86rem;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

.admin-nav a:hover {
    background: rgba(255, 255, 255, .065);
    color: #fff;
}

.admin-nav a.active {
    background: rgba(255, 106, 26, .12);
    color: #fff;
}

.admin-nav a.active::after {
    content: "";
    position: absolute;
    right: .7rem;
    bottom: .28rem;
    left: .7rem;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--admin-gold), var(--admin-orange));
}

.user-tools,
.nav-actions,
.actions,
.footer-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .6rem;
}

.user-tools {
    margin-left: auto;
    flex: 0 0 auto;
}

.user-name {
    max-width: 11rem;
    overflow: hidden;
    color: #d7e0ee;
    font-size: .85rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.balance-pill {
    padding: .38rem .7rem;
    border: 1px solid rgba(255, 201, 40, .24);
    border-radius: 99rem;
    background: rgba(255, 201, 40, .08);
    color: var(--admin-gold-soft);
    font-size: .8rem;
    white-space: nowrap;
}

.logout {
    min-height: 2.55rem;
    padding: .5rem .7rem;
    border-color: var(--admin-line);
    background: transparent;
    color: #fff;
    box-shadow: none;
}

.page {
    width: min(100% - 2rem, 86rem);
    margin-inline: auto;
    padding: 2.25rem 0 4rem;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.eyebrow {
    margin: 0 0 .3rem;
    color: var(--admin-gold);
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: .15em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    color: #fff;
    line-height: 1.12;
}

h1 {
    margin: 0;
    font-size: clamp(1.85rem, 4vw, 2.65rem);
    letter-spacing: -.045em;
}

h2 {
    margin: 0 0 .8rem;
    font-size: 1.15rem;
    letter-spacing: -.025em;
}

h3 {
    margin: .1rem 0 .45rem;
    font-size: 1rem;
    letter-spacing: -.015em;
}

.subtitle,
.muted,
.metric-hint,
.help {
    color: var(--admin-muted);
}

.subtitle {
    max-width: 48rem;
    margin: .45rem 0 0;
}

.grid {
    display: grid;
    gap: 1rem;
}

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

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(19rem, .75fr);
    gap: 1rem;
}

.card {
    min-width: 0;
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    background: linear-gradient(145deg, rgba(15, 31, 64, .94), rgba(8, 23, 49, .95));
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .14);
}

.card .card {
    margin-bottom: 0;
    background: rgba(3, 10, 24, .35);
    box-shadow: none;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .9rem;
}

.card-head p {
    margin: .35rem 0 0;
}

.metric {
    min-height: 8.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.metric::before {
    content: "";
    width: 3rem;
    height: 3px;
    margin-bottom: 1rem;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--admin-gold), var(--admin-orange));
}

.metric-label {
    color: #dbe4f2;
    font-size: .88rem;
    font-weight: 800;
}

.metric-value {
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -.045em;
}

.metric-hint {
    font-size: .8rem;
}

.action-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.action-card p {
    margin: 0 0 1rem;
}

.action-card form {
    display: grid;
    gap: .65rem;
    margin-top: auto;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--admin-line);
    border-radius: .8rem;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

th {
    padding: .72rem .75rem;
    background: rgba(255, 255, 255, .055);
    color: #c9d4e5;
    font-size: .7rem;
    font-weight: 850;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: .8rem .75rem;
    border-top: 1px solid var(--admin-line);
    color: #e1e8f3;
    vertical-align: middle;
}

tbody tr {
    transition: background .14s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, .035);
}

td strong {
    color: #fff;
}

.truncate {
    display: block;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem .62rem;
    border: 1px solid var(--admin-line);
    border-radius: 99rem;
    background: rgba(255, 255, 255, .065);
    color: #d6deeb;
    font-size: .72rem;
    font-weight: 850;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    background: currentColor;
    opacity: .9;
}

.badge.active {
    border-color: rgba(70, 214, 147, .25);
    background: rgba(70, 214, 147, .12);
    color: #8de8bc;
}

.badge.pending {
    border-color: rgba(255, 201, 40, .25);
    background: rgba(255, 201, 40, .12);
    color: #ffe078;
}

.badge.expired,
.badge.inactive {
    background: rgba(158, 172, 196, .1);
    color: #b3bfd2;
}

.badge.blocked,
.badge.deactivated {
    border-color: rgba(255, 123, 114, .25);
    background: rgba(255, 70, 61, .12);
    color: #ffaaa4;
}

.badge.super-admin {
    border-color: rgba(255, 201, 40, .28);
    background: rgba(255, 201, 40, .12);
    color: #ffe078;
}

.badge.reseller {
    border-color: rgba(255, 106, 26, .3);
    background: rgba(255, 106, 26, .12);
    color: #ffad7c;
}

.badge.subreseller {
    border-color: rgba(80, 155, 255, .3);
    background: rgba(80, 155, 255, .12);
    color: #a7cdff;
}

.alert {
    margin-bottom: 1rem;
    padding: .9rem 1rem;
    border: 1px solid;
    border-radius: .75rem;
}

.alert.success {
    border-color: rgba(70, 214, 147, .35);
    background: rgba(70, 214, 147, .1);
    color: #a6f1cb;
}

.alert.error {
    border-color: rgba(255, 123, 114, .38);
    background: rgba(255, 70, 61, .1);
    color: #ffd1ce;
}

.alert ul {
    margin: .2rem 0;
    padding-left: 1.2rem;
}

.filters,
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: .9rem;
    align-items: end;
}

.filters {
    border-color: rgba(255, 201, 40, .16);
    background: linear-gradient(120deg, rgba(17, 36, 72, .95), rgba(9, 24, 51, .95));
}

.field {
    min-width: 0;
    grid-column: span 6;
}

.field.third {
    grid-column: span 4;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: .32rem;
    color: #e0e7f2;
    font-size: .86rem;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: .62rem .72rem;
    border: 1px solid rgba(255, 255, 255, .17);
    border-radius: .62rem;
    background: rgba(3, 10, 24, .68);
    color: #fff;
}

input::placeholder,
textarea::placeholder {
    color: #718098;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--admin-gold);
}

select {
    color-scheme: dark;
}

textarea {
    min-height: 6rem;
    resize: vertical;
}

input[type="checkbox"] {
    width: 1rem;
    min-height: 1rem;
    accent-color: var(--admin-orange);
}

.check-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0;
}

.help {
    margin: .3rem 0 0;
    font-size: .79rem;
}

.form-card {
    max-width: 52rem;
}

.stacked-form {
    display: grid;
    gap: .7rem;
}

.stacked-form + .stacked-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--admin-line);
}

dl.details {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    margin: 0;
}

dl.details dt,
dl.details dd {
    min-width: 0;
    margin: 0;
    padding: .72rem .8rem;
    border-top: 1px solid var(--admin-line);
}

dl.details dt {
    color: var(--admin-muted);
    font-weight: 750;
}

dl.details dd {
    color: #edf3fb;
    overflow-wrap: anywhere;
}

code,
.secret {
    max-width: 100%;
    padding: .25rem .45rem;
    border: 1px dashed rgba(255, 201, 40, .32);
    border-radius: .45rem;
    background: rgba(255, 201, 40, .06);
    color: #ffe89a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

.secret {
    display: block;
    padding: .8rem;
}

.empty {
    padding: 2.8rem 1rem;
    color: var(--admin-muted);
    text-align: center;
}

.empty strong {
    display: block;
    margin-bottom: .25rem;
    color: #fff;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.pagination a,
.pagination span {
    padding: .48rem .7rem;
    border: 1px solid var(--admin-line);
    border-radius: .5rem;
    background: rgba(255, 255, 255, .04);
    text-decoration: none;
}

.pagination .disabled {
    color: #78869b;
}

.amount-positive {
    color: #8de8bc;
    font-weight: 800;
}

.amount-negative {
    color: #ffaaa4;
    font-weight: 800;
}

.audit-entry {
    padding: .9rem 0;
    border-top: 1px solid var(--admin-line);
}

.audit-entry:first-of-type {
    border-top: 0;
}

.audit-entry p {
    margin-bottom: 0;
}

.admin-footer,
.site-footer,
footer {
    margin-top: auto;
    border-top: 1px solid var(--admin-line);
    background: rgba(3, 10, 24, .65);
    color: #7f8ea7;
    font-size: .8rem;
}

.admin-footer-inner,
.footer-inner {
    width: min(100% - 2rem, 86rem);
    min-height: 4.5rem;
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-links a {
    color: #aebbd0;
}

.auth-shell {
    width: min(100% - 2rem, 31rem);
    margin: auto;
    padding: clamp(3rem, 8vw, 6rem) 0;
}

.auth-card {
    padding: clamp(1.4rem, 5vw, 2rem);
    border: 1px solid rgba(255, 201, 40, .2);
    border-radius: var(--admin-radius-lg);
    background: linear-gradient(145deg, rgba(15, 31, 64, .97), rgba(8, 23, 49, .97));
    box-shadow: var(--admin-shadow);
}

.auth-card h1 {
    font-size: clamp(1.9rem, 5vw, 2.55rem);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin-bottom: 1.5rem;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 900;
}

.login-brand img {
    width: 5rem;
    height: 5rem;
    object-fit: contain;
}

.auth-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.security-note {
    margin: 1rem 0 0;
    color: #8290a7;
    font-size: .76rem;
    text-align: center;
}

@media (max-width: 76rem) {
    .brand-copy small {
        display: none;
    }

    .admin-nav a {
        padding-inline: .5rem;
        font-size: .8rem;
    }

    .user-name {
        display: none;
    }
}

@media (max-width: 70rem) {
    .grid.metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 56rem) {
    .topbar-inner {
        min-height: 4.8rem;
        flex-wrap: wrap;
        padding: .6rem 0;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .admin-nav {
        display: none;
        order: 4;
        width: 100%;
        padding: .4rem;
        border: 1px solid var(--admin-line);
        border-radius: .8rem;
        background: rgba(7, 17, 38, .95);
        flex-direction: column;
        align-items: stretch;
    }

    .admin-nav.open {
        display: flex;
    }

    .admin-nav a {
        padding: .7rem;
        font-size: .86rem;
    }

    .user-tools {
        margin-left: 0;
    }

    .page {
        padding-top: 1.4rem;
    }

    .page-head {
        flex-direction: column;
    }

    .field,
    .field.third {
        grid-column: 1 / -1;
    }

    dl.details {
        grid-template-columns: 1fr;
    }

    dl.details dt {
        padding-bottom: .15rem;
    }

    dl.details dd {
        padding-top: .15rem;
        border-top: 0;
    }
}

@media (max-width: 40rem) {
    .topbar-inner,
    .shell,
    .site-footer-inner,
    .page,
    .admin-footer-inner,
    .footer-inner {
        width: min(100% - 1rem, 86rem);
    }

    .brand img {
        width: 3.4rem;
        height: 3.4rem;
    }

    .brand-copy {
        display: none;
    }

    .balance-pill {
        display: none;
    }

    .logout {
        min-height: 2.5rem;
    }

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

    .card {
        padding: 1rem;
    }

    .card-head {
        flex-direction: column;
    }

    .table-wrap {
        border-inline: 0;
        border-radius: 0;
    }

    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-footer-inner,
    .footer-inner {
        min-height: 0;
        padding: 1.1rem 0;
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}

@media (max-width: 28rem) {
    .menu-toggle {
        padding-inline: .75rem;
    }

    .user-tools {
        gap: .35rem;
    }

    .actions > .button,
    .actions > button {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    button,
    .button,
    tbody tr {
        transition: none;
    }
}
