/* ============================================================================
   Design tokens — light (default) and dark. Warm cream/near-black pairing,
   modelled on a technical survey-plan aesthetic: quiet neutrals, one amber
   "highlight" tone for the plot-summary card, green for ready/success states.
   ========================================================================= */
:root {
  --bg: #F7F4EC;
  --surface: #FFFFFF;
  --surface-2: #F1EEE3;
  --border: #E7E2D6;
  --border-strong: #D8D3C2;
  --text: #17150F;
  --text-secondary: #5B5645;
  --text-tertiary: #948F7C;
  --accent: #3A6B52;          /* deep survey-green: focus rings, links, active states */
  --accent-ring: rgba(58,107,82,.22);
  --amber-bg: #FBF3D9;
  --amber-border: #E8C868;
  --amber-text: #5A4A16;
  --success: #1E7A4C;
  --success-bg: #E5F3EA;
  --success-dot: #2FAE72;
  --danger: #B3261E;
  --danger-bg: #FBEAE9;
  --warn: #9A5B12;
  --warn-bg: #FCF1E1;
  --black: #17150F;
  --on-black: #F7F4EC;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(23,21,15,.07);
  --shadow-md: 0 6px 20px rgba(23,21,15,.10);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17160F;
  --surface: #211F17;
  --surface-2: #2B2920;
  --border: #3B392F;
  --border-strong: #4B4839;
  --text: #F3F1E8;
  --text-secondary: #B8B39F;
  --text-tertiary: #837E6B;
  --accent: #6FCB9C;
  --accent-ring: rgba(111,203,156,.25);
  --amber-bg: #35290F;
  --amber-border: #5C4A1C;
  --amber-text: #E8C868;
  --success: #4ADE94;
  --success-bg: #17301F;
  --success-dot: #4ADE94;
  --danger: #F2867E;
  --danger-bg: #3A1917;
  --warn: #E8B15A;
  --warn-bg: #362A14;
  --black: #F3F1E8;
  --on-black: #17160F;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: 'Manrope', -apple-system, "Segoe UI", sans-serif; font-size: 14px;
  color: var(--text); background: var(--bg); height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-ring); }

/* ============================================================================ header */
header {
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border);
  padding: 0 18px; height: 58px; display: flex; align-items: center; gap: 18px;
}
header .brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
header .brand-mark {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
header h1 { font-size: 15px; font-weight: 800; margin: 0; letter-spacing: -.1px; white-space: nowrap; }
#tabs { display: flex; gap: 3px; background: var(--surface-2); border-radius: 10px; padding: 4px; flex: 1; min-width: 0; overflow-x: auto; }
#tabs button {
  display: flex; align-items: center; justify-content: center; gap: 6px; background: transparent; color: var(--text-secondary);
  padding: 8px 14px; font-size: 12.5px; font-weight: 600; border-radius: 8px; white-space: nowrap; border: 0; cursor: pointer; font-family: inherit;
}
#tabs button svg { flex-shrink: 0; }
#tabs button.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-sm); }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#status { font-size: 12px; font-weight: 700; color: var(--success); background: var(--success-bg); border-radius: 20px; padding: 0; }
#status:not(:empty) { padding: 5px 12px; }
#themeToggle, #settingsBtn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0;
}
#themeToggle:hover, #settingsBtn:hover { background: var(--surface-2); }
#themeToggle .i-moon { display: none; } :root[data-theme="dark"] #themeToggle .i-sun { display: none; } :root[data-theme="dark"] #themeToggle .i-moon { display: block; }
.brand-mark img { display: block; max-width: 100%; max-height: 100%; }
.brand-mark .logo-dark { display: none; } :root[data-theme="dark"] .brand-mark .logo-light { display: none; } :root[data-theme="dark"] .brand-mark .logo-dark { display: block; }

/* ============================================================================ layout shell */
#layout { flex: 1; display: grid; grid-template-columns: var(--aside-w, 220px) 460px 1fr; min-height: 0; transition: grid-template-columns .18s ease; }
#layout.resizing { transition: none; }
#layout[hidden] { display: none; }
#layout.nav-collapsed { grid-template-columns: 0px 460px 1fr; }
#layout.nav-collapsed aside { overflow: hidden; border-right: 0; }
aside { position: relative; background: var(--surface); overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--border); white-space: nowrap; }
.aside-resize { position: absolute; top: 0; right: -3px; bottom: 0; width: 6px; cursor: col-resize; z-index: 20; }
.aside-resize:hover, .aside-resize.active { background: var(--accent-ring); }

.nav-title { background: var(--surface-2); color: var(--text-secondary); padding: 10px 14px; font-size: 11.5px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; justify-content: space-between; }
.nav-title #cloudRefresh { border: 0; background: none; color: var(--text-secondary); font-size: 13px; cursor: pointer; line-height: 1; padding: 0; }
.nav-title #cloudRefresh:hover { color: var(--text); }
button.nav { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 14px; cursor: pointer; font-size: 13.5px; font-family: inherit; color: var(--text); }
button.nav:hover { background: var(--surface-2); }
#plotList, #cloudPlotList, #groupList { list-style: none; margin: 0; padding: 0; }
#plotList li, #cloudPlotList li, #groupList li { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
#plotList li:hover, #plotList li.active, #cloudPlotList li:hover, #groupList li:hover, #groupList li.active { background: var(--accent-ring); }
#plotList li small, #cloudPlotList li small, #groupList li small { color: var(--text-tertiary); display: block; }
#plotList li > div, #cloudPlotList li > div, #groupList li > div { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#plotList .del { flex: 0 0 auto; margin-left: 8px; border: 0; background: none; color: var(--danger); font-size: 16px; cursor: pointer; }
#cloudPlotList .cloud-badge { color: var(--text-tertiary); font-size: 15px; flex: none; margin-left: 8px; }
main { overflow-y: auto; padding: 16px; background: var(--bg); margin: 0; }
main h2 { font-size: 15px; font-weight: 700; margin: 4px 0 12px; }

