/* AdminUI structure; shared typography and controls come from the WebUI visual baseline. */
.page {
    --bg: #f3f4f5;
    --surface: #fff;
    --surface-2: #e8eaec;
    --border: #d1d5db;
    --text: #1f2328;
    --muted: #606771;
    --accent: #4b5563;
    --accent-strong: #30363d;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem;
    background: #2f3338;
    color: #fff;
}

.brand { color: #fff; font-size: 1.1rem; font-weight: 700; text-decoration: none; }
.console-label { margin: 0.3rem 0 1rem; color: #c7cbd1; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 0.25rem; }
.sidebar nav a { display: flex; align-items: center; min-height: 3rem; border-radius: 4px; color: #e5e7eb; padding: 0 0.75rem; text-decoration: none; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.sidebar nav a.active { background: #f3f4f6; color: #1f2328; }
.nav-footer { display: grid; gap: 0.5rem; margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.18); padding-top: 0.75rem; }
.nav-footer small { color: #c7cbd1; }
.nav-footer .button.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.main { min-width: 0; min-height: 100vh; background: var(--bg); }
.content { padding: 2rem 1.5rem; }

.master-detail,
.admin-layout { display: grid; grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.selection-list { display: grid; gap: 0.4rem; margin-top: 1rem; }
.selection-list button { display: grid; gap: 0.2rem; width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); padding: 0.7rem; text-align: left; }
.selection-list button.selected { border-color: var(--accent); background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.75rem; align-items: end; }
.report-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem; align-items: end; }
.actions { display: flex; gap: 0.5rem; align-items: center; }
.panel { margin-top: 0; }
.panel + .panel { margin-top: 1rem; }
.metric-card.selectable { width: 100%; color: inherit; text-align: left; cursor: pointer; }
.button.danger { border-color: var(--bad); background: var(--bad); color: #fff; }
.status.ok { background: #e7f6ee; color: var(--ok); }
.status.warn { background: #fff5dc; color: var(--warn); }
.status.bad { background: #fff1ef; color: var(--bad); }
.loading { padding: 3rem; text-align: center; }
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0; background: #fff3cd; padding: 0.8rem; }

/* Admin forms need normal prose labels for checks; the shared baseline intentionally
   uses compact uppercase labels for field captions. */
.check-field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.35rem;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
    text-transform: none;
}

.check-field input {
    width: 1rem;
    min-height: 1rem;
    padding: 0;
}

.admin-detail,
.quota-editor,
.tenant-users-editor,
.mapping-rules-editor {
    display: grid;
    gap: 1rem;
}

.master-panel {
    position: sticky;
    top: 1rem;
}

.tenant-search-grid {
    display: grid;
    gap: 0.65rem;
}

.search-actions,
.editor-actions {
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.tenant-access {
    display: flex;
    gap: 0.5rem;
    min-width: min(28rem, 50vw);
}

.tenant-tabs {
    justify-self: start;
}

.plan-form-section {
    display: grid;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.85rem;
}

.plan-form-section h3 {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    padding: 0.5rem 0.65rem;
}

.plan-form-grid {
    display: grid;
    gap: 0.75rem;
    align-items: end;
}

.compact-grid { grid-template-columns: minmax(14rem, 28rem); }
.quota-grid,
.sending-grid,
.billing-grid,
.retention-grid,
.plan-editor-grid,
.user-editor-grid,
.mapping-rule-grid,
.tenant-details-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.summary-grid div {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem;
}

.summary-grid span,
.snapshot-age {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.summary-grid strong { overflow-wrap: anywhere; font-size: 0.9rem; }
.client-context { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-top: 0.85rem; color: var(--muted); font-size: 0.85rem; }
.secret-output textarea { margin: 0.5rem 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.plan-preview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.plan-preview div { display: grid; gap: 0.2rem; min-width: 0; }
.plan-preview span { color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.plan-preview strong { overflow-wrap: anywhere; }

.override-field {
    border-color: #d97706;
    background: #fffbeb;
    box-shadow: inset 3px 0 0 #f59e0b;
}

.override-field > h3 { color: #92400e; }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-dot { width: 0.65rem; height: 0.65rem; border-radius: 50%; }
.legend-dot.delivered { background: #147a4a; }
.legend-dot.queued { background: #2364aa; }
.legend-dot.deferred { background: #9a6200; }
.legend-dot.failed { background: #b42318; }
.chart-wrap { min-width: 42rem; overflow-x: auto; }
.chart-plot { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr); gap: 0.5rem; }
.chart-y-labels { display: flex; flex-direction: column; justify-content: space-between; padding: 1.85rem 0; color: var(--muted); font-size: 0.75rem; }
.timeseries-chart { width: 100%; min-width: 42rem; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 3; }
.chart-line.delivered, .chart-point.delivered { stroke: #147a4a; fill: #147a4a; }
.chart-line.queued, .chart-point.queued { stroke: #2364aa; fill: #2364aa; }
.chart-line.deferred, .chart-point.deferred { stroke: #9a6200; fill: #9a6200; }
.chart-line.failed, .chart-point.failed { stroke: #b42318; fill: #b42318; }
.chart-x-labels { display: grid; min-width: 42rem; gap: 0.25rem; padding-left: 3.75rem; color: var(--muted); font-size: 0.75rem; text-align: center; }
.empty { padding: 1.5rem; color: var(--muted); text-align: center; }

@media (max-width: 1200px) {
    .dashboard-metrics { grid-template-columns: repeat(3, minmax(10rem, 1fr)); }
    .quota-grid, .sending-grid, .billing-grid, .retention-grid, .plan-editor-grid, .user-editor-grid, .mapping-rule-grid, .tenant-details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plan-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .master-detail, .admin-layout { grid-template-columns: 1fr; }
    .master-panel { position: static; }
    .tenant-access { min-width: 0; width: 100%; }
    .page-header, .panel-head { align-items: flex-start; flex-wrap: wrap; }
    .actions { flex-wrap: wrap; }
}

@media (max-width: 760px) {
    .page,
    .master-detail,
    .admin-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .content { padding: 1rem; }
    .quota-grid, .sending-grid, .billing-grid, .retention-grid, .plan-editor-grid, .user-editor-grid, .mapping-rule-grid, .tenant-details-grid, .summary-grid, .plan-preview, .dashboard-metrics { grid-template-columns: 1fr; }
    .tenant-access { display: grid; }
    .tenant-tabs { display: flex; width: 100%; overflow-x: auto; }
    .content { padding: 1rem 0.75rem; }
}
