/* Control center — design tokens. Light by default, dark by system setting or the toggle. */
:root {
  --font-ui: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --bg: #f4f6fa; --side: #ffffff; --panel: #ffffff; --panel-2: #f6f8fb; --hover: #eef2f8;
  --line: #e3e8f0; --line-2: #d4dbe6; --grid: #e8ecf2;
  --text: #0f172a; --text-2: #334155; --muted: #64748b;
  --accent: #3b63f3; --accent-2: #2f52d6; --accent-soft: rgba(59, 99, 243, .10); --on-accent: #ffffff;
  --ok: #15803d; --ok-soft: rgba(22, 163, 74, .12); --warn: #b45309; --warn-soft: rgba(217, 119, 6, .13);
  --bad: #dc2626; --bad-soft: rgba(220, 38, 38, .11); --crit: #be123c; --crit-soft: rgba(225, 29, 72, .13); --info: #0369a1; --info-soft: rgba(2, 132, 199, .11);
  --c1: #3b63f3; --c2: #0d9488; --c3: #ea8a1a; --c4: #8b5cf6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05); --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --r: 12px; --r-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e15; --side: #0d121b; --panel: #111823; --panel-2: #151d2a; --hover: #1a2433;
    --line: #1f2a3a; --line-2: #2a374b; --grid: #1c2635;
    --text: #e6ebf3; --text-2: #c3ccda; --muted: #8391a7;
    --accent: #6b8dff; --accent-2: #86a2ff; --accent-soft: rgba(107, 141, 255, .14); --on-accent: #0a0e15;
    --ok: #34d399; --ok-soft: rgba(52, 211, 153, .13); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
    --bad: #f87171; --bad-soft: rgba(248, 113, 113, .14); --crit: #fb7185; --crit-soft: rgba(251, 113, 133, .16); --info: #38bdf8; --info-soft: rgba(56, 189, 248, .13);
    --c1: #6b8dff; --c2: #2dd4bf; --c3: #f5a524; --c4: #a78bfa;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .02) inset; --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e15; --side: #0d121b; --panel: #111823; --panel-2: #151d2a; --hover: #1a2433;
  --line: #1f2a3a; --line-2: #2a374b; --grid: #1c2635;
  --text: #e6ebf3; --text-2: #c3ccda; --muted: #8391a7;
  --accent: #6b8dff; --accent-2: #86a2ff; --accent-soft: rgba(107, 141, 255, .14); --on-accent: #0a0e15;
  --ok: #34d399; --ok-soft: rgba(52, 211, 153, .13); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
  --bad: #f87171; --bad-soft: rgba(248, 113, 113, .14); --crit: #fb7185; --crit-soft: rgba(251, 113, 133, .16); --info: #38bdf8; --info-soft: rgba(56, 189, 248, .13);
  --c1: #6b8dff; --c2: #2dd4bf; --c3: #f5a524; --c4: #a78bfa;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .02) inset; --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* --- base ------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.block { display: block; }
.ellipsis { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-act { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.audit-act .ellipsis { max-width: 360px; }
.icon { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- controls ----------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--hover); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.only-icon { padding: 0; width: 36px; }
.btn.sm.only-icon { width: 30px; }
.btn.block { width: 100%; height: 42px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }

input, select, textarea { width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel);
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); opacity: .8; }
input.otp { font-family: var(--font-mono); font-size: 20px; letter-spacing: .45em; text-align: center; height: 46px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { margin-top: 5px; font-size: 12px; color: var(--muted); }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 4px; }
.form-error:empty { min-height: 0; }
.form-section { margin: 18px 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* --- layout ------------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; background: var(--side); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; flex: none;
  background: linear-gradient(135deg, #4f7bff 0%, #6a4dff 55%, #9b4dff 100%); box-shadow: 0 6px 18px rgba(88, 99, 255, .35); }
.logo .icon { width: 21px; height: 21px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-2); font-weight: 550; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item span:not(.nav-badge):not(.count) { flex: 1; }
.nav-badge .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-link { display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 550; }
.side-link:hover { background: var(--hover); }
.side-status { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.side-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.side-status.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 2.4s infinite; }
.side-status.bad .dot { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.ss-t { font-size: 13px; font-weight: 600; }
.ss-s { font-size: 11.5px; color: var(--muted); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px var(--ok-soft); } 50% { box-shadow: 0 0 0 7px transparent; } }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 6px 2px 8px; }
.me-name { flex: 1; min-width: 0; }
.me-name strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.me-name small { color: var(--muted); }
.main { padding: 28px 32px 48px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 650; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.charts { gap: 20px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 36px; }
.portal-id { display: flex; flex-direction: column; margin-right: 8px; }
.portal-id strong { font-size: 15px; }
.portal-id a { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.portal-id a .icon { width: 12px; height: 12px; }
.portal-tabs { margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

/* badges, dots, avatars */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bad, .badge.high { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn, .badge.medium { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.critical { background: var(--crit); color: #fff; border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 12.5px; font-weight: 700; flex: none; color: #fff; }
.av-0 { background: linear-gradient(135deg, #3b82f6, #6366f1); } .av-1 { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.av-2 { background: linear-gradient(135deg, #f59e0b, #ef4444); } .av-3 { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.av-4 { background: linear-gradient(135deg, #10b981, #84cc16); } .av-5 { background: linear-gradient(135deg, #f43f5e, #f97316); }
.you { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }

/* --- overview ----------------------------------------------------------------------------- */
.health-card { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); margin-bottom: 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.health-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; }
.health-icon .icon { width: 22px; height: 22px; }
.health-card.ok .health-icon { background: var(--ok-soft); color: var(--ok); }
.health-card.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.health-card.warn .health-icon { background: var(--warn-soft); color: var(--warn); }
.health-card.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.health-card.bad .health-icon { background: var(--bad-soft); color: var(--bad); }
.health-card.idle .health-icon { background: var(--info-soft); color: var(--info); }
.health-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
.health-main strong { font-size: 15px; }
.health-main span { color: var(--muted); }
.health-main .health-err { color: var(--bad); font-size: 12.5px; margin-top: 2px; }
.health-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.health-meta span { display: inline-flex; align-items: center; gap: 6px; }
.health-meta .icon { width: 15px; height: 15px; }
.health-meta strong { color: var(--text); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { margin: 0; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.kpi.wide { grid-column: 1 / -1; }
.kpi-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-head .icon { width: 16px; height: 16px; }
.kpi-body { display: flex; align-items: center; gap: 14px; }
.kpi-txt { min-width: 0; }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); flex: none; }
.kpi-ic .icon { width: 24px; height: 24px; }
.ring { width: 56px; height: 56px; flex: none; }
.ring-bg { fill: none; stroke: var(--grid); stroke-width: 6; }
.ring-fg { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring.ok .ring-fg { stroke: var(--ok); } .ring.warn .ring-fg { stroke: var(--warn); } .ring.bad .ring-fg { stroke: var(--bad); }
.ring-txt { font: 700 12px var(--font-ui); fill: var(--text); }
.spark { width: 100%; height: 40px; display: block; margin: 0 -2px -6px; }
.spark-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-area { stroke: none; opacity: .12; }
.spark.c1 .spark-line { stroke: var(--c1); } .spark.c1 .spark-area { fill: var(--c1); }
.spark.c2 .spark-line { stroke: var(--c2); } .spark.c2 .spark-area { fill: var(--c2); }
.spark.c4 .spark-line { stroke: var(--c4); } .spark.c4 .spark-area { fill: var(--c4); }
.spark-empty { height: 40px; }

.chart-block { min-width: 0; }
.chart-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 13px; color: var(--text-2); margin: 4px 0 8px; }
.legend { display: flex; gap: 12px; font-weight: 500; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }
.legend i.c1 { background: var(--c1); } .legend i.c2 { background: var(--c2); } .legend i.c3 { background: var(--c3); }
.chart-wrap { position: relative; }
canvas.chart { width: 100%; display: block; cursor: crosshair; }
.chart-tip { position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s; background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 8px 10px; box-shadow: var(--shadow-lg); font-size: 12px; min-width: 130px; z-index: 2; }
.chart-tip.on { opacity: 1; }
.tip-t { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; }
.tip-row strong { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.app-card { border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: var(--panel-2); display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.app-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ok); }
.app-card.down::before { background: var(--bad); }
.app-top { display: flex; align-items: center; gap: 10px; }
.app-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); flex: none; }
.app-ic .icon { width: 17px; height: 17px; }
.app-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.app-metrics div { display: flex; flex-direction: column; }
.app-metrics small { color: var(--muted); font-size: 11.5px; }
.app-metrics strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.warn-t { color: var(--warn); }
.app-foot { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }

.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.svc { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); }
.svc .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.svc.ok .dot { background: var(--ok); } .svc.bad .dot { background: var(--bad); }
.svc.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); }
.svc-name { flex: 1; font-weight: 600; font-size: 13px; }
.svc-state { font-size: 12px; color: var(--muted); }
.svc.bad .svc-state { color: var(--bad); }
.req-list { display: flex; flex-direction: column; gap: 12px; }
.req-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.req-host { flex: 1; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.req-bar { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.req-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--c1), var(--c4)); }

/* --- tables ------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  padding: 10px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.tbl th:first-child { border-top-left-radius: 8px; } .tbl th:last-child { border-top-right-radius: 8px; }
.tbl td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.dim .user-cell { opacity: .6; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.user-cell > div { min-width: 0; }
.user-cell strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.user-cell small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.user-cell .badge { margin-top: 4px; }
.meter { min-width: 90px; }
.meter-txt { font-size: 13px; font-variant-numeric: tabular-nums; }
.meter-bar { height: 5px; border-radius: 3px; background: var(--grid); margin-top: 4px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.meter-bar i.warn { background: var(--warn); } .meter-bar i.bad { background: var(--bad); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.pager-btns { display: flex; align-items: center; gap: 6px; }

/* --- security ----------------------------------------------------------------------------- */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.callout.bad .icon { color: var(--bad); margin-top: 2px; }
.sev-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.sev-tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.sev-tile strong { display: block; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sev-tile small { color: var(--muted); }
.sev-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex: none; }
.sev-tile.critical .sev-ic { background: var(--crit-soft); color: var(--crit); }
.sev-tile.high .sev-ic { background: var(--bad-soft); color: var(--bad); }
.sev-tile.medium .sev-ic { background: var(--warn-soft); color: var(--warn); }
.sev-tile.info .sev-ic { background: var(--info-soft); color: var(--info); }
.sev-tile.critical:not(.zero) { border-color: color-mix(in srgb, var(--crit) 50%, var(--line)); }
.sev-tile.zero { opacity: .7; }
.events { display: flex; flex-direction: column; }
.event { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.event.critical .event-ic { background: var(--crit-soft); color: var(--crit); }
.event.high .event-ic { background: var(--bad-soft); color: var(--bad); }
.event.medium .event-ic { background: var(--warn-soft); color: var(--warn); }
.event.info .event-ic { background: var(--info-soft); color: var(--info); }
.event.acked { opacity: .62; }
.event-main { flex: 1; min-width: 0; }
.event-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.event-cat { font-weight: 600; }
.event-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.event-title { font-weight: 600; margin-top: 4px; overflow-wrap: anywhere; }
.event details { margin-top: 6px; }
.event summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 600; width: max-content; }
.event pre { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font: 12px/1.5 var(--font-mono); color: var(--text-2);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.event-side { display: flex; align-items: flex-start; }
.acked-by { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.acked-by .icon { width: 14px; height: 14px; color: var(--ok); }

/* --- settings ----------------------------------------------------------------------------- */
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv span { color: var(--muted); }
.session-list { display: flex; flex-direction: column; gap: 8px; }
.session { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); }
.session.current { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.session-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); flex: none; }
.session-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-main small { color: var(--muted); max-width: none; }
.session-meta { display: flex; flex-direction: column; align-items: flex-end; }
.session-meta small { color: var(--muted); }
.qr-box { text-align: center; }
.qr { width: 220px; height: 220px; display: block; margin: 12px auto; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }

/* --- overlays ----------------------------------------------------------------------------- */
.modal-back { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px 24px; overflow: auto;
  background: rgba(8, 12, 20, .52); backdrop-filter: blur(3px); animation: fade .15s ease; }
.modal { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .18s ease; }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal-head h2 { flex: 1; font-size: 17px; font-weight: 700; }
.modal-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.modal-icon.bad { background: var(--bad-soft); color: var(--bad); }
.modal-body { padding: 16px 20px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.modal-user { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 8px; }
.lead { margin: 0 0 14px; color: var(--text-2); }
.stepup-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.stepup-note .icon { color: var(--accent); width: 16px; height: 16px; margin-top: 2px; }
.secret { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px dashed var(--line-2); }
.secret code { flex: 1; font: 600 17px var(--font-mono); letter-spacing: .04em; word-break: break-all; text-align: left; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.menu { position: absolute; z-index: 40; min-width: 220px; padding: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: rise .12s ease; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; text-align: left; font-weight: 500; }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--hover); }
.menu-item.danger, .menu-item.danger .icon { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-soft); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 11px; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); animation: rise .18s ease; transition: opacity .25s, transform .25s; }
.toast .icon { width: 18px; height: 18px; }
.toast.ok .icon { color: var(--ok); } .toast.err .icon { color: var(--bad); } .toast.info .icon { color: var(--info); }
.toast.err { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* empty and loading states */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 16px; color: var(--muted); text-align: center; }
.empty .icon { width: 30px; height: 30px; opacity: .55; }
.skel-wrap { display: flex; flex-direction: column; gap: 10px; }
.skel { height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--grid) 0%, var(--hover) 50%, var(--grid) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.skel:nth-child(2n) { width: 75%; } .skel:nth-child(3n) { width: 55%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* --- login -------------------------------------------------------------------------------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 15% -10%, rgba(99, 102, 241, .18), transparent 60%), radial-gradient(700px 500px at 110% 110%, rgba(20, 184, 166, .14), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 30px 28px 24px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login-brand .logo { width: 46px; height: 46px; border-radius: 13px; }
.login-brand .logo .icon { width: 24px; height: 24px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.login-card .btn.block { margin-top: 6px; }
.login-foot { display: flex; align-items: center; gap: 7px; margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.login-foot .icon { width: 14px; height: 14px; }

/* --- responsive --------------------------------------------------------------------------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .brand > div { display: none; }
  .logo { width: 34px; height: 34px; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-item { width: auto; height: 36px; padding: 0 10px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; border: 0; padding: 0; }
  .side-status, .me-name, .side-link span { display: none; }
  .side-link { padding: 0 9px; }
  .me { padding: 0; }
  .me .avatar { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid-2, .sev-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2.charts, .grid-2:not(.charts) { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-item span:not(.nav-badge):not(.count) { display: none; }
  .kpis { grid-template-columns: 1fr; }
  .sev-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .toolbar > * { flex: 1 1 100%; }
  /* tables turn into stacked cards */
  .tbl.responsive thead { display: none; }
  .tbl.responsive, .tbl.responsive tbody, .tbl.responsive tr, .tbl.responsive td { display: block; width: 100%; }
  .tbl.responsive tr { border: 1px solid var(--line); border-radius: 11px; padding: 6px 12px; margin-bottom: 10px; background: var(--panel); }
  .tbl.responsive td { border: 0; padding: 7px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  .tbl.responsive td[data-label="Korisnik"], .tbl.responsive td[data-label="Administrator"] { display: block; text-align: left; }
  .tbl.responsive td[data-label="Korisnik"]::before, .tbl.responsive td[data-label="Administrator"]::before { display: none; }
  .tbl.responsive td.actions { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
  .ellipsis { max-width: 60vw; }
  .event-time { margin-left: 0; }
  .session { flex-wrap: wrap; }
  .session-meta { align-items: flex-start; width: 100%; padding-left: 48px; }
  .modal-back { padding-top: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.user-cell .uname { font-family: var(--font-mono); font-size: 11.5px; }
.tbl.fixed { table-layout: fixed; }
.tbl.fixed .ellipsis, .tbl.fixed .audit-act .ellipsis { max-width: 100%; }
.tbl.fixed td { overflow: hidden; }
.tbl.fixed .audit-act { align-items: stretch; }
.tbl.fixed .audit-act .badge { align-self: flex-start; }
@media (max-width: 640px) { .tbl.responsive colgroup { display: none; } .tbl.fixed .ellipsis { max-width: 62vw; } }
@media (max-width: 960px) { .sidebar { scrollbar-width: none; } .sidebar::-webkit-scrollbar { display: none; } }

/* --- protection ------------------------------------------------------------------------------ */
.posture-top { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 16px; margin-bottom: 16px; }
.posture-top > .card { margin: 0; }
.score-card { display: flex; align-items: center; gap: 22px; }
.ring.big { width: 120px; height: 120px; }
.ring.big .ring-bg, .ring.big .ring-fg { stroke-width: 10; }
.ring-txt.big { font-size: 30px; font-weight: 800; }
.score-title { font-size: 17px; font-weight: 700; }
.score-sub { color: var(--text-2); margin: 4px 0 6px; }
.mini-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mini { margin: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; border-left: 3px solid var(--line-2); }
.mini.ok { border-left-color: var(--ok); } .mini.bad { border-left-color: var(--bad); } .mini.warn { border-left-color: var(--warn); }
.mini-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.mini-head .icon { width: 15px; height: 15px; }
.mini-v { font-weight: 650; }
.mini.bad .mini-v { color: var(--bad); }
.posture-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.checks { display: flex; flex-direction: column; }
.check { display: flex; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.check:last-child { border-bottom: 0; }
.check-ic { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none; }
.check-ic .icon { width: 15px; height: 15px; }
.check.ok .check-ic { background: var(--ok-soft); color: var(--ok); }
.check.warn .check-ic { background: var(--warn-soft); color: var(--warn); }
.check.bad .check-ic { background: var(--bad-soft); color: var(--bad); }
.check.idle .check-ic { background: var(--panel-2); color: var(--muted); }
.check-main { flex: 1; min-width: 0; }
.check-title { font-weight: 600; }
.check-detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.check-fix { margin-top: 6px; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); overflow-wrap: anywhere; }
.check-state { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.check.bad .check-state { color: var(--bad); } .check.warn .check-state { color: var(--warn); } .check.ok .check-state { color: var(--ok); }
.ban-list { display: flex; flex-direction: column; gap: 6px; }
.ban { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); }
.spacer { flex: 1; }
.lynis-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.lynis-item { font-size: 13px; padding: 7px 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.lynis-item .mono { margin-right: 8px; color: var(--muted); }
.lynis-item.warn .mono { color: var(--warn); }
.lynis-more summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 10px; }
.callout.info { background: var(--accent-soft); border-color: transparent; }
.callout.info .icon { color: var(--accent); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; margin: 8px 0 12px; }
.callout.warn .icon { color: var(--warn); margin-top: 2px; }

/* --- API keys ---------------------------------------------------------------------------------- */
.key-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.keys { display: flex; flex-direction: column; }
.key-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row.locked { opacity: .65; }
.key-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); flex: none; }
.key-row.locked .key-ic { background: var(--panel-2); color: var(--muted); }
.key-ic .icon { width: 15px; height: 15px; }
.key-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.key-main strong { font-size: 12.5px; overflow-wrap: anywhere; }
.key-main small { color: var(--muted); }
.key-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.fp { font-family: var(--font-mono); font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; font-family: var(--font-mono); }
@media (max-width: 1100px) { .posture-top, .posture-groups, .key-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .mini-cards { grid-template-columns: minmax(0, 1fr); } .score-card { flex-direction: column; text-align: center; } .key-row { flex-wrap: wrap; } }

/* --- image AI per portal (API keys page) ------------------------------------------------------- */
.ai-box { border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); padding: 14px; margin-bottom: 6px; }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ai-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-quick { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ai-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.ai-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.ai-row select { height: 34px; font-size: 13px; }
.change-list { margin: 0 0 12px; padding-left: 18px; }
.change-list li { margin: 3px 0; }
@media (max-width: 640px) { .ai-rows { grid-template-columns: minmax(0, 1fr); } }