/* the collapse/expand toggle lives inside "ADD NEW PLOT" 's own header row, not floating independently */
.form-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.form-head h2 { margin: 0; }
#navToggle {
  width: 34px; height: 34px; flex-shrink: 0; padding: 0; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); color: var(--text-secondary);
}
#navToggle:hover { background: var(--surface-2); color: var(--text); }
#navToggle .i-expand { display: none; } #navToggle.collapsed .i-collapse { display: none; } #navToggle.collapsed .i-expand { display: flex; }

/* ============================================================================ cards (fieldset), section labels, form controls */
fieldset {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-md);
  margin: 0 0 14px; padding: 16px 18px; box-shadow: var(--shadow-sm);
}
legend {
  background: transparent; color: var(--text); padding: 0 4px 0 0; font-size: 14px; font-weight: 700; display: flex; align-items: center;
}
legend::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); margin-right: 8px; flex-shrink: 0; }
label { display: block; margin: 8px 0; font-weight: 600; font-size: 13px; color: var(--text); }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 500; }
input, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 13.5px;
  background: var(--surface); color: var(--text); outline: none; margin-top: 4px;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input[type=color] { width: 100%; padding: 3px; appearance: auto; -webkit-appearance: auto; }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); margin-top: 0; }
label.inline select { width: auto; min-width: 76px; margin-top: 0; }
label.inline input[type=checkbox] { margin-top: 0; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; }

/* buttons */
button {
  padding: 9px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
}
button.primary { background: var(--black); color: var(--on-black); border-color: var(--black); }
button:hover { filter: brightness(0.96); }
:root[data-theme="dark"] button:hover { filter: brightness(1.12); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* tables */
table { width: 100%; border-collapse: collapse; margin: 8px 0; }
th { text-align: left; font-size: 11.5px; font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
td { padding: 4px; }
td:first-child { width: 50px; font-weight: 600; color: var(--text-tertiary); }
td input.bad { border-color: var(--danger); background: var(--danger-bg); }
small { color: var(--text-tertiary); display: block; margin-top: 4px; font-size: 12px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
#startInfo { margin-top: 8px; font-weight: 600; font-size: 12.5px; color: var(--text-secondary); }
#searchResults div { padding: 7px 8px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; border-radius: 6px; }
#searchResults div:hover { background: var(--surface-2); }
#errors { color: var(--danger); white-space: pre-line; }
.ok { color: var(--success); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
#mapWrap { margin: 12px; box-shadow: var(--shadow-md); min-height: 0; border-radius: var(--radius-md); overflow: hidden; position: relative; }
#map { width: 100%; height: 100%; }

.view-toggle { position: absolute; top: 16px; right: 16px; z-index: 900; }
#layersBtn { position: absolute; top: 58px; right: 16px; z-index: 900; }
#layersBtn.on { background: var(--black); color: var(--on-black); }
.vt-trigger { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-md); color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer; }
.vt-caret { transition: transform .15s ease; flex-shrink: 0; }
.view-toggle:hover .vt-caret, .view-toggle.open .vt-caret { transform: rotate(180deg); }
.vt-menu { display: none; flex-direction: column; gap: 2px; position: absolute; top: 100%; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 4px; min-width: 148px; }
.view-toggle:hover .vt-menu, .view-toggle.open .vt-menu { display: flex; }
.vt-menu button { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 7px; border: 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 600; text-align: left; width: 100%; }
.vt-menu button.on { background: var(--black); color: var(--on-black); }
.vt-menu button:hover:not(.on) { background: var(--surface-2); }

/* the engineering-drawing view: always a fixed white/black "paper" look, independent of light/dark theme,
   like a real printed plan */
#drawingView { position: absolute; inset: 0; background: #ffffff; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 16px; }
#drawingView[hidden] { display: none; }
#drawingView svg { max-width: 100%; max-height: 100%; width: auto; height: auto; min-width: 0; min-height: 0; display: block; font-family: 'Manrope', sans-serif; }

.dr-toolbar { position: absolute; top: 16px; left: 16px; z-index: 900; display: flex; gap: 8px; }
.dr-toolbar[hidden] { display: none; }
.dr-toolbar button { display: flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 10px; font-size: 12px; font-weight: 700; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); color: var(--text); }
.dr-toolbar button[hidden] { display: none; }
.dr-toolbar button:disabled { opacity: 0.45; cursor: not-allowed; }
.dr-toolbar button.primary { background: var(--black); color: var(--on-black); border-color: var(--black); }
.dr-toolbar button.danger { color: var(--danger); border-color: var(--danger); }
.dr-toolbar button.danger:hover { background: var(--danger-bg); }
.dr-toolbar button.on { background: var(--black); color: var(--on-black); border-color: var(--black); }
#drawingView.drawing svg { cursor: crosshair; }
.ldt-hint { display: flex; align-items: center; padding: 0 6px; font-size: 12px; font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); }
#map.drawing-lot { cursor: crosshair; }

/* "+ Add New Plot" method chooser */
.modal-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 22px; width: 420px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 14px; font-size: 16px; }
.npm-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.npm-options button { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-family: inherit; }
.npm-options button:hover { background: var(--accent-ring); border-color: var(--black); }
.npm-options button svg { flex-shrink: 0; color: var(--text-secondary); }
.npm-options button b { display: block; font-size: 13px; }
.npm-options button small { color: var(--text-secondary); font-size: 11.5px; }
#npmCancel { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); cursor: pointer; font-family: inherit; font-size: 13px; }
#npmCancel:hover { background: var(--surface-2); }

