/* =============================================================================
 * app.css — Fielding
 *
 * Dark UI with high-contrast accents: tablets in direct sun wash out low
 * contrast, and a dark shell keeps the imagery basemap the brightest thing on
 * screen. Controls are sized for gloved thumbs (44 px minimum targets).
 * ========================================================================== */

:root {
  --bg:        #0D1117;
  --bg-2:      #141A22;
  --bg-3:      #1B2330;
  --bg-4:      #232D3C;
  --line:      #2C3846;
  --line-2:    #3A4859;
  --fg:        #E8EDF3;
  --fg-2:      #A9B6C5;
  --fg-3:      #6F7F92;

  --accent:    #FF7A00;   /* comm orange — the app's primary */
  --accent-2:  #FFA24D;
  --blue:      #2F6FEB;
  --cyan:      #00E5FF;
  --green:     #22C55E;
  --amber:     #F59E0B;
  --red:       #EF4444;

  --radius:    10px;
  --radius-sm: 7px;
  --topbar-h:  54px;
  --status-h:  30px;
  --sidebar-w: 310px;
  --panel-w:   430px;

  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --shadow-sm: 0 3px 10px rgba(0,0,0,.35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font-family: var(--mono); font-size: 11px; background: var(--bg-4);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px;
}
.muted { color: var(--fg-3); }
.mono { font-family: var(--mono); }
.is-hidden { display: none !important; }

/* ============================================================== splash */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity .35s ease;
}
#splash.is-gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-mark { animation: spin 2.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.splash-inner h1 {
  margin: 14px 0 4px; font-size: 26px; letter-spacing: .06em; font-weight: 700;
}
.splash-inner p { color: var(--fg-3); margin: 0; }
.splash-err { max-width: 460px; padding: 24px; text-align: left; }
.splash-err h2 { color: var(--red); margin-top: 0; }

