:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #697386;
  --line: #e2e8f0;
  --primary: #2251cc;
  --primary-dark: #173c9e;
  --success: #16835d;
  --warning: #c7780a;
  --danger: #c73d4a;
  --critical: #9f1830;
  --dark: #2c3547;
  --shadow: 0 12px 30px rgba(31, 48, 78, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: radial-gradient(circle at top right, rgba(34,81,204,.08), transparent 34rem), var(--bg); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 72px; padding: 0 28px; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(226,232,240,.9); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-weight: 800; color: white; background: linear-gradient(135deg, var(--primary), #6d45d7); box-shadow: 0 8px 18px rgba(34,81,204,.24); }
.brand-mark.big { width: 56px; height: 56px; border-radius: 17px; font-size: 20px; }
.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar nav form { margin: 0; }
.user-chip { padding: 8px 12px; border-radius: 999px; background: #eef3ff; color: #29468d; }
.link-button { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0; }
.page { width: min(1450px, calc(100% - 32px)); margin: 28px auto 56px; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; padding: 28px 32px; border-radius: 24px; color: white; background: linear-gradient(120deg, #172f72, #245bd0 58%, #6b49d7); box-shadow: 0 18px 45px rgba(28,58,135,.22); }
.hero.compact { padding: 24px 30px; }
.hero h1 { margin: 4px 0 7px; font-size: clamp(28px, 4vw, 44px); line-height: 1.08; }
.hero p { margin: 0; color: rgba(255,255,255,.8); }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .16em; color: #cdddff !important; }
.status-badge { flex: 0 0 auto; padding: 13px 18px; border-radius: 999px; font-weight: 800; border: 1px solid rgba(255,255,255,.24); background: rgba(255,255,255,.15); }
.status-badge.healthy { background: rgba(24,151,101,.86); }
.status-badge.warning { background: rgba(207,128,12,.9); }
.status-badge.critical { background: rgba(180,31,57,.92); }
.status-badge.unknown { background: rgba(44,53,71,.7); }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { padding: 19px; border-radius: var(--radius); background: var(--panel); border: 1px solid rgba(226,232,240,.9); box-shadow: var(--shadow); }
.metric-card span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { display: block; font-size: 32px; margin: 7px 0 2px; letter-spacing: -.04em; }
.metric-card small { color: #8a94a6; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: minmax(0,1.55fr) minmax(330px,.85fr); }
.panel { background: var(--panel); border: 1px solid rgba(226,232,240,.95); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 19px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
canvas { width: 100%; height: auto; max-height: 280px; background: linear-gradient(180deg,#fbfdff,#f7faff); border: 1px solid var(--line); border-radius: 14px; }
.chart-legend { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.legend.waiting { background: #d58a18; }
.legend.active { background: #2251cc; }
.resource-list { display: grid; gap: 16px; }
.resource-list > div { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 12px; }
.resource-list span { color: var(--muted); }
.resource-list strong { text-align: right; }
.progress { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: #e9eef6; overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--primary),#6c46d8); transition: width .35s ease; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.state { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.state::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #a3acbb; }
.state.running::before { background: var(--success); box-shadow: 0 0 0 4px rgba(22,131,93,.12); }
.state.stopped::before, .state.exited::before, .state.missing::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(199,61,74,.11); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 11px; border: 1px solid transparent; padding: 9px 15px; font-weight: 750; cursor: pointer; transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(32,46,78,.12); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--primary); }
.button.secondary { color: var(--ink); background: #f7f9fc; border-color: var(--line); }
.button.warning { color: #7c4600; background: #fff0d8; border-color: #f2c77e; }
.button.danger { color: #8f2030; background: #ffe7ea; border-color: #efb2ba; }
.button.success { color: #086848; background: #dcf7eb; border-color: #a6ddc7; }
.button.dark { color: white; background: var(--dark); }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.action-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; }
.danger-zone { border-color: #f0d2d6; }
.action-result { margin-top: 15px; padding: 12px 14px; border-radius: 10px; background: #eef8f4; color: #0f6d4c; white-space: pre-wrap; }
.log-box { min-height: 250px; max-height: 410px; overflow: auto; padding: 14px; border-radius: 13px; color: #d9e1ef; background: #111827; font: 12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
.log-line { padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.log-line strong { color: #93c5fd; }
.execution-list { min-height: 250px; max-height: 410px; overflow: auto; }
.execution { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.execution:last-child { border-bottom: 0; }
.execution h3 { margin: 0 0 4px; font-size: 14px; }
.execution p { margin: 0; color: var(--muted); font-size: 12px; }
.audit-list { max-height: 360px; overflow: auto; }
.audit-item { display: grid; grid-template-columns: 160px 150px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-item:last-child { border-bottom: 0; }
.audit-ok { color: var(--success); font-weight: 800; }
.audit-fail { color: var(--danger); font-weight: 800; }
.warnings { display: grid; gap: 8px; margin-bottom: 18px; }
.warning-item { padding: 13px 16px; border-radius: 12px; color: #7b4400; background: #fff2dc; border: 1px solid #f1cf95; }
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; }
.alert.danger { color: #8d2432; background: #ffe8eb; border: 1px solid #efbbc2; }
.alert.success { color: #0c6748; background: #e1f7ed; border: 1px solid #aaddc7; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(460px,100%); padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 24px 60px rgba(31,48,78,.13); }
.login-title { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.login-title h1 { margin: 0; font-size: 22px; }
.login-title p { margin: 5px 0 0; color: var(--muted); }
.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 7px; color: #485366; font-size: 14px; font-weight: 700; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: #fff; border: 1px solid #cfd7e5; border-radius: 10px; outline: none; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(34,81,204,.1); }
.user-grid { grid-template-columns: minmax(360px,.8fr) minmax(0,1.2fr) !important; }
.permission-list { display: grid; gap: 13px; }
.permission-list > div { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fafcff; }
.permission-list p { margin: 5px 0 0; color: var(--muted); }
.role { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.role-viewer { color: #49566d; background: #edf0f5; }
.role-instructor { color: #805000; background: #fff0cc; }
.role-admin { color: #173f9d; background: #e5edff; }
@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3,1fr); }
  .action-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 820px) {
  .topbar { padding: 0 16px; align-items: flex-start; flex-direction: column; padding-top: 12px; padding-bottom: 12px; }
  .topbar nav { width: 100%; overflow-x: auto; }
  .page { width: min(100% - 20px,1450px); margin-top: 16px; }
  .hero { align-items: flex-start; flex-direction: column; padding: 24px; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .grid.two, .user-grid { grid-template-columns: 1fr !important; }
  .action-grid { grid-template-columns: repeat(2,1fr); }
  .audit-item { grid-template-columns: 1fr; gap: 3px; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
}