/* Send-to-phone QR modal */
.modal-card.qr-card { width: 380px; max-width: 92vw; padding: 0; display: flex; flex-direction: column; }
#qrBox { display: flex; justify-content: center; background: #fff; border-radius: 10px; padding: 16px; margin: 14px 0; }
#qrBox svg { width: 100%; height: auto; max-width: 260px; }
#qrMeta { text-align: center; font-size: 12.5px; }

/* Settings modal — report template/branding, backup, appraiser profile */
.modal-card.settings-card { width: 640px; max-width: 94vw; padding: 0; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h3 { margin: 0; }
.modal-head button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0; }
.modal-head button:hover { background: var(--surface-2); }
.modal-head button[hidden] { display: none; }
.modal-body { padding: 18px 22px; overflow-y: auto; }

/* the access gate — sits above everything, including the header, until sign-in + an active account status */
#authGate { position: fixed; inset: 0; z-index: 5000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
#authGate[hidden] { display: none; }
.auth-card { width: 360px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 28px 26px; text-align: center; }
.auth-card .brand-mark { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.auth-card h2 { margin: 0 0 18px; font-size: 17px; }
.auth-card h3 { margin: 0 0 12px; font-size: 14px; }
.auth-card form, .auth-card > div { text-align: left; }
.auth-card label { text-align: left; }
.auth-card button[type="submit"], .auth-card > form button.primary { width: 100%; margin-top: 6px; }
.auth-card .auth-switch { font-size: 12.5px; color: var(--text-secondary); text-align: center; margin: 14px 0 0; }
.auth-card .auth-switch a { color: var(--text); font-weight: 700; }
.auth-card #authErr, .auth-card #authErr2 { min-height: 16px; font-size: 12.5px; margin: 6px 0; }
.auth-card #authLoading p, .auth-card #authOffline p, .auth-card #authInactive p { color: var(--text-secondary); font-size: 13px; }
.auth-card .actions { justify-content: center; }
#drDrawHint { position: absolute; top: 62px; left: 16px; right: 150px; z-index: 900; background: var(--black); color: var(--on-black); font-size: 12px; font-weight: 600; padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow-md); }
#drDrawHint[hidden] { display: none; }

/* right-docked slide-in editor for the drawing's title block */
#drEditor {
  position: absolute; top: 0; right: 0; bottom: 0; width: 340px; max-width: 88%; z-index: 950;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease;
}
#drEditor.open { transform: translateX(0); }
#drEditor[hidden] { display: none; }
.dr-editor-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dr-editor-head b { font-size: 14px; }
.dr-editor-head button { width: 28px; height: 28px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--border-strong); }
.dr-editor-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.dr-editor-body label { font-size: 12.5px; }
.dr-editor-body .row { gap: 10px; } .dr-editor-body .row label { flex: 1; }
.dr-editor-body table { font-size: 11px; }
.dr-editor-body table input { padding: 5px 6px; font-size: 11px; margin-top: 0; }
.dr-editor-body hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0 10px; }
.dr-editor-body > b { display: block; margin-bottom: 6px; }
#drLotFields[hidden], #drTopoFields[hidden] { display: none; }
.vlabel { background: var(--surface); border: 1px solid var(--accent); border-radius: 50%; width: 22px; height: 22px; line-height: 20px; text-align: center; font-weight: 700; font-size: 12px; color: var(--accent); }
svg path.movable { cursor: move; } .leaflet-interactive.movable { cursor: move; }

textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 10px; font: inherit; font-size: 13.5px; background: var(--surface); color: var(--text); margin-top: 4px; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* details / summary — custom chevron instead of the native triangle */
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 700; font-size: 13px; list-style: none; display: flex; align-items: center; color: var(--text); }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; width: 7px; height: 7px; border-right: 1.6px solid var(--text-secondary); border-bottom: 1.6px solid var(--text-secondary);
  transform: rotate(-45deg); margin-right: 9px; transition: transform .15s; flex-shrink: 0;
}
details[open] > summary::before { transform: rotate(45deg); }

#aiOut { margin-top: 8px; font-size: 13px; }
#aiOut ul { margin: 4px 0 4px 18px; padding: 0; }
#aiOut .err { color: var(--danger); } #aiOut .note { color: var(--warn); }
input[type=file] { border: 1px dashed var(--border-strong); background: var(--surface-2); padding: 8px 10px; }

/* toggle-switch look for every checkbox in the app (no HTML changes needed) */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 32px; height: 18px; min-width: 32px; border-radius: 9px;
  background: var(--border-strong); border: 0; position: relative; cursor: pointer; padding: 0; margin: 0; flex-shrink: 0; vertical-align: middle;
  transition: background .15s;
}
input[type=checkbox]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s;
}
input[type=checkbox]:checked { background: var(--success-dot); }
input[type=checkbox]:checked::before { left: 16px; }
input[type=checkbox]:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }

#compPanel {
  position: fixed; right: 22px; bottom: 22px; width: min(760px, calc(100vw - 44px)); max-height: min(640px, calc(100vh - 100px));
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); z-index: 2000;
  display: flex; flex-direction: column; padding: 0 16px 14px; border-radius: var(--radius-lg); overflow: hidden;
}
#compPanel[hidden], #compPanel.min { display: none; }
#compPanel.max { right: 4vw; left: 4vw; bottom: 5vh; top: 5vh; width: auto; max-height: none; }

/* title bar: name + window controls, always pinned to the very top regardless of how the toolbar below wraps */
.cp-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 -16px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cp-titlebar > b { font-size: 14px; }
.cp-titlebar-actions { display: flex; align-items: center; gap: 6px; }
.cp-titlebar-actions button {
  width: 30px; height: 30px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
}
.cp-titlebar-actions button:hover { background: var(--border-strong); }
#compClose:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
#compMaximize .ic-restore { display: none; } #compPanel.max #compMaximize .ic-max { display: none; } #compPanel.max #compMaximize .ic-restore { display: flex; }

