/* PRR Studio web — the desktop app's ArcGIS-Pro-like palette */
:root {
  --bg: #f0f1f2; --panel: #fff; --soft: #e4eaf0; --border: #d3d6da; --text: #2a2e33; --muted: #6a7078;
  --accent: #0079c1; --accent-dim: #00567f; --hover: #e5f1fb; --sel: #dcebf9; --danger: #c62828;
  --s1: #4c8bf5; --s2: #f2a33a; --s3: #2e9e5b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
code { background: var(--soft); padding: 0 3px; border-radius: 3px; }
.hidden { display: none !important; }

.top { display: flex; align-items: center; gap: 18px; padding: 6px 14px; background: #f7f8fa; border-bottom: 1px solid var(--border); flex: none; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 11.5px; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-bottom: 3px solid transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: .45; cursor: default; }
.tabs button:not(:disabled):hover { background: var(--hover); }
.tabs i, .tabs .navonly { display: none; }  /* desktop: text tabs; phones: icon bar (see @media) */
.who { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

main { flex: 1; min-height: 0; position: relative; }
.pane { display: none; position: absolute; inset: 0; }
.pane.on { display: flex; }
.side { width: 340px; flex: none; background: var(--panel); border-right: 1px solid var(--border); padding: 10px 12px; overflow-y: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px; gap: 8px; overflow: auto; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
h3:first-child { margin-top: 2px; }
.hint { color: var(--muted); margin: 6px 0; }
.small { font-size: 11.5px; }
input[type=search], input[type=number], input[type=date], select { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: 3px; background: #fff; margin-bottom: 6px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
button { border: 1px solid var(--border); background: #fff; padding: 6px 12px; border-radius: 3px; cursor: pointer; }
button:hover:not(:disabled) { background: var(--hover); border-color: #aad4f5; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-dim); }
button.danger { color: var(--danger); }
button.ghost { background: none; }
button.wide { width: 100%; margin-top: 14px; padding: 9px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.col { display: flex; flex-direction: column; gap: 5px; }
.col button { text-align: left; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 9px 11px; }
.card b.t { font-size: 14px; display: block; }
.card .kv { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 6px 0; font-size: 12px; }
.card .kv span:nth-child(odd) { color: var(--muted); }
.list { border: 1px solid var(--border); border-radius: 3px; max-height: 260px; overflow-y: auto; background: #fff; }
.list:empty { display: none; }
.list div { padding: 5px 8px; cursor: pointer; border-bottom: 1px solid #f0f1f2; display: flex; gap: 6px; align-items: baseline; }
.list div:hover { background: var(--hover); }
.list div.on { background: var(--sel); }
.list i { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.list small { color: var(--muted); margin-left: auto; white-space: nowrap; }
.file { display: inline-block; position: relative; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file span { display: inline-block; border: 1px solid var(--border); padding: 6px 12px; border-radius: 3px; background: #fff; }
.file:hover span { background: var(--hover); }

#map { flex: 1; border: 1px solid var(--border); border-radius: 4px; min-height: 300px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: -1px; }

.grid3 { display: grid; grid-template-columns: auto 1fr 1fr; gap: 3px 6px; align-items: center; }
.grid3 input { margin: 0; min-width: 0; padding: 4px 3px; font-size: 12px; }
.grid3 b { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.sw::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.s1::before { background: var(--s1); } .s2::before { background: var(--s2); } .s3::before { background: var(--s3); }
.plot { flex: 1; min-height: 360px; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.plot.short { flex: none; height: 300px; min-height: 0; }

.form label.f { display: block; margin: 7px 0 2px; font-weight: 600; font-size: 12px; }
.form .chk { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.form .chk input { margin: 0; }
.form .group { border-top: 1px solid var(--soft); margin-top: 10px; padding-top: 4px; }
.form .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; max-height: 210px; overflow-y: auto; border: 1px solid var(--border); padding: 4px 6px; border-radius: 3px; }
.run { display: flex; gap: 8px; align-items: center; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
#barfill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.subtabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); }
.subtabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 10px; color: var(--muted); font-weight: 600; }
.subtabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.periods label { margin-right: 8px; cursor: pointer; }
.periods .log { margin-left: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; background: #fff; }
th, td { padding: 3px 6px; border-bottom: 1px solid #eceef0; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; background: #f7f8fa; position: sticky; top: 0; }
.tablewrap { overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 4px; flex: 1; }
#metrics { overflow-x: auto; }
pre.sum { white-space: pre-wrap; font-size: 11.5px; padding: 8px 10px; margin: 0; }

.foot { flex: none; display: flex; justify-content: space-between; gap: 10px; padding: 4px 12px; background: #f7f8fa; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.foot .cred { text-align: right; }
.busy { position: fixed; inset: 0; background: rgba(240, 241, 242, .55); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.busy > div { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 16px 20px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.12); max-width: 90vw; }
.spin { width: 20px; height: 20px; border: 3px solid var(--soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 16px; bottom: 34px; background: #2a2e33; color: #fff; padding: 9px 14px; border-radius: 4px; z-index: 3000; max-width: 420px; }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  main { flex: none; }
  .pane { position: static; flex-direction: column; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .top { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  /* phones: steps become pages, switched from a fixed bottom bar (like SWRC/HCC Fitter) */
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--panel); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0,0,0,.06); padding-bottom: env(safe-area-inset-bottom); }
  .tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; font-size: 11.5px;
    border-bottom: 0; border-top: 3px solid transparent; white-space: nowrap; }
  .tabs button.on { border-top-color: var(--accent); background: var(--sel); }
  .tabs button i { display: block; font-style: normal; font-size: 19px; line-height: 1; }
  .tabs .n { display: none; }
  .tabs .navonly { display: flex; }
  .credbtn { display: none; }
  .who { display: none; }
  .toast { bottom: 72px; left: 12px; right: 12px; max-width: none; }
  #map { min-height: 60vh; }
  .plot { min-height: 340px; }
  .foot { flex-direction: column; }
  .foot .cred { text-align: left; }
}

/* licences & credits */
.credbtn { padding: 4px 9px; font-size: 11.5px; white-space: nowrap; }
.foot a, .hint a { color: var(--accent); }
.card .cite { margin: 4px 0 8px; line-height: 1.35; }
.card .kv a { color: var(--accent); }
.modal { position: fixed; inset: 0; background: rgba(42, 46, 51, .35); display: flex; align-items: center; justify-content: center; z-index: 2500; padding: 16px; }
.sheet { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 10px 32px rgba(0,0,0,.18); width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; }
.sheethead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sheethead h2 { font-size: 16px; font-weight: 600; margin: 0; }
.credits { overflow: auto; padding: 4px 14px 14px; }
.credits p { margin: 8px 0; }
.credits table { margin-bottom: 6px; }
.credits th, .credits td { white-space: normal; text-align: left; vertical-align: top; padding: 4px 6px; }
.credits td:first-child { width: 22%; }
.credits td:nth-child(2) { width: 15%; }
.credits a { color: var(--accent); }
.leaflet-container .leaflet-control-attribution { max-width: calc(100vw - 40px); white-space: normal; }
@media (max-width: 860px) {
  .credits td:first-child, .credits td:nth-child(2) { width: auto; }
  .modal { padding: 0; }
  .sheet { border-radius: 0; height: 100%; }
}