/* ============================================================== topbar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
#projectName {
  font-weight: 650; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 210px;
}
#projectMeta { font-size: 11px; white-space: nowrap; overflow: hidden;
               text-overflow: ellipsis; max-width: 210px; }

.topbar-search { flex: 1; min-width: 90px; max-width: 460px; position: relative; }
#searchInput {
  width: 100%; height: 34px; padding: 0 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 17px; outline: none;
}
#searchInput:focus { border-color: var(--accent); background: var(--bg-4); }

/* ------------------------------------------------------- search dropdown */
.search-results {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  z-index: 1400; max-height: min(68vh, 520px); overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.search-results.is-open { display: block; }
.sr-group {
  padding: 7px 12px 4px; font-size: 10px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--fg-3);
  background: var(--bg-3); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
.sr-row {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 8px 12px; background: transparent; border: none;
  border-bottom: 1px solid var(--line); text-align: left; color: var(--fg-2);
}
.sr-row:hover, .sr-row.is-active { background: rgba(255,122,0,.13); color: var(--fg); }
.sr-ic {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 6px; background: var(--bg-4); font-size: 12px;
}
.sr-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sr-lbl { font-size: 13px; font-weight: 650; color: var(--fg);
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: 11px; color: var(--fg-3);
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-empty, .sr-note {
  padding: 14px 12px; font-size: 12px; color: var(--fg-3); line-height: 1.5;
}
.sr-note { border-top: 1px solid var(--line); color: var(--amber); }

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 3px; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 16px; color: var(--fg-2);
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.is-on { color: var(--accent); border-color: var(--line-2); background: var(--bg-3); }

.text-btn {
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
  font-weight: 550;
}
.text-btn:hover { background: var(--bg-4); color: var(--fg); }
.text-btn.is-primary {
  background: var(--accent); border-color: var(--accent); color: #1A0E00; font-weight: 650;
}
.text-btn.is-primary:hover { background: var(--accent-2); }

.basemap-sel {
  height: 34px; padding: 0 8px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
  max-width: 150px;
}

/* =============================================================== shell */
#shell {
  position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  display: flex;
}

/* ============================================================= sidebar */
#sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  flex: 1; height: 42px; background: transparent; border: none;
  border-bottom: 2px solid transparent; color: var(--fg-3);
  font-weight: 600; font-size: 12.5px; letter-spacing: .02em;
}
.tab:hover { color: var(--fg-2); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-pane { display: none; flex: 1; min-height: 0; overflow-y: auto; }
.tab-pane.is-active { display: block; }
.pane-hint {
  margin: 0; padding: 10px 12px; font-size: 12px; color: var(--fg-3);
  border-bottom: 1px solid var(--line); line-height: 1.45;
}
.pane-bar {
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}

/* ------------------------------------------------------------ palette */
.pal-group { border-bottom: 1px solid var(--line); }
.pal-group-head {
  width: 100%; height: 34px; padding: 0 12px; background: var(--bg-3);
  border: none; display: flex; align-items: center; justify-content: space-between;
  color: var(--fg-2); font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
}
.pal-chev { transition: transform .15s; }
.pal-group.is-collapsed .pal-chev { transform: rotate(-90deg); }
.pal-group.is-collapsed .pal-grid { display: none; }

.pal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px; padding: 8px;
}
.pal-item {
  min-height: 72px; padding: 7px 4px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; text-align: center;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--fg-2);
  transition: transform .08s, border-color .12s, background .12s;
}
.pal-item:hover { background: var(--bg-4); border-color: var(--line-2); color: var(--fg); }
.pal-item:active { transform: scale(.96); }
.pal-item.is-active {
  border-color: var(--accent); background: rgba(255,122,0,.14); color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.pal-ic { display: block; height: 26px; line-height: 0; }
.pal-lbl { font-size: 10.5px; font-weight: 600; line-height: 1.2; }

/* -------------------------------------------------------- feature list */
.lst-group {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; background: var(--bg-3);
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--fg-3); position: sticky; top: 0; z-index: 2;
}
.lst-group-n { color: var(--fg-3); }
.lst-row {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; background: transparent; border: none;
  border-bottom: 1px solid var(--line); text-align: left; color: var(--fg-2);
  min-height: 50px;
}
.lst-row:hover { background: var(--bg-3); }
.lst-row.is-active { background: rgba(255,122,0,.12); color: var(--fg); }
.lst-ic { flex: none; line-height: 0; }
.lst-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lst-lbl { font-weight: 600; font-size: 13px; color: var(--fg);
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-sub { font-size: 11px; color: var(--fg-3);
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-qc {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
}
.lst-flag { color: var(--amber); }

.qc-draft    { background: #38424F; color: #C3CEDA; }
.qc-complete { background: rgba(34,197,94,.22);  color: var(--green); }
.qc-needs_review { background: rgba(245,158,11,.22); color: var(--amber); }
.qc-rejected { background: rgba(239,68,68,.22);  color: var(--red); }

/* -------------------------------------------------------------- layers */
.lyr-row {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
.lyr-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.lyr-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lyr-name { font-size: 13px; font-weight: 600;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lyr-sub { font-size: 11px; color: var(--fg-3); }
.lyr-act {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
}
.lyr-act.is-danger:hover { background: rgba(239,68,68,.18); color: var(--red); }
.lyr-color { width: 32px; height: 30px; padding: 2px; background: var(--bg-3);
             border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* -------------------------------------------------------------- legend */
.legend-note {
  margin: 0; padding: 11px 12px; font-size: 11.5px; line-height: 1.5;
  color: var(--fg-3); border-bottom: 1px solid var(--line);
}
.legend-group {
  padding: 8px 12px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3);
}
.legend-row {
  display: flex; align-items: center; gap: 9px; padding: 5px 12px;
}
.legend-ic { line-height: 0; flex: none; }
.legend-lbl { flex: 1; font-size: 12.5px; }
.legend-n { color: var(--fg-3); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ================================================================= map */
#mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0A0E14; }
#map.cursor-cross { cursor: crosshair; }
#map.cursor-grab  { cursor: grab; }

.leaflet-container { background: #0A0E14; font-family: var(--font); }
.leaflet-control-attribution {
  background: rgba(13,17,23,.78) !important; color: var(--fg-3) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--fg-2) !important; }
.leaflet-bar a {
  background: var(--bg-2) !important; color: var(--fg) !important;
  border-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--bg-4) !important; }
.leaflet-control-scale-line {
  background: rgba(13,17,23,.75); color: var(--fg-2); border-color: var(--line-2);
}

/* markers — the symbol is centred inside a larger, invisible tap target */
.fx-marker {
  transition: filter .12s;
  display: grid; place-items: center;
  background: none; border: none;
}
.fx-sym { display: grid; place-items: center; line-height: 0; }
.fx-marker.is-selected { filter: drop-shadow(0 0 6px var(--cyan)); z-index: 1000 !important; }
.fx-marker.is-flagged  { filter: drop-shadow(0 0 5px var(--amber)); }
.sym-svg { display: block; overflow: visible; }

.fx-label {
  background: rgba(13,17,23,.78) !important; border: none !important;
  color: #fff !important; font-size: 10.5px !important; font-weight: 650;
  padding: 0 5px !important; border-radius: 3px !important;
  box-shadow: none !important; white-space: nowrap;
}
.fx-label.is-small { font-size: 9.5px !important; opacity: .85; padding: 0 4px !important; }
.fx-label::before { display: none !important; }

/* Cable size lettered along the run.
   The chip has to survive being dropped on white concrete, black asphalt and
   dark green canopy in the same drawing, so it carries its own near-opaque
   ground rather than relying on a text halo; the border is tinted to the
   cable's disposition color so the number stays tied to its own line when
   several routes share a street. iconSize is 0x0, so the chip centres itself
   on the line with translate(-50%,-50%) — a percentage MARGIN would resolve
   against the zero-width icon box and move it nowhere. */
/* Bore footage, lettered parallel to the bore and offset clear of its conduit.
   Reads as a dimension rather than as a label on the cable: no fill, a dashed
   rule under the text, and tinted to the cable's own colour so it stays tied
   to its run where several share a street. */
.fx-bore { pointer-events: none; }
.fx-bore-inner {
  position: absolute; left: 0; top: 0;
  transform-origin: center center;
  display: inline-block; white-space: nowrap;
  padding: 1px 5px 2px;
  background: rgba(10,14,20,.82);
  border: 0; border-bottom: 1.5px dashed currentColor; border-radius: 2px;
  font-size: 11.5px; font-weight: 800;
  letter-spacing: .4px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 2px rgba(0,0,0,.9);
}

/* Station callouts at the two ends of a bore. Lighter than the footage above
   the line — a tick-and-text dimension rather than a chip — because there are
   two of them and they sit closer to the structures' own labels. */
.fx-bore-end { pointer-events: none; }
.fx-bore-end-inner {
  position: absolute; left: 0; top: 0;
  transform-origin: center center;
  display: inline-block; white-space: nowrap;
  padding: 1px 5px 2px;
  background: rgba(10,14,20,.82);
  border: 0; border-top: 1.5px solid currentColor; border-radius: 2px;
  font-size: 11px; font-weight: 750;
  letter-spacing: .3px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 2px rgba(0,0,0,.9);
}

.fx-size { pointer-events: none; }
.fx-size-inner {
  position: absolute; left: 0; top: 0;
  transform-origin: center center;
  display: inline-block; white-space: nowrap;
  padding: 1.5px 6px 2.5px;
  background: rgba(10,14,20,.9);
  border: 2px solid #fff; border-radius: 3px;
  color: #fff; font-size: 12px; font-weight: 800;
  letter-spacing: .3px; line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  box-shadow: 0 1px 3px rgba(0,0,0,.55);
}

/* Structure label, living inside the marker's own icon rather than in a
   Leaflet tooltip — see Sym.icon. Positioned by MapView.layoutLabels, which
   sets left/top in pixels relative to the icon box, so nothing here may
   assume a side. pointer-events stay off: the label must never steal a tap
   meant for the symbol, which on a tablet is the difference between editing
   a pole and editing nothing. */
.fx-pin-label {
  position: absolute;
  white-space: nowrap;
  pointer-events: none;
  /* Rotation is set per label by MapView.layoutLabels, not here: it depends
     on which way the cable runs. The origin is what makes that placement
     work — the element turns about its own centre, so the placer lines up
     centres rather than corners. */
  transform-origin: 50% 50%;
  padding: 1px 5px 2px;
  background: rgba(13,17,23,.86);
  border-radius: 3px;
  color: #fff; font-size: 10.5px; font-weight: 650;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
}
/* Both hide the same way. Two classes rather than one so the placing
   suspend cannot clobber what the crew set the label toggle to. */
.labels-off .fx-pin-label,
.labels-placing .fx-pin-label { display: none; }

.fx-snap-tip {
  background: rgba(0,229,255,.92) !important; color: #002028 !important;
  font-size: 11px !important; font-weight: 700; border: none !important;
  padding: 2px 7px !important; border-radius: 4px !important;
}
.fx-snap-tip::before { display: none !important; }
.fx-snap-hint { animation: snapPulse 1.1s ease-in-out infinite; }
@keyframes snapPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}
/* state boundaries: readable over imagery without competing with survey data */
.fx-state-label {
  pointer-events: none; white-space: nowrap;
}
.fx-state-label span {
  display: inline-block; transform: translate(-50%, -50%);
  font-size: 11px; font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: #BFEEFF;
  text-shadow: 0 0 4px #000, 0 0 9px #000, 0 1px 2px #000;
  opacity: .82;
}
.fx-search-pin { animation: searchPin 1.4s ease-in-out infinite; }
@keyframes searchPin {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.fx-vertex     { cursor: move; }
.fx-vertex-mid { cursor: copy; }
.fx-gps-dot    { animation: gpsPulse 2s ease-in-out infinite; }
@keyframes gpsPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* ---------------------------------------------------------- tool rail */
#toolbar {
  position: absolute; top: 12px; left: 12px; z-index: 900;
  display: flex; flex-direction: column; gap: 4px; padding: 5px;
  background: rgba(20,26,34,.94); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.tool {
  width: 58px; min-height: 50px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--fg-2);
}
.tool:hover { background: var(--bg-3); color: var(--fg); }
.tool.is-active {
  background: var(--accent); color: #1A0E00; border-color: var(--accent);
}
.tool.is-on { background: rgba(47,111,235,.25); color: var(--cyan);
              border-color: var(--blue); }
.tool.is-gps { color: var(--cyan); }
.tool-ic  { font-size: 18px; line-height: 1; }
.tool-lbl { font-size: 9.5px; font-weight: 700; letter-spacing: .03em; }
.tool-sep { height: 1px; background: var(--line); margin: 3px 4px; }

/* ------------------------------------------------------- float bars */
.floatbar {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(-140%);
  top: 12px; z-index: 900;
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: rgba(20,26,34,.96); border: 1px solid var(--line-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transition: transform .2s ease, opacity .2s ease;
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.floatbar.is-on { transform: translateX(-50%) translateY(0); opacity: 1;
                  pointer-events: auto; }
.floatbar-title {
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent);
}
.floatbar-val { font-size: 12.5px; color: var(--fg-2);
                font-variant-numeric: tabular-nums; }
.floatbar-val.is-strong { color: var(--fg); font-weight: 700; }

/* --------------------------------------------------------- status bar */
#statusbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--status-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(13,17,23,.92); border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--fg-3); z-index: 800;
  backdrop-filter: blur(6px);
}
.status-spacer { flex: 1; }
.status-hint { color: var(--fg-2); }
.status-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 11px;
  font-variant-numeric: tabular-nums;
}
.stat { padding: 2px 8px; border-radius: 11px; margin-right: 6px; font-weight: 600; }
.stat-draft { background: rgba(148,163,184,.18); color: #B6C2D0; }
.stat-flag  { background: rgba(245,158,11,.18); color: var(--amber); }

.status-chip[hidden] { display: none; }
.status-chip.is-offline  { color: #FFE0A6; border-color: rgba(245,158,11,.4); font-weight: 600; }
.status-chip.is-native   { color: #A9F3C4; border-color: rgba(34,197,94,.35); }
.status-chip.is-upscaled { color: #FFE0A6; border-color: rgba(245,158,11,.4); }

.gps-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); }
.gps-good { background: var(--green); box-shadow: 0 0 6px var(--green); }
.gps-fair { background: var(--amber); }
.gps-poor { background: var(--red); }

/* =============================================================== panel */
#panel {
  width: var(--panel-w); flex: none; background: var(--bg-2);
  border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column;
}
#panel.is-empty { display: flex; align-items: center; justify-content: center; }
.pnl-empty { text-align: center; padding: 30px; max-width: 280px; }
.pnl-empty-icon { opacity: .5; margin-bottom: 12px; }
.pnl-empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--fg-2); }
.pnl-empty p { margin: 0; font-size: 12.5px; color: var(--fg-3); line-height: 1.5; }

.pnl-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--bg-3); border-bottom: 1px solid var(--line);
}
.pnl-icon { line-height: 0; flex: none; }
.pnl-head-meta { flex: 1; min-width: 0; }
.pnl-title { margin: 0; font-size: 16px; font-weight: 700;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl-type { font-size: 11.5px; color: var(--fg-3); }
.pnl-qc { padding: 3px 9px; border-radius: 11px; font-size: 10.5px; font-weight: 700; }
.pnl-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--fg-3); font-size: 14px;
}
.pnl-close:hover { background: var(--bg-4); color: var(--fg); }

