body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: #f1f5f9;
    color: #0f172a;
}

:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --card-soft: #fcfcfd;
    --text: #111111;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #7f15cf;
    --accent-soft: #f3e8ff;
    --danger: #111111;
    --danger-soft: #f3f4f6;
    --warning-soft: #f3e8ff;
    --success-soft: #f3e8ff;
    --shadow: 0 2px 10px rgba(17, 17, 17, 0.03);
}

* {
    box-sizing: border-box;
}

body.admin-dashboard {
    background: var(--bg);
    color: var(--text);
}

.wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 0.875rem;
}

.card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
}

label {
    display: block;
    margin-top: 10px;
    font-size: 0.875rem;
    font-weight: 600;
}

input {
    width: 100%;
    margin-top: 5px;
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    box-sizing: border-box;
}

button {
    margin-top: 12px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.error {
    margin-top: 10px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #7f1d1d;
    border-radius: 7px;
    padding: 9px 10px;
}

.panel-filter {
    min-height: 100%;
}

.shell {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 18px 14px 28px;
}

.topbar,
.panel,
.client-card,
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #111111;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

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

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

.logout {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

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

.stat {
    padding: 12px 14px;
}

.stat strong {
    display: block;
    font-size: 22px;
    margin-top: 4px;
    line-height: 1.1;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    align-items: stretch;
}

.dashboard-span-1 {
    grid-column: span 1;
}

.dashboard-span-2 {
    grid-column: span 2;
}

.dashboard-span-3 {
    grid-column: span 3;
}

.dashboard-span-4 {
    grid-column: 1 / -1;
}

.panel {
    padding: 14px 16px;
}

.dashboard-grid > .panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dashboard-grid > .panel form {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.dashboard-grid > .panel form > button[type="submit"] {
    margin-top: 14px;
    padding-top: 12px;
}

h1,
h2,
h3 {
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 16px;
}

h3 {
    font-size: 14px;
}

p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.45;
}

label {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
button {
    width: 100%;
    margin-top: 5px;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font: inherit;
    font-size: 13px;
}

input,
select {
    background: #fff;
    color: var(--text);
}

button {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    border: 0;
}

button.secondary {
    background: #f3f4f6;
    color: #111111;
    border: 1px solid var(--border);
}

button.danger {
    background: #111111;
}

.flash {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 13px;
}

.flash.success {
    background: var(--success-soft);
    border-color: #d8b4fe;
    color: #6b21a8;
}

.flash.error {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111111;
}

.clients {
    display: grid;
    gap: 8px;
    align-self: start;
}

.client-card {
    padding: 16px 18px;
}

.pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid transparent;
}

.pill.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: #d8b4fe;
}

.pill.disabled {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.pill.locked_by_quota {
    background: #111111;
    color: #ffffff;
}

.client-layout {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
    gap: 10px;
}

.subpanel {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--card-soft);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}

th,
td {
    text-align: left;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
    font-size: 13px;
}

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.client-projects th,
.client-projects td {
    padding-left: 12px;
    padding-right: 12px;
}

.client-projects th:first-child,
.client-projects td:first-child {
    padding-left: 0;
}

.client-projects th:last-child,
.client-projects td:last-child {
    padding-right: 0;
}

.project-cell strong,
.project-usage strong {
    display: inline-block;
    margin-bottom: 2px;
}

.project-meta {
    display: grid;
    gap: 2px;
    margin-top: 2px;
}

.project-meta-row {
    color: var(--muted);
    font-size: 12px;
}

.project-usage {
    min-width: 220px;
}

.usage-summary {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.usage-percent {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

.usage-bar {
    width: 100%;
    height: 6px;
    margin: 7px 0 8px;
    border-radius: 999px;
    background: #e9d5ff;
    overflow: hidden;
}

.usage-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.usage-breakdown {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.metric-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 11px;
    font-weight: 600;
}

.project-actions {
    min-width: 240px;
}

.project-actions .inline-form {
    display: grid;
    grid-template-columns: minmax(72px, 88px) minmax(110px, 1fr) auto;
    align-items: center;
}

.project-actions .inline-form button {
    width: 100%;
}

.project-actions .inline-form:last-child {
    grid-template-columns: 1fr;
}

.project-actions-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.project-actions-controls .inline-form {
    display: block;
}

.project-actions-controls .inline-form button {
    width: 100%;
    margin-top: 0;
}

.inline-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select,
.inline-form button {
    width: auto;
    margin-top: 0;
}

.inline-form input {
    min-width: 76px;
}

.inline-form-row-gap {
    margin-bottom: 6px;
}

.stack-form {
    display: grid;
    gap: 0;
}

.panel-context {
    color: var(--muted);
    font-size: 12px;
}

.mono {
    font-family: Menlo, Monaco, monospace;
    font-size: 12px;
}

.empty {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    font-size: 12px;
}

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

    .dashboard-span-1,
    .dashboard-span-2,
    .dashboard-span-3,
    .dashboard-span-4 {
        grid-column: 1 / -1;
    }

    .client-layout {
        grid-template-columns: 1fr;
    }

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

    .topbar {
        padding: 14px;
    }
}
