/* Smart Meter & Enclosure Locator — shared styles (approved Phase 3 design).
   No inline styles anywhere: the Content-Security-Policy only allows this file. */
:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --navy-soft: #e7edf6;
  --blue: #1d4ed8;
  --blue-bg: #e8effd;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --text: #0f172a;
  --muted: #4b5563;
  --faint: #8a94a3;
  --border: #d4dae4;
  --line: #edf0f4;
  --green: #15803d;
  --green-bg: #e7f6ec;
  --red: #b91c1c;
  --red-bg: #fdecec;
  --orange: #b45309;
  --orange-bg: #fff3e0;
  --amber: #fbbf24;
  --hl: #dcfce7;
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }
.show-sm { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Header ---------- */
.app-header { background: var(--navy); color: #fff; }
.app-header .inner { max-width: 880px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.app-header.wide .inner { max-width: 1180px; flex-wrap: wrap; }
.logo { width: 40px; height: 40px; flex: none; display: block; }
.app-title { font-size: 19px; font-weight: 700; line-height: 1.2; }
.app-sub { font-size: 13px; opacity: .8; }
.header-link { margin-left: auto; color: #cbd5e1; font-size: 14px; text-decoration: none; padding: 8px 4px; }
.header-link:hover { color: #fff; }

main { max-width: 880px; margin: 0 auto; padding: 16px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap; background: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: #f3b4b4; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn .ico { font-size: 1.05em; }
.input, select.input {
  width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
label.field { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 6px; }
.field-error { color: var(--red); font-weight: 600; margin-top: 8px; }

/* ---------- Search box ---------- */
.search-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.search-box label { display: block; font-weight: 600; margin-bottom: 8px; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-input {
  flex: 1 1 260px; min-width: 0; height: 56px; padding: 0 16px; font-size: 20px;
  border: 2px solid var(--border); border-radius: 10px; font-family: var(--mono); text-transform: uppercase; background: #fff;
}
.search-input::placeholder { text-transform: none; font-family: system-ui, sans-serif; font-size: 16px; color: var(--faint); }
.search-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.search-row .btn { height: 56px; }

/* ---------- Banners, loading, toast ---------- */
.banner { margin-top: 16px; padding: 12px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.banner.flush { margin-top: 0; }
.banner.ok { background: var(--green-bg); border-color: #a7dcb8; color: #14532d; }
.banner.warn { background: var(--orange-bg); border-color: #f5c98a; color: #7c2d12; }
.banner.err { background: var(--red-bg); border-color: #f3b4b4; color: #7f1d1d; }
.banner.info { background: var(--blue-bg); border-color: #b8c9f5; color: #1e3a8a; }
.banner .b-ico { font-weight: 800; flex: none; }
.loading { margin-top: 16px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--navy); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 60;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* ---------- Suggestions ---------- */
.suggest { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.suggest button {
  width: 100%; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  min-height: 48px; padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.suggest button:hover { border-color: var(--navy); }
.suggest .id { font-family: var(--mono); font-weight: 700; }
.suggest .kind { color: var(--muted); font-size: 14px; }

/* ---------- Result card ---------- */
.card { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.card-head .top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.big-id { font-family: var(--mono); font-size: 28px; font-weight: 800; color: var(--navy); line-height: 1.15; overflow-wrap: anywhere; }
.count { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; font-weight: 600; display: inline-block; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.grey { background: #eef1f5; color: var(--muted); }
.chip.orange { background: var(--orange-bg); color: var(--orange); }
.chip.red { background: var(--red-bg); color: var(--red); }
.section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section h3 { margin: 0 0 10px; font-size: 15px; color: var(--navy); }
.capacity { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.capacity .num { font-size: 18px; font-weight: 800; }
.segs { display: flex; gap: 4px; }
.seg { width: 22px; height: 10px; border-radius: 3px; background: #e2e6ee; }
.seg.on { background: var(--green); }
table { width: 100%; border-collapse: collapse; }
.slots td, .slots th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.slots th { font-size: 13px; color: var(--muted); font-weight: 600; }
.slots td:first-child { white-space: nowrap; }
.slots tr:last-child td { border-bottom: 0; }
.slots .meter { font-family: var(--mono); font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.slots .empty { color: var(--faint); font-family: inherit; font-weight: 400; }
.slots tr.match td { background: var(--hl); }
.slots tr.match td:first-child { box-shadow: inset 4px 0 0 var(--green); }
.tag-searched { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 800; letter-spacing: .05em; background: var(--green); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.pill { font-size: 13px; font-weight: 600; }
.pill.occ { color: var(--green); }
.pill.emp { color: var(--faint); }
.coords { font-family: var(--mono); font-size: 17px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.coords small { font-family: system-ui, sans-serif; color: var(--muted); font-size: 13px; margin-right: 4px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .btn { width: 100%; }
.loc-warn { margin: 0 0 12px; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.details div { min-width: 0; }
.details dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.details dd.none { color: var(--faint); font-weight: 400; }
.replaced-note { background: var(--navy-soft); border-radius: 8px; padding: 10px 12px; color: var(--navy); }
.pager { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
footer.app-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; }

/* ---------- Admin ---------- */
.role { background: var(--amber); color: #3b2a00; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .03em; }
.role.admin { background: #cbd5e1; color: var(--navy); }
.who { margin-left: auto; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.who .btn-sm { min-height: 34px; }
.admin-tabs { background: var(--navy-2); }
.admin-tabs .inner { max-width: 1180px; margin: 0 auto; padding: 0 8px; display: flex; overflow-x: auto; scrollbar-width: none; }
.admin-tabs a { color: #cbd5e1; text-decoration: none; padding: 12px; white-space: nowrap; font-weight: 600; font-size: 15px; border-bottom: 3px solid transparent; }
.admin-tabs a.active { color: #fff; border-bottom-color: var(--amber); }
.admin-tabs a.ext { margin-left: auto; }
.admin-main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.admin-main h1 { font-size: 22px; margin: 4px 0; color: var(--navy); }
.admin-main .lead { color: var(--muted); margin: 0 0 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .value.text { font-size: 18px; }
.stat .value.good { color: var(--green); }
.stat .value.warn { color: var(--orange); }
.stat .sub { font-size: 12px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 16px; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.panel-body { padding: 16px; }
.table-wrap { overflow-x: auto; }
.data th, .data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 14px; vertical-align: top; }
.data td.wrap { white-space: normal; min-width: 240px; }
.data th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data .empty-row td { text-align: center; color: var(--muted); padding: 24px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 14px; max-width: 560px; }
.form-grid.wide { max-width: none; }
.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.radio-card { border: 2px solid var(--border); border-radius: 10px; padding: 12px; display: flex; gap: 10px; cursor: pointer; align-items: flex-start; }
.radio-card input { margin-top: 4px; }
.radio-card.sel { border-color: var(--navy); background: var(--navy-soft); }
.radio-card small { display: block; color: var(--muted); font-weight: 400; }
.drop { display: block; border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: var(--surface-2); cursor: pointer; }
.drop.over { border-color: var(--navy); background: var(--navy-soft); }
.drop .file { font-family: var(--mono); color: var(--navy); font-weight: 700; overflow-wrap: anywhere; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.step { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: #e5e9f0; color: var(--muted); }
.step.done { background: var(--green-bg); color: var(--green); }
.step.cur { background: var(--navy); color: #fff; }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kv div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kv b { display: block; font-size: 22px; color: var(--navy); font-variant-numeric: tabular-nums; }
.kv b.good { color: var(--green); }
.kv b.warn { color: var(--orange); }
.kv b.bad { color: var(--red); }
.kv span { font-size: 13px; color: var(--muted); }
.col-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.subhead { margin: 18px 0 8px; font-size: 15px; color: var(--navy); }
.progress { height: 14px; background: #e5e9f0; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s; }
.progress.indeterminate > i { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters .btn-sm.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; }
.login h1 { margin: 10px 0 4px; font-size: 20px; color: var(--navy); }
.login .btn { width: 100%; }
.center { text-align: center; }
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 480px; width: 100%; padding: 20px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { margin: 0 0 8px; color: var(--navy); font-size: 19px; }
.modal.danger h2 { color: var(--red); }
.modal ul { padding-left: 20px; margin: 8px 0 14px; }
.modal .button-row { justify-content: flex-end; }
.details-json { font-size: 13px; color: var(--muted); }

@media (max-width: 640px) {
  .app-sub { display: none; }
  .search-row .btn { flex: 1 1 0; }
  .actions { grid-template-columns: 1fr; }
  .big-id { font-size: 24px; }
  .stats, .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 22px; }
  .app-header.wide .who { margin-left: 0; width: 100%; }
  .app-header.wide .who .btn-sm { padding: 0 10px; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
}
@media print {
  .app-header, .search-box, .actions, footer.app-foot { display: none; }
  body { background: #fff; }
}
