:root {
  --bg: #f1f5f9; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #4338ca; --brand-ink: #ffffff; --ok: #16a34a; --warn: #d97706; --urgent: #dc2626;
  --radius: 14px; --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; }
button { font: inherit; cursor: pointer; }

/* Wide-screen container rules (mobile-first; grows with the viewport). */
.wrap { width: 100%; padding: 0 16px; margin: 0 auto; }
@media (min-width: 1280px) { .wrap { max-width: min(100%, 1680px); padding: 0 clamp(1.5rem, 2.5vw, 3rem); } }
@media (min-width: 1920px) { .wrap { max-width: 1840px; } }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 1rem; height: 60px; }
.logo { font-weight: 800; color: var(--brand); font-size: 1.15rem; letter-spacing: -.02em; }
.logo span { color: var(--ink); }
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav button { background: transparent; border: 0; padding: .5rem .8rem; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav button.active { background: var(--brand); color: var(--brand-ink); }
/* Phones: logo on top, menu as a swipeable row underneath (no page-level horizontal scroll). */
@media (max-width: 767px) {
  .topbar .wrap { height: auto; flex-wrap: wrap; padding-top: .55rem; padding-bottom: .4rem; gap: .3rem; }
  .nav { width: 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav button { white-space: nowrap; flex: none; }
}
.nav button:hover:not(.active) { background: var(--bg); }

main { padding: 1.5rem 0 4rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cols { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .cols.two { grid-template-columns: 2fr 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.card h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: .6rem; }
.spread { justify-content: space-between; }
.stat { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill.ok { background: #dcfce7; color: #166534; } .pill.off { background: #fee2e2; color: #991b1b; }
.pill.info { background: #e0e7ff; color: #3730a3; } .pill.warn { background: #fef3c7; color: #92400e; }
.pill.urgent { background: #fee2e2; color: #991b1b; }

label { display: block; font-weight: 600; margin: .7rem 0 .25rem; font-size: .9rem; }
input, select, textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn { background: var(--brand); color: var(--brand-ink); border: 0; padding: .6rem 1rem; border-radius: 10px; font-weight: 700; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; }
.btn.danger { background: var(--urgent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }

.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 1rem; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart .col > i { width: 100%; max-width: 46px; background: var(--brand); border-radius: 6px 6px 0 0; display: block; }
.chart .col small { color: var(--muted); font-size: .72rem; }

.center { max-width: 26rem; margin: 8vh auto; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; }
.toast.err { background: var(--urgent); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 40; }
.modal { background: var(--card); border-radius: var(--radius); padding: 1.3rem; max-width: 30rem; width: 100%; max-height: 90vh; overflow: auto; }
.list > div { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list > div:last-child { border-bottom: 0; }
.tag { font-size: .78rem; background: var(--bg); padding: .1rem .5rem; border-radius: 6px; margin: 0 .3rem .3rem 0; display: inline-block; }
.hidden { display: none; }
code.mono { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: .15rem .4rem; border-radius: 6px; }
.big-code { font-size: 2.4rem; font-weight: 800; letter-spacing: .3em; text-align: center; color: var(--brand); margin: 1rem 0; }

/* Location map (OpenStreetMap tiles, no library) */
.map { position: relative; height: 240px; overflow: hidden; border-radius: 10px; background: #e5e7eb; margin-top: .5rem; }
.map-in { position: absolute; left: 50%; top: 50%; }
.map-in img { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; }
.map-pin { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.map-acc { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(67,56,202,.15); border: 1px solid rgba(67,56,202,.5); }
.map-attr { position: absolute; right: 4px; bottom: 2px; font-size: .68rem; background: rgba(255,255,255,.8); padding: 0 .3rem; border-radius: 4px; color: #333; }
