/* Monitco — dark dashboard theme (follows the original Monitco dashboard: black panels, cyan accents). */
:root {
  --bg: #0b0e11; --bg2: #12171c; --panel: #161c22; --panel2: #1d252d; --line: #26313b;
  --text: #e6edf2; --muted: #8c9aa6; --accent: #17a2b8; --accent2: #5bc8db;
  --ok: #28a745; --bad: #dc3545; --warn: #f0ad4e; --off: #6c757d;
  --radius: 10px; --sidebar: 220px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent2); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: .95rem; margin: 0; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .bad { color: var(--bad); } .ok { color: var(--ok); }
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.sidebar .logo { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 800; letter-spacing: 2px; color: var(--text); text-decoration: none; border-bottom: 2px solid var(--accent); }
.sidebar .logo svg { width: 34px; height: 34px; }
.sidebar nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; }
.sidebar nav a, .sidebar nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; width: 100%; }
.sidebar nav a:hover, .sidebar nav button:hover { background: var(--panel2); }
.sidebar nav a.active { background: var(--accent); color: #031317; font-weight: 600; }
.sidebar .signal { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar .signal.none { color: var(--bad); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .path { color: var(--muted); font-weight: 400; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; text-decoration: none; }
.iconbtn:hover { color: var(--text); background: var(--panel2); }
.iconbtn.on { color: var(--accent2); }
.devsel { max-width: 240px; padding: 7px 10px; border-radius: 8px; background: var(--panel); color: var(--text); border: 1px solid var(--line); font: inherit; }
.content { padding: 16px; max-width: 1500px; width: 100%; }
.menu-toggle { display: none; }
footer.copy { color: var(--muted); font-size: .8rem; text-align: center; padding: 24px 16px; margin-top: auto; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; z-index: 40; transition: left .2s; height: 100vh; }
  body.nav-open .sidebar { left: 0; box-shadow: 0 0 40px #000; }
  .menu-toggle { display: inline-flex; }
  .devsel { max-width: 140px; }
}

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.card.alarm { border-color: var(--bad); border-top-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.card-h { display: flex; align-items: center; gap: 6px; padding: 8px 10px 6px 12px; border-bottom: 1px solid var(--line); }
.card-h h3 { flex: 1; color: var(--accent2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-h .num { color: var(--muted); font-weight: 400; margin-right: 4px; }
.card-h .iconbtn { width: 30px; height: 30px; }
.card-b { padding: 12px; flex: 1; }
.card-f { padding: 8px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.section-title { margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-size: .78rem; font-weight: 700; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel > h2 { color: var(--accent2); }

/* gauges */
.gauge { height: 190px; }
.reading { text-align: center; margin-top: -26px; }
.reading .v { font-size: 1.6rem; font-weight: 700; }
.reading .u { color: var(--muted); margin-left: 4px; }
.reading .lim { color: var(--muted); font-size: .78rem; }

/* indicators (inputs) */
.ind { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ind:last-child { border-bottom: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--off); flex-shrink: 0; box-shadow: 0 0 0 3px #0003; }
.dot.ok { background: var(--ok); } .dot.alarm { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.ind .nm { flex: 1; min-width: 0; } .ind .st { font-weight: 600; }
.ind .iconbtn { width: 28px; height: 28px; }

/* switches (outputs) */
.sw-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.sw-row:last-child { border-bottom: 0; }
.sw-row .nm { flex: 1; }
.switch { position: relative; width: 54px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--bad); border-radius: 28px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(26px); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }
.pending { color: var(--warn); font-size: .78rem; }

/* map */
.map { height: 320px; border-radius: 8px; background: #111; }
/* Dark map like the original dashboard (OpenStreetMap tiles inverted; Google Maps uses its own dark style). */
.map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
.leaflet-popup-content { color: #222; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 6px 12px; cursor: pointer; font: inherit; }
.tabs button.on { background: var(--accent); color: #031317; font-weight: 600; }
.stale { color: var(--bad); font-weight: 600; } .fresh { color: var(--ok); }

/* banners */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; border-left-width: 5px; background: var(--panel); }
.banner.error { border-color: var(--bad); } .banner.warn { border-color: var(--warn); } .banner.info { border-color: var(--accent); } .banner.ok { border-color: var(--ok); }
.banner .txt { flex: 1; } .banner b { display: block; margin-bottom: 2px; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

/* forms & buttons */
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: .88rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 6px 0 0; vertical-align: middle; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #031317; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: none; color: var(--accent2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--panel2); }
.pill.ok { background: #12351f; color: #5fd383; } .pill.bad { background: #3b1418; color: #ff7b86; } .pill.warn { background: #3b2d12; color: #f0c26b; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 1.8rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .85rem; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, 94vw); }
dialog.wide { width: min(980px, 96vw); }
dialog::backdrop { background: #000a; }
dialog .dh { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
dialog .dh h2 { flex: 1; margin: 0; }
dialog .db { padding: 16px; }
.dual { position: relative; height: 34px; margin: 10px 4px 4px; }
.dual input[type=range] { position: absolute; left: 0; right: 0; top: 8px; width: 100%; margin: 0; padding: 0; pointer-events: none; background: none; border: 0; -webkit-appearance: none; appearance: none; }
.dual input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: pointer; }
.dual input[type=range]::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: pointer; }
.dual .track { position: absolute; left: 0; right: 0; top: 16px; height: 6px; border-radius: 6px; background: var(--bad); }
.dual .fill { position: absolute; top: 16px; height: 6px; background: var(--ok); }
.chart { height: 360px; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px #0008; max-width: 360px; }
.toast.error { border-color: var(--bad); } .toast.ok { border-color: var(--ok); }

/* auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #0f2a33 0, var(--bg) 60%); }
.auth .box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 12px; padding: 24px; }
.auth .brand { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 800; letter-spacing: 3px; font-size: 1.3rem; margin-bottom: 16px; color: var(--text); text-decoration: none; }
.auth .brand svg { width: 40px; height: 40px; }
.auth .links { display: flex; justify-content: space-between; margin-top: 14px; font-size: .9rem; }
.code-input { font-size: 1.6rem; letter-spacing: 10px; text-align: center; }

/* plans */
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan .price { font-size: 2rem; font-weight: 800; } .plan .price small { font-size: .9rem; color: var(--muted); font-weight: 400; }
.plan ul { padding-left: 18px; color: var(--muted); flex: 1; }

/* label printing */
@media print {
  .sidebar, .topbar, .noprint, footer.copy { display: none !important; }
  body { background: #fff; color: #000; }
  .label-card { border: 1px dashed #000 !important; color: #000 !important; background: #fff !important; }
}
.label-card { display: inline-flex; gap: 16px; align-items: center; padding: 16px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; color: #000; }
.label-card .qr { width: 128px; height: 128px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
