/* MINARVIS portal — Brand Policy v2.1: Dawn White paper, Deep Steel headings, Charcoal Steel type,
   Golden Haze only as a band, Sun Bronze hairlines, Anchor Green = live RTK fix only. No shadows, no glows. */
:root {
  --dawn: #FAF5EB; --steel: #6B8AA3; --deep: #3E5B72; --haze: #F4DDA6; --bronze: #C99764;
  --char: #1F2A33; --green: #2E8B6B; --amber: #D9913A; --red: #B83C2E;
  --paper2: #F3ECDD; --line: #E4D6BC; --muted: #5A6874;
  --head: 'Inter Tight', 'Helvetica Neue', Arial, sans-serif;
  --body: 'Inter', Arial, system-ui, sans-serif;
  --mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--dawn); color: var(--char); font: 14px/1.45 var(--body); display: flex; flex-direction: column; min-height: 100vh; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; color: var(--deep); margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 15px; margin-top: 1.4em; }
.mono { font-family: var(--mono); font-weight: 500; font-size: 12.5px; }
[hidden] { display: none !important; }
a { color: var(--deep); }

.demo-band { background: var(--haze); color: var(--char); font-size: 12.5px; padding: 6px 16px; border-bottom: 1px solid var(--bronze); }
.demo-band strong { font-family: var(--head); letter-spacing: .06em; }