.pnl-card {
  margin: 10px; padding: 11px; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.pnl-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pnl-card-title { font-size: 11px; font-weight: 800; letter-spacing: .09em;
                  text-transform: uppercase; color: var(--fg-3); }
.pnl-card-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--bg-4); display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--fg-2);
}

.pnl-loc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin-bottom: 10px;
}
.pnl-kv { display: flex; flex-direction: column; min-width: 0; }
.pnl-kv.is-wide { grid-column: 1 / -1; }
.pnl-k { font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
         color: var(--fg-3); }
.pnl-v { font-size: 12.5px; font-family: var(--mono); color: var(--fg);
         overflow: hidden; text-overflow: ellipsis; }

.pnl-loc-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.pnl-btn {
  min-height: 34px; padding: 0 11px; border-radius: var(--radius-sm);
  background: var(--bg-4); border: 1px solid var(--line-2); color: var(--fg-2);
  font-size: 12px; font-weight: 600;
}
.pnl-btn:hover { background: var(--line); color: var(--fg); }
.pnl-btn.is-primary { background: var(--accent); border-color: var(--accent);
                      color: #1A0E00; }
.pnl-btn.is-primary:hover { background: var(--accent-2); }
.pnl-btn.is-primary:disabled { opacity: .55; }
.pnl-btn.is-danger { color: #FFB4B4; }
.pnl-btn.is-danger:hover { background: rgba(239,68,68,.2); color: #fff; }
.pnl-btn.is-warn { color: var(--amber); border-color: rgba(245,158,11,.5); }
.pnl-btn.is-block { width: 100%; margin-top: 8px; }

.pnl-complete.is-ok { border-color: rgba(34,197,94,.35); }
.pnl-complete-top { display: flex; justify-content: space-between;
                    align-items: baseline; margin-bottom: 7px; }
.pnl-complete-lbl { font-size: 12px; font-weight: 600; }
.pnl-complete.is-ok .pnl-complete-lbl { color: var(--green); }
.pnl-complete-pct { font-size: 11px; color: var(--fg-3); }
.pnl-bar { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.pnl-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .25s;
}
.pnl-missing { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pnl-missing-chip {
  font-size: 10.5px; padding: 2px 7px; border-radius: 9px;
  background: rgba(245,158,11,.15); color: var(--amber);
}
.pnl-mark { width: 100%; margin-top: 9px; }

.pnl-photo-strip { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; }
.pnl-thumb {
  position: relative; flex: none; width: 84px; height: 84px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line-2); cursor: pointer;
}
.pnl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pnl-thumb-del {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: rgba(0,0,0,.65); color: #fff;
  font-size: 11px; display: grid; place-items: center;
}
.photo-full { width: 100%; border-radius: var(--radius); margin-bottom: 10px; }

/* Photo spaces — a labelled box per required shot. Empty reads as an invitation
   (dashed, glyph, name); filled reads as done (solid green edge, tick, the shot
   itself). Four across on the panel, three on a phone. */
.pnl-photo-strip.is-slots { display: block; overflow: visible; }
.pnl-slot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 7px;
}
.pnl-slot {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 5px; text-align: center; cursor: pointer;
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--fg-3); font: inherit;
}
.pnl-slot:hover { border-color: var(--accent); background: var(--bg-4); }
.pnl-slot-glyph {
  font-size: 15px; font-weight: 800; letter-spacing: .04em; color: var(--fg-3);
}
.pnl-slot:hover .pnl-slot-glyph { color: var(--accent); }
.pnl-slot-lbl { font-size: 10px; line-height: 1.2; color: var(--fg-2); }
.pnl-slot.is-filled {
  border-style: solid; border-color: rgba(34,197,94,.45); padding: 0;
}
.pnl-slot.is-filled img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.pnl-slot.is-filled .pnl-slot-lbl {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 3px 4px; background: rgba(0,0,0,.66); color: #fff;
}
.pnl-slot-tick {
  position: absolute; top: 3px; right: 3px; z-index: 1; width: 17px; height: 17px;
  border-radius: 50%; background: var(--green); color: #06230F;
  font-size: 10px; font-weight: 800; display: grid; place-items: center;
}
.pnl-card-count.is-ok { background: rgba(34,197,94,.18); color: var(--green); }

.pnl-misc { display: flex; gap: 6px; margin-top: 7px; }
.pnl-misc-open { flex: 1; text-align: left; }
.pnl-misc-open:disabled { opacity: .55; }
.pnl-misc-add { flex: none; }

.misc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.misc-grid .pnl-thumb {
  width: 100%; height: auto; aspect-ratio: 1 / 1; padding: 0;
  background: none; cursor: pointer;
}
.photo-file { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.photo-file-lbl {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-3);
}
.photo-file .ff-in { flex: 1; }

/* ====================================================== owner picker */
.ff-owner-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; cursor: pointer; font: inherit;
}
.ff-owner-btn:hover { border-color: var(--accent); }
.ff-owner-val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ff-owner-val.is-empty { color: var(--fg-3); }
.ff-owner-note {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg-3);
  padding: 2px 6px; border-radius: 9px; background: var(--bg);
}

