:root {
    --background: #0b0c10;
    --surface: rgba(255, 255, 255, 0.07);
    --surface-border: rgba(255, 255, 255, 0.12);
    --text: #ffffff;
    --muted: #a6a8b3;
    --purple: #8a2be2;
    --cyan: #00f5d4;
    --danger: #ff5c7a;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, rgba(138, 43, 226, 0.22), transparent 34rem),
        radial-gradient(circle at 85% 25%, rgba(0, 245, 212, 0.12), transparent 30rem),
        var(--background);
    font-family: Inter, "Segoe UI", sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 0 6vw;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(11, 12, 16, 0.72);
    backdrop-filter: blur(18px);
}

.admin-nav,
.admin-account,
.admin-account form {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-nav a,
.back-link {
    color: var(--muted);
    text-decoration: none;
}

.admin-nav a:hover,
.back-link:hover {
    color: var(--cyan);
}

.brand {
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.brand span,
.eyebrow {
    color: var(--cyan);
}

.environment,
.card small,
.hero p {
    color: var(--muted);
}

.page {
    width: min(1180px, 88vw);
    margin: 0 auto;
    padding: 72px 0;
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 48px;
}

.eyebrow {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.2em;
}

h1 {
    margin: 10px 0 12px;
    font-size: clamp(2.3rem, 6vw, 4.8rem);
    line-height: 0.98;
}

.hero p {
    max-width: 680px;
    margin: 0;
    font-size: 1.05rem;
}

.status {
    flex: 0 0 auto;
    padding: 10px 14px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-ok {
    color: var(--cyan);
    border-color: rgba(0, 245, 212, 0.35);
    background: rgba(0, 245, 212, 0.08);
}

.status-error {
    color: var(--danger);
    border-color: rgba(255, 92, 122, 0.35);
    background: rgba(255, 92, 122, 0.08);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.card {
    display: flex;
    min-height: 190px;
    padding: 24px;
    flex-direction: column;
    justify-content: flex-end;
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(20px);
}

.card-link {
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}

.card-link:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 245, 212, .45);
}

.card:first-child {
    background:
        linear-gradient(145deg, rgba(138, 43, 226, 0.22), rgba(0, 245, 212, 0.08)),
        var(--surface);
}

.card-label {
    margin-bottom: auto;
    color: var(--cyan);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.card strong {
    margin-bottom: 8px;
    font-size: 1.25rem;
}

.card-muted {
    opacity: 0.72;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel,
.table-shell,
.filters {
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 20px 80px rgba(0, 0, 0, .25);
    backdrop-filter: blur(20px);
}

.login-card {
    width: min(440px, 100%);
    padding: 40px;
}

.login-card h1 {
    font-size: 2.2rem;
}

.login-brand {
    margin-bottom: 28px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

input,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    outline: none;
    background: rgba(0, 0, 0, .25);
}

input:focus,
select:focus {
    border-color: var(--purple);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    color: var(--muted);
}

.checkbox input {
    width: 18px;
    min-height: 18px;
}

.button,
.link-button {
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    cursor: pointer;
    text-decoration: none;
}

.button {
    display: inline-flex;
    min-height: 42px;
    padding: 9px 16px;
    align-items: center;
    justify-content: center;
}

.button-primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--purple), #6630d8);
}

.button-danger {
    border-color: rgba(255, 92, 122, .45);
    background: rgba(255, 92, 122, .15);
}

.button-small {
    min-height: 34px;
    padding: 6px 10px;
}

.link-button {
    padding: 6px 8px;
    border: 0;
    background: transparent;
}

.danger,
.validation {
    color: var(--danger);
}

.section-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 28px;
}

.section-header h1 {
    margin-bottom: 8px;
}

.section-header p,
.muted {
    color: var(--muted);
}

.section-header.compact h1 {
    font-size: clamp(2rem, 4vw, 3.8rem);
}

.filters {
    display: grid;
    grid-template-columns: 1fr 220px auto;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--surface-border);
}

th {
    color: var(--muted);
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

td strong,
td small,
.access-row small {
    display: block;
}

td small {
    margin-top: 4px;
    color: var(--muted);
}

.accent {
    color: var(--cyan) !important;
}

.status-pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, .08);
    font-size: .78rem;
}

.status-active {
    color: var(--cyan);
    background: rgba(0, 245, 212, .1);
}

.status-blocked,
.status-deleted {
    color: var(--danger);
    background: rgba(255, 92, 122, .1);
}
.payment-succeeded { color:var(--cyan); background:rgba(0,245,212,.1); }
.payment-failed,.payment-cancelled,.payment-refunded { color:var(--danger); background:rgba(255,92,122,.1); }
.payment-created,.payment-pending { color:#ffd166; background:rgba(255,209,102,.1); }
.payment-action { margin-top:20px; }

.pagination {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.pagination a {
    padding: 8px 12px;
    color: var(--text);
    border-radius: 8px;
    background: var(--surface);
    text-decoration: none;
}

.pagination a.active {
    background: var(--purple);
}

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

.panel {
    padding: 24px;
}

.panel h2 {
    margin-top: 0;
}

.panel-danger {
    border-color: rgba(255, 92, 122, .3);
}

dl {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 10px 16px;
}

dt {
    color: var(--muted);
}

dd {
    margin: 0;
}

.metric {
    margin: 8px 0;
    color: var(--cyan);
    font-size: 2.2rem;
    font-weight: 800;
}

.compact-form {
    margin-top: 20px;
}

.access-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface-border);
}