.cp-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex-shrink: 0; }
.cp-head label { display: flex; align-items: center; gap: 4px; margin: 0; font-weight: 600; }
.cp-head input, .cp-head select { border: 1px solid var(--border); padding: 5px 8px; width: auto; margin-top: 0; }
.cp-body { overflow: auto; margin-top: 8px; flex: 1; }

/* Messenger-style minimized bubble */
#compBubble {
  position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; padding: 0;
  background: var(--black); color: var(--on-black); border: none; box-shadow: var(--shadow-md); z-index: 2000;
  display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; user-select: none;
  transition: box-shadow .15s;
}
#compBubble:active { cursor: grabbing; box-shadow: 0 10px 28px rgba(23,21,15,.28); }
#compBubble[hidden] { display: none; }
#compBubble:hover { filter: brightness(1.12); }
.cp-bubble-badge {
  position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; border-radius: 10px; padding: 0 4px;
  background: var(--success-dot); color: #fff; font-size: 10.5px; font-weight: 800; font-family: 'Manrope', sans-serif;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg);
}
.cp-bubble-badge[hidden] { display: none; }
#compTable { font-size: 12px; } #compTable th, #compTable td { border-bottom: 1px solid var(--border); padding: 3px 5px; white-space: nowrap; }
#compTable input { width: 90px; border: 1px solid var(--border); padding: 4px; margin-top: 0; } #compTable input.w { width: 220px; } #compTable input.s { width: 60px; }
#compTable td:first-child { width: auto; font-weight: normal; }
#compTable tr.out { color: var(--text-tertiary); } #compTable .warn { color: var(--warn); }
#compStats { font-weight: 600; margin-top: 6px; } #compMsg { font-size: 13px; color: var(--warn); }
.cnum { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; line-height: 22px; text-align: center; font-size: 12px; font-weight: 700; border: 2px solid var(--surface); }

#reportView { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: 380px 1fr; gap: 14px; padding: 16px; background: var(--bg); }
#reportView[hidden] { display: none; }
.rv-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm); min-width: 0; align-self: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.tblwrap { overflow-x: auto; }
#mTable, #bTable { font-size: 12px; } #mTable th, #mTable td, #bTable th, #bTable td { border: 1px solid var(--border); padding: 3px 4px; white-space: nowrap; text-align: left; }
#mTable td:first-child, #bTable td:first-child { width: auto; font-weight: normal; }
#mTable input, #bTable input { width: 70px; border: 1px solid var(--border); padding: 4px; margin-top: 0; } #mTable input.d { width: 240px; } #mTable input.u { width: 90px; } #bTable input.d { width: 160px; }
#mSummary, #bSummary, #r_total { font-weight: 600; margin-top: 8px; line-height: 1.6; font-size: 13px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; } .thumbs figure { margin: 0; position: relative; } .thumbs img { height: 90px; border: 1px solid var(--border); border-radius: 8px; }
.thumbs button { position: absolute; top: 4px; right: 4px; padding: 0 6px; } .thumbs figcaption { font-size: 11px; color: var(--text-tertiary); max-width: 140px; }
.actions.big button { padding: 11px 20px; font-size: 14px; } #r_msg, #n_msg { color: var(--warn); margin-top: 8px; }

.cpin { overflow: visible; } .clabel { position: absolute; left: 26px; top: -6px; background: var(--surface); border: 1px solid var(--accent); border-radius: 5px; padding: 1px 6px; font: 11px/1.25 'Manrope', sans-serif; white-space: nowrap; color: var(--text); box-shadow: var(--shadow-sm); }
.clabel.ap { border-color: var(--warn); background: var(--warn-bg); } .cnum.ap { background: var(--warn); }

#mapNotice { position: fixed; left: 50%; transform: translateX(-50%); top: 68px; background: var(--warn-bg); border: 1px solid var(--warn); color: var(--warn); padding: 9px 16px; border-radius: var(--radius-sm); z-index: 3000; max-width: 560px; font-size: 13px; box-shadow: var(--shadow-md); }
#mapNotice[hidden] { display: none; }
details.mapbox { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 12px; background: var(--surface); }
details.mapbox summary { font-weight: 700; }

#hazLegend { position: fixed; right: 26px; bottom: 34px; max-width: 320px; z-index: 1200; pointer-events: auto; max-height: 22vh; overflow-y: auto; }
.hzbox { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin: 8px 0; } .hzmsg { font-size: 12px; color: var(--text-secondary); margin: 3px 0; }
.hzmap { font-size: 12px; } .hzmap th, .hzmap td { padding: 3px 4px; text-align: left; } .hzmap td:first-child { width: auto; font-weight: normal; } .hzmap input { width: 110px; margin-top: 0; } .hzmap input[type=color] { width: 40px; padding: 0; border: 0; appearance: auto; -webkit-appearance: auto; border-radius: 4px; }
.sw { display: inline-block; width: 12px; height: 12px; margin: 0 3px 0 6px; border: 1px solid var(--border-strong); vertical-align: -2px; border-radius: 3px; } #hazOut { margin-top: 8px; font-size: 13px; }
.hzl { background: var(--surface); padding: 3px 9px; margin-top: 3px; border: 1px solid var(--border-strong); font-size: 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }

.tip { display: inline-block; cursor: help; color: var(--accent); font-weight: 700; position: relative; }
#tipBox { position: fixed; display: none; width: 300px; max-width: calc(100vw - 16px); background: var(--black); color: var(--on-black); padding: 9px 11px; border-radius: var(--radius-sm); font: 400 12px/1.4 'Manrope', sans-serif; z-index: 6000; box-shadow: var(--shadow-md); pointer-events: none; }

