/* Control Board — shared theme and layout */

:root,
[data-theme="light"] {
  --bg: #eef2f7;
  --bg-glow: rgba(37, 99, 235, .08);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-2: #0891b2;
  --accent-soft: rgba(37, 99, 235, .1);
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, .12);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, .12);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, .12);
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --header-bg: rgba(255, 255, 255, .86);
  --overlay: rgba(15, 23, 42, .45);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-glow: rgba(56, 189, 248, .08);
  --surface: #111c2e;
  --surface-2: #0f172a;
  --surface-3: #1b2a41;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #243449;
  --border-strong: #334155;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --accent-soft: rgba(56, 189, 248, .12);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, .13);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .13);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .13);
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
  --header-bg: rgba(11, 18, 32, .86);
  --overlay: rgba(0, 0, 0, .6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  background:
    radial-gradient(900px 420px at 8% -10%, var(--bg-glow), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }

/* Header ------------------------------------------------------------------ */

.board-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(12px);
}
.top-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  flex: 0 0 auto;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .5px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px var(--accent-soft);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text small { font-size: 11px; color: var(--muted); }

.board-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.board-nav a {
  padding: 7px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.board-nav a:hover { color: var(--text); background: var(--surface-3); }
.board-nav a.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.board-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.pill b { color: var(--accent); font-size: 13px; }
.pill-label { font-size: 11px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-sun, .i-moon { display: none; }
[data-theme="light"] .i-moon { display: block; }
[data-theme="dark"] .i-sun { display: block; }

.signout {
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 7px 4px;
}
.signout:hover { text-decoration: underline; }

/* Layout ------------------------------------------------------------------ */

.board-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 24px 12px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; letter-spacing: -.4px; }
.page-head p { margin-top: 4px; font-size: 13px; }
.page-head .crumbs { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.page-head .crumbs a { color: var(--accent); text-decoration: none; }
.page-head .crumbs a:hover { text-decoration: underline; }

.report-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 20px;
  padding-bottom: 4px;
}
.report-tabs a {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.report-tabs a:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.report-tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.report-title { margin-top: 2px; margin-bottom: 16px; }
.report-title h1 { font-size: 22px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title a { color: var(--accent); text-decoration: none; text-transform: none; letter-spacing: 0; font-weight: 600; }
.section-title a:hover { text-decoration: underline; }

/* Cards ------------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 700;
}
.card .val { font-size: 27px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.blue { color: var(--accent); }

/* Status cards ------------------------------------------------------------ */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.target-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 17px 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, transform .2s;
}
.target-card:hover { transform: translateY(-2px); }
.target-card.is-up:hover { border-color: var(--green); }
.target-card.is-down { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }

.target-head { display: flex; align-items: center; gap: 14px; }
.target-id { min-width: 0; flex: 1; }
.target-name {
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.target-desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.target-url {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-url:hover { text-decoration: underline; }

.target-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}
.meta-item { min-width: 0; }
.meta-lbl {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.meta-val {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-actions { margin-top: 14px; display: flex; gap: 8px; }

.srv-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .3px;
}
.srv-badge.local { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.srv-badge.remote { background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.srv-badge.unknown { background: var(--surface-3); color: var(--muted); }

/* Pulsing status orb ------------------------------------------------------ */

.orb {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
}
.orb .core { width: 16px; height: 16px; border-radius: 50%; position: relative; z-index: 2; }
.orb.online .core { background: var(--green); box-shadow: 0 0 10px var(--green), 0 0 24px var(--green-soft); }
.orb.offline .core { background: var(--red); box-shadow: 0 0 10px var(--red), 0 0 24px var(--red-soft); }
.orb.online::before, .orb.online::after,
.orb.offline::before, .orb.offline::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--green);
  animation: aura 2.2s ease-out infinite;
}
.orb.offline::before, .orb.offline::after { border-color: var(--red); }
.orb.online::after, .orb.offline::after { animation-delay: 1.1s; }
@keyframes aura {
  0% { transform: scale(.65); opacity: .95; }
  75% { transform: scale(1.65); opacity: 0; }
  100% { transform: scale(1.65); opacity: 0; }
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

/* Tables ------------------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 800;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
table a { color: var(--accent); text-decoration: none; }
table a:hover { text-decoration: underline; }

.meter {
  background: var(--surface-3);
  border-radius: 6px;
  height: 7px;
  width: 92px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .3px;
}

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn.block { width: 100%; }

/* Hour chart -------------------------------------------------------------- */

.hour-chart {
  display: grid;
  grid-template-columns: repeat(24, minmax(18px, 1fr));
  gap: 4px;
  align-items: end;
  height: 150px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
}
.hour-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.hour-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .85;
}
.hour-label { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Login ------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-card {
  width: 100%;
  max-width: 370px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.login-card h1 { font-size: 20px; }
.login-card p { font-size: 13px; margin: 6px 0 20px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--red); font-size: 13px; margin-top: 12px; font-weight: 600; }

/* Modal ------------------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.open { display: grid; place-items: center; padding: 18px; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  outline: none;
  animation: modal-in .18s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.modal-head { display: flex; align-items: center; gap: 14px; padding-right: 30px; }
.modal-head .orb { width: 44px; height: 44px; }
.modal-head h2 { font-size: 18px; letter-spacing: -.2px; }
.modal-head p { font-size: 12px; margin-top: 2px; }
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.modal-grid dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  font-weight: 800;
}
.modal-grid dd { font-size: 14px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.modal-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* Footer ------------------------------------------------------------------ */

.board-foot {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 30px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

/* Focus ------------------------------------------------------------------- */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1040px) {
  .top-inner { flex-wrap: wrap; gap: 12px; }
  .board-nav { order: 3; }
  .board-tools { order: 2; }
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .top-inner { padding: 10px 14px; }
  .board-main { padding: 18px 14px 10px; }
  .board-foot { padding: 20px 14px 24px; }
  .pill .pill-label { display: none; }
  .brand-text small { display: none; }
  .page-head h1 { font-size: 21px; }
  .modal-grid { grid-template-columns: 1fr; }
  .target-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .board-tools { width: 100%; justify-content: flex-end; }
  .board-nav { width: 100%; }
  .board-nav a { flex: 1; text-align: center; }
}

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