:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172335;
  background: #f3f5f9;
  font-synthesis: none;
  --muted: #53647b;
  --line: #dce4ee;
  --blue: #235dc7;
  --green: #067258;
  --amber: #92520d;
  --red: #a72739;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
button:focus-visible, summary:focus-visible { outline: 3px solid #4487ee; outline-offset: 3px; }
h1, h2, p, dl { margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 750; letter-spacing: -.048em; line-height: 1.08; }
h2 { font-size: 1.18rem; font-weight: 700; letter-spacing: -.025em; }
small { font-size: .8125rem; }
.page { width: min(100% - 64px, 1216px); margin-inline: auto; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.identity { display: flex; align-items: center; gap: 12px; }
.identity strong, .identity small { display: block; }
.identity small { color: var(--muted); margin-top: 3px; }
.machine-icon {
  display: grid; place-items: center; width: 41px; height: 41px; border-radius: 12px;
  background: #e6eefc; color: #2257a8; position: relative; flex: none;
}
.machine-icon::before { content: ""; width: 23px; height: 12px; border: 1.7px solid; border-radius: 5px; }
.machine-icon::after { content: ""; position: absolute; right: 11px; bottom: 17px; width: 3px; height: 3px; background: currentColor; border-radius: 50%; }
.heartbeat, .summary, .vpn-badge { display: flex; align-items: center; gap: 8px; }
.heartbeat, .summary { color: var(--tone, var(--muted)); font-size: .9rem; font-weight: 620; }
.heartbeat { text-align: right; font-variant-numeric: tabular-nums; }
.header-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 8px 12px; }
.header-button {
  min-height: 34px; padding: 6px 10px; border: 1px solid #b9c7dc; border-radius: 8px;
  background: white; color: #24436b; font-weight: 630; font-size: .875rem;
}
.header-button:hover { background: #eaf0fa; }
i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
[data-tone="ok"] { --tone: var(--green); }
[data-tone="warning"] { --tone: var(--amber); }
[data-tone="critical"] { --tone: var(--red); }

main.page { padding-block: 30px 42px; }
.overview { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 21px; }
.summary { margin-top: 12px; }
.uptime { display: grid; gap: 5px; text-align: right; flex: none; }
.uptime span { color: var(--muted); font-size: .875rem; }
.uptime strong { font: 600 1.04rem var(--mono); }
.issues { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 17px; padding: 0; list-style: none; }
.issues li {
  padding: 7px 11px; font-size: .875rem; border: 1px solid #cad6e4; border-radius: 8px;
  background: white; color: var(--tone, var(--muted));
}
.issues li[data-tone="warning"] { background: #fff7e9; border-color: #efdab5; }
.issues li[data-tone="critical"] { background: #fff2f4; border-color: #f2c7cf; }

.connection {
  background: #122745; color: #f7faff; border-radius: 19px; padding: 22px 24px 16px;
  --muted: #b9cbe4; --green: #7be4bb; --amber: #ffcd84; --red: #ffa8b2;
}
.connection-top, .connection-bottom { display: flex; align-items: start; justify-content: space-between; gap: 12px 20px; }
.connection-top { align-items: center; margin-bottom: 15px; }
.connection-top h2 { font-size: 1.22rem; }
.connection-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.connection-button {
  color: #e7effc; border: 1px solid #5f7697; border-radius: 8px; background: transparent;
  font-size: .875rem; font-weight: 600; min-height: 34px; padding: 6px 12px;
}
.connection-button.primary { background: #e6efff; color: #18395f; border-color: #e6efff; }
.connection-button:hover:not(:disabled) { background: #36547a; }
.connection-button.primary:hover:not(:disabled) { background: #fff; }
.connection-grid { display: grid; grid-template-columns: 1.06fr 1fr 1fr; gap: 10px; }
.vpn-cell, .ip-cell { padding: 14px 15px; border: 1px solid #405879; border-radius: 11px; background: #1b3354; min-width: 0; }
.connection-label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 9px; }
.vpn-badge { color: var(--tone, var(--muted)); font-size: clamp(1.02rem, 2.1vw, 1.35rem); line-height: 1.3; letter-spacing: -.02em; }
.vpn-badge strong { font-weight: 720; }
.vpn-cell p, .ip-cell .country { display: block; color: var(--muted); margin-top: 7px; font-size: .875rem; line-height: 1.35; }
.address { display: block; font: 650 clamp(1rem, 2vw, 1.37rem)/1.28 var(--mono); letter-spacing: -.035em; overflow-wrap: anywhere; }
.connection-bottom { margin-top: 14px; font-size: .8125rem; color: var(--muted); }
.connection-bottom summary { color: #e4edfb; cursor: pointer; font-size: .875rem; }
.connection-bottom p { margin-top: 7px; line-height: 1.45; max-width: 42ch; }
.ip-timing { display: flex; flex-direction: column; gap: 3px; text-align: right; line-height: 1.45; }
#ip-time { color: #edf4ff; }
.routes { margin-top: 11px; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.routes dd { margin: 0; color: #e7effa; font-family: var(--mono); overflow-wrap: anywhere; }

.resources { margin-top: 24px; }
.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; }
.section-heading { margin-bottom: 10px; }
.section-heading > span, .muted, .chart-summary { color: var(--muted); font-size: .875rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.metric-card, .panel { background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.metric-card { color: inherit; min-height: 116px; text-align: left; display: flex; flex-direction: column; align-items: start; padding: 13px 14px; gap: 5px; }
.metric-card:hover { border-color: #88a8d9; }
.metric-card[aria-pressed="true"] { border-color: #4f7dd4; box-shadow: inset 0 0 0 1px #4f7dd4; }
.metric-title { font-size: .91rem; font-weight: 660; }
.metric-value { font-size: clamp(1.45rem, 3vw, 1.95rem); font-weight: 740; font-variant-numeric: tabular-nums; letter-spacing: -.044em; line-height: 1.15; }
.metric-value .unit { font-size: .93rem; font-weight: 620; color: var(--muted); letter-spacing: 0; }
.metric-detail { color: var(--tone, var(--muted)); font-size: .85rem; line-height: 1.3; margin-top: auto; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 11px; margin-block: 14px; }
.panel { padding: 15px 16px; }
.range { display: flex; flex: none; border-radius: 9px; background: #edf2f8; padding: 2px; gap: 1px; }
.range button { border: 0; border-radius: 7px; padding: 6px 8px; color: #425977; background: transparent; font-size: .8125rem; font-weight: 600; white-space: nowrap; }
.range button[aria-pressed="true"] { background: white; color: #174ca6; box-shadow: 0 1px 3px #17355e21; }
.chart-frame { height: 202px; margin-top: 12px; position: relative; }
canvas { display: block; width: 100%; height: 100%; }
.chart-empty { position: absolute; left: 44px; right: 8px; top: 42%; text-align: center; color: var(--muted); font-size: .95rem; pointer-events: none; }
.chart-summary { min-height: 20px; padding-left: 2px; line-height: 1.4; }
.events ol, .apps ul { list-style: none; margin: 9px 0 0; padding: 0; }
.events ol { max-height: 240px; overflow: auto; }
.events li, .apps li { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid #edf1f7; font-size: .875rem; }
.events li:last-child, .apps li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font: .79rem var(--mono); white-space: nowrap; }
.events .muted, .apps .muted { line-height: 1.4; }
.events p, .apps p { margin-top: 12px; }
.apps li { justify-content: space-between; }
.apps li strong { font: 600 .88rem var(--mono); }

.entry-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.entry { width: min(100%, 410px); padding: 25px; background: #fff; border: 1px solid var(--line); border-radius: 17px; }
.entry-icon { display: block; border-radius: 12px; margin-bottom: 17px; }
.entry h1 { font-size: clamp(1.72rem, 7vw, 2rem); }
.entry p { color: var(--muted); margin-top: 9px; line-height: 1.48; }
.entry form { display: grid; gap: 10px; margin-top: 24px; }
.entry label { font-weight: 640; }
.password-input { display: flex; align-items: center; border: 1px solid #a9bad1; border-radius: 9px; }
.password-input:focus-within { outline: 2px solid #4487ee; outline-offset: 2px; }
.password-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: #172335; font: inherit; padding: 11px; }
.password-input button { background: transparent; border: 0; color: var(--blue); min-height: 44px; padding: 0 9px; font-size: .875rem; }
.entry-button {
  display: inline-grid; place-items: center; border: 0; border-radius: 9px; min-height: 44px;
  padding: 8px 11px; background: #235dc7; color: #fff; font-weight: 680; text-decoration: none;
}
.entry-button:hover { background: #174ca6; }
.entry p.sign-in-message { color: var(--red); margin-top: 2px; }
.entry > a, .entry > button { margin-top: 17px; }

@media (max-width: 850px) {
  .page { width: calc(100% - 40px); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 570px) {
  .page { width: calc(100% - 28px); }
  .topbar-inner { min-height: 64px; }
  .heartbeat { font-size: .8125rem; }
  .header-actions { padding-block: 7px; }
  main.page { padding-top: 23px; }
  .overview { align-items: start; flex-direction: column; }
  .uptime { display: flex; align-items: baseline; text-align: left; }
  .connection { padding: 15px; }
  .connection-top, .connection-bottom { flex-direction: column; align-items: stretch; }
  .connection-grid { grid-template-columns: 1fr 1fr; }
  .vpn-cell { grid-column: 1 / -1; }
  .ip-timing { text-align: left; }
  .metric-card { padding: 11px; min-height: 104px; }
  .panel { padding-inline: 12px; }
  .apps .panel-heading { align-items: start; flex-direction: column; }
}

@media (max-width: 365px) {
  .connection-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-heading { align-items: start; flex-wrap: wrap; }
}