.alert {
    margin: 20px 0;
    padding: 14px 16px;
    border-radius: 10px;
}

.alert-success {
    color: var(--cyan);
    background: rgba(0, 245, 212, .1);
}

.alert-error {
    color: var(--danger);
    background: rgba(255, 92, 122, .1);
}

.admin-cards {
    display: grid;
    gap: 18px;
}

.administrator-heading,
.administrator-actions,
.inline-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.administrator-heading {
    justify-content: space-between;
}

.administrator-heading h2 {
    margin: 10px 0 4px;
}

.administrator-heading p {
    margin: 0 0 12px;
    color: var(--muted);
}

.administrator-actions {
    margin-top: 20px;
    padding-top: 18px;
    flex-wrap: wrap;
    border-top: 1px solid var(--surface-border);
}

.inline-form {
    flex: 1 1 300px;
}

.inline-form input,
.inline-form select {
    min-width: 130px;
}

.warning {
    color: #ffd166;
}

.form-panel {
    max-width: 680px;
}

.legal-filters {
    grid-template-columns: minmax(240px, 420px) auto;
}

.legal-editor textarea {
    width: 100%;
    padding: 16px;
    resize: vertical;
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, .28);
    font: 14px/1.55 "Cascadia Code", Consolas, monospace;
}

.legal-preview {
    padding: clamp(24px, 5vw, 48px);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, .06);
    line-height: 1.65;
}

.legal-preview h1,
.legal-preview h2,
.legal-preview h3 {
    font-size: revert;
    line-height: 1.3;
}

.legal-preview .notice {
    padding: 16px;
    border: 1px solid rgba(0, 245, 212, .4);
    border-radius: 10px;
    background: rgba(0, 245, 212, .08);
}

.legal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.legal-current {
    color: var(--cyan);
    background: rgba(0, 245, 212, .1);
}

.legal-draft,
.legal-scheduled {
    color: #ffd166;
    background: rgba(255, 209, 102, .1);
}

.legal-archived,
.legal-superseded {
    opacity: .7;
}
.billing-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; align-items:end; }
.billing-grid > label { color:var(--muted); font-size:.8rem; }
.feature-grid { display:grid; gap:8px; margin-top:22px; }
.feature-row { display:grid; grid-template-columns:2fr .8fr 1fr 1fr auto; gap:10px; align-items:center; padding-top:10px; border-top:1px solid var(--surface-border); }
.feature-row small { display:block; color:var(--muted); }
.provider-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.provider-card { display:grid; grid-template-columns:1.4fr 1fr .7fr .7fr auto; gap:10px; align-items:end; padding:14px; border:1px solid var(--surface-border); border-radius:12px; }
.provider-card small,.model-editor small { display:block; margin-top:4px; color:var(--muted); }
.provider-card label,.model-editor label { color:var(--muted); font-size:.8rem; }
.ai-operation,.ai-json-panel { margin-top:20px; }
.model-editor { border-top:1px solid var(--surface-border); }
.model-editor summary { display:flex; justify-content:space-between; gap:20px; align-items:center; padding:16px 4px; cursor:pointer; }
.model-editor form { padding:0 4px 20px; }
.model-editor textarea { width:100%; padding:12px; color:var(--text); border:1px solid var(--surface-border); border-radius:10px; background:rgba(0,0,0,.25); resize:vertical; }
.model-summary-meta { display:flex; gap:10px; align-items:center; }
.model-settings-grid { display:grid; grid-template-columns:1fr .7fr .8fr .8fr; gap:12px; align-items:end; }
.ai-request-filters { grid-template-columns:1fr 190px 160px auto; }
.ai-completed { color:var(--cyan); background:rgba(0,245,212,.1); }
.ai-failed,.ai-cancelled { color:var(--danger); background:rgba(255,92,122,.1); }
.ai-created,.ai-queued,.ai-processing { color:#ffd166; background:rgba(255,209,102,.1); }
.ai-json-panel pre { overflow:auto; padding:16px; border-radius:10px; color:#d9fbf5; background:rgba(0,0,0,.35); white-space:pre-wrap; word-break:break-word; }
.prompt-text { line-height:1.6; white-space:pre-wrap; }

@media (max-width: 800px) {
    .hero {
        flex-direction: column;
    }

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

    .admin-nav {
        display: none;
    }

    .admin-account > span {
        display: none;
    }

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

    .administrator-heading,
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .legal-actions {
        grid-template-columns: 1fr;
    }
    .billing-grid,
    .feature-row,
    .provider-grid,
    .provider-card,
    .model-settings-grid,
    .ai-request-filters { grid-template-columns:1fr; }

    .page {
        width: min(100% - 28px, 1180px);
        padding: 40px 0;
    }
}
