:root {
  color-scheme: dark;
  --bg: #07100e;
  --panel: rgba(13, 29, 25, 0.86);
  --panel-strong: #102620;
  --line: rgba(132, 181, 165, 0.17);
  --text: #eaf7f2;
  --muted: #8ca9a0;
  --accent: #45e6a8;
  --accent-2: #27bdf2;
  --warn: #f6bd4d;
  --danger: #ff6b73;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(44, 169, 126, 0.16), transparent 34rem),
    radial-gradient(circle at 95% 20%, rgba(39, 189, 242, 0.10), transparent 30rem),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }

.eyebrow { margin: 0 0 0.35rem; color: var(--accent); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 3vw, 1.9rem); letter-spacing: -0.03em; }
h2 { margin-bottom: 0; font-size: 1rem; }
.muted { color: var(--muted); }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 1.25rem; }
.login-shell { width: min(100%, 430px); }
.login-card {
  position: relative;
  overflow: hidden;
  padding: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(18, 44, 36, 0.96), rgba(8, 22, 18, 0.96));
  box-shadow: var(--shadow);
}
.login-card::after { content: ""; position: absolute; inset: auto -20% -40% 35%; height: 180px; background: rgba(69, 230, 168, 0.10); filter: blur(50px); }
.brand-mark { display: grid; width: 48px; height: 48px; margin-bottom: 1.8rem; place-items: center; border: 1px solid rgba(69, 230, 168, 0.3); border-radius: 15px; background: rgba(69, 230, 168, 0.08); }
.brand-mark span { width: 16px; height: 16px; border: 4px solid var(--accent); border-top-color: transparent; border-radius: 50%; transform: rotate(35deg); }
.login-note { margin: 0.9rem 0 1.7rem; color: var(--muted); line-height: 1.7; }
.login-form { position: relative; z-index: 1; display: grid; gap: 0.75rem; }
.login-form label { color: #bfd2cb; font-size: 0.82rem; font-weight: 700; }
.login-form input, .log-controls input, .log-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(3, 13, 10, 0.72);
}
.login-form input { height: 50px; padding: 0 0.9rem; font-size: 1rem; }
.login-form input:focus, .log-controls input:focus, .log-controls select:focus { border-color: rgba(69, 230, 168, 0.7); box-shadow: 0 0 0 3px rgba(69, 230, 168, 0.1); }
.login-form button { height: 50px; border: 0; border-radius: 10px; color: #03120d; background: linear-gradient(120deg, var(--accent), #72f2c1); font-weight: 850; }
.login-form button:disabled { cursor: wait; opacity: 0.65; }
.form-error { min-height: 1.3em; margin: 0.1rem 0 0; color: var(--danger); font-size: 0.85rem; }
.secure-note { position: relative; z-index: 1; display: flex; align-items: center; gap: 0.5rem; margin: 1.4rem 0 0; color: var(--muted); font-size: 0.75rem; }

.topbar { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 1rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: rgba(7, 16, 14, 0.82); backdrop-filter: blur(18px); }
.topbar-actions, .connection-state { display: flex; align-items: center; gap: 0.75rem; }
.connection-state { color: var(--muted); font-size: 0.78rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #70847d; }
.status-dot.online { background: var(--accent); box-shadow: 0 0 12px rgba(69, 230, 168, 0.8); }
.status-dot.pending { background: var(--warn); box-shadow: 0 0 10px rgba(246, 189, 77, 0.55); }
.ghost-button { padding: 0.55rem 0.8rem; border: 1px solid var(--line); border-radius: 9px; color: #cbe0d8; background: rgba(255,255,255,0.025); }
.ghost-button:hover { border-color: rgba(69, 230, 168, 0.45); color: var(--text); }

.dashboard { width: min(1520px, 100%); margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 3rem) 3rem; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 16px 38px rgba(0, 0, 0, 0.18); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 1rem; }
.service-card, .clock-card { padding: 1.2rem; }
.panel-heading, .metric-top, .logs-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.panel-label { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.badge { align-self: center; padding: 0.38rem 0.62rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; }
.badge.online { border-color: rgba(69,230,168,.3); color: var(--accent); background: rgba(69,230,168,.08); }
.badge.offline { border-color: rgba(255,107,115,.35); color: var(--danger); background: rgba(255,107,115,.08); }
.service-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1.2rem; }
.service-facts div { min-width: 0; padding: 0.8rem; border-radius: 10px; background: rgba(255,255,255,.025); }
.service-facts span, .service-facts strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-facts span { margin-bottom: 0.3rem; color: var(--muted); font-size: 0.7rem; }
.service-facts strong { font: 650 0.82rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.clock-card { display: flex; flex-direction: column; justify-content: center; }
.clock { margin: 0.1rem 0 0.5rem; font: 750 clamp(1.15rem, 2vw, 1.55rem) ui-monospace, SFMono-Regular, Menlo, monospace; }
.sampling-error { margin-top: 0.45rem; overflow: hidden; color: var(--danger); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.metric-card { padding: 1rem; }
.metric-top span { color: var(--muted); font-size: 0.75rem; font-weight: 750; }
.metric-top strong { font: 800 1.25rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.progress { height: 5px; margin: 0.85rem 0 0.7rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.06); }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .35s ease; }
.progress span[data-level="warn"] { background: var(--warn); }
.progress span[data-level="danger"] { background: var(--danger); }
.metric-card p { margin: 0; overflow: hidden; color: var(--muted); font: 0.72rem ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.network-card { display: grid; grid-column: span 2; grid-template-columns: 1fr 1fr; align-items: center; }
.network-card div { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 1rem; }
.network-card div + div { border-left: 1px solid var(--line); }
.network-card .direction { color: var(--muted); font-size: 0.75rem; font-weight: 800; }
.network-card strong { min-width: 0; font: 800 1.1rem ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }

.logs-panel { margin-top: 1rem; overflow: hidden; }
.logs-header { padding: 1rem 1rem 0.85rem; }
.log-controls { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 0.55rem; }
.log-controls label { display: grid; gap: 0.28rem; color: var(--muted); font-size: 0.66rem; }
.log-controls input, .log-controls select { height: 34px; padding: 0 0.55rem; font-size: 0.75rem; }
.search-label { width: 150px; }
.toggle-label { display: flex !important; height: 34px; flex-direction: row; align-items: center; gap: .4rem !important; }
.toggle-label input { width: 15px; height: 15px; accent-color: var(--accent); }
.log-meta { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.67rem; }
.log-lines { height: min(55vh, 650px); min-height: 360px; overflow: auto; padding: 0.5rem 0; background: rgba(1, 8, 6, 0.73); scrollbar-color: #285044 transparent; }
.log-row { display: grid; grid-template-columns: 100px 58px minmax(0, 1fr); gap: 0.65rem; padding: 0.34rem 0.8rem; border-left: 2px solid transparent; font: 0.72rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-row:hover { border-left-color: var(--accent); background: rgba(69,230,168,.035); }
.log-row time { color: #6f8e84; }
.log-level { font-weight: 850; }
.level-emerg, .level-alert, .level-crit, .level-error { color: var(--danger); }
.level-warn { color: var(--warn); }
.level-notice { color: #d4e572; }
.level-info { color: var(--accent); }
.level-debug { color: #78968d; }
.log-message { min-width: 0; color: #c9ddd6; overflow-wrap: anywhere; white-space: pre-wrap; }

@media (max-width: 900px) {
  .hero-grid, .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock-card { min-height: 150px; }
  .network-card { grid-column: span 2; }
  .service-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logs-header { align-items: stretch; flex-direction: column; }
  .log-controls { justify-content: flex-start; }
}

@media (max-width: 600px) {
  .topbar { align-items: flex-start; padding: .85rem 1rem; }
  .topbar .eyebrow { font-size: .6rem; }
  .topbar h1 { font-size: 1.2rem; }
  .connection-state span:last-child { display: none; }
  .dashboard { padding: .8rem .75rem 2rem; }
  .hero-grid, .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .service-card { grid-column: span 2; }
  .clock-card { grid-column: span 2; min-height: 130px; }
  .metric-card { padding: .85rem; }
  .metric-top { flex-direction: column; gap: .2rem; }
  .network-card { padding: .8rem .2rem; }
  .network-card div { padding: 0 .65rem; }
  .network-card strong { font-size: .9rem; }
  .logs-header { padding: .85rem; }
  .log-controls { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .search-label { width: auto; }
  .toggle-label { align-self: end; }
  .log-meta { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .log-lines { height: 58vh; min-height: 420px; }
  .log-row { grid-template-columns: 80px 48px minmax(0, 1fr); gap: .4rem; padding: .32rem .55rem; font-size: .64rem; }
  .login-card { padding: 1.6rem; border-radius: 20px; }
}
