:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0c1916;
  --panel-2: #10211d;
  --line: #203a33;
  --text: #e7f2ed;
  --muted: #86a098;
  --accent: #53e0a1;
  --accent-dark: #123d2d;
  --danger: #ff7c7c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% -10%, #153a2e 0, transparent 32rem), var(--bg); color: var(--text); }
header { height: 68px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(7, 17, 15, .82); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 5; }
.brand, .header-actions, .compose-row, .panel-heading, .message-meta { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #052117; font-weight: 900; letter-spacing: -.06em; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 12px; }
.tabs { max-width: 1400px; margin: 0 auto; padding: 24px clamp(18px, 4vw, 64px) 0; display: flex; gap: 8px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; padding: 10px 15px; }
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--accent); background: var(--accent-dark); border-color: #285844; }
.app-shell { max-width: 1400px; margin: 0 auto; padding: 18px clamp(18px, 4vw, 64px) 70px; }
.tab-panel[hidden] { display: none; }
.message-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 20px; }
.messages { grid-row: span 2; }
.map-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr); gap: 20px; }
.status-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.status-hero, .device-state { display: flex; align-items: center; }
.status-hero { grid-column: 1 / -1; justify-content: space-between; }
.device-state { gap: 14px; }
.device-state .status-dot { width: 12px; height: 12px; margin: 0; }
.device-state p { margin-bottom: 0; }
.detail-grid { margin: 0; }
.detail-grid > div { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(0, 2fr); gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.detail-grid > div:first-child { border-top: 0; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.telemetry-panel { grid-column: 1 / -1; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #081411; }
.metric span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.metric strong { color: var(--accent); font-size: 20px; }
.panel { background: linear-gradient(145deg, rgba(16, 33, 29, .96), rgba(10, 23, 20, .96)); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.16); }
.map-panel { min-width: 0; }
#map { height: min(68vh, 720px); min-height: 480px; border-radius: 12px; background: #081411; border: 1px solid var(--line); }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2); color: var(--text); }
.mesh-node-marker { display: grid; place-items: center; border: 2px solid #07110f; border-radius: 50%; background: var(--accent); color: #052117; box-shadow: 0 3px 12px rgba(0,0,0,.45), 0 0 0 2px rgba(83,224,161,.3); font-size: 10px; font-weight: 900; letter-spacing: -.02em; }
.mesh-node-marker span { max-width: 38px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.panel-heading { justify-content: space-between; margin-bottom: 18px; }
h1, h2, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 18px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; margin-bottom: 5px; }
.muted, .empty { color: var(--muted); }
.empty { padding: 26px 4px; text-align: center; }
textarea, input { width: 100%; color: var(--text); background: #081411; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: inherit; outline: none; }
textarea { min-height: 92px; resize: vertical; }
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(83,224,161,.1); }
label { color: var(--muted); font-size: 12px; }
.compose-row { margin-top: 12px; align-items: end; }
.compose-row label:first-child { flex: 1; }
.compose-row label:nth-child(2) { width: 90px; }
.channel-lock { display: flex; align-items: center; gap: 8px; height: 43px; padding: 0 13px; color: var(--muted); background: #081411; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.channel-lock strong { color: var(--accent); }
button { border: 0; border-radius: 10px; padding: 12px 17px; background: var(--accent); color: #052117; font-weight: 800; cursor: pointer; white-space: nowrap; }
button:disabled { opacity: .45; cursor: wait; }
button.quiet { padding: 7px 10px; background: transparent; color: var(--muted); }
.pill, .count, .state { border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; }
.pill.online, .state.acknowledged, .state.transmitted { color: var(--accent); background: var(--accent-dark); }
.pill.offline, .state.failed, .state.unknown { color: #d8aaa3; background: #3a211f; }
.count { color: var(--muted); background: #091411; }
.message-item, .node-item, .command-item { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 2px; border-top: 1px solid var(--line); }
.message-item:first-child, .node-item:first-child, .command-item:first-child { border-top: 0; }
.message-item p, .node-item p, .command-item p { margin: 4px 0 0; color: #bfd0ca; font-size: 14px; }
.message-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 10px; }
.reply-button { color: var(--accent); background: transparent; padding: 4px 8px; font-size: 11px; }
.avatar { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-dark); color: var(--accent); font-size: 11px; font-weight: 900; }
.message-meta { justify-content: space-between; }
time, .node-item p, .command-item p { color: var(--muted); font-size: 11px; }
.status-dot { width: 8px; height: 8px; margin: 7px 4px 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.status-dot:not(.located) { background: #536c64; box-shadow: none; }
.node-item.mappable { cursor: pointer; }
.node-item.mappable:hover { background: rgba(83,224,161,.04); }
.command-item { grid-template-columns: auto 1fr; align-items: center; }
.state { background: #1b302a; color: #9fc2b5; }
.login-page { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(390px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .brand-mark { margin-bottom: 25px; }
.login-card h1 { margin-bottom: 6px; }
.login-card form { display: grid; gap: 12px; margin-top: 28px; }
.error { color: var(--danger); background: #321c1c; padding: 10px; border-radius: 8px; }
.hidden { display: none !important; }
@media (max-width: 900px) { .message-layout, .map-layout, .status-layout { grid-template-columns: 1fr; } .status-hero, .telemetry-panel { grid-column: auto; } .messages { grid-row: auto; } #map { min-height: 420px; } }
@media (max-width: 600px) { .compose-row { align-items: stretch; flex-direction: column; } .compose-row label:nth-child(2) { width: 100%; } .header-actions form { display: none; } .tabs { overflow-x: auto; } #map { min-height: 360px; } }
