:root {
  color-scheme: light;
  --sta-bg: #f4f9fd;
  --sta-surface: #fff;
  --sta-blue-soft: #eaf6ff;
  --sta-primary: #1677c8;
  --sta-deep: #123a5a;
  --sta-text: #17324d;
  --sta-muted: #63788a;
  --sta-border: #ddeaf2;
  --sta-success: #1e9b63;
  --sta-warning: #d98b00;
  --sta-danger: #d84a4a;
  --sta-shadow: 0 12px 32px rgba(18,58,90,.08);
  font-family: Inter, Manrope, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; background: var(--sta-bg); color: var(--sta-text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; overflow: hidden; color: #fff; background: linear-gradient(180deg,#103b5d,#0d2d48); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; margin-top: 3px; font-size: 12px; color: #b9daee; }
.nav { display: grid; gap: 7px; margin-top: 24px; }
.nav button { width: 100%; display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 0; border-radius: 12px; color: #d9edf8; background: transparent; text-align: left; }
.nav button:hover, .nav button.active { color: #fff; background: rgba(25,167,206,.2); }
.nav-icon { width: 24px; text-align: center; font-size: 17px; }
.sidebar-footer { position: absolute; left: 18px; right: 18px; bottom: 22px; padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; color: #c8e0ed; background: rgba(255,255,255,.06); font-size: 12px; line-height: 1.45; }

.content { min-width: 0; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 30px; position: sticky; top: 0; z-index: 4; border-bottom: 1px solid var(--sta-border); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 3px 0 0; color: var(--sta-muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions > span:not(.badge) { color: var(--sta-muted); font-size: 12px; }
main { padding: 30px; }

.icon-button, .primary, .secondary { border-radius: 11px; padding: 10px 14px; font-weight: 800; }
.icon-button, .secondary { border: 1px solid var(--sta-border); color: var(--sta-deep); background: #fff; }
.primary { border: 1px solid var(--sta-primary); color: #fff; background: var(--sta-primary); }

.monitor-banner { padding: 14px 16px; border-radius: 14px; color: #e9f6fe; background: #153d5d; font-size: 13px; line-height: 1.5; }
.card, .health-card { border: 1px solid var(--sta-border); border-radius: 18px; background: var(--sta-surface); box-shadow: var(--sta-shadow); }
.grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; }
.metrics-grid, .mini-grid { margin-top: 18px; }
.metric { padding: 19px; }
.metric span { color: var(--sta-muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 27px; letter-spacing: -.7px; }
.metric small { display: block; margin-top: 7px; color: var(--sta-muted); line-height: 1.4; }
.tone-ok { color: var(--sta-success) !important; }
.tone-warn { color: var(--sta-warning) !important; }
.tone-danger { color: var(--sta-danger) !important; }

.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; white-space: nowrap; font-size: 11px; font-weight: 900; }
.badge.ok { color: #147348; background: #e8f8f0; }
.badge.warn { color: #946100; background: #fff4df; }
.badge.danger { color: #9b2929; background: #fff0f0; }
.badge.info { color: #0f67a9; background: #eaf6ff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.health-section { margin-top: 22px; }
.section-heading, .page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading h2, .page-heading h2 { margin: 0; font-size: 24px; }
.section-heading h3 { margin: 0; font-size: 16px; }
.section-heading p, .page-heading p { margin: 5px 0 0; color: var(--sta-muted); font-size: 13px; line-height: 1.45; }
.health-heading { margin-bottom: 12px; }
.health-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.health-card { min-width: 0; padding: 18px; }
.health-card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .35px; }
.health-kpi { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--sta-border); font-size: 12px; }
.health-kpi:first-of-type { border-top: 0; }
.health-kpi span { color: var(--sta-muted); }
.health-kpi strong { text-align: right; overflow-wrap: anywhere; }
.card-note { margin: 10px 0 0; color: var(--sta-muted); font-size: 11px; line-height: 1.45; }

.summary-section { margin-top: 18px; }
.section-card { padding: 22px; }
.section-card > p { margin: 6px 0 18px; color: var(--sta-muted); font-size: 13px; line-height: 1.5; }
.readiness-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.readiness-grid > div { padding: 14px; border: 1px solid var(--sta-border); border-radius: 14px; background: #fbfdff; }
.readiness-grid span, .readiness-grid small { display: block; color: var(--sta-muted); font-size: 11px; }
.readiness-grid strong { display: block; margin: 6px 0; font-size: 15px; }
.drift-alert { margin-top: 18px; }

.section-grid { margin-top: 18px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.page-heading { margin-bottom: 18px; }
.table-scroll { overflow: auto; }
.risk-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.risk-table th, .risk-table td { padding: 12px; border-bottom: 1px solid var(--sta-border); text-align: left; vertical-align: top; font-size: 13px; }
.risk-table th { color: var(--sta-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.risk-table small { color: var(--sta-muted); }
.event { display: grid; grid-template-columns: 35px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--sta-border); }
.event:last-child { border-bottom: 0; }
.event-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; background: var(--sta-blue-soft); font-weight: 800; }
.event strong { display: block; font-size: 13px; }
.event span { display: block; margin-top: 3px; color: var(--sta-muted); font-size: 12px; line-height: 1.45; }

.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 7px; color: var(--sta-deep); font-size: 13px; font-weight: 800; }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--sta-border); border-radius: 11px; outline: none; color: var(--sta-text); background: #fff; }
.form-stack textarea { min-height: 110px; resize: vertical; }
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus { border-color: var(--sta-primary); box-shadow: 0 0 0 3px rgba(22,119,200,.12); }
.compact-action { margin-top: 14px; }
.permission-box { padding: 16px; border: 1px solid var(--sta-border); border-radius: 14px; background: #f8fbfd; }
.permission-box p { margin-bottom: 0; color: var(--sta-muted); line-height: 1.55; }

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.alert.danger { border: 1px solid #f2baba; color: #9b2929; background: #fff0f0; }
.alert.success { border: 1px solid #a9dec4; color: #176e49; background: #ecfaf3; }
.alert.warning-box { border: 1px solid #f1d79d; color: #72520e; background: #fff9ea; }

.result-card { margin-top: 18px; padding: 22px; }
.result-card h3 { margin: 0 0 12px; }
.result-card pre { margin: 0; max-height: 420px; overflow: auto; padding: 15px; border-radius: 12px; color: #eaf6ff; background: #0f2d46; font-size: 12px; line-height: 1.5; }
.empty-inline { padding: 16px 0; color: var(--sta-muted); font-size: 13px; }
.loading-card, .error-state { min-height: 260px; display: grid; place-items: center; padding: 28px; border: 1px solid var(--sta-border); border-radius: 18px; text-align: center; background: #fff; }
.spinner { width: 30px; height: 30px; margin-bottom: 14px; border: 3px solid var(--sta-border); border-top-color: var(--sta-primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state h2 { margin: 0 0 8px; }
.error-state p { max-width: 620px; margin: 0 0 18px; color: var(--sta-muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%,rgba(25,167,206,.18),transparent 32%), radial-gradient(circle at 85% 80%,rgba(22,119,200,.15),transparent 30%), var(--sta-bg); }
.login-card { width: min(460px,100%); padding: 34px; border: 1px solid var(--sta-border); border-radius: 24px; background: #fff; box-shadow: var(--sta-shadow); }
.wide-card { width: min(560px,100%); }
.login-card > img { width: 190px; max-height: 64px; object-fit: contain; object-position: left center; }
.login-card h1 { margin: 22px 0 8px; font-size: 28px; }
.login-card p, .login-card small { color: var(--sta-muted); line-height: 1.55; }
.login-card small { display: block; margin-top: 18px; }
.security-label { display: inline-flex; margin-top: 24px; padding: 6px 9px; border-radius: 999px; color: #147348; background: #e8f8f0; font-size: 11px; font-weight: 900; }
.security-label.warning { color: #946100; background: #fff4df; }
.mfa-setup { display: grid; gap: 16px; }
.mfa-qr { width: 260px !important; height: 260px !important; justify-self: center; padding: 14px; border: 1px solid var(--sta-border); border-radius: 18px; object-fit: contain; background: #fff; }
.secret-box { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--sta-border); border-radius: 14px; background: var(--sta-blue-soft); }
.secret-box-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.secret-box code { overflow-wrap: anywhere; }
.actions-row { display: flex; justify-content: flex-end; margin-top: 16px; }
code { padding: 2px 5px; border-radius: 6px; color: var(--sta-deep); background: var(--sta-blue-soft); }

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .health-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .section-grid { grid-template-columns: 1fr; }
  .readiness-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 14px 18px; align-items: flex-start; }
  .top-actions > span:not(.badge) { display: none; }
  main { padding: 18px; }
  .grid, .health-grid, .readiness-grid { grid-template-columns: 1fr; }
  .section-heading, .page-heading { flex-direction: column; }
  .risk-table { min-width: 760px; }
}
