/* OreRank app: same identity as the website (ink, copper accent, gold signal, warm paper). */
:root {
  color-scheme: light;
  --surface-0: #f1efea; --surface-1: #f7f6f3; --surface-2: #ffffff;
  --text-primary: #13171d; --text-secondary: #5a5f66; --line: #e4e1db;
  --accent: #b5541b; --accent-text: #ffffff; --accent-soft: #f6e7dc;
  --signal: #c27c0e;
  --series-1: #b5541b; --series-2: #c2571a; --series-3: #3d6fd1;
  --good: #2f7d4f; --warning: #c48a00; --serious: #c2571a; --critical: #c0392b;
  --grid: #e9e5de;
  --f-display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --shadow: 0 1px 2px rgba(20, 32, 40, .06), 0 4px 16px rgba(20, 32, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #0f1115; --surface-1: #15181d; --surface-2: #1b1f25;
    --text-primary: #ebe7e0; --text-secondary: #a9a39a; --line: #2a2f37;
    --accent: #f08a3c; --accent-text: #160a02; --accent-soft: #3a2416;
    --signal: #f5b733;
    --series-1: #f08a3c; --series-2: #f08a4b; --series-3: #7aa2f2; --grid: #262a31;
    --good: #5cc28a; --warning: #f5b733; --serious: #f08a4b; --critical: #f07065;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #0f1115; --surface-1: #15181d; --surface-2: #1b1f25;
  --text-primary: #ebe7e0; --text-secondary: #a9a39a; --line: #2a2f37;
  --accent: #f08a3c; --accent-text: #160a02; --accent-soft: #3a2416;
  --signal: #f5b733;
  --series-1: #f08a3c; --series-2: #f08a4b; --series-3: #7aa2f2; --grid: #262a31;
  --good: #5cc28a; --warning: #f5b733; --serious: #f08a4b; --critical: #f07065;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface-0); color: var(--text-primary); font: 14px/1.5 var(--f-body); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* shell */
#shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
#topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 52px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 9px; font: 800 16px/1 var(--f-display); font-stretch: 112%; color: var(--text-primary); text-decoration: none; }
.crumb { color: var(--text-secondary); font-size: 13px; padding-left: 14px; border-left: 1px solid var(--line); }
#topbar .spacer { flex: 1; }
#topbar .pill:empty { display: none; }
#topbar .pill { font: 500 12px var(--f-mono); color: var(--text-secondary); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
#topbar a.plain, #topbar button.plain { color: var(--text-secondary); text-decoration: none; font-size: 13px; background: none; border: 0; padding: 6px 4px; cursor: pointer; }
#topbar a.plain:hover, #topbar button.plain:hover { color: var(--accent); }
#topbar [hidden] { display: none; }
#app { display: flex; min-height: 0; }
#panel { width: 440px; max-width: 100%; display: flex; flex-direction: column; background: var(--surface-1); border-right: 1px solid var(--line); min-height: 0; }
#panel-body { overflow-y: auto; padding: 4px 20px 32px; flex: 1; }
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

/* tabs */
nav#tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 2px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface-1); flex: none; }
nav#tabs button { display: flex; align-items: center; gap: 6px; background: transparent; color: var(--text-secondary); border: 0; border-bottom: 2px solid transparent; padding: 10px 6px 8px; border-radius: 0; justify-content: center; cursor: pointer; font: 500 13px var(--f-body); white-space: nowrap; }
nav#tabs button svg { width: 15px; height: 15px; flex: none; }
nav#tabs button:hover { color: var(--text-primary); }
nav#tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
nav#tabs button[hidden] { display: none; }
.tab { display: none; } .tab.active { display: block; }

/* type */
.muted { color: var(--text-secondary); } .small { font-size: 12px; }
h2 { font: 800 20px/1.2 var(--f-display); font-stretch: 112%; margin: 20px 0 6px; }
h2 .muted { font: 400 14px var(--f-body); }
h3 { font: 500 11px/1.2 var(--f-mono); margin: 22px 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .08em; }
.lead-text { color: var(--text-secondary); margin: 0 0 14px; }
code, .mono { font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* controls */
button { background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 4px; padding: 7px 13px; font: 600 13px var(--f-body); cursor: pointer; transition: filter .15s; }
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--line); }
button.secondary:hover { border-color: var(--accent); filter: none; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--accent); padding: 0; border: 0; font-weight: 500; }
input, select, textarea { font: 14px var(--f-body); color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { font-family: var(--f-mono); font-size: 13px; }
label { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; } label.inline input { width: 84px; margin: 0; }
label.check[hidden] { display: none; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text-primary); font-weight: 400; } label.check input { width: auto; margin: 0; accent-color: var(--accent); }
.stack { display: grid; gap: 10px; padding-top: 10px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; } .row.wrap { flex-wrap: wrap; } .row select { width: auto; }
details { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 10px 0; background: var(--surface-2); }
summary { cursor: pointer; font-weight: 600; }