.own-head {
  position: sticky; top: 0; z-index: 2; background: var(--bg-2);
  padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.own-where {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 9px;
}
.own-where-lbl {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-3);
}
.own-state { flex: none; width: 190px; }
/* Its own line: squeezed into the row beside a 190px select it wrapped down
   to a 34px column and read as noise. */
.own-src { flex: 1 0 100%; font-size: 11.5px; color: var(--fg-3); }
.own-search { width: 100%; }

.own-list { max-height: 52vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.own-group {
  position: sticky; top: 0; z-index: 1; background: var(--bg-2);
  padding: 9px 2px 4px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase; color: var(--fg-3);
}
.own-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 40px; padding: 7px 9px; text-align: left; font: inherit;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); color: var(--fg); cursor: pointer;
}
.own-row:hover { background: var(--bg-4); border-color: var(--line-2); }
.own-row.is-on { background: rgba(255,122,0,.14); border-color: rgba(255,122,0,.5); }
.own-row-n { min-width: 0; font-size: 13px; }
.own-row-t { flex: none; font-size: 10.5px; color: var(--fg-3); }
.own-row.is-manual {
  background: rgba(255,122,0,.12); border-color: rgba(255,122,0,.45);
  margin-bottom: 4px;
}
.own-row.is-manual .own-row-n { font-weight: 700; color: var(--accent-2); }

