:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #66717d;
  --line: #dce2e7;
  --panel: #ffffff;
  --canvas: #f3f6f7;
  --soft: #edf2f4;
  --green: #087a55;
  --green-soft: #e2f3ed;
  --blue: #2f6fed;
  --blue-soft: #e8efff;
  --amber: #b96b00;
  --amber-soft: #fff2d7;
  --red: #b4232f;
  --red-soft: #fdebee;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea { font: inherit; letter-spacing: 0; }

button { cursor: pointer; }

.boot,
.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}

.boot { gap: 12px; }

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-size: 18px;
  font-weight: 850;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.qeyet-wordmark {
  --qeyet-wordmark-size: 25px;
  align-items: baseline;
  color: var(--ink);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: var(--qeyet-wordmark-size);
  font-variant-ligatures: none;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

.qeyet-wordmark.compact { --qeyet-wordmark-size: 21px; }

.qeyet-wordmark-eye {
  font-size: .72em;
  line-height: 1;
  margin: 0 .045em;
  position: relative;
}

.qeyet-wordmark-eye::before {
  background: currentColor;
  border-radius: 2px;
  content: "";
  height: .075em;
  left: 0;
  position: absolute;
  right: 0;
  top: -.22em;
}

.login-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  max-width: 430px;
  padding: 26px;
  width: calc(100% - 32px);
}

.login-heading { align-items: center; display: flex; gap: 12px; }
.login-heading h1 { font-size: 20px; margin: 0; }
.login-heading p { color: var(--muted); margin: 3px 0 0; }

label { color: var(--muted); display: grid; font-size: 12px; font-weight: 700; gap: 6px; }

input,
select,
textarea {
  background: #fff;
  border: 1px solid #cbd3da;
  border-radius: 6px;
  color: var(--ink);
  min-height: 40px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

textarea { min-height: 92px; resize: vertical; }

input:focus,
select:focus,
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }

.primary,
.secondary,
.danger-button,
.icon-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 750;
  gap: 7px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
}