/* lists and cards */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--surface-2); transition: border-color .15s; }
.list li.sel { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
#site-list li { cursor: pointer; } #site-list li:hover { border-color: var(--accent); }
.list li .title { font-weight: 600; } .list li .actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.list li .actions button { padding: 5px 10px; font-size: 12px; }
.list li .actions select { width: auto; padding: 4px 6px; font-size: 12px; }
.empty { border: 1px dashed var(--line); border-radius: 6px; padding: 16px; color: var(--text-secondary); font-size: 13px; text-align: center; }
.badge { display: inline-flex; align-items: center; gap: 4px; font: 500 11px var(--f-mono); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--text-secondary); white-space: nowrap; }
.badge .ico { font-weight: 700; }
.badge.good { border-color: var(--good); color: var(--good); } .badge.critical { border-color: var(--critical); color: var(--critical); }
.badge.warning { border-color: var(--warning); color: var(--warning); } .badge.serious { border-color: var(--serious); color: var(--serious); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; } td, th { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 500; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin: 8px 0; } .kv div:nth-child(odd) { color: var(--text-secondary); }

#sel-bar:not(:empty) { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; padding: 8px 10px; margin: 10px 0; }
#sel-bar strong { color: var(--text-primary); }

/* map overlays */
.menu-toggle { display: grid; place-items: center; padding: 6px !important; margin-left: -6px; }
#app.menu-hidden #panel { display: none; }
.mag-ramp { height: 10px; border-radius: 2px; background: linear-gradient(90deg, #0a0aff, #8080ff, #f5f5f5, #ff8080, #ff0a0a); margin: 4px 0 2px; }
#map-controls { position: absolute; top: 12px; left: 12px; width: 240px; z-index: 3; box-shadow: var(--shadow); display: grid; gap: 4px; }
#map-controls label { color: var(--text-primary); font-weight: 400; }
#map-controls select { width: auto; padding: 4px 6px; font-size: 12px; margin: 0 0 0 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.dot.s1 { background: var(--series-1); } .dot.s2 { background: var(--series-2); }
.sq { width: 12px; height: 10px; display: inline-block; border: 2px solid #eda100; }
.ramp { height: 10px; border-radius: 2px; background: linear-gradient(90deg, #cde2fb, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b); margin: 4px 0 2px; }
#toast { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: var(--surface-2); border-radius: 6px; padding: 10px 16px; display: none; z-index: 5; max-width: 90%; box-shadow: var(--shadow); font-size: 13px; }
.marker { width: 24px; height: 24px; border-radius: 50%; background: var(--signal); color: #fff; display: grid; place-items: center; font: 600 11px var(--f-mono); border: 2px solid #fff; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.marker.pos { background: var(--good); } .marker.neg { background: #6b6a65; }
.maplibregl-popup-content { background: var(--surface-2); color: var(--text-primary); border-radius: 6px; box-shadow: var(--shadow); font: 13px/1.45 var(--f-body); padding: 10px 12px; }
.maplibregl-popup-tip { border-top-color: var(--surface-2) !important; border-bottom-color: var(--surface-2) !important; }

/* sign-in */
#signin { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--surface-0); padding: 16px; }
#signin[hidden] { display: none; }
#signin form { width: 100%; max-width: 400px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
#signin h1 { font: 800 24px/1.15 var(--f-display); font-stretch: 112%; margin: 0; }
#signin .err { color: var(--critical); font-size: 13px; min-height: 1em; }

/* charts */
.viz { margin: 8px 0; } .viz svg { width: 100%; height: auto; display: block; }
.viz .legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-secondary); margin: 4px 0; }
.viz .legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 4px; }
.viz .tip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; color: var(--text-primary); display: none; white-space: nowrap; z-index: 4; }
.viz-wrap { position: relative; }

@media (max-width: 800px) {
  #shell { height: auto; }
  #app { flex-direction: column; }
  #panel { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  #map-wrap { height: 70vh; }
  #map-controls { width: 200px; }
  .crumb, #topbar .pill { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- workspace v2 (scoped to the map workspace: #shell, #topbar, #app) ---- */
#shell { grid-template-rows: 56px minmax(0, 1fr); }
#topbar { height: 56px; gap: 12px; padding: 0 14px; }
#topbar .logo .wordmark { font-size: 17px; }
#topbar .crumb { font: 500 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; }
#topbar .site-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 12.5px var(--f-body); color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; padding: 4px 11px; }
#topbar .site-pill[hidden] { display: none; }
#topbar .tb-icon { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; border-radius: 8px; border: 1px solid transparent; background: none;
  color: var(--text-secondary); text-decoration: none; font: 500 12.5px var(--f-body); cursor: pointer; }
#topbar .tb-icon:hover { background: var(--surface-1); border-color: var(--line); color: var(--text-primary); filter: none; }
#topbar .tb-icon[hidden] { display: none; }
#topbar .menu-toggle { width: 34px; height: 34px; border-radius: 8px; color: var(--text-secondary); }
#topbar .menu-toggle:hover { background: var(--surface-1); }

/* icon rail + panel */
#app #panel { width: auto; display: grid; grid-template-columns: 76px 392px; flex-direction: row; background: var(--surface-1); }
#app nav#tabs { grid-column: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; }
#app nav#tabs button { flex-direction: column; gap: 4px; padding: 9px 4px 7px; border: 0; border-radius: 10px; font: 500 10.5px var(--f-body); white-space: nowrap; color: var(--text-secondary); position: relative; }
#app nav#tabs button svg { width: 20px; height: 20px; }
#app nav#tabs button:hover { background: var(--surface-2); color: var(--text-primary); }
#app nav#tabs button.active { background: var(--accent-soft); color: var(--accent); border: 0; }
#app nav#tabs button.active::before { content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
#app #panel-body { grid-column: 2; padding: 6px 18px 40px; border-right: 1px solid var(--line); background: var(--surface-1); }
#app.menu-hidden #panel { display: grid; grid-template-columns: 76px; }
#app.menu-hidden #panel-body { display: none; }
#app #panel-body h2 { font-size: 21px; margin: 18px 0 8px; }
#app #panel-body h3 { margin: 22px 0 8px; }
#app #panel-body details { border-radius: 10px; }
#app #panel-body .list li { border-radius: 10px; padding: 11px 13px; }
#app #panel-body .list li:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
#app #panel-body button { border-radius: 8px; }
#app #panel-body input, #app #panel-body select, #app #panel-body textarea { border-radius: 8px; }
#app #sel-bar:not(:empty) { border-radius: 10px; }

/* layers card */
#app #map-controls { top: 12px; left: 12px; width: 280px; padding: 0; gap: 0; border-radius: 12px; overflow: hidden; max-height: calc(100% - 90px); display: flex; flex-direction: column; }
#app .lc-toggle { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--surface-2); color: var(--text-primary); border: 0; border-radius: 0; padding: 10px 12px; font: 600 13px var(--f-body); }
#app .lc-toggle:hover { filter: none; background: var(--surface-1); }
#app .lc-toggle .lc-chev { margin-left: auto; color: var(--text-secondary); transition: transform .15s; }
#app #map-controls.collapsed .lc-chev { transform: rotate(-90deg); }
#app #map-controls.collapsed .lc-body { display: none; }
#app .lc-body { overflow-y: auto; padding: 4px 12px 12px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
#app .lc-grp { display: grid; gap: 5px; padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
#app .lc-grp:last-of-type { border-bottom: 0; }
#app .lc-h { font: 500 10.5px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
#app .lc-grp label.check { font-size: 12.5px; line-height: 1.35; align-items: flex-start; }
#app .lc-grp label.check input { margin-top: 2px; }
#app .lc-grp label.bm { display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
#app .lc-grp label.bm select { margin: 0; }
#app .coords { position: absolute; left: 12px; bottom: 12px; z-index: 3; background: color-mix(in srgb, var(--surface-2) 88%, transparent); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; font-size: 11.5px; color: var(--text-secondary); backdrop-filter: blur(4px); pointer-events: none; }
#app .coords:empty { display: none; }
#app .maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
#app .maplibregl-ctrl-scale { border-radius: 4px; }

@media (max-width: 800px) {
  #app #panel { grid-template-columns: minmax(0, 1fr); width: 100%; min-width: 0; }
  #app #panel-body { min-width: 0; overflow-x: hidden; }
  #topbar { gap: 4px; padding: 0 8px; } #topbar .logo .wordmark { font-size: 15px; } #topbar #lnk-docs { display: none; }
  #app nav#tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  #app nav#tabs button { min-width: 64px; }
  #app nav#tabs button.active::before { display: none; }
  #app #panel-body { grid-column: 1; border-right: 0; }
  #app.menu-hidden #panel { grid-template-columns: minmax(0, 1fr); }
  #app #map-controls { width: 220px; }
  #topbar .tb-icon span, #topbar .site-pill { display: none; }
}