.pnl-body { padding: 0 10px 10px; }
.pnl-foot {
  display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line);
  background: var(--bg-3); position: sticky; bottom: 0;
}
.pnl-foot .pnl-btn { flex: 1; }

.panel-close-fab {
  display: none; position: fixed; top: calc(var(--topbar-h) + 8px); right: 10px;
  z-index: 1500; width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-4); border: 1px solid var(--line-2); color: var(--fg);
}

/* ============================================================== forms */
.ff-section {
  margin-top: 10px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius);
  /* NOT overflow:hidden. It was here to clip the header's hover fill to the
     rounded corner, and it also clipped every dropdown that opens downward
     from the last field in a section -- Pole use lost 230 of its 240 px and
     could not be used at all. The header rounds its own corners instead. */
}
.ff-sec-head {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 10px 11px; background: transparent; border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--fg); text-align: left; min-height: 44px;
}
.ff-section.is-collapsed .ff-sec-head { border-radius: var(--radius); }
.ff-sec-body { border-radius: 0 0 var(--radius) var(--radius); }
.ff-sec-head:hover { background: var(--bg-4); }
.ff-sec-badge {
  flex: none; min-width: 26px; height: 20px; padding: 0 5px; border-radius: 5px;
  background: var(--bg); display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800; letter-spacing: .04em; color: var(--fg-3);
}
.ff-sec-title { flex: 1; font-size: 13px; font-weight: 650; }
.ff-sec-count {
  font-size: 10.5px; color: var(--fg-3); font-variant-numeric: tabular-nums;
  background: var(--bg); padding: 2px 7px; border-radius: 9px;
}
.ff-sec-chev { color: var(--fg-3); font-size: 11px; transition: transform .15s; }
.ff-section.is-collapsed .ff-sec-chev { transform: rotate(-90deg); }
.ff-section.is-collapsed .ff-sec-body { display: none; }
.ff-sec-body { padding: 4px 11px 12px; border-top: 1px solid var(--line); }
.ff-sec-note {
  margin: 9px 0; padding: 8px 10px; font-size: 11.5px; line-height: 1.5;
  color: var(--fg-2); background: rgba(47,111,235,.1);
  border-left: 2px solid var(--blue); border-radius: 0 5px 5px 0;
}

.ff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.ff-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ff-row.is-wide { grid-column: 1 / -1; }
.ff-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--fg-2); line-height: 1.3;
}
.ff-req { color: var(--accent); font-weight: 800; }
.ff-unit-tag {
  margin-left: auto; font-size: 10px; color: var(--fg-3);
  background: var(--bg); padding: 1px 5px; border-radius: 4px;
}
.ff-hint { font-size: 10.5px; color: var(--fg-3); line-height: 1.4; }

.ff-in {
  width: 100%; min-height: 38px; padding: 7px 9px;
  background: var(--bg); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); color: var(--fg); outline: none;
}
.ff-in:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,122,0,.18); }
.ff-area { resize: vertical; min-height: 62px; line-height: 1.45; }
select.ff-in { appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236F7F92' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  background-size: 10px; }
.ff-select-wrap { display: flex; flex-direction: column; gap: 5px; }
.ff-other { display: none; }
.ff-other.is-on { display: block; }

/* feet + inches */
.ff-height { display: flex; align-items: center; gap: 4px; }
.ff-height .ff-in { width: 62px; text-align: right; }
.ff-unit { color: var(--fg-3); font-size: 12px; }
.ff-height-out {
  margin-left: 4px; font-family: var(--mono); font-size: 12px;
  color: var(--accent-2); font-weight: 600;
}

/* bearing */
.ff-bearing { display: flex; align-items: center; gap: 6px; }
.ff-bearing .ff-in { width: 72px; text-align: right; }
.ff-dial { color: var(--accent); line-height: 0; }
.ff-bearing-out { font-size: 11.5px; color: var(--fg-2); font-family: var(--mono); }

/* toggle */
.ff-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
             min-height: 38px; }
.ff-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ff-track {
  width: 42px; height: 24px; border-radius: 12px; background: var(--bg);
  border: 1px solid var(--line-2); position: relative; transition: background .15s;
  flex: none;
}
.ff-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--fg-3); transition: transform .15s, background .15s;
}
.ff-toggle input:checked + .ff-track { background: rgba(255,122,0,.28);
                                        border-color: var(--accent); }
