@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
  --blue-950: #08224d;
  --blue-900: #0b3475;
  --blue-800: #12479a;
  --blue-600: #2469dc;
  --blue-100: #dbe8ff;
  --blue-050: #eef4ff;
  --cream-100: #f2ebdd;
  --cream-050: #f8f4eb;
  --paper: #fffdf8;
  --ink: #11284a;
  --ink-soft: #53647d;
  --line: #d9d2c4;
  --line-blue: #b9c9e4;
  --green: #14765d;
  --green-soft: #d9eee7;
  --amber: #9a5a0a;
  --amber-soft: #f7e7c8;
  --red: #b63a43;
  --red-soft: #f6dfe1;
  --font-ui: 'Fira Sans', 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'SFMono-Regular', Consolas, monospace;
  --sidebar: 224px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--cream-050);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; }
svg { display: block; }

:focus-visible {
  outline: 3px solid var(--blue-600);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: white;
  background: var(--blue-900);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.14);
  color: white;
  background: var(--blue-950);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 77px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 4px;
  background: var(--blue-600);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand small { margin-top: 1px; color: #aabbd5; font-size: 11px; letter-spacing: .035em; }

.nav-list { display: grid; gap: 4px; padding: 18px 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #bdcbe0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .01em;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.nav-item svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: white; border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.1); }

.sidebar-footer {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding: 20px 24px 24px;
  border-top: 1px solid rgba(255,255,255,.14);
}

.sidebar-footer strong { margin-top: 8px; font-size: 13px; font-weight: 500; }
.sidebar-footer > span:last-child { color: #aabbd5; font-family: var(--font-mono); font-size: 11px; }

.main { margin-left: var(--sidebar); min-height: 100vh; }

.topbar {
  min-height: 77px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(248,244,235,.92);
  backdrop-filter: blur(12px);
}

.eyebrow {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .105em;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.018em;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-actions form { margin: 0; }

.sync-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 12px;
}

.sync-dot, .state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.sync-state.is-live .sync-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(20,118,93,.12); }
.sync-state.is-stale .sync-dot { background: var(--amber); }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.icon-button:hover { border-color: var(--line-blue); background: var(--paper); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.load-error {
  margin: 18px clamp(20px, 3vw, 42px) 0;
  padding: 12px 14px;
  border: 1px solid #e6b9bc;
  color: #8d252d;
  background: var(--red-soft);
  font-size: 13px;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, .9fr);
  min-height: 318px;
  color: white;
  background: var(--blue-900);
}

.result-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 34px clamp(24px, 4vw, 56px);
}

.status-line { display: flex; align-items: center; gap: 12px; color: #c8d8ef; font-size: 13px; }

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 3px;
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.state-badge.is-found .state-dot { background: #7ee1bd; box-shadow: 0 0 0 4px rgba(126,225,189,.13); }
.result-kicker { margin: 33px 0 5px; color: #9fb8dc; font-size: 12px; }

.ip-row { display: flex; align-items: center; gap: 20px; min-width: 0; }

.ip-row h2 {
  margin: 0;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: clamp(32px, 4.6vw, 64px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -.045em;
  text-wrap: balance;
}

.copy-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 4px;
  color: white;
  background: rgba(255,255,255,.08);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.copy-button:hover:not(:disabled) { border-color: white; background: rgba(255,255,255,.14); }
.copy-button:disabled { opacity: .45; cursor: not-allowed; }
.copy-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.result-meta { margin: 14px 0 0; color: #b8cce7; font-family: var(--font-mono); font-size: 11px; letter-spacing: .01em; }

.route-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px clamp(24px, 3vw, 42px);
  border-left: 1px solid rgba(255,255,255,.17);
  background-color: rgba(4,24,57,.28);
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 24px 24px;
}

.route-node { position: relative; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; align-items: center; }
.route-node > span { grid-row: 1 / 3; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; font-family: var(--font-mono); font-size: 9px; }
.route-node strong { font-size: 13px; font-weight: 500; }
.route-node small { color: #9fb8dc; font-family: var(--font-mono); font-size: 10px; }
.route-link { height: 38px; margin-left: 14px; border-left: 1px dashed rgba(255,255,255,.38); }
.route-link i { display: block; width: 5px; height: 5px; margin: 16px 0 0 -3px; border-radius: 50%; background: #7ee1bd; }

.confidence {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 80px;
  padding: 14px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: var(--amber-soft);
}

.confidence svg { width: 23px; fill: none; stroke: var(--amber); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.confidence h2 { margin: 0 0 2px; font-size: 14px; }
.confidence p { margin: 0; max-width: 85ch; color: #684515; font-size: 12px; text-wrap: pretty; }
.confidence-tag { padding: 4px 7px; border: 1px solid rgba(154,90,10,.35); border-radius: 3px; color: var(--amber); font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: .08em; }
.confidence.is-confirmed { background: var(--green-soft); }
.confidence.is-confirmed svg { stroke: var(--green); }
.confidence.is-confirmed p, .confidence.is-confirmed .confidence-tag { color: var(--green); }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.metric-strip article { min-width: 0; padding: 25px clamp(18px, 2.5vw, 34px); border-right: 1px solid var(--line); }
.metric-strip article:last-child { border-right: 0; }
.metric-label { display: block; color: var(--ink-soft); font-size: 12px; }
.metric-strip strong { display: block; margin: 6px 0 1px; font-family: var(--font-mono); font-size: 31px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.metric-strip small { color: var(--ink-soft); font-size: 11px; letter-spacing: .015em; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .7fr); border-bottom: 1px solid var(--line); }
.timeline-panel, .system-panel { min-width: 0; padding: 28px clamp(20px, 3vw, 42px) 22px; }
.timeline-panel { border-right: 1px solid var(--line); background: var(--cream-050); }
.system-panel { background: var(--paper); }

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 3px 0 0; font-size: 18px; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; }

.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; color: var(--ink-soft); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 1px; }
.legend-blocked { background: var(--blue-100); border: 1px solid #9db6db; }
.legend-unstable { background: var(--amber); }
.legend-working { background: var(--blue-600); }

.chart-wrap { min-height: 230px; margin-top: 14px; overflow: hidden; }
.chart-wrap svg { width: 100%; height: 230px; }
.chart-grid { stroke: #ded7ca; stroke-width: 1; stroke-dasharray: 3 5; }
.chart-axis { fill: #69778c; font-family: var(--font-mono); font-size: 9px; }
.chart-blocked { fill: #b9cae4; }
.chart-unstable { fill: var(--amber); }
.chart-working { fill: var(--blue-600); }
.chart-bar { transition: opacity 180ms ease; }
.chart-bar:hover { opacity: .72; }

.system-list { margin: 16px 0 0; }
.system-list div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid #e7e1d7; }
.system-list div:last-child { border-bottom: 0; }
.system-list dt { color: var(--ink-soft); font-size: 12px; }
.system-list dd { margin: 0; max-width: 58%; font-family: var(--font-mono); font-size: 11px; text-align: right; overflow-wrap: anywhere; }

.history-section { padding: 30px clamp(20px, 3vw, 42px) 48px; background: var(--paper); }
.history-heading { align-items: end; }
.filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.filter {
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}
.filter:hover { border-color: var(--line-blue); color: var(--ink); }
.filter.is-active { border-color: var(--blue-900); color: white; background: var(--blue-900); }

.table-wrap { margin-top: 18px; overflow-x: auto; border-top: 1px solid var(--ink); }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 12px; }
th { height: 38px; color: var(--ink-soft); font-size: 10px; font-weight: 500; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
th, td { padding: 0 14px; border-bottom: 1px solid #e7e1d7; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; text-align: right; }
td { height: 49px; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 160ms ease; }
tbody tr:hover { background: var(--cream-050); }
.cell-ip, .cell-number, .cell-date { font-family: var(--font-mono); }
.cell-ip { font-weight: 500; }
.cell-number, .cell-date { color: var(--ink-soft); font-size: 11px; }
.cell-status { display: flex; align-items: center; gap: 7px; }
.cell-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-working { color: var(--green); }
.status-unstable { color: var(--amber); }
.status-blocked { color: var(--red); }
.empty-row { height: 96px; color: var(--ink-soft); text-align: center !important; }
.table-note { margin: 11px 0 0; color: var(--ink-soft); font-size: 10px; letter-spacing: .02em; }

.toast {
  position: fixed;
  z-index: 40;
  right: 20px;
  bottom: 20px;
  padding: 11px 15px;
  border-radius: 4px;
  color: white;
  background: var(--blue-950);
  box-shadow: 0 12px 34px rgba(8,34,77,.24);
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

.login-page { min-height: 100vh; background: var(--paper); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .9fr) minmax(440px, 1.1fr); }
.login-brand { min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 0 clamp(32px, 5vw, 76px) 54px; color: white; background-color: var(--blue-950); background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 32px 32px; }
.login-brand .brand { width: fit-content; margin-left: calc(clamp(32px, 5vw, 76px) * -1); border-right: 1px solid rgba(255,255,255,.14); }
.brand-inverse { color: white; }
.login-brand > div:nth-child(2) { max-width: 520px; }
.login-brand .eyebrow { color: #8fa9ce; }
.login-brand h1 { max-width: 11ch; margin: 18px 0 18px; font-size: clamp(42px, 5vw, 70px); font-weight: 500; line-height: .98; letter-spacing: -.045em; text-wrap: balance; }
.login-brand p { max-width: 48ch; margin: 0; color: #afc1da; font-size: 14px; text-wrap: pretty; }
.login-route { display: flex; align-items: center; max-width: 420px; color: #aac0de; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; }
.login-route span { display: grid; place-items: center; width: 58px; height: 34px; border: 1px solid rgba(255,255,255,.3); border-radius: 3px; }
.login-route i { flex: 1; border-top: 1px dashed rgba(255,255,255,.35); }

.login-form-wrap { display: grid; place-items: center; padding: 40px; background: var(--cream-050); }
.login-form-inner { width: min(100%, 390px); }
.login-form-inner h2 { margin: 10px 0 4px; font-size: 29px; line-height: 1.16; letter-spacing: -.025em; }
.login-form-inner > p { margin: 0 0 28px; color: var(--ink-soft); font-size: 13px; }
.login-form { display: grid; gap: 9px; }
.login-form label { font-size: 12px; font-weight: 500; }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; height: 50px; padding: 0 48px 0 14px; border: 1px solid var(--line-blue); border-radius: 4px; color: var(--ink); background: var(--paper); font-family: var(--font-mono); font-size: 14px; transition: border-color 180ms ease, box-shadow 180ms ease; }
.password-wrap input:focus { border-color: var(--blue-600); outline: 0; box-shadow: 0 0 0 3px rgba(36,105,220,.15); }
.password-toggle { position: absolute; top: 3px; right: 3px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; color: var(--ink-soft); background: transparent; cursor: pointer; }
.password-toggle svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.login-submit { height: 48px; display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 0 16px; border: 0; border-radius: 4px; color: white; background: var(--blue-900); cursor: pointer; font-size: 13px; font-weight: 600; letter-spacing: .01em; transition: background-color 180ms ease, transform 180ms ease; }
.login-submit:hover { background: var(--blue-800); transform: translateY(-1px); }
.login-submit span { font-size: 19px; font-weight: 400; }
.login-footnote { display: block; margin-top: 18px; color: var(--ink-soft); font-size: 10px; letter-spacing: .018em; }
.login-error { margin-bottom: 16px; padding: 10px 12px; border: 1px solid #e6b9bc; border-radius: 3px; color: #8d252d; background: var(--red-soft); font-size: 12px; }

@media (max-width: 1024px) {
  :root { --sidebar: 196px; }
  .result-panel { grid-template-columns: 1fr 320px; }
  .ip-row { align-items: flex-start; flex-direction: column; gap: 14px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip article:nth-child(2) { border-right: 0; }
  .metric-strip article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .analysis-grid { grid-template-columns: 1fr; }
  .timeline-panel { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .shell { padding-bottom: 64px; }
  .sidebar { inset: auto 0 0; width: 100%; height: 64px; flex-direction: row; border-top: 1px solid rgba(255,255,255,.15); border-right: 0; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .nav-list { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 6px 8px; }
  .nav-item { min-height: 52px; justify-content: center; flex-direction: column; gap: 2px; padding: 3px; font-size: 10px; }
  .nav-item svg { width: 17px; }
  .main { margin-left: 0; }
  .topbar { min-height: 66px; padding: 10px 16px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 18px; }
  .sync-state { padding: 0 8px; }
  .sync-state span:last-child { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .result-panel { grid-template-columns: 1fr; }
  .result-copy { min-height: 280px; padding: 28px 20px; }
  .status-line { align-items: flex-start; flex-direction: column; gap: 8px; }
  .result-kicker { margin-top: 30px; }
  .ip-row h2 { font-size: clamp(30px, 11vw, 46px); }
  .route-visual { display: none; }
  .confidence { grid-template-columns: auto 1fr; padding: 14px 18px; }
  .confidence-tag { grid-column: 2; width: fit-content; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip article { padding: 20px 18px; }
  .metric-strip strong { font-size: 26px; }
  .metric-strip article:nth-child(2) { border-right: 0; }
  .legend { justify-content: flex-start; }
  .section-heading, .history-heading { align-items: flex-start; flex-direction: column; }
  .history-section { padding: 26px 16px 38px; }
  .filters { justify-content: flex-start; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .filter { flex: none; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody { display: grid; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  tbody td { display: block; height: auto; padding: 0; border: 0; text-align: left !important; }
  tbody td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--ink-soft); font-family: var(--font-ui); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
  tbody .cell-status { align-items: flex-start; }
  tbody .cell-status::before { width: 100%; }
  tbody .cell-status i { margin-top: 5px; }
  tbody .cell-date { grid-column: 1 / -1; }
  tbody .empty-row { display: table-cell; height: auto; padding: 26px 0; }
  tbody .empty-row::before { display: none; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 310px; padding: 0 24px 30px; }
  .login-brand .brand { min-height: 66px; margin-left: -24px; padding-left: 24px; }
  .login-brand > div:nth-child(2) { margin-top: auto; }
  .login-brand h1 { margin: 12px 0; font-size: 40px; }
  .login-brand p, .login-route { display: none; }
  .login-form-wrap { min-height: calc(100vh - 310px); padding: 34px 22px; align-items: start; }
}

@media (max-width: 410px) {
  .topbar-actions { gap: 6px; }
  .sync-state { border: 0; background: transparent; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric-strip article { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-strip article:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
