@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap");

:root {
  --bg0: #f4f8fc;
  --bg1: #ffffff;
  --bg2: #eef5fb;
  --line: rgba(30, 90, 160, 0.12);
  --text: #0f2744;
  --muted: #5a7390;
  --accent: #1a6fd4;
  --accent-bright: #2b87ef;
  --accent-soft: rgba(26, 111, 212, 0.1);
  --accent-dim: #0d4f9c;
  --warn: #d97706;
  --danger: #dc4a3d;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(15, 55, 110, 0.08);
  --shadow-sm: 0 4px 14px rgba(15, 55, 110, 0.06);
  --radius: 16px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Sora", "Manrope", system-ui, sans-serif;
  --dial-face: #f7fbff;
  --dial-rim: #d5e6f7;
  --needle: #e11d48;
  --needle-hub: #0f2744;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(920px 480px at 8% -8%, rgba(43, 135, 239, 0.16), transparent 55%),
    radial-gradient(760px 420px at 100% 0%, rgba(14, 88, 180, 0.1), transparent 50%),
    linear-gradient(180deg, #eaf3fb 0%, var(--bg0) 42%, #f8fbfe 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

.nav {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  align-items: center; justify-content: space-between;
  margin-bottom: 28px; padding: 14px 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}
.brand {
  font-family: var(--display);
  font-size: 1.22rem; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
}
.brand span { color: var(--accent); }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted); padding: 8px 13px; border-radius: 999px;
  text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--accent-dim); background: var(--accent-soft);
  text-decoration: none;
}

.header-row {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0; color: var(--accent);
  font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700;
}
h1 {
  margin: 6px 0 0; font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 700;
  letter-spacing: -0.03em; color: var(--text);
}
.sub { margin: 8px 0 0; color: var(--muted); max-width: 42rem; line-height: 1.5; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
}
.badge-on { background: rgba(26, 111, 212, 0.12); color: var(--accent-dim); }
.badge-off { background: rgba(220, 74, 61, 0.12); color: var(--danger); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0; font-family: var(--display);
  font-size: 1.05rem; font-weight: 650;
}
.muted { color: var(--muted); font-size: 0.88rem; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
}
.card h3 { margin: 0 0 4px; font-size: 1rem; word-break: break-all; }
.card .meta { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.pill {
  display: inline-block; margin-top: 8px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
}
.pill.on { background: rgba(26, 111, 212, 0.14); color: var(--accent-dim); }
.pill.off { background: rgba(90, 115, 144, 0.12); color: var(--muted); }
.pill.warn { background: rgba(217, 119, 6, 0.14); color: var(--warn); }

.metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 12px 0 8px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px; padding: 8px;
}
.metric .k { display: block; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.metric .v { font-size: 1.05rem; font-weight: 700; }
.metric .u { color: var(--muted); font-size: 0.75rem; margin-left: 2px; }

.ok-line { margin: 0 0 10px; font-size: 0.8rem; color: var(--muted); }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 0.85rem;
  font-weight: 600; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: rgba(26, 111, 212, 0.45); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: #fff; border-color: transparent; font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(220, 74, 61, 0.35); }
.controls, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(26, 111, 212, 0.55);
  box-shadow: 0 0 0 3px rgba(26, 111, 212, 0.12);
}
textarea { min-height: 72px; resize: vertical; }
.form-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-bottom: 12px;
}
.form-grid .full { grid-column: 1 / -1; }

table.data {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
table.data th, table.data td {
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

.feed { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.feed-item {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 0.82rem;
}
.feed-item .top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); margin-bottom: 4px; }

.empty { color: var(--muted); margin: 8px 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 0.85rem;
  font-weight: 600;
}
.tab.active {
  color: #fff;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  border-color: transparent;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 35, 64, 0.45);
  display: none; align-items: center; justify-content: center; padding: 16px; z-index: 40;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(560px, 100%); background: #fff;
  border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(15, 55, 110, 0.2);
}
.modal h3 { margin: 0 0 12px; font-family: var(--display); }

/* ——— Analog gauge meters ——— */
.gauge-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.gauge-card {
  background: linear-gradient(180deg, #ffffff 0%, #f3f8fd 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.gauge-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.gauge-card .g-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 4px;
}
.gauge-card .g-value {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.gauge-card .g-unit {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  margin-left: 3px;
}
.gauge-card .g-hint {
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.gauge-svg {
  width: 148px;
  height: 118px;
  margin: 0 auto;
  display: block;
  overflow: visible;
}
.gauge-svg .dial-outer {
  fill: var(--dial-rim);
}
.gauge-svg .dial-face {
  fill: var(--dial-face);
  stroke: #c5daf0;
  stroke-width: 1.2;
}
.gauge-svg .dial-inner {
  fill: none;
  stroke: rgba(26, 111, 212, 0.08);
  stroke-width: 10;
}
.gauge-svg .track {
  fill: none;
  stroke: #d7e6f5;
  stroke-width: 8;
  stroke-linecap: round;
}
.gauge-svg .arc {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}
.gauge-svg .tick {
  stroke: #8aa9c7;
  stroke-width: 1.4;
  stroke-linecap: round;
}
.gauge-svg .tick-major {
  stroke: var(--accent-dim);
  stroke-width: 2;
}
.gauge-svg .tick-label {
  fill: var(--muted);
  font-size: 5.5px;
  font-family: var(--font);
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}
.gauge-svg .needle {
  fill: var(--needle);
  filter: drop-shadow(0 1px 1px rgba(15, 39, 68, 0.25));
}
.gauge-svg .needle-tail {
  fill: #334155;
}
.gauge-svg .hub-ring {
  fill: #fff;
  stroke: var(--needle-hub);
  stroke-width: 1.5;
}
.gauge-svg .hub {
  fill: var(--needle-hub);
}
.gauge-svg .pivot-shine {
  fill: rgba(255, 255, 255, 0.55);
}

.meter-stack { display: flex; flex-direction: column; gap: 10px; }
.meter-row {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.meter-row h4 { margin: 0 0 2px; font-size: 0.95rem; font-weight: 700; }
.meter-row .meta { margin: 0; font-size: 0.78rem; color: var(--muted); }

@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .gauge-svg { width: 132px; height: 106px; }
}