.ff-toggle input:checked + .ff-track .ff-thumb { transform: translateX(18px);
                                                  background: var(--accent); }
.ff-toggle-lbl { font-size: 12px; color: var(--fg-2); }

/* multi-select */
.ff-multi { position: relative; }
.ff-multi-btn {
  width: 100%; min-height: 38px; padding: 5px 26px 5px 8px;
  background: var(--bg); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); text-align: left;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; position: relative;
}
.ff-multi-empty { color: var(--fg-3); font-size: 12px; }
.ff-chip {
  font-size: 10.5px; padding: 2px 7px; border-radius: 9px;
  background: rgba(255,122,0,.16); color: var(--accent-2); font-weight: 600;
}
.ff-caret { position: absolute; right: 9px; color: var(--fg-3); font-size: 10px; }
.ff-multi-list {
  display: none; position: absolute; z-index: 60; top: calc(100% + 3px); left: 0; right: 0;
  max-height: 240px; overflow-y: auto;
  background: var(--bg-4); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.ff-multi.is-open .ff-multi-list { display: block; }
.ff-multi-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  font-size: 12px; cursor: pointer; min-height: 38px;
}
.ff-multi-row:hover { background: var(--line); }
.ff-multi-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.ff-auto {
  min-height: 38px; padding: 8px 9px; background: var(--bg);
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  color: var(--fg-2); font-family: var(--mono); font-size: 12px;
}