#reportView.withPrev { grid-template-columns: 340px minmax(0, 1fr) minmax(420px, 46vw); }
#prevCol { position: sticky; top: 0; height: calc(100vh - 90px); display: flex; flex-direction: column; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
#prevCol[hidden] { display: none; } #pv_frame { flex: 1; border: 1px solid var(--border); background: var(--surface-2); margin-top: 8px; width: 100%; border-radius: var(--radius-sm); }
#c_out, #bk_msg { margin-top: 8px; font-size: 13px; }
.bad { color: var(--danger); font-weight: 600; } .okk { color: var(--success); font-weight: 600; }
#b_logoBox img { height: 50px; background: var(--surface); border-radius: 6px; }

#seisLegend { position: fixed; right: 26px; bottom: 34px; max-width: 320px; z-index: 1200; pointer-events: auto; margin-bottom: 0; max-height: 22vh; overflow-y: auto; } #hazLegend:not(:empty) ~ #seisLegend { bottom: calc(22vh + 42px); }
.hzrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0; } #seisOut { font-size: 13px; margin-top: 8px; } #seisOut .err, #r_msg .err { color: var(--danger); }

#z_res { font-size: 12px; } #z_res th, #z_res td { border: 1px solid var(--border); padding: 3px 4px; text-align: left; vertical-align: top; } #z_res td:first-child { width: auto; font-weight: normal; }
.zset { margin: 4px 0; font-size: 13px; } .zset button { padding: 2px 8px; margin-left: 6px; } #z_msg { font-size: 13px; color: var(--warn); }

#appsView { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 26px; background: var(--bg); } #appsView[hidden] { display: none; }
#appsGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.appcard { text-align: left; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius-md); padding: 15px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); font-size: 14px; position: relative; font-family: inherit; }
.appcard:hover { box-shadow: var(--shadow-md); } .appcard .tagx { align-self: flex-end; font-size: 10px; background: var(--surface-2); color: var(--text-secondary); padding: 3px 9px; border-radius: 10px; letter-spacing: .3px; font-weight: 700; }
.appcard .ic { font-size: 26px; } .appcard small { color: var(--text-secondary); } .appcard em { position: absolute; left: 15px; top: 15px; font-size: 11px; color: var(--success); font-style: normal; font-weight: 700; } .appcard.added { border-top-color: var(--success); }
#appsPanel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm); max-width: 980px; } .apform { margin: 10px 0; } #ap_head { margin: 10px 0 8px; font-size: 15px; font-weight: 700; color: var(--accent); }
#ap_rows { font-size: 13px; } #ap_rows td { border-bottom: 1px solid var(--border); padding: 5px 7px; } #ap_rows td:first-child { width: 60%; font-weight: normal; } #ap_rows tr.b td { font-weight: 700; background: var(--surface-2); } #ap_notes small { display: block; margin-top: 8px; }
#appsGrid[hidden], #appsPanel[hidden], #appsIntro[hidden] { display: none; }

#toolsView { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 26px; background: var(--bg); } #toolsView[hidden] { display: none; }
#mtGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; } #mtGrid[hidden], #mtPanel[hidden], #mtIntro[hidden] { display: none; }
#mtPanel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-sm); max-width: 1040px; }

#zrAlignBox { border: 1px solid var(--accent); border-radius: var(--radius-md); padding: 10px; margin-top: 8px; background: var(--accent-ring); }
#zrCanvas { display: block; margin: 6px 0; border-radius: var(--radius-sm); }

.dg-op-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.dg-op-row[hidden] { display: none; }
#dgLegendImg img { margin: 6px 0; border-radius: 6px; }

/* ============================================================================ plotter: plot-summary card + floating map status card */
#plotSummary { background: var(--amber-bg); border: 1px solid var(--amber-border); border-radius: var(--radius-md); padding: 14px 16px; margin: 0 0 14px; }
#plotSummary .ps-head { display: flex; align-items: center; justify-content: space-between; }
#plotSummary .ps-head .ps-title { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 700; color: var(--amber-text); }
#plotSummary .ps-head .ps-value { font-size: 15px; font-weight: 800; color: var(--amber-text); }
#plotSummary .ps-div { height: 1px; background: var(--amber-border); opacity: .6; margin: 10px 0; }
#plotSummary .ps-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; color: var(--amber-text); }
#plotSummary .ps-row span:first-child { opacity: .75; font-weight: 500; }
#plotSummary .ps-row span:last-child { font-weight: 700; }
#plotSummary .ps-pills { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
#plotSummary .ps-pill { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--amber-border); border-radius: 20px; padding: 5px 10px; font-size: 11.5px; font-weight: 700; color: var(--amber-text); }
#plotSummary .ps-row .ok { color: var(--success); }
#plotSummary .ps-row .warn { color: var(--warn); }
/* The main CTA: full-width, its own row, noticeably bigger than every other button in the card — the one
   thing here meant to catch your eye immediately rather than sit alongside everything else. */
#plotSummary .ps-cta { display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 10px; padding: 12px 16px; border-radius: 10px; border: none; background: var(--black); color: var(--on-black); text-align: left; box-shadow: 0 4px 0 rgba(0,0,0,.4), 0 7px 14px rgba(0,0,0,.28); transform: translateY(0); transition: transform .1s ease, box-shadow .1s ease; }
#plotSummary .ps-cta:hover { filter: brightness(1.15); }
#plotSummary .ps-cta:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.22); }
#plotSummary .ps-cta svg { flex-shrink: 0; }
#plotSummary .ps-cta span { display: flex; flex-direction: column; gap: 1px; }
#plotSummary .ps-cta span > * { font-size: 14.5px; font-weight: 800; }
#plotSummary .ps-cta small { font-size: 11px; font-weight: 600; opacity: .7; }
#plotSummary .ps-hint { display: block; font-size: 11px; line-height: 1.4; color: var(--amber-text); opacity: .75; margin-bottom: 10px; }

