*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    background: #f0f2f5;
    color: #1a1a2e;
}

code, pre, .font-mono, [style*="monospace"] {
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace !important;
}

/* ── Layout ───────────────────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */

.sidebar {
    width: 220px;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 10;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.1rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.nav-section {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.28);
    padding: 0.85rem 0.65rem 0.3rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    color: rgba(255,255,255,0.58);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.9);
}

.nav-item.active {
    background: rgba(255,255,255,0.11);
    color: #fff;
    font-weight: 500;
}

.nav-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.75;
}

.sidebar-version {
    padding: 0.6rem 1.25rem;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.2);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

/* ── Main content ─────────────────────────────────────────── */

.main-content {
    margin-left: 220px;
    flex: 1;
    background: #f0f2f5;
    min-height: 100vh;
}

.content-body {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.content-title {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

/* ── Stat cards ───────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem 1.5rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border-top: 3px solid transparent;
}

.stat-card.total    { border-top-color: #6b7280; }
.stat-card.active   { border-top-color: #107c10; }
.stat-card.disabled { border-top-color: #d83b01; }
.stat-card.failed   { border-top-color: #a80000; }

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.4rem;
    font-variant-numeric: tabular-nums;
}

.stat-card.total .stat-value    { color: #374151; }
.stat-card.active .stat-value   { color: #107c10; }
.stat-card.disabled .stat-value { color: #d83b01; }
.stat-card.failed .stat-value   { color: #a80000; }

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    margin-bottom: 1.5rem;
}

.card h2, .card h3 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
}

/* ── Quick actions ────────────────────────────────────────── */

.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Page headers ─────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #111827;
}

/* ── Status badges ────────────────────────────────────────── */

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-pending        { background: #e5e7eb; color: #374151; }
.status-provisioning   { background: #dbeafe; color: #1e40af; }
.status-active         { background: #dcfce7; color: #166534; }
.status-disabling      { background: #fef3c7; color: #92400e; }
.status-suspended      { background: #f3f4f6; color: #6b7280; }
.status-enabling       { background: #dbeafe; color: #1e40af; }
.status-deprovisioning { background: #fee2e2; color: #991b1b; }
.status-failed         { background: #fee2e2; color: #7f1d1d; }

/* ── Tables ───────────────────────────────────────────────── */

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

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

th, td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

tbody tr:hover td { background: #f9fafb; }
tbody tr:last-child td { border-bottom: none; }

/* ── Detail grid ──────────────────────────────────────────── */

.detail-grid { margin: 0; }

.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 0.9rem;
    align-items: baseline;
}

.detail-row:last-child { border-bottom: none; }

dt {
    color: #6b7280;
    font-weight: 500;
    padding-right: 1rem;
}

dd { margin: 0; word-break: break-all; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.btn-primary { background: #0078d4; color: #fff; }
.btn-primary:hover { background: #006abc; }

.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }

.btn-sm {
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    background: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}

.btn-sm:hover { background: #e5e7eb; }

/* ── Forms ────────────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 1.25rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1a1a2e;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #0078d4;
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
}

.hint {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.78rem;
    margin-left: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

/* ── Alerts ───────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Misc ─────────────────────────────────────────────────── */

.back-link {
    display: inline-block;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.back-link:hover { color: #374151; }

.text-muted { color: #9ca3af; }

.empty-state {
    color: #6b7280;
    font-size: 0.9rem;
    text-align: center;
    padding: 2.5rem 0;
}

.empty-state a { color: #0078d4; }
.empty-state p { margin: 0.4rem 0; }

code {
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: 0.82em;
    background: #f3f4f6;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    color: #374151;
}

/* ── Info alert ───────────────────────────────────────────── */

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ── Warning alert ────────────────────────────────────────── */

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ── Deploy button ────────────────────────────────────────── */

.btn-deploy {
    background: #166534;
    color: #fff;
    border-color: #166534;
    padding: 0.55rem 1.5rem;
    font-size: 0.925rem;
}

.btn-deploy:hover { background: #14532d; border-color: #14532d; }

.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover { background: #b45309; border-color: #b45309; }

/* ── Audit log action badges ──────────────────────────────── */

.action-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: capitalize;
}

.action-provision_started   { background: #dbeafe; color: #1e40af; }
.action-provision_succeeded { background: #dcfce7; color: #166534; }
.action-provision_failed    { background: #fee2e2; color: #991b1b; }
.action-provision_timeout   { background: #fef3c7; color: #92400e; }
.action-disable_started     { background: #fef3c7; color: #92400e; }
.action-disable_succeeded   { background: #f3f4f6; color: #374151; }
.action-disable_failed      { background: #fee2e2; color: #991b1b; }
.action-enable_started      { background: #dbeafe; color: #1e40af; }
.action-enable_succeeded    { background: #dcfce7; color: #166534; }
.action-enable_failed       { background: #fee2e2; color: #991b1b; }

/* ── Confirm card ─────────────────────────────────────────── */

.confirm-card {
    border: 1px solid #d1fae5;
    background: #f0fdf4;
}

/* ── Pagination ───────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0 0;
    border-top: 1px solid #f0f2f5;
    margin-top: 0.25rem;
}

.pagination-info {
    font-size: 0.8rem;
    color: #6b7280;
    min-width: 4rem;
    text-align: center;
}

/* ── Delete preview ───────────────────────────────────────── */

.delete-preview-card {
    border: 1px solid #fecaca;
    background: #fff5f5;
}

.confirm-delete-card {
    border: 1px solid #e5e7eb;
    background: #fff;
}

.btn-danger {
    background: #991b1b;
    color: #fff;
    border-color: #991b1b;
}

.btn-danger:hover { background: #7f1d1d; border-color: #7f1d1d; }

/* ── Page header action group ─────────────────────────────── */

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ── Resource type badge ──────────────────────────────────── */

.rtype {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* ── Preview page ─────────────────────────────────────────── */

.preview-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
    margin: -0.25rem 0 1rem;
}

.preview-detail {
    font-size: 0.8rem;
}

.preview-table td {
    vertical-align: top;
}

/* ── Code block (pre-formatted commands) ─────────────────── */

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
    line-height: 1.6;
}
