:root {
  --ink: #10233f;
  --muted: #65738a;
  --line: #dbe4f0;
  --cloud: #f3f7fc;
  --paper: #ffffff;
  --blue: #1648d8;
  --blue-dark: #0e36ab;
  --mint: #13866f;
  --mint-soft: #dff5ef;
  --red: #c93646;
  --red-soft: #fee9eb;
  --amber: #9a6500;
  --amber-soft: #fff2cc;
  --shadow: 0 12px 35px rgba(27, 55, 99, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--cloud); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 5%, rgba(22, 72, 216, .09), transparent 28rem),
    var(--cloud);
  font: 16px/1.5 Inter, Manrope, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, .button, a { touch-action: manipulation; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(22, 72, 216, .35); outline-offset: 2px; }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 100; padding: 10px 14px; background: var(--ink); color: white; border-radius: 10px; }
.skip-link:focus { top: 12px; }

.shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: 248px;
  display: flex; flex-direction: column; padding: 24px 18px;
  color: #f7faff; background: #10233f;
}
.brand { display: flex; gap: 12px; align-items: center; margin: 2px 6px 34px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px;
  background: linear-gradient(145deg, #2f66ff, #19a68a); box-shadow: 0 10px 24px rgba(0,0,0,.22);
  font-size: 19px; font-weight: 850;
}
.brand small { display: block; color: #9db0ca; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: grid; gap: 7px; }
.nav a {
  min-height: 48px; display: flex; align-items: center; padding: 0 14px;
  color: #b9c7da; text-decoration: none; border-radius: 13px; font-weight: 610;
  transition: background 160ms ease, color 160ms ease;
}
.nav a:hover, .nav a[aria-current="page"] { color: white; background: rgba(255,255,255,.1); }
.sidebar-footer { margin-top: auto; padding: 16px 8px 4px; color: #9db0ca; font-size: 13px; }
.status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: #dce8f7; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #3dd8b4; box-shadow: 0 0 0 5px rgba(61,216,180,.12); }

.workspace { min-height: 100dvh; margin-left: 248px; padding: 32px clamp(24px, 4vw, 64px) 54px; }
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.subtitle { max-width: 680px; margin: 10px 0 0; color: var(--muted); }
.account { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--muted); font-size: 14px; }
.account input { display: none; }
.link-button { min-height: 44px; padding: 0 8px; color: var(--ink); background: transparent; font-weight: 700; }
.link-button:hover { color: var(--blue); background: transparent; }

.network-strip {
  position: relative; overflow: hidden; min-height: 92px; margin-bottom: 24px; padding: 20px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  color: white; background: linear-gradient(115deg, #123db7, #1c62e8 58%, #159780);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.network-strip::after {
  content: ""; position: absolute; inset: 0; opacity: .2;
  background-image: linear-gradient(90deg, transparent 49%, white 50%, transparent 51%);
  background-size: 42px 100%; transform: skewX(-18deg) scale(1.5);
}
.network-strip > * { position: relative; z-index: 1; }
.network-strip strong { display: block; font-size: 18px; }
.network-strip span { color: rgba(255,255,255,.78); font-size: 14px; }
.network-number { font: 700 25px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric, .card { background: var(--paper); border: 1px solid rgba(190,204,223,.7); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { min-height: 132px; padding: 19px; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { margin-top: 16px; font: 750 clamp(26px, 3vw, 36px)/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.05em; }
.metric-note { margin-top: 10px; color: var(--mint); font-size: 12px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 18px; }
.card { padding: 22px; }
.spaced-card { margin-top: 18px; }
.history-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head a { color: var(--blue); font-size: 14px; font-weight: 700; text-decoration: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.toolbar form { display: flex; flex: 1 1 420px; gap: 10px; }
label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; color: var(--ink);
  background: white; border: 1px solid #c8d4e4; border-radius: 12px;
}
textarea { min-height: 132px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgba(22,72,216,.12); }
.field { margin-bottom: 16px; }
.checkbox { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.checkbox input { width: 20px; min-height: 20px; margin: 0; }
.help { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }

.button, button {
  min-height: 48px; padding: 0 17px; border: 0; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: white; background: var(--blue); font-weight: 730; text-decoration: none;
  transition: background 160ms ease, transform 100ms ease;
}
.button:hover, button:hover { background: var(--blue-dark); }
.button:active, button:active { transform: scale(.98); }
.button.secondary { color: var(--ink); background: #e8eef7; }
.button.secondary:hover { background: #dce6f3; }
.button.danger { background: var(--red); }
.button.small { min-height: 42px; padding: 0 13px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.name { font-weight: 720; }
.subtext { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; }
.badge.active { color: #0c6a57; background: var(--mint-soft); }
.badge.off { color: #637088; background: #edf1f6; }
.badge.warn { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.empty { padding: 38px 18px; color: var(--muted); text-align: center; }
.flash { margin: -8px 0 18px; padding: 13px 15px; border-radius: 12px; background: var(--mint-soft); color: #0c6a57; font-weight: 650; }
.flash.error { color: var(--red); background: var(--red-soft); }

.messages { display: grid; gap: 10px; margin: 18px 0; }
.message { max-width: 78%; padding: 11px 13px; border-radius: 14px 14px 14px 4px; background: #eef3fa; }
.message.out { justify-self: end; border-radius: 14px 14px 4px 14px; color: white; background: var(--blue); }
.message time { display: block; margin-top: 5px; opacity: .7; font-size: 11px; }

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 22px; background: #10233f; }
.login-card { width: min(100%, 430px); padding: 30px; background: white; border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-card .brand { color: var(--ink); margin: 0 0 28px; }
.login-card h1 { font-size: 31px; }
.login-card button { width: 100%; margin-top: 6px; }

.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .workspace { margin-left: 0; padding: 22px 16px 34px; }
  .topline { display: block; margin-bottom: 20px; }
  .account { margin-top: 10px; }
  .metrics { gap: 10px; }
  .metric { min-height: 112px; padding: 15px; }
  .metric-value { margin-top: 12px; font-size: 27px; }
  .card { padding: 16px; }
  .network-strip { align-items: flex-start; padding: 18px; }
  .network-number { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar form { display: grid; grid-template-columns: 1fr auto; }

  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .responsive-table tr:last-child { border-bottom: 0; }
  .responsive-table td { display: grid; grid-template-columns: 108px minmax(0,1fr); gap: 12px; padding: 5px 0; border: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
  .responsive-table td.primary { display: block; margin-bottom: 6px; }
  .responsive-table td.primary::before { display: none; }

  .mobile-nav {
    position: fixed; z-index: 40; inset: auto 0 0; min-height: calc(68px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px);
  }
  .mobile-nav a {
    min-height: 54px; display: grid; place-items: center; padding: 4px;
    color: var(--muted); text-decoration: none; border-radius: 10px; font-size: 11px; font-weight: 700;
  }
  .mobile-nav a[aria-current="page"] { color: var(--blue); background: #edf2ff; }
  .message { max-width: 90%; }
}

@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .network-strip { display: block; }
  .network-number { margin-top: 13px; }
  .toolbar form { grid-template-columns: 1fr; }
  .toolbar .button, .toolbar button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