/* Export: a quiet, document-like row — these hand data off and leave the app, so they read as filed
   paperwork (monospace extensions, hairline outline) rather than another thing to click and do. */
#plotSummary .ps-export { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
#plotSummary .ps-export-label { font-size: 11px; color: var(--amber-text); opacity: .6; margin-right: 1px; }
#plotSummary .ps-export button { font: 11px/1 ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; letter-spacing: .01em; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--amber-border); background: var(--surface); color: var(--amber-text); }
#plotSummary .ps-export button:hover { background: var(--amber-border); }

/* Actions: the workflow keeps going after these — a step you take inside the app — so they're solid,
   iconed buttons in the brand's gold, with the one that opens the biggest next step (Comparables) in black.
   Background must differ from the card behind them (also amber-bg) or they vanish into it — --surface,
   not --amber-bg, is what actually gives these a visible button shape. */
#plotSummary .ps-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
#plotSummary .ps-actions button { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 8px 13px; border-radius: 8px; border: 1.5px solid var(--amber-border); background: var(--surface); color: var(--amber-text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
#plotSummary .ps-actions button:hover { background: var(--amber-border); color: var(--amber-bg); }


/* settings accordion — card blocks */
#settingsModal .modal-body { background: var(--surface-2); }
#settingsModal details.acc { margin: 0 0 12px; }
details.acc > summary::before { display: none; }
details.acc { border: 1px solid var(--border); border-radius: 14px; margin: 0; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow .2s ease, border-color .2s ease; }
details.acc[open] { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
details.acc > summary { padding: 14px 16px; font-weight: 700; font-size: 14px; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; user-select: none; transition: background .15s ease; }
details.acc > summary:hover { background: var(--surface-2); }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: rotate(45deg); transition: transform .3s ease; margin-right: 3px; }
details.acc.is-open > summary::after { transform: rotate(-135deg); }
details.acc[open] > summary { border-bottom: 1px solid var(--border); }
details.acc > .acc-body { padding: 14px 16px 16px; }
/* map data-layers panel */
#layersPanel { position: absolute; top: 100px; right: 16px; width: 340px; max-width: calc(100% - 32px); max-height: calc(100% - 150px); overflow-y: auto; z-index: 900; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 6px 12px 10px; }
#layersPanel[hidden] { display: none; }
#layersPanel .lp-sec { padding: 8px 0; border-bottom: 1px solid var(--border); }
#layersPanel .lp-sec:last-child { border-bottom: 0; }
#layersPanel .lp-title { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); margin-bottom: 4px; }
.hzbox:not(:has(.hzvis:checked)) > .lay-extra { display: none; }
#dgBox .hzbox:not(:has(#dgOn:checked)) > .lay-extra { display: none; }
#zrAlignFloat { position: absolute; top: 16px; left: 56px; z-index: 950; width: 360px; max-width: calc(100% - 80px); max-height: calc(100% - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
#zrAlignFloat:has(#zrAlignBox[hidden]) { display: none; }
#zrAlignFloat #zrAlignBox { padding: 12px 14px; }

