[hidden] { display: none !important; }
:root {
  --bg: #f3f6fa; --card: #fff; --ink: #14202e; --muted: #5d6b7c; --line: #dfe5ec;
  --brand: #0b5cab; --brand-2: #e7f0fa; --ok: #1f9d55; --off: #b8c2cc; --warn: #d97706; --err: #c62828;
  --radius: 12px;
  font-family: "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

header#topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); font-size: 17px; }
.brand img { width: 28px; height: 28px; }
#nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
#nav a.active { background: var(--brand-2); color: var(--brand); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 16px; }

button, .btn { font: inherit; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; display: inline-block; }
button.ghost, .btn.ghost { background: transparent; color: var(--brand); }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button.sm { padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; background: #fff; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
label input, label select { margin-top: 4px; color: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile .k { color: var(--muted); font-size: 13px; } .tile .v { font-size: 26px; font-weight: 700; }
.tile .v small { font-size: 14px; font-weight: 400; color: var(--muted); }

.meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.meter { cursor: pointer; transition: box-shadow .15s; }
.meter:hover { box-shadow: 0 4px 14px rgba(11,92,171,.12); }
.meter .name { font-weight: 600; }
.meter .vals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.meter .vals .k { font-size: 12px; color: var(--muted); } .meter .vals .v { font-size: 18px; font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--off); margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,157,85,.15); }
.flash { animation: flash .8s; } @keyframes flash { from { background: #e4f6ea; } to { background: transparent; } }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: #fff; color: var(--muted); padding: 5px 12px; }
.seg button.on { background: var(--brand); color: #fff; }

.chart { width: 100%; height: 240px; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .grid { stroke: #edf1f5; } .chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; }
.chart .area { fill: rgba(11,92,171,.08); }
.chart .bar { fill: var(--brand); } .chart .bar:hover { fill: #094c8c; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfd; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--brand-2); color: var(--brand); white-space: nowrap; }
.badge.grey { background: #eef1f4; color: var(--muted); } .badge.warn { background: #fff3e0; color: var(--warn); }
code, .code { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f4f8; padding: 1px 6px; border-radius: 5px; }

.auth { max-width: 420px; margin: 7vh auto; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo img { width: 56px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.err { color: var(--err); font-size: 14px; min-height: 20px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

#modal { position: fixed; inset: 0; background: rgba(20,32,46,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 30; font-size: 14px; }

@media (max-width: 640px) {
  main { padding: 12px; } header#topbar { padding: 8px 12px; gap: 8px; }
  .tile .v { font-size: 21px; } .who span { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .brand { flex: 1; } #nav { order: 3; width: 100%; flex: none; }
  #search { width: 100% !important; } .row.spread > .row { width: 100%; }
}