/* collections */
.ff-coll .ff-sec-badge { color: #fff; }
.ff-item {
  margin-top: 8px; background: var(--bg-4); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); overflow: hidden;
}
.ff-item-head { display: flex; align-items: stretch; }
.ff-item-toggle {
  flex: 1; display: flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 7px 9px; background: transparent; border: none; color: var(--fg);
  text-align: left; min-width: 0;
}
.ff-item-toggle:hover { background: var(--line); }
.ff-item-num {
  flex: none; width: 20px; height: 20px; border-radius: 5px; background: var(--bg);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 800;
  color: var(--fg-3);
}
.ff-item-sum { flex: 1; font-size: 12px; overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
.ff-item-act {
  width: 34px; background: transparent; border: none; border-left: 1px solid var(--line);
  color: var(--fg-3); font-size: 12px;
}
.ff-item-act:hover { background: var(--line); color: var(--fg); }
.ff-item-act.is-danger:hover { background: rgba(239,68,68,.22); color: #fff; }
.ff-item.is-collapsed .ff-grid { display: none; }
.ff-item .ff-grid { padding: 0 9px 11px; }

.ff-add {
  width: 100%; min-height: 40px; margin-top: 9px;
  background: transparent; border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm); color: var(--accent); font-weight: 650;
  font-size: 12.5px;
}
.ff-add:hover { background: rgba(255,122,0,.1); border-color: var(--accent); }

/* The map route into a collection sits above the typed one and is solid
   rather than dashed, because it is the way in that is meant to be taken. */
.ff-add.is-pick {
  border-style: solid; border-color: #8E5BC7; color: #C9A6F0;
  background: rgba(142,91,199,.12); margin-top: 11px;
}
.ff-add.is-pick:hover { background: rgba(142,91,199,.24); border-color: #C9A6F0; }

/* ------------------------------------------- placement-method chooser */
.sec-span {
  font-weight: 700; font-size: 15px; color: var(--fg) !important;
  letter-spacing: .01em;
}
.sec-sub { margin-top: -6px !important; font-size: 12px; }
.sec-methods { display: grid; gap: 6px; margin-top: 4px; }
.sec-method {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 44px; padding: 0 12px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--fg); font-size: 13.5px;
  font-weight: 600;
}
.sec-method:hover { background: var(--line); border-color: #8E5BC7; }
.sec-method.is-bored { border-color: rgba(142,91,199,.6); }
.sec-method-tag {
  flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #C9A6F0;
  background: rgba(142,91,199,.18); border-radius: 999px; padding: 3px 8px;
}
.ff-empty { margin: 8px 0; font-size: 12px; color: var(--fg-3); line-height: 1.5; }

/* ============================================================== modals */
.modal-back {
  position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center;
  background: rgba(6,9,13,.7); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s; padding: 16px;
}
.modal-back.is-in { opacity: 1; }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 14px; box-shadow: var(--shadow);
  transform: translateY(10px); transition: transform .18s;
}
.modal-back.is-in .modal { transform: translateY(0); }
.modal.is-wide { max-width: 660px; }
.modal-head {
  display: flex; align-items: center; padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-x { width: 28px; height: 28px; border: none; background: transparent;
           color: var(--fg-3); border-radius: 6px; }
.modal-x:hover { background: var(--bg-4); color: var(--fg); }
.modal-body { padding: 15px; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; line-height: 1.55; color: var(--fg-2); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 15px;
  border-top: 1px solid var(--line);
}

.btn {
  min-height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
  background: var(--bg-4); border: 1px solid var(--line-2); color: var(--fg-2);
  font-weight: 600; font-size: 13px;
}
.btn:hover { background: var(--line); color: var(--fg); }
.btn.is-primary { background: var(--accent); border-color: var(--accent);
                  color: #1A0E00; }
.btn.is-primary:hover { background: var(--accent-2); }
.btn.is-danger { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.5);
                 color: #FFB4B4; }
.btn.is-danger:hover { background: var(--red); color: #fff; }
.btn.is-ghost { background: transparent; border-color: var(--line); }
.btn.is-block { width: 100%; }

.imp-h {
  margin: 16px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--fg-3);
}
.imp-summary {
  padding: 10px 12px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 12.5px; line-height: 1.6;
  margin-bottom: 12px;
}
.imp-warn { color: var(--amber); margin-top: 6px; font-size: 12px; }
.imp-modes { display: grid; gap: 8px; }
.imp-mode {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: left; color: var(--fg-2);
}
.imp-mode:hover { border-color: var(--line-2); background: var(--bg-4); }
.imp-mode.is-active { border-color: var(--accent); background: rgba(255,122,0,.1); }
.imp-mode strong { font-size: 13px; color: var(--fg); }
.imp-mode span { font-size: 11.5px; color: var(--fg-3); line-height: 1.45; }
.imp-map { margin-top: 8px; max-height: 320px; overflow-y: auto;
           border: 1px solid var(--line); border-radius: var(--radius);
           padding: 8px 10px; }
.imp-map-row {
  display: grid; grid-template-columns: 1fr 46px 1.5fr; gap: 8px;
  align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line);
}
.imp-map-row:last-child { border-bottom: none; }
.imp-map-val { font-size: 12px; overflow: hidden; text-overflow: ellipsis;
               white-space: nowrap; }
.imp-map-n { font-size: 11px; color: var(--fg-3); text-align: right;
             font-variant-numeric: tabular-nums; }
.imp-map-row .ff-in { min-height: 30px; font-size: 11.5px; }

.imp-attrs { max-height: 50vh; overflow: auto; }
.imp-attrs table { width: 100%; border-collapse: collapse; font-size: 12px; }
.imp-attrs th, .imp-attrs td {
  padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left;
  vertical-align: top;
}
.imp-attrs th { color: var(--fg-3); font-weight: 600; width: 40%; }

.exp-scope { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: 16px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
  font-size: 12px; font-weight: 600;
}
.chip.is-active { background: var(--accent); border-color: var(--accent);
                  color: #1A0E00; }

.prj-wrap { display: flex; flex-direction: column; gap: 10px; }
.prj-list { display: flex; flex-direction: column; gap: 6px; }
.prj-row {
  display: flex; align-items: center; gap: 9px; padding: 10px 11px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
}
.prj-row.is-active { border-color: var(--accent); }
.prj-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.prj-name { font-weight: 650; font-size: 13.5px; }
.prj-sub { font-size: 11px; color: var(--fg-3); }
.prj-h { margin: 12px 0 4px; font-size: 12px; color: var(--fg-2); }
.prj-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prj-backup { margin-top: 8px; }

.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.cache-prog { font-size: 12px; color: var(--fg-3); margin: 8px 0; min-height: 16px; }
.keymap { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; }
.keymap-row { display: flex; align-items: center; gap: 8px; font-size: 12px;
              color: var(--fg-3); }

/* ------------------------------------------------------ centerline offsets */
.cl-caution {
  font-size: 12px; line-height: 1.55; color: var(--fg-2);
  background: rgba(245,158,11,.1); border-left: 2px solid var(--amber);
  padding: 10px 12px; border-radius: 0 5px 5px 0; margin: 10px 0 4px;
}
.cl-caution strong { color: var(--amber); }
.cl-caution em { color: var(--fg); font-style: normal; font-family: var(--mono);
                 font-size: 11.5px; }
.cl-status {
  padding: 9px 12px; border-radius: var(--radius); background: var(--bg-3);
  border: 1px solid var(--line); font-size: 12.5px; color: var(--fg-3);
  margin-bottom: 9px;
}
.cl-status.is-ok { color: var(--green); border-color: rgba(34,197,94,.35); }
.cl-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cl-actions .btn { flex: 1; min-width: 190px; }
.cl-preview { margin-bottom: 12px; }
.cl-chip-ok { background: rgba(34,197,94,.16) !important; color: #A9F3C4 !important; }
.cl-table {
  margin-top: 9px; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; max-height: 260px; overflow-y: auto;
}
.cl-eop { margin-bottom: 4px; }
.cl-widths { margin-bottom: 4px; }
.cl-wrow {
  display: grid; grid-template-columns: 1fr 62px 84px 22px; gap: 8px;
  align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line);
}
.cl-wrow:last-child { border-bottom: none; }
.cl-wlbl { font-size: 12.5px; }
.cl-wn { font-size: 11px; color: var(--fg-3); text-align: right; }
.cl-win { min-height: 32px; text-align: right; }
.cl-chip-warn { background: rgba(245,158,11,.18) !important; color: #FFE0A6 !important; }
.cl-dim { color: var(--fg-3) !important; }

.cl-table.is-derived .cl-trow {
  grid-template-columns: 1fr 1.1fr 58px 74px 46px;
}
.cl-trow {
  display: grid; grid-template-columns: 1.1fr 1.3fr 74px 46px; gap: 8px;
  padding: 6px 11px; font-size: 12px; border-bottom: 1px solid var(--line);
  align-items: center;
}
.cl-trow:last-child { border-bottom: none; }
.cl-trow.is-head {
  background: var(--bg-3); font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-3); position: sticky; top: 0;
}
.cl-feat { font-weight: 650; overflow: hidden; text-overflow: ellipsis;
           white-space: nowrap; }
.cl-road { color: var(--fg-3); overflow: hidden; text-overflow: ellipsis;
           white-space: nowrap; }
.cl-off { font-family: var(--mono); text-align: right; color: var(--fg); }
.cl-off.is-changed { color: var(--amber); font-weight: 700; }
.cl-side { text-align: center; font-weight: 700; color: var(--accent-2); }

/* ---------------------------------------------------------- danger zone */
.imp-h.is-danger-h { color: #FF8B8B; }

.danger-zone {
  display: flex; align-items: center; gap: 14px; padding: 12px 13px;
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.4);
  border-radius: var(--radius);
}
.danger-zone-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.danger-zone-text strong { font-size: 13px; color: var(--fg); }
.danger-zone-text span { font-size: 11.5px; color: var(--fg-3); line-height: 1.45; }

.danger-banner {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px;
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.45);
  border-radius: var(--radius); margin-bottom: 14px;
}
.danger-icon { font-size: 19px; color: var(--red); line-height: 1.2; }
.danger-banner strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.danger-banner .muted { font-size: 11.5px; line-height: 1.45; }

.clear-list {
  max-height: 190px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg-3);
}
.clear-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 11px;
  border-bottom: 1px solid var(--line);
}
.clear-row:last-child { border-bottom: none; }
.clear-ic { line-height: 0; flex: none; }
.clear-lbl { flex: 1; font-size: 12.5px; }
.clear-n {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px;
  color: var(--fg-2); background: var(--bg); padding: 2px 9px; border-radius: 10px;
}
.clear-totals {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px;
}
.clear-totals span {
  font-size: 11.5px; font-weight: 650; padding: 3px 10px; border-radius: 11px;
  background: rgba(239,68,68,.14); color: #FFB4B4;
}
.clear-recover {
  font-size: 12px; line-height: 1.55; color: var(--fg-2);
  background: var(--bg-3); border-left: 2px solid var(--amber);
  padding: 9px 11px; border-radius: 0 5px 5px 0; margin: 10px 0 12px;
}
.clear-recover strong { color: var(--amber); }
.clear-opt {
  display: flex; align-items: center; gap: 9px; margin: 12px 0 4px;
  font-size: 12.5px; cursor: pointer; min-height: 38px;
}
.clear-opt input { width: 17px; height: 17px; accent-color: var(--red); }
.clear-prompt { margin-top: 14px; font-size: 12px; }
.clear-input {
  font-family: var(--mono); font-size: 15px; letter-spacing: .18em;
  text-align: center; text-transform: none;
}
.clear-input.is-valid {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(239,68,68,.25);
  color: #FFC2C2;
}
.clear-foot {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
  padding-top: 13px; border-top: 1px solid var(--line);
}
.clear-foot .btn { min-width: 110px; }
.clear-foot .btn.is-danger:disabled {
  opacity: .4; cursor: not-allowed; background: rgba(239,68,68,.1);
}

