:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --panel-soft: #eef3ed;
  --text: #202522;
  --muted: #66706a;
  --line: #d9dfd6;
  --teal: #0f8b8d;
  --green: #4d8b31;
  --amber: #b26b00;
  --red: #ba3b3b;
  --ink: #17201c;
  --shadow: 0 10px 28px rgba(31, 38, 34, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  margin-bottom: 16px;
}

.auth-panel h1 {
  margin: 0 0 18px;
  font-size: 28px;
  line-height: 1.15;
}

.auth-panel label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.auth-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.auth-row input,
.ip-form input {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

.auth-row input:focus,
.ip-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

.auth-row button,
.primary-button {
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 22px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.live-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.icon-button:hover,
.segmented button:hover {
  border-color: #b8c5ba;
  background: #f9fbf6;
}

main {
  display: grid;
  gap: 18px;
}

.metric-grid,
.traffic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.traffic-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.traffic-card,
.workbench,
.alerts-panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card,
.traffic-card {
  min-height: 132px;
  padding: 16px;
}

.metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.metric-head span,
.traffic-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-head strong {
  font-size: 26px;
  line-height: 1;
}

.metric-card p,
.traffic-card p,
.section-head p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: #e7ece4;
  overflow: hidden;
  margin-top: 18px;
}

.bar span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.bar span.warn {
  background: var(--amber);
}

.bar span.danger {
  background: var(--red);
}

.split-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.split-meta span {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.traffic-section,
.workbench,
.alerts-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-head h2,
.list-panel h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.traffic-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
}

.traffic-card p {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}

.traffic-card b {
  color: var(--text);
  font-size: 13px;
}

.traffic-card em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.ip-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.segmented button {
  min-width: 72px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(31, 38, 34, 0.12);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  white-space: nowrap;
}

.form-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 13px;
}

.list-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.list-panel {
  box-shadow: none;
  overflow: hidden;
}

.list-panel h3 {
  padding: 14px 14px 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 800;
  background: #fbfcf9;
}

td code {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.empty-row td {
  color: var(--muted);
}

.row-action {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--red);
}

.row-action:hover {
  border-color: #efcaca;
  background: #fff4f4;
}

.alerts-panel table {
  min-width: 680px;
}

.message-cell {
  max-width: 560px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 920px) {
  .metric-grid,
  .traffic-grid,
  .list-grid {
    grid-template-columns: 1fr 1fr;
  }

  .ip-form {
    grid-template-columns: 1fr 1fr;
  }

  .segmented {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .traffic-grid,
  .list-grid,
  .ip-form {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .traffic-section,
  .workbench,
  .alerts-panel {
    padding: 14px;
  }
}
