:root {
  --bg: #0a0c0f;
  --panel: #111419;
  --panel-2: #171b21;
  --line: #2a3038;
  --line-soft: #1e242b;
  --text: #f2f5f7;
  --muted: #8f9aa6;
  --accent: #2dd4bf;
  --blue: #60a5fa;
  --green: #55d68b;
  --amber: #f6c65b;
  --red: #f07d79;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  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; }
a { color: inherit; }
.hidden { display: none !important; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.muted { color: var(--muted); }
.right { text-align: right; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #090b0e;
}
.login-panel {
  width: min(400px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #06110f;
  font-weight: 850;
  border-radius: 5px;
}
.brand-name { font-size: 15px; font-weight: 760; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-form { padding: 22px 20px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.field input, .field select, .field textarea,
.toolbar input, .toolbar select {
  width: 100%;
  min-height: 38px;
  color: var(--text);
  background: #0d1014;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
  outline: none;
}
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }

.btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 12px;
  color: var(--text);
  background: var(--panel-2);
  font-weight: 680;
  white-space: nowrap;
}
.btn:hover { border-color: #4a5562; background: #1c2229; }
.btn.primary { color: #04110f; background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: rgba(240,125,121,.45); }
.btn.small { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.form-error { min-height: 18px; color: var(--red); font-size: 12px; margin-top: 10px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #0d1014;
  display: flex;
  flex-direction: column;
}
.side-brand {
  min-height: 66px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.side-brand .brand-mark { width: 32px; height: 32px; }
.nav { padding: 10px 8px; display: grid; gap: 2px; overflow-y: auto; }
.nav button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 4px;
  padding: 9px 10px;
  font-weight: 650;
}
.nav button:hover { background: #151a20; color: var(--text); }
.nav button.active { background: #1b2328; color: var(--accent); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px; }
.viewer-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.viewer-role { color: var(--muted); font-size: 11px; text-transform: uppercase; margin-top: 2px; }

.main, .content, .view, .band, .panel, .split > *, .table-wrap { min-width: 0; max-width: 100%; }
.topbar {
  min-height: 66px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(10,12,15,.96);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 17px; font-weight: 780; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.status-line { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.mobile-menu { display: none; }

.content { padding: 20px 22px 44px; max-width: 1600px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.section-head {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: 14px; font-weight: 760; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.metric { min-height: 88px; padding: 15px; background: var(--panel); border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.metric-value { margin-top: 9px; font-size: 22px; line-height: 1; font-weight: 780; }
.metric-detail { margin-top: 7px; color: var(--muted); font-size: 11px; }

.band { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 12px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { height: 42px; padding: 8px 11px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 760; background: #101318; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #14191f; }
.empty { color: var(--muted); text-align: center; padding: 28px !important; }
.table-action { min-width: 112px; width: 112px; padding: 6px 28px 6px 8px; font-size: 12px; }
.credential-value { min-height: 40px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-family: var(--mono); overflow-wrap: anywhere; }

.badge { display: inline-flex; align-items: center; min-height: 22px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.badge.good { color: var(--green); border-color: rgba(85,214,139,.35); background: rgba(85,214,139,.07); }
.badge.warn { color: var(--amber); border-color: rgba(246,198,91,.35); background: rgba(246,198,91,.07); }
.badge.bad { color: var(--red); border-color: rgba(240,125,121,.35); background: rgba(240,125,121,.07); }
.badge.info { color: var(--blue); border-color: rgba(96,165,250,.35); background: rgba(96,165,250,.07); }

.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); }
.panel-head { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head h2 { font-size: 13px; margin: 0; }
.panel-body { padding: 15px; }
.key-value { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.key-value:last-child { border-bottom: 0; }
.key-value span:first-child { color: var(--muted); }

dialog { width: min(560px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-head { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 14px; }
.dialog-body { padding: 16px; }
.dialog-actions { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; width: min(360px, calc(100vw - 36px)); }
.toast { border: 1px solid var(--line); background: #151a20; padding: 11px 13px; border-radius: 5px; box-shadow: 0 12px 32px rgba(0,0,0,.32); }
.toast.error { border-color: rgba(240,125,121,.6); }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: -230px; width: 218px; z-index: 50; transition: left .18s ease; }
  .shell.menu-open .sidebar { left: 0; box-shadow: 12px 0 40px rgba(0,0,0,.45); }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 10px 12px; min-height: 58px; }
  .content { padding: 14px 12px 36px; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric { min-height: 80px; }
  .metric:nth-child(n) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .metric-value { font-size: 19px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; }
  .toolbar input, .toolbar select { flex: 1; min-width: 0; }
  .status-line span:last-child { display: none; }
}