/* gate */
.gate { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.gate-card { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--deep); padding: 28px; }
.gate-logo { display: block; width: 240px; height: auto; margin: 0 0 18px -8px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.uid { background: var(--paper2); padding: 8px 10px; border: 1px solid var(--line); word-break: break-all; user-select: all; }
.gate-foot { margin-top: auto; }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--char); }
input, select { font: 14px var(--body); color: var(--char); background: #fff; border: 1px solid #CFC2A8; border-radius: 3px; padding: 7px 8px; min-width: 0; }
input[type=number], #in-lat, #in-lon { font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, button:focus-visible, .drop:focus { outline: 2px solid var(--steel); outline-offset: 1px; }
fieldset { min-width: 0; border: 0; border-top: 1px solid var(--line); margin: 14px 0 0; padding: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-family: var(--head); font-weight: 600; color: var(--deep); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; padding: 0 8px 0 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; margin-top: 8px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.grid2, .grid3, .grid4 { display: grid; gap: 10px; }
.grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: 1.3fr 1.3fr .7fr 1fr; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.msg { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
.msg.bad { color: #8a4f12; } .msg.good { color: var(--deep); }
.empty { color: var(--muted); font-style: italic; margin: 4px 0; }

.btn { font: 600 13.5px var(--head); letter-spacing: .01em; border: 1px solid var(--deep); color: var(--deep); background: transparent; padding: 7px 14px; border-radius: 3px; cursor: pointer; }
.btn:hover { background: var(--paper2); }
.btn.primary { background: var(--deep); color: var(--dawn); }
.btn.primary:hover { background: #33495c; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.link { border: 0; padding: 0; text-decoration: underline; align-self: flex-start; font-weight: 500; }
.btn.danger-outline { border-color: var(--amber); color: #8a4f12; }
.btn:disabled { opacity: .5; cursor: default; }

/* app shell */
.app { flex: 1; display: grid; grid-template-columns: minmax(380px, 460px) 1fr; grid-template-rows: auto auto 1fr auto; grid-template-areas: "top top" "tabs stage" "panel stage" "foot foot"; min-height: 0; height: calc(100vh - 31px); }
.topbar { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-bottom: 1px solid var(--bronze); background: var(--dawn); }
.topbar-logo { height: 40px; width: auto; }
.topbar-title { font-family: var(--head); font-weight: 600; color: var(--deep); padding-left: 14px; border-left: 1px solid var(--line); }
.site-pick { flex-direction: row; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 12.5px; }
.conn { color: var(--muted); font-size: 12px; }
.conn.on { color: var(--deep); } .conn.off { color: var(--amber); }
.tabs { grid-area: tabs; display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; background: var(--dawn); }
.tabs button { font: 600 13.5px var(--head); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; }
.tabs button.active { color: var(--deep); border-bottom-color: var(--bronze); }
.panel { grid-area: panel; overflow-y: auto; overflow-x: hidden; padding: 14px 16px 24px; border-right: 1px solid var(--line); min-height: 0; }
.stage { grid-area: stage; position: relative; min-height: 0; display: flex; flex-direction: column; }
.map { flex: 1; min-height: 320px; background: var(--paper2); }
.foot { grid-area: foot; display: flex; justify-content: space-between; gap: 16px; font-size: 11.5px; color: var(--muted); padding: 6px 16px; border-top: 1px solid var(--line); background: var(--dawn); }

.list { list-style: none; margin: 6px 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:hover, .list li.sel { background: var(--paper2); }
.list .t { font-weight: 500; }
.list .s { color: var(--muted); font-size: 12px; }
.list .grow { flex: 1; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--steel); flex: none; }
.dot.marker { background: var(--bronze); border-radius: 2px; transform: rotate(45deg); }
.dot.orb { background: var(--deep); }
.dot.misfire, .dot.hazard { background: var(--red); }
.dot.stale { background: #b9b2a3; }

.badge { font: 600 11px var(--head); letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--steel); color: var(--deep); border-radius: 2px; white-space: nowrap; }
.badge.fix-rtk-fixed { border-color: var(--green); color: var(--green); }
.badge.fix-rtk-float { border-color: var(--amber); color: #8a4f12; }
.badge.warn { border-color: var(--amber); color: #8a4f12; }

.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; align-self: flex-start; }
.seg button { font: 500 12.5px var(--body); background: #fff; border: 0; border-right: 1px solid var(--line); padding: 6px 10px; cursor: pointer; color: var(--char); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--deep); color: var(--dawn); }

.drop { border: 1px dashed var(--steel); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; background: #fff; }
.drop.over { background: var(--paper2); }

.nudge { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.pad { display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 34px); gap: 4px; }
.pad [data-nudge=n] { grid-area: 1 / 2; } .pad [data-nudge=w] { grid-area: 2 / 1; } .pad [data-nudge=e] { grid-area: 2 / 3; } .pad [data-nudge=s] { grid-area: 3 / 2; }
.pad-v { display: flex; flex-direction: column; gap: 4px; }
.pad button, .pad-v button { font: 600 13px var(--head); border: 1px solid var(--deep); background: #fff; color: var(--deep); border-radius: 3px; cursor: pointer; min-width: 40px; height: 34px; }
.pad button:active, .pad-v button:active { background: var(--deep); color: var(--dawn); }

.align { border: 1px solid var(--line); border-left: 3px solid var(--deep); background: #fff; padding: 10px 12px; margin-top: 10px; }
.align h3 { margin-top: 0; }
.readout { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--steel); padding: 10px 12px; margin-top: 14px; white-space: pre-wrap; line-height: 1.6; }
.readout:empty { display: none; }
.sticky-actions { position: sticky; bottom: -24px; background: var(--dawn); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 14px; }

table.cp { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.cp th { font: 600 11px var(--head); color: var(--muted); text-align: left; padding: 4px 3px; border-bottom: 1px solid var(--line); }
table.cp td { padding: 2px; }
table.cp input { width: 100%; padding: 4px; font-size: 12px; }
table.cp td.res { white-space: nowrap; padding: 0 4px; }
table.cp td.res.bad { color: #8a4f12; font-weight: 600; }

.relate { position: absolute; top: 10px; right: 10px; z-index: 500; background: rgba(250, 245, 235, .96); border: 1px solid var(--line); border-left: 3px solid var(--deep); padding: 8px 12px; white-space: pre; line-height: 1.55; }
.preview { height: 280px; border-top: 1px solid var(--line); display: flex; flex-direction: column; background: var(--dawn); }
.preview-head { display: flex; justify-content: space-between; padding: 4px 12px; font: 600 12px var(--head); color: var(--deep); border-bottom: 1px solid var(--line); }
#preview { flex: 1; width: 100%; min-height: 0; display: block; }

.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--char); color: var(--dawn); padding: 8px 16px; border-radius: 3px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 2000; }
.toast.show { opacity: 1; }

/* map icons */
.mk { width: 22px; height: 22px; position: relative; }
.mk .body { position: absolute; inset: 4px; border-radius: 50%; background: var(--steel); border: 2px solid var(--deep); }
.mk.marker .body { border-radius: 2px; background: var(--bronze); border-color: #8f6a43; transform: rotate(45deg); }
.mk.orb .body { background: var(--deep); border-color: var(--char); }
.mk.misfire .body, .mk.hazard .body { background: var(--red); border-color: #7d281f; }   /* safety-critical only (Brand Policy §04) */
.mk .tick { position: absolute; left: 10px; top: -6px; width: 2px; height: 12px; background: var(--char); transform-origin: 1px 17px; }
.mk.sel .body { outline: 2px solid var(--char); outline-offset: 2px; }
.mk.draft .body { background: var(--haze); border-color: var(--deep); border-style: dashed; }
.dev { width: 16px; height: 16px; border-radius: 50%; background: var(--deep); border: 2px solid var(--dawn); outline: 1px solid var(--deep); }
.dev.stale { background: #b9b2a3; outline-color: #8d8778; }
.dev-label { font: 500 11px var(--mono); background: rgba(250,245,235,.92); border: 1px solid var(--line); padding: 1px 4px; white-space: nowrap; }
.leaflet-container { font: 12px var(--body); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 46vh auto auto; grid-template-areas: "top" "tabs" "stage" "panel" "foot"; height: auto; }
  .panel { border-right: 0; overflow: visible; }
  .topbar { flex-wrap: wrap; }
  .topbar-title { display: none; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .foot { flex-direction: column; }
  .preview { height: 220px; }
}
