@import url("theme.css");

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
}

.mono { font-family: "SFMono-Regular", ui-monospace, Consolas, monospace; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
}
.brand .logo {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.brand .sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin-top: 0.25rem;
}

.nav { list-style: none; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav a.active {
  background: rgba(61,220,132,0.12);
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar-foot {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .title { font-size: 1.05rem; font-weight: 600; margin-right: auto; }
.topbar .meta { font-size: 0.75rem; color: var(--text-muted); font-family: ui-monospace, monospace; }

.content { padding: 1.25rem 1.5rem 2rem; flex: 1; }

.btn {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--panel-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #041008; border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.68rem; }

select, input[type="search"], input[type="password"], input[type="number"] {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}
label.field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card .label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.card .value { font-size: 1.6rem; font-weight: 700; font-family: ui-monospace, monospace; margin-top: 0.25rem; }
.card .hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }
.card.warn .value { color: var(--warn); }
.card.crit .value { color: var(--crit); }
.card.ok .value { color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}
.panel-head h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}
.panel-body { padding: 0; }

#rail {
  display: flex;
  gap: 1px;
  background: var(--line);
  overflow-x: auto;
}
.rail-cell {
  flex: 1 1 0;
  min-width: 150px;
  background: var(--panel);
  padding: 0.9rem 1rem;
}
.rail-cell .ns { font-family: ui-monospace, monospace; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-cell .ratio { font-family: ui-monospace, monospace; font-size: 1.5rem; font-weight: 700; }
.rail-cell .sub { font-size: 0.68rem; color: var(--text-muted); }
.rail-cell.ok .ratio { color: var(--rail-ok); }
.rail-cell.warn .ratio { color: var(--rail-warn); }
.rail-cell.crit .ratio { color: var(--rail-crit); }

table.data { width: 100%; border-collapse: collapse; font-family: ui-monospace, monospace; font-size: 0.76rem; }
table.data th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}
table.data td { padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data td.n { text-align: right; font-variant-numeric: tabular-nums; }

.pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.pager strong { color: var(--text); }

.empty, .loading {
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: ui-monospace, monospace;
}
.flare { color: var(--crit); }
.amber { color: var(--warn); }
.leaf { color: var(--accent); }
.dim { color: var(--text-muted); }

.idx-row {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
}
.idx-row:last-child { border-bottom: none; }
.idx-row .cmd {
  display: block;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.45rem;
  color: var(--accent);
  overflow-x: auto;
  white-space: pre;
}
.shape {
  color: var(--text-muted);
  font-size: 0.68rem;
  display: block;
  margin-top: 0.15rem;
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.long-text summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.long-text summary:hover {
  color: var(--accent);
}
.code-inline {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.code-block {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  margin: 0.35rem 0 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.glossary-section {
  margin-bottom: 1.75rem;
}
.glossary-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.glossary-list {
  margin: 0;
}
.glossary-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.glossary-item:last-child {
  border-bottom: none;
}
.glossary-item dt {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.glossary-item dd {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 52rem;
}
.banner a {
  color: var(--accent);
}

.alert-item {
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}
.alert-item summary {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-family: ui-monospace, monospace;
}
.alert-item summary::-webkit-details-marker {
  display: none;
}
.alert-item summary::before {
  content: "▸";
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.alert-item[open] summary::before {
  content: "▾";
}
.alert-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--warn) 18%, var(--panel));
  color: var(--warn);
}
.alert-item.alert-collscan .alert-badge {
  background: color-mix(in srgb, var(--crit) 18%, var(--panel));
  color: var(--crit);
}
.alert-summary {
  color: var(--warn);
  line-height: 1.45;
}
.alert-detail {
  padding: 0 1rem 0.85rem 2rem;
  border-top: 1px dashed var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.alert-title {
  margin: 0.55rem 0 0.35rem;
  font-weight: 600;
  color: var(--text);
}
.alert-meta {
  margin: 0.35rem 0;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.alert-details {
  margin: 0.5rem 0;
  padding-left: 1.1rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.alert-rec {
  margin: 0.55rem 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text);
}
.alert-detail .btn {
  margin-top: 0.35rem;
}

.banner {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}
.banner.amber { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--panel)); }

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 0.3rem;
}
.status-dot.live { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.25rem; margin-bottom: 0.35rem; }
.login-card p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.25rem; }
.login-card input[type="password"] { width: 100%; margin-bottom: 0.75rem; }
.login-card .actions { display: flex; gap: 0.5rem; align-items: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
  }
  .brand { border: none; margin: 0; padding: 0.5rem; }
  .nav { display: flex; flex-wrap: wrap; width: 100%; }
  .nav a { padding: 0.5rem 0.75rem; border-left: none; border-radius: 6px; }
  .sidebar-foot { width: 100%; flex-direction: row; flex-wrap: wrap; border: none; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
