/* PPH Hardware dashboard */
:root {
  --bg: #F3F6F8; --card: #FFFFFF; --ink: #0F1B24; --muted: #51616C; --line: #E2E8EC; --line-soft: #EEF2F4;
  --side: #0F1B24; --side-ink: #C9D3D9; --side-hi: #1C2D39;
  --accent: #0B6F78; --accent-hi: #08515A; --teal: #0E8A94; --teal-soft: #5FB8BF;
  --ok-bg: #E3F3EC; --ok: #17633F; --warn-bg: #FFF1D6; --warn: #8A5300; --bad-bg: #FBE4E2; --bad: #A3241C;
  --pin-warn: #F2B33D; --pin-bad: #A82A22; --orange: #E0962A;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); } a:hover { color: var(--accent-hi); }
h1 { margin: 0; font-size: 26px; line-height: 1.2; }
h2 { margin: 0 0 12px; font-size: 16px; }
h3 { margin: 18px 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
code, .mono { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 600; } .block { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.t-critical { color: var(--bad) !important; } .t-warning { color: var(--warn) !important; }
.ic { flex: none; }

/* Layout */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 100%; background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 26px; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 0 8px; }
.brand:hover { color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: #14A3AE; color: var(--side); display: flex; align-items: center; justify-content: center; }
.brand strong { display: block; font-size: 15px; } .brand small { display: block; font-size: 12px; color: #93A4AE; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border-radius: 8px; color: var(--side-ink); text-decoration: none; }
.nav a:hover { background: var(--side-hi); color: #fff; }
.nav a.active { background: var(--side-hi); color: #fff; font-weight: 600; }
.count { margin-left: auto; background: var(--pin-warn); color: var(--ink); font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.side-foot { margin-top: auto; font-size: 13px; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; }
.side-foot .linkbtn { color: var(--side-ink); display: inline-flex; gap: 8px; align-items: center; padding: 6px 0; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px 30px 48px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 700px) { .main { padding: 18px 14px 40px; } .side { gap: 14px; } .side-foot { display: none; } .nav { flex-direction: row; flex-wrap: wrap; } }

.page-head { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.grow-3 { flex: 3 1 480px; } .grow-2 { flex: 2 1 320px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }
.empty ol { margin: 0; padding-left: 20px; line-height: 1.9; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi span { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi strong { font-size: 30px; line-height: 1.15; overflow-wrap: anywhere; }
.kpi strong.kpi-sm { font-size: 19px; }
.kpi small { font-size: 13px; color: var(--muted); }

/* Badges, alerts, flashes */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge-healthy { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-critical { background: var(--bad-bg); color: var(--bad); }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border-radius: 10px; margin-bottom: 8px; color: var(--ink); text-decoration: none; }
a.alert:hover { color: var(--ink); filter: brightness(.97); }
.alert small { display: block; color: #3F4E58; font-size: 12px; }
.alert-critical { background: var(--bad-bg); } .alert-warning { background: var(--warn-bg); } .alert-info { background: #EAF2FB; }
.pill { flex: none; background: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.alert-critical .pill { color: var(--bad); } .alert-warning .pill { color: var(--warn); } .alert-info .pill { color: #1D4F86; }
.flash { padding: 11px 14px; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: #6B4100; }
.flash form.inline { display: inline; }

/* Forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #26343E; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #C9D3DA; border-radius: 8px; padding: 9px 11px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-soft); outline-offset: 0; border-color: var(--teal); }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .grow { flex: 1 1 240px; }
form.inline { display: inline; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid #C9D3DA; background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: #F2F5F7; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hi); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #821C16; color: #fff; }
.linkbtn { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #C9D3DA; border-radius: 8px; padding: 0 12px; min-width: min(320px, 100%); }
.search input { border: none; outline: none; flex: 1; padding-left: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
details summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
details { margin-top: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table-sm td { padding: 7px 10px; font-size: 13px; } .table-sm th { padding: 8px 10px; }
.table tr.current td { background: #F2F8F8; }
.kv { margin: 0; }
.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.kv dt { color: var(--muted); flex: none; max-width: 45%; } .kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 500; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.list li > div { flex: 1 1 160px; }

/* Charts */
.bar-row { margin-bottom: 12px; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar { height: 8px; background: #EDF1F3; border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--teal); border-radius: 4px; }
.columns { display: flex; align-items: flex-end; gap: 10px; min-height: 170px; border-bottom: 1px solid var(--line); padding-top: 10px; overflow-x: auto; }
.col { flex: 1 0 52px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.col-bar { width: 100%; max-width: 56px; background: var(--teal); border-radius: 6px 6px 0 0; }
.bg-warning { background: var(--orange); } .bg-critical { background: var(--pin-bad); }

/* Map */
.map { height: 380px; border-radius: 10px; background: #E6EDF0; z-index: 0; }
.map-sm { height: 300px; margin: 8px 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; display: inline-block; }
.dot-healthy { background: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.dot-warning { background: var(--pin-warn); box-shadow: 0 0 0 1px #B07A10; }
.dot-critical { background: var(--pin-bad); box-shadow: 0 0 0 1px var(--pin-bad); }
.pin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; box-shadow: 0 2px 6px rgba(15,27,36,.35); }
.pin-healthy { background: var(--teal); color: #fff; } .pin-warning { background: var(--pin-warn); color: var(--ink); } .pin-critical { background: var(--pin-bad); color: #fff; }
.leaflet-container { font: inherit; }

/* Device page */
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; }
.device-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
.device-head p { margin: 6px 0 0; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Keys */
.new-key { border-color: var(--teal); background: #F2FAFA; }
.copy-row { display: flex; gap: 8px; } .copy-row input { flex: 1; }
.code { background: var(--ink); color: #E6EDF0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }

/* Login */
.center-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 22px; } .login p { margin: 0; }