.offset-readout { display: flex; align-items: baseline; gap: 6px; margin: 12px 0; }
.offset-num { font-size: 40px; font-weight: 800; color: var(--accent);
              font-variant-numeric: tabular-nums; }
.offset-unit { font-size: 16px; color: var(--fg-3); }

/* ============================================================== toasts */
#toasts {
  position: fixed; bottom: calc(var(--status-h) + 14px); left: 50%;
  transform: translateX(-50%); z-index: 6000;
  display: flex; flex-direction: column; gap: 7px; align-items: center;
  pointer-events: none; width: min(92vw, 520px);
}
.toast {
  padding: 10px 16px; border-radius: 22px; font-size: 12.5px; font-weight: 600;
  background: var(--bg-4); border: 1px solid var(--line-2); color: var(--fg);
  box-shadow: var(--shadow); opacity: 0; transform: translateY(10px);
  transition: opacity .22s, transform .22s; text-align: center; max-width: 100%;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-ok    { border-color: rgba(34,197,94,.55);  background: #14301F; color: #B6F5CE; }
.toast-warn  { border-color: rgba(245,158,11,.55); background: #33260A; color: #FFE0A6; }
.toast-error { border-color: rgba(239,68,68,.6);   background: #331414; color: #FFC2C2; }

/* ========================================================== responsive */
.only-narrow { display: none; }

@media (max-width: 1180px) {
  :root { --panel-w: 370px; --sidebar-w: 268px; }
  .topbar-search { max-width: 240px; }
}

@media (max-width: 900px) {
  :root { --panel-w: 340px; }
  .only-wide { display: none; }
  #projectMeta { display: none; }
  .text-btn { padding: 0 10px; }
}

@media (max-width: 760px) {
  .only-narrow { display: grid; }
  .topbar-search { display: none; }

  #sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 1100;
    transform: translateX(-100%); transition: transform .22s ease;
    width: min(84vw, 320px); box-shadow: var(--shadow);
  }
  body.sidebar-open #sidebar { transform: translateX(0); }

  #panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
    width: 100%; height: 72vh; border-left: none;
    border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0;
    transform: translateY(100%); transition: transform .25s ease;
    box-shadow: var(--shadow);
  }
  body.panel-open #panel { transform: translateY(0); }
  body.panel-open .panel-close-fab { display: grid; }
  #panel.is-empty { display: none; }

  .ff-grid { grid-template-columns: 1fr; }
  .prj-form { grid-template-columns: 1fr; }
  .keymap { grid-template-columns: 1fr; }
  .pnl-loc-grid { grid-template-columns: 1fr 1fr; }

  #toolbar { top: auto; bottom: calc(var(--status-h) + 10px); left: 10px;
             flex-direction: row; }
  .tool { width: 50px; min-height: 46px; }
  body.panel-open #toolbar { display: none; }

  .floatbar { flex-wrap: wrap; justify-content: center; width: calc(100vw - 24px);
              gap: 8px; }
  .status-hint { display: none; }
}

@media (max-width: 420px) {
  .pnl-loc-grid { grid-template-columns: 1fr; }
  .tool-lbl { display: none; }
  .tool { width: 44px; min-height: 44px; }
}

/* Reduce motion for anyone who asks for it. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