.lg-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; margin: 0; } .lg-row span { display: flex; flex-direction: column; } .lg-row small { margin: 0; font-size: 11.5px; color: var(--text-secondary); font-weight: 400; }
.lg-soon { margin-top: 10px; font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.soon-pill { background: var(--warn-bg); color: var(--warn); border-radius: 100px; padding: 2px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }

/* add-new-plot wizard */
.modal-card.wizard-card { width: 640px; max-width: 94vw; padding: 0; display: flex; flex-direction: column; max-height: 90vh; }
.wizard-card .modal-body { flex: 1; min-height: 0; }
.wizard-card fieldset { margin-bottom: 14px; }
.wizard-card fieldset:last-child { margin-bottom: 0; }
.pw-head-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-head .pw-back { width: auto; height: auto; border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 700; }
.wizard-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 22px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.wizard-foot[hidden] { display: none; }
.wizard-foot #pwErr { font-size: 12.5px; white-space: pre-line; flex: 1; }
.wizard-foot #pwGo { padding: 9px 26px; }
#pwBody #llApply { display: none; }
#pickBar { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 3500; width: min(560px, calc(100vw - 24px)); background: var(--black); color: var(--on-black); padding: 10px 14px 10px 18px; border-radius: 12px; box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; }
#pickBar .pbTop { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
#pickBar .pbLoc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#pickBar .pbLoc input { margin: 0; padding: 7px 9px; font-size: 12.5px; font-weight: 500; min-width: 0; }
#pbStatus { font-size: 11.5px; font-weight: 500; opacity: .8; min-height: 14px; }
@media (max-width: 520px) { #pickBar .pbLoc { grid-template-columns: 1fr; } }
#pickBar[hidden] { display: none; }
#pickBar button { padding: 4px 12px; font-size: 12px; }
#emptyPlot { text-align: center; padding: 34px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface); }
#emptyPlot[hidden] { display: none; }
#emptyPlot p { margin: 0 0 8px; }
#emptyPlot button { margin-top: 10px; padding: 9px 20px; }
#formHold[hidden] { display: none; }
#fsActions { margin-top: 4px; }

/* appraisal report: guided creation wizard + empty state */
#reportEmpty, #reportWizard { grid-column: 1 / -1; }
#reportEmpty[hidden], #reportWizard[hidden] { display: none; }
#reportEmpty { text-align: center; padding: 60px 16px; max-width: 480px; margin: 40px auto; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface); }
#reportEmpty p { margin: 0 0 8px; }
#reportWizard { max-width: 780px; margin: 0 auto; padding: 8px 0 40px; }
.rw-steps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 22px; }
.rw-step { display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border-radius: 100px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.rw-step .rw-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.rw-step.current { border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.rw-step.current .rw-dot { background: var(--black); color: var(--on-black); }
.rw-step.done .rw-dot { background: var(--success); color: #fff; }
.rw-step.done .rw-dot::before { content: "✓"; }
.rw-body { display: flex; flex-direction: column; gap: 14px; }
.rw-body fieldset { margin: 0; }
.rw-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.rw-foot #rwErr { flex: 1; font-size: 12.5px; }
.rw-foot #rwNext { padding: 9px 26px; }
.rw-foot button.ghost { background: transparent; border-color: var(--border); }

/* in-app AI assistant */
#agBtn { position: fixed; left: 10px; bottom: 0; z-index: 4000; width: 108px; height: 150px; background: transparent; border: none; box-shadow: none; padding: 0; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; }
#agAvatar { width: 100%; height: 132px; display: flex; align-items: flex-end; justify-content: center; }
#agAvatar img { width: auto; height: 100%; max-width: 100%; object-fit: contain; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.28)); transition: transform .15s ease; animation: ag-bob-avatar 3.2s ease-in-out infinite; transform-origin: bottom center; }
#agBtn:hover #agAvatar img { animation-play-state: paused; transform: translateY(-3px) scale(1.03); }
@keyframes ag-bob-avatar { 0%, 100% { transform: translateY(0) rotate(0deg); } 30% { transform: translateY(-5px) rotate(-1.5deg); } 60% { transform: translateY(-1px) rotate(1deg); } }
#agBubble { position: absolute; left: 96px; bottom: 68px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 8px 14px; font-size: 12.5px; font-weight: 700; line-height: 1.35; white-space: nowrap; text-align: left; box-shadow: var(--shadow-sm); animation: ag-bob 2.6s ease-in-out infinite; }
#agBubble small { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-top: 1px; }
@keyframes ag-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
#agBtn[aria-expanded="true"] #agBubble { display: none; }
#agBtn:hover { filter: brightness(1.15); }
#agPanel { position: fixed; left: 14px; bottom: 158px; z-index: 4000; width: 380px; max-width: calc(100vw - 32px); height: min(620px, calc(100vh - 130px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden; }
#agPanel[hidden] { display: none; }
.ag-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ag-head b { font-size: 13.5px; }
.ag-note { font-size: 11px; color: var(--text-secondary); flex: 1; }
.ag-head button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.ag-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ag-row { display: flex; align-items: flex-end; gap: 7px; max-width: 100%; }
.ag-row-user { align-self: flex-end; flex-direction: row-reverse; }
.ag-face { width: 30px; height: 30px; object-fit: contain; object-position: bottom; flex-shrink: 0; }
.ag-msg { max-width: 100%; padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.ag-msg.ag-bot { background: var(--surface-2); border-bottom-left-radius: 3px; }
.ag-msg.ag-user { background: var(--black); color: var(--on-black); border-bottom-right-radius: 3px; }
.ag-msg.ag-err { background: var(--danger-bg); color: var(--danger); }
.ag-msg.ag-typing { display: flex; align-items: center; gap: 4px; padding: 11px 13px; }
.ag-msg.ag-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); animation: ag-typing-bounce 1.1s ease-in-out infinite; }
.ag-msg.ag-typing span:nth-child(2) { animation-delay: .15s; }
.ag-msg.ag-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ag-typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.ag-tool { max-width: 100%; font-size: 11.5px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; display: flex; align-items: center; gap: 6px; }
.ag-tool .ag-spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text-secondary); animation: ag-spin .7s linear infinite; flex-shrink: 0; }
.ag-tool.ag-done .ag-spin { display: none; }
.ag-tool.ag-done::before { content: "✓"; color: var(--success); font-weight: 700; }
@keyframes ag-spin { to { transform: rotate(360deg); } }
.ag-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ag-input-row textarea { flex: 1; resize: none; max-height: 90px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.ag-input-row button { align-self: flex-end; padding: 8px 16px; }

.ag-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.ag-suggest[hidden] { display: none; }
.ag-suggest button { font-size: 11.5px; font-weight: 600; padding: 6px 11px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.ag-suggest button:hover { border-color: var(--border-strong); }

/* multiple plots (group view) */
#plotList .grpTick, #cloudPlotList .grpTick { flex: none; align-self: center; margin: 0 10px 0 0; }
#plotList li > div, #cloudPlotList li > div { flex: 1 1 auto; }
#grpBar { margin: 8px 12px 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); font-size: 12.5px; }
#grpBar[hidden] { display: none; }
#grpBar .grpHead { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
#grpBar #grpTotal { color: var(--text-secondary); font-size: 11.5px; }
#grpBar .grpBtns { display: flex; flex-wrap: wrap; gap: 6px; }
#grpBar button { padding: 4px 10px; font-size: 12px; }
#grpBar .grpExp { margin-top: 8px; color: var(--text-secondary); font-size: 11.5px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
#grpBar .grpExp button { font-family: ui-monospace, monospace; font-size: 11px; padding: 2px 8px; }
#grpBar { overflow: hidden; }
#grpResult { margin-top: 8px; }
.grpLine { padding: 3px 0; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; } .grpLine.bad { color: var(--danger); font-weight: 600; } .grpLine.warn { color: var(--warn, #b26a00); } .grpLine.ok { color: var(--accent); }
.grpNote { color: var(--text-secondary); }

/* many lots at once */
.modal-card.batch-card { width: 960px; max-width: 96vw; padding: 0; display: flex; flex-direction: column; }
.batch-card .modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.batch-card .modal-body { padding: 14px 22px; overflow-y: auto; }
.batchTabs { display: flex; gap: 6px; margin-bottom: 10px; }
.batchTabs button { border-radius: 100px; padding: 5px 14px; font-size: 12.5px; }
.batchTabs button.on { background: var(--black); color: var(--on-black); border-color: var(--black); }
#batchText { width: 100%; font-size: 12.5px; }
.batchDefaults { margin-top: 12px; }
.batchGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
#batchOut { margin-top: 12px; overflow-x: auto; }
.batchTbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.batchTbl th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); padding: 0 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.batchTbl td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.batchTbl td input[type=text], .batchTbl td input:not([type]) { margin: 0; padding: 4px 6px; font-size: 12px; }
.batchTbl td input[type=checkbox] { margin: 0; vertical-align: middle; }
.batchTbl td { vertical-align: middle; }
.warnTxt { color: var(--warn); } .badTxt { color: var(--danger); font-weight: 600; } .okTxt { color: var(--accent); }
.batch-card .wizard-foot { padding: 12px 22px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); }

.batchOpen { padding: 0 6px; border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.batchDet { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin: 2px 0 6px; }
.batchTie { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.batchTie label { font-size: 11.5px; color: var(--text-secondary); display: block; }
.batchTie input, .batchLines input { margin: 3px 0 0; padding: 5px 7px; font-size: 12.5px; width: 100%; box-sizing: border-box; }
.batchLines { width: 100%; border-collapse: collapse; font-size: 12px; }
.batchLines th { text-align: left; font-size: 10.5px; color: var(--text-secondary); padding: 0 6px 4px; }
.batchLines td { padding: 2px 6px; border: 0; }
.batchLines td:first-child { width: 54px; color: var(--text-secondary); white-space: nowrap; }

/* ---- tidy form controls ---- */
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 34px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%235B5645' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
}
:root[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23C9C3B0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); }
select:disabled { opacity: .6; cursor: not-allowed; }
label.inline select { padding-right: 30px; }
.fieldPair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .fieldPair { grid-template-columns: 1fr; gap: 0; } }
details.refMore { margin-top: 10px; font-size: 12.5px; }
details.refMore summary { cursor: pointer; color: var(--text-secondary); font-weight: 600; padding: 2px 0; }
details.refMore .row { margin: 8px 0; }

/* searchable reference list (combo.js) */
.cbWrap { position: relative; }
.cbList { position: absolute; left: 0; right: 0; top: 100%; z-index: 4000; margin-top: 4px; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.cbList[hidden] { display: none; }
.cbItem { padding: 8px 12px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.cbItem small { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }
.cbItem.on, .cbItem:hover { background: var(--accent-ring); }
.cbItem b { font-weight: 700; }
.cbEmpty { padding: 10px 12px; font-size: 12.5px; color: var(--text-secondary); }

/* multiple plots: one lot at a time */
#mfTop { margin: 0 0 12px; text-align: right; } #mfTop[hidden] { display: none; }
.linkBtn { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 2px 0; }
.linkBtn:hover { text-decoration: underline; }
.multiFoot { flex-wrap: wrap; align-items: center; }
.multiFoot[hidden] { display: none; }
.multiMsg { flex: 1 1 200px; min-width: 0; font-size: 12.5px; }
#pwMultiInfo { color: var(--text-secondary); } #pwMultiErr { white-space: pre-line; }
.multiBtns { display: flex; gap: 8px; flex-wrap: wrap; }
.multiBtns button:disabled { opacity: .45; cursor: not-allowed; }
.batch-card .pw-head-l { display: flex; align-items: center; gap: 10px; }
.batch-card .pw-head-l h3 { margin: 0; }

.batchGrid select, .batchGrid input { min-width: 0; }

/* saved groups (groups.js) */
#groupList { list-style: none; margin: 0; padding: 0; }
#groupList li { display: flex; align-items: center; cursor: pointer; }
#groupList li > div { flex: 1 1 auto; min-width: 0; }
#groupList .grpMember { padding-left: 26px; }
#groupList .grpIcon { flex: none; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; padding: 2px 6px; font-size: 14px; }
#groupList .grpIcon:hover { color: var(--text); }
#groupList .grpGroupTick, #groupList .grpTick { flex: none; align-self: center; margin: 0 10px 0 0; }
.gdTable, .gdLots { width: 100%; border-collapse: collapse; font-size: 13px; }
.gdTable td { padding: 5px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.gdTable td:first-child { color: var(--text-secondary); width: 46%; padding-right: 10px; }
.gdHead { margin: 16px 0 6px; font-size: 12px; font-weight: 600; } .gdMuted { color: var(--text-tertiary); font-weight: 400; font-size: 11.5px; }
.gdLots th { text-align: left; font-size: 11.5px; color: var(--text-secondary); padding: 3px 6px 3px 0; }
.gdLots td { padding: 3px 6px 3px 0; } .gdLots input { width: 100%; }
.gdBad { color: var(--danger); } .gdNote { color: var(--text-secondary); font-size: 12px; margin-top: 6px; }
.gdLots { table-layout: fixed; } .gdLots th:nth-child(1) { width: 46%; } .gdLots th:nth-child(2) { width: 18%; } .gdLots th:nth-child(3) { width: 22%; } .gdLots input { min-width: 0; width: 100% !important; box-sizing: border-box; }

/* AI credits button (header) */
#creditChip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 700; cursor: pointer; }
#creditChip svg { color: #be9650; } #creditChip:hover { background: var(--surface-2); }
#creditChip.low { border-color: var(--danger); color: var(--danger); } #creditChip.low svg { color: var(--danger); }

/* Filo on the sign-in card: peeks over the top edge */
.auth-card { position: relative; margin-top: 120px; }
.auth-mascot { position: absolute; left: 50%; bottom: calc(100% - 1px); transform: translateX(-50%); z-index: 1; line-height: 0; pointer-events: auto; }
@media (max-height: 640px) { .auth-card { margin-top: 90px; } .auth-mascot { transform: translateX(-50%) scale(.75); transform-origin: 50% 100%; } }

button[hidden] { display: none !important; }