.primary { background: var(--green); color: #fff; }
.primary { text-decoration: none; }
.primary:hover { background: #066b4a; }
.secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.secondary:hover { background: var(--soft); }
.danger-button { background: var(--red); color: #fff; }
.icon-button { background: transparent; color: var(--muted); height: 38px; padding: 8px; width: 38px; }
.icon-button:hover { background: var(--soft); color: var(--ink); }
.icon-button svg, button svg { height: 17px; width: 17px; }

.operator-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: sticky;
  top: 0;
}

.sidebar-brand { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 10px; min-height: 66px; padding: 12px 16px; }
.sidebar-brand strong { display: block; }
.sidebar-brand > div > span:last-child { color: var(--muted); display: block; font-size: 11px; margin-top: 2px; }

.nav-list { display: grid; gap: 3px; padding: 12px 8px; }
.nav-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #4d5965;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  min-height: 40px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}
.nav-button.active { background: var(--green-soft); color: var(--green); font-weight: 800; }
.nav-button:hover { background: var(--soft); }
.nav-button svg { height: 18px; width: 18px; }

.sidebar-footer { border-top: 1px solid var(--line); margin-top: auto; padding: 12px; }
.node-mini-status { align-items: center; color: var(--muted); display: flex; font-size: 11px; gap: 7px; margin-bottom: 10px; }
.live-dot { background: #9ca6af; border-radius: 50%; height: 8px; width: 8px; }
.live-dot.online { background: #16a36f; }

.main-area { min-width: 0; }
.topbar { align-items: center; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); display: flex; gap: 12px; min-height: 66px; padding: 10px 22px; position: sticky; top: 0; z-index: 10; }
.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 18px; margin: 0; }
.topbar-title p { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.topbar-actions { align-items: center; display: flex; gap: 8px; margin-left: auto; }
.range-select { min-height: 36px; padding: 6px 30px 6px 9px; width: auto; }

.content { display: grid; gap: 20px; margin: 0 auto; max-width: 1500px; padding: 22px; }

.metrics-grid { display: grid; gap: 10px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 7px; display: grid; gap: 7px; min-height: 104px; padding: 13px; }
.metric-label { align-items: center; color: var(--muted); display: flex; font-size: 11px; font-weight: 750; gap: 6px; }
.metric-label svg { height: 15px; width: 15px; }
.metric-value { font-size: 24px; font-weight: 820; line-height: 1; overflow-wrap: anywhere; }
.metric-note { color: var(--muted); font-size: 11px; }
.tone-green .metric-label { color: var(--green); }
.tone-blue .metric-label { color: var(--blue); }
.tone-amber .metric-label { color: var(--amber); }
.tone-red .metric-label { color: var(--red); }

.split-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); }
.surface { background: #fff; border: 1px solid var(--line); border-radius: 7px; min-width: 0; }
.surface-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 10px; min-height: 50px; padding: 10px 14px; }
.surface-header h2 { font-size: 14px; margin: 0; }
.surface-header span { color: var(--muted); font-size: 11px; margin-left: auto; }
.surface-body { padding: 14px; }
.chart-shell { height: 250px; position: relative; }
.chart-shell canvas { height: 100%; width: 100%; }

.health-list { display: grid; }
.health-row { align-items: center; border-bottom: 1px solid #edf0f2; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; min-height: 44px; padding: 8px 0; }
.health-row:last-child { border-bottom: 0; }
.health-row span { color: var(--muted); font-size: 12px; }
.health-row strong { font-size: 12px; }

.alert-list { display: grid; gap: 7px; }
.alert-row { align-items: flex-start; background: var(--soft); border-left: 3px solid #8b96a1; border-radius: 4px; display: flex; gap: 8px; padding: 9px 10px; }
.alert-row.warning { background: var(--amber-soft); border-color: var(--amber); }
.alert-row.critical { background: var(--red-soft); border-color: var(--red); }
.alert-row.info { background: var(--blue-soft); border-color: var(--blue); }
.alert-row p { font-size: 12px; margin: 0; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 720px; width: 100%; }
th { color: var(--muted); font-size: 10px; font-weight: 800; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid #e9edf0; padding: 10px 12px; vertical-align: middle; }
td { font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.table-primary { display: grid; gap: 2px; }
.table-primary strong { font-size: 12px; }
.table-primary span { color: var(--muted); font-size: 10px; }

.pill { border-radius: 999px; display: inline-flex; font-size: 10px; font-weight: 800; padding: 4px 7px; text-transform: capitalize; }
.pill.active, .pill.resolved { background: var(--green-soft); color: var(--green); }
.pill.trial, .pill.investigating, .pill.warning { background: var(--amber-soft); color: var(--amber); }
.pill.suspended, .pill.critical { background: var(--red-soft); color: var(--red); }
.pill.info, .pill.monitoring { background: var(--blue-soft); color: var(--blue); }

.toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar .primary { margin-left: auto; }
.empty-state { color: var(--muted); padding: 42px 20px; text-align: center; }
.empty-state svg { height: 30px; margin-bottom: 8px; width: 30px; }

.modal-backdrop { align-items: center; background: rgba(23,33,43,.46); display: none; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 100; }
.modal-backdrop.visible { display: flex; }
.modal { background: #fff; border-radius: 8px; box-shadow: 0 20px 60px rgba(23,33,43,.2); display: grid; gap: 16px; max-height: calc(100dvh - 40px); max-width: 560px; overflow-y: auto; padding: 20px; width: 100%; }
.modal h2 { font-size: 17px; margin: 0; }
.modal p { color: var(--muted); margin: 0; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.secret-output { background: #f1f5f7; border: 1px solid var(--line); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; padding: 12px; }

.toast-stack { bottom: 16px; display: grid; gap: 8px; max-width: 360px; position: fixed; right: 16px; z-index: 120; }
.toast { background: #17212b; border-radius: 6px; color: #fff; font-size: 12px; padding: 10px 13px; }

.security-callout { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 6px; padding: 15px; }
.security-callout h2 { font-size: 14px; margin: 0 0 6px; }
.security-callout p { color: var(--muted); line-height: 1.5; margin: 0; }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .operator-shell { grid-template-columns: 1fr; }
  .sidebar { border-bottom: 1px solid var(--line); border-right: 0; min-height: 0; position: static; }
  .sidebar-brand { min-height: 58px; }
  .nav-list { display: flex; overflow-x: auto; padding: 7px 8px; }
  .nav-button { flex: 0 0 auto; width: auto; }
  .nav-button span { display: none; }
  .sidebar-footer { display: none; }
  .topbar { min-height: 58px; padding: 8px 12px; top: 0; }
  .topbar-title p { display: none; }
  .content { padding: 12px; }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 20px; }
  .topbar-actions .range-select { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal-backdrop { align-items: flex-end; padding: 8px; }
  .modal { max-height: calc(100dvh - 16px); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
