:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #122033;
    --muted: #65758b;
    --line: #dbe3ee;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --accent: #2563eb;
    --danger: #dc2626;
    --warning: #d97706;
    --ok: #16a34a;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Tahoma, Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    color: #e5edf8;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
}

.brand strong,
.login-brand strong {
    display: block;
    font-size: 18px;
}

.brand small,
.login-brand small {
    display: block;
    color: #a8b3c7;
    margin-top: 3px;
}

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

.nav a {
    padding: 12px 14px;
    border-radius: 8px;
    color: #b8c2d6;
}

.nav a.active,
.nav a:hover {
    color: #fff;
    background: var(--sidebar-soft);
}

.domain-box {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
}

.domain-box span {
    color: #94a3b8;
    font-size: 12px;
}

.domain-box strong {
    direction: ltr;
    text-align: left;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.main {
    min-width: 0;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 4vw, 40px);
}

h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 16px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.button:hover {
    border-color: #b8c5d6;
}

.button.primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.button.primary:hover {
    background: var(--brand-dark);
}

.button.subtle {
    background: #eef3f9;
}

.button.danger {
    border-color: var(--danger);
    color: #fff;
    background: var(--danger);
}

.button.wide {
    width: 100%;
}

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

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

.stat-card,
.panel-section,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card span,
.stat-card small,
.metric-list span,
table small,
.user-card span,
.download-tile span,
.secret-box span {
    color: var(--muted);
}

.stat-card strong {
    font-size: 28px;
    overflow-wrap: anywhere;
}

.compact {
    font-size: 18px !important;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
    gap: 18px;
}

.panel-section {
    padding: 18px;
    min-width: 0;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-title span,
.section-title a {
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

td {
    font-size: 14px;
}

td strong,
td small {
    display: block;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

.mono {
    direction: ltr;
    text-align: left;
    font-family: Consolas, "Courier New", monospace;
    overflow-wrap: anywhere;
}

.progress {
    height: 8px;
    width: 100%;
    min-width: 120px;
    border-radius: 999px;
    background: #e7edf5;
    overflow: hidden;
}

.progress i {
    display: block;
    height: 100%;
    min-width: 0;
    background: var(--accent);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
}

.status.active {
    background: #dcfce7;
    color: #166534;
}

.status.disabled {
    background: #fee2e2;
    color: #991b1b;
}

.status.over_quota {
    background: #ffedd5;
    color: #9a3412;
}

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

.metric-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

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

.user-card {
    display: grid;
    gap: 9px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.user-card:hover,
.download-tile:hover {
    border-color: var(--brand);
}

.search {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: min(100%, 420px);
}

.search input {
    max-width: 520px;
}

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

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

.form label {
    display: grid;
    gap: 7px;
}

.form label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--accent);
}

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

.form-actions {
    display: flex;
    gap: 10px;
}

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

.download-tile,
.secret-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.download-tile {
    display: grid;
    gap: 6px;
}

.secret-box {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.subscription-admin {
    display: grid;
    gap: 14px;
}

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

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

.mini-metrics div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    display: grid;
    gap: 5px;
}

.mini-metrics span {
    color: var(--muted);
    font-size: 12px;
}

.mini-metrics strong {
    font-size: 18px;
}

.danger-zone {
    display: flex;
    justify-content: flex-end;
}

.flash-stack {
    display: grid;
    gap: 8px;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}

.flash.success {
    border-color: #86efac;
    background: #f0fdf4;
}

.flash.warning {
    border-color: #fed7aa;
    background: #fff7ed;
}

.flash.danger {
    border-color: #fecaca;
    background: #fef2f2;
}

.footer {
    margin-top: auto;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.footer a {
    color: var(--brand-dark);
    font-weight: 800;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 20px;
    background: #eaf0f7;
}

.login-wrap {
    width: min(100%, 460px);
}

.login-panel {
    padding: 26px;
    display: grid;
    gap: 20px;
}

.login-panel h1 {
    font-size: 28px;
}

.sub-body {
    min-height: 100vh;
    background: #eef3f8;
    color: var(--ink);
}

.sub-page {
    width: min(100%, 920px);
    margin: 0 auto;
    padding: 24px;
    display: grid;
    gap: 16px;
}

.sub-header,
.sub-hero,
.sub-panel,
.sub-timeline,
.sub-grid article {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(219, 227, 238, 0.95);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px;
}

.sub-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sub-brand strong,
.sub-brand small {
    display: block;
}

.sub-brand small,
.sub-identity {
    color: var(--muted);
}

.sub-hero {
    min-height: 240px;
    padding: 28px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: center;
    gap: 20px;
}

.sub-hero h1 {
    margin: 0;
    font-size: clamp(32px, 7vw, 58px);
    line-height: 1.08;
}

.sub-identity {
    margin: 12px 0 0;
    direction: ltr;
    text-align: right;
    overflow-wrap: anywhere;
}

.usage-ring {
    --ring: calc(var(--percent) * 1%);
    width: 188px;
    aspect-ratio: 1;
    margin-inline-start: auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--brand) var(--ring), #e5edf6 0);
    position: relative;
}

.usage-ring::before {
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: #fff;
}

.usage-ring div {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 4px;
}

.usage-ring strong {
    font-size: 34px;
}

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

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

.sub-grid article {
    min-height: 118px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sub-grid span,
.sub-timeline span,
.sub-progress-head span,
.sub-scale {
    color: var(--muted);
    font-size: 13px;
}

.sub-grid strong {
    font-size: 23px;
    overflow-wrap: anywhere;
}

.sub-panel {
    padding: 18px;
    display: grid;
    gap: 12px;
}

.sub-progress-head,
.sub-scale {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.sub-progress-head strong {
    font-size: 20px;
}

.sub-progress {
    height: 16px;
    border-radius: 999px;
    background: #e4ebf4;
    overflow: hidden;
}

.sub-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.sub-timeline {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.sub-timeline div {
    display: grid;
    gap: 6px;
}

.sub-timeline strong {
    font-size: 17px;
}

@media (max-width: 1100px) {
    .shell {
        grid-template-columns: 1fr;
    }

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

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

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

@media (max-width: 720px) {
    .main,
    .sidebar {
        padding: 18px;
    }

    .topbar,
    .actions-row,
    .search,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid,
    .split,
    .user-cards,
    .grid-form,
    .download-grid,
    .mini-metrics,
    .sub-grid,
    .sub-timeline {
        grid-template-columns: 1fr;
    }

    .link-row,
    .sub-hero {
        grid-template-columns: 1fr;
    }

    .usage-ring {
        margin: 0 auto;
        width: 168px;
    }

    .button,
    .search input {
        width: 100%;
        max-width: none;
    }
}
