:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface2: #f9fafc;
  --line: #e5e7eb;
  --line2: #d0d5dd;
  --text: #111827;
  --muted: #667085;
  --soft: #98a2b3;
  --blue: #2563eb;
  --blue2: #eff6ff;
  --blue3: #dbeafe;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.07);
  --r: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-stack { width: min(460px, 100%); display: grid; gap: 18px; }
.auth-brand-mark {
  width: max-content;
  border: 1px solid var(--blue3);
  background: var(--blue2);
  color: var(--blue);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 900;
  margin: 0 auto;
}
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 24px;
}
.auth-panel h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
.auth-panel p { margin: 10px 0 20px; color: var(--muted); line-height: 1.55; }

.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  color: var(--muted);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { min-height: 48px; padding: 0 10px 8px; display: flex; align-items: center; }
.brand b { display: block; color: var(--text); font-size: 23px; letter-spacing: 0; line-height: 1; }
.nav { display: grid; gap: 7px; }
.nav button {
  min-height: 46px;
  border: 0;
  background: transparent;
  color: #475467;
  text-align: left;
  padding: 0 14px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: .16s;
}
.nav button:hover { background: var(--surface2); color: var(--text); }
.nav button.active { background: var(--blue2); color: var(--blue); font-weight: 800; box-shadow: inset 0 0 0 1px var(--blue3); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .45; }
.sidebar-account { margin-top: auto; }
.sidebar-user-button {
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface2);
  color: var(--text);
  padding: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
  transition: .16s;
}
.sidebar-user-button:hover { border-color: var(--line2); background: var(--surface); box-shadow: 0 12px 26px rgba(16, 24, 40, .08); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue2); display: grid; place-items: center; font-weight: 900; color: var(--blue); }
.sidebar-user-text { min-width: 0; display: grid; gap: 3px; }
.sidebar-user-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.sidebar-user-text small { color: var(--muted); }

.main { min-width: 0; }
.content {
  min-height: 100vh;
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px;
  background: var(--bg);
}
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 38px; line-height: 1.05; letter-spacing: 0; }
.page-head p { margin: 12px 0 0; color: #1f2937; font-size: 16px; line-height: 1.55; max-width: 690px; }
.eyebrow, .status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue2);
  border: 1px solid var(--blue3);
  color: var(--blue);
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 13px;
}
.status.online, .ok { color: var(--green); }
.status.danger, .eyebrow.danger, .bad { color: var(--red); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  transition: .16s;
}
.btn.compact { min-height: 38px; padding: 0 12px; }
.btn:hover { border-color: var(--line2); transform: translateY(-1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.red { color: var(--red); border-color: #fecaca; background: var(--surface); }

.view { display: none; }
.view.active { display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.kpi { padding: 16px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { display: block; font-size: 24px; margin-top: 8px; overflow-wrap: anywhere; }
.kpi small { color: var(--muted); }

.generation-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.generation-stack { display: grid; gap: 16px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.card { overflow: hidden; margin-bottom: 18px; }
.card-head { min-height: 56px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; }
.card-head h2 { font-size: 16px; margin: 0; }
.card-body { padding: 18px; }
.summary-card { position: sticky; top: 24px; margin-bottom: 0; }
.summary-top { padding: 22px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--surface), var(--surface2)); }
.summary-top h2 { font-size: 24px; margin: 14px 0 6px; letter-spacing: 0; }
.summary-top p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.summary-body { padding: 20px; display: grid; gap: 12px; }
.summary-row { display: flex; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary-row span { color: var(--muted); font-size: 13px; }
.summary-row b { text-align: right; font-size: 13px; overflow-wrap: anywhere; }

.segmented { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface2); overflow-x: auto; }
.segmented button { min-height: 34px; border: 0; border-radius: 12px; padding: 0 12px; background: transparent; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--blue); font-weight: 800; box-shadow: 0 8px 20px rgba(16, 24, 40, .06); }
.table-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: #344054; background: var(--surface2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td small { display: block; margin-top: 4px; color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; background: var(--surface2); border: 1px solid var(--line); padding: 2px 6px; border-radius: 8px; }

.router-grid { grid-template-columns: repeat(3, 1fr); }
.router-card { min-height: 260px; }
.router-lines { display: grid; gap: 10px; margin-top: 16px; }
.router-lines div { border-top: 1px solid var(--line); padding-top: 10px; }
.router-lines b { display: block; margin-top: 4px; font-size: 13px; line-height: 1.35; }

.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 800; margin-bottom: 8px; }
.input {
  height: 40px;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  width: 100%;
}
.input.large { height: 48px; }
.input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; }
.muted { color: var(--muted); }
.form-error { min-height: 20px; color: var(--red); margin: 0; font-size: 14px; }

dialog {
  border: 0;
  border-radius: var(--r);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 22px 70px rgba(16, 24, 40, .2);
}
dialog form { padding: 22px; }
dialog h2 { margin: 0; }
dialog p { margin: 0; }
dialog menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 8px 0 0; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .generation-layout, .router-grid, .kpi-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .content { padding: 18px; background: var(--bg); }
  .page-head, .card-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 30px; }
}
