/* ============ Restaurant Chain Tycoon — styles ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #12151b;
  --panel: #1b1f27;
  --panel2: #222734;
  --line: #2c313d;
  --text: #d7dbe2;
  --dim: #8b93a3;
  --accent: #4da3ff;
  --gold: #ffd24a;
  --green: #69c07d;
  --red: #e06c5f;
  --orange: #d39030;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  user-select: none;
}

h2 { font-size: 16px; } h3 { font-size: 13px; margin-bottom: 6px; color: #fff; }
h4 { font-size: 12px; color: #cdd3dd; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
.dim { color: var(--dim); font-size: 12px; }
.gold { color: var(--gold); }
.good { color: var(--green); } .bad { color: var(--red); } .link { cursor: pointer; color: var(--accent); }
.mt6 { margin-top: 8px; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #20242e, #181c24);
  border-bottom: 1px solid var(--line);
  padding: 7px 14px; flex: none; z-index: 20;
}
#topbar .brand { font-weight: 700; font-size: 14px; letter-spacing: .3px; white-space: nowrap; }
#topbar .brand span { color: var(--gold); }
#topbar .stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 12px; font-size: 13px; white-space: nowrap;
}
#topbar .stat b { color: #fff; font-size: 14px; }
.delta { font-size: 11px; margin-left: 6px; }
#speeds button, #pauseBtn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
#speeds { display: flex; gap: 4px; }
#speeds button.active { background: var(--accent); color: #0d1117; border-color: var(--accent); font-weight: 700; }
.top-spacer { flex: 1; }
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: #fff; }
.btn.primary { background: #22598f; border-color: #2f6cab; color: #fff; }
.btn.primary:hover { background: #2b6cad; }
.btn.danger { background: #7a2f2a; border-color: #933a30; color: #ffd6d1; }
.btn.warn { background: #7a5a1c; border-color: #93701f; color: #ffe9b0; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 2px 8px; font-size: 11.5px; border-radius: 5px; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#map-wrap { flex: 1; position: relative; min-height: 0; background: radial-gradient(1200px 500px at 60% 30%, #1a2530 0%, #12151b 70%); overflow: hidden; }
#map-wrap svg { width: 100%; height: 100%; display: block; cursor: grab; }
#map-wrap svg:active { cursor: grabbing; }
#map-holder { position: absolute; inset: 0; }

/* provinces by district type */
.prov { stroke: #ffffff88; stroke-width: .5; cursor: pointer; transition: filter .1s; }
.prov:hover, .prov.hover { filter: brightness(1.25); }
.prov.selected { stroke: var(--gold); stroke-width: 1.8; }
.t-OFFICE { fill: #4f7ea8; } .t-STUDENT { fill: #8d6bb5; }
.t-RESIDENTIAL { fill: #749a6b; } .t-TOURIST { fill: #d39030; } .t-NIGHTLIFE { fill: #a85d77; }
.marker { fill: var(--gold); stroke: #00000066; stroke-width: .8; }
.marker-label { font-size: 6px; fill: #1b1f27; font-weight: 700; }

#map-tooltip {
  display: none; position: fixed; z-index: 50; pointer-events: none;
  background: #0d1117ee; border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font-size: 12px; max-width: 220px;
  box-shadow: 0 4px 16px #0009;
}
#legend {
  position: absolute; left: 10px; bottom: 10px; z-index: 5;
  background: #0d1117cc; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 11.5px;
}
#legend .leg { display: flex; align-items: center; gap: 6px; margin: 2px 0; cursor: pointer; }
#legend .sq { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
#legend .mk { color: var(--gold); }
#zoombtns { position: absolute; right: 10px; top: 10px; z-index: 5; display: flex; gap: 5px; }
#zoombtns button {
  width: 30px; height: 30px; border-radius: 7px; background: #0d1117cc; color: var(--text);
  border: 1px solid var(--line); cursor: pointer; font-size: 14px;
}
#pauseBadge {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: #7a1c1cdd; border: 1px solid #933; border-radius: 7px;
  padding: 4px 14px; font-weight: 700; letter-spacing: 2px; display: none;
}
body.paused #pauseBadge { display: block; }

/* ---------- bottom panel ---------- */
#bottom {
  flex: none; height: 300px; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line);
  transition: height .15s;
}
#bottom.collapsed { height: 34px; }
#tabbar {
  display: flex; gap: 2px; align-items: center; padding: 0 8px; height: 34px;
  border-bottom: 1px solid var(--line); background: #171b22; flex: none;
}
#tabbar .tab {
  background: transparent; border: none; color: var(--dim); padding: 9px 14px; cursor: pointer;
  font-size: 12.5px; border-bottom: 2px solid transparent; border-radius: 0;
}
#tabbar .tab:hover { color: var(--text); }
#tabbar .tab.active { color: #fff; border-bottom-color: var(--gold); }
#tabbar .spacer { flex: 1; }
#collapseBtn { background: none; border: none; color: var(--dim); font-size: 15px; cursor: pointer; padding: 4px 10px; }
#bottom.collapsed #tabpanes { display: none; }
#tabpanes { flex: 1; overflow: hidden; min-height: 0; }
#tabpanes > div { display: none; height: 100%; overflow-y: auto; padding: 10px 14px; }
#tabpanes > div.active { display: block; }

.pane-hint { color: var(--dim); text-align: center; padding: 34px 20px; line-height: 1.8; font-size: 13px; }
.pane-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.pane-head h2 { display: inline-block; margin-right: 10px; }
.pane-head .head-actions { margin-left: auto; display: flex; gap: 8px; }
.pane-cols { display: flex; gap: 10px; align-items: flex-start; }
.pane-cols .col { display: flex; flex-direction: column; gap: 10px; }
.rest-cols .col:first-child { flex: 1; } .rest-cols .col:last-child { flex: 1.4; }
.grow2 { flex: 2; }

.card {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px;
}
.tablewrap { overflow-x: auto; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { text-align: left; color: var(--dim); font-weight: 500; padding: 2px 0; width: 55%; }
table.kv td { text-align: right; padding: 2px 0; }
table.kv tr.sep td, table.kv tr.sep th { border-top: 1px solid var(--line); padding-top: 5px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tbl th { text-align: left; color: var(--dim); font-weight: 500; padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 4px 8px 4px 0; border-bottom: 1px solid #23283322; }
table.tbl tr.clickable:hover td { background: #ffffff08; cursor: pointer; }
table.fin td.group { background: #ffffff06; }
.kv-inline { display: flex; gap: 22px; color: var(--dim); flex-wrap: wrap; }
.badge {
  display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: 11px;
  background: #ffffff14; border: 1px solid #ffffff22; vertical-align: middle; white-space: nowrap;
}
.badge.ok { background: #2d5a35; border-color: #3f7a4c; }
.badge.muted { color: var(--dim); background: #ffffff0a; }
.badge.type-OFFICE { background: #4f7ea855; border-color: #4f7ea8; }
.badge.type-STUDENT { background: #8d6bb550; border-color: #8d6bb5; }
.badge.type-RESIDENTIAL { background: #749a6b50; border-color: #749a6b; }
.badge.type-TOURIST { background: #d3903050; border-color: #d39030; }
.badge.type-NIGHTLIFE { background: #a85d7750; border-color: #a85d77; }
.chip {
  display: inline-block; border-radius: 6px; background: #ffffff10; padding: 2px 7px;
  margin: 2px 3px 2px 0; font-size: 11.5px; border: 1px solid #ffffff18; white-space: nowrap;
}
.chip.good { border-color: var(--green); } .chip.bad { border-color: var(--red); color: #e6b3ac; }
.warn-hint { color: var(--orange); background: #d3903022; border: 1px solid #d3903044; border-radius: 7px; padding: 7px 9px; margin-top: 8px; font-size: 12px; }
.chainfit { font-size: 12px; margin: 2px 0; }

.subrow { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.subrow .bar { flex: 1; height: 8px; background: #ffffff12; border-radius: 4px; overflow: hidden; }
.subrow .bar > div { height: 100%; }
.subrow > span:first-child { width: 52px; display: inline-block; }
.subrow > span:last-child { width: 26px; text-align: right; }
.chk { cursor: pointer; }
.review { padding: 5px 0; border-bottom: 1px solid #ffffff0d; font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; }
.review .day { color: var(--dim); font-size: 11px; flex: none; width: 32px; }
.reviews-list { max-height: 100%; }

.chain-card { margin-bottom: 10px; }
.chain-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.chain-head h3 { margin: 0; }
.chain-head select { margin-left: 6px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.row-spread { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
input[type=range] { width: 280px; vertical-align: middle; accent-color: var(--accent); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tinychart { width: 100%; height: auto; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: #05070bcc; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; max-width: 860px; width: min(92vw, 860px); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 12px 60px #000c;
}
.modal-card h3 { margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-cols .col { flex: 1; }
.frm { display: block; color: var(--dim); margin: 12px 0 4px; font-size: 12px; }
input.txt, select.txt {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; font-size: 13px;
}
input.txt:focus, select.txt:focus { outline: none; border-color: var(--accent); }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex-wrap: wrap; }
label.opt {
  display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; cursor: pointer; font-size: 12px; line-height: 1.5;
}
label.opt:has(input:checked) { border-color: var(--accent); background: #12223a; }
.candlist { max-height: 330px; overflow-y: auto; padding-right: 4px; }
.cand-type { margin-bottom: 10px; }
.cand {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 9px; margin: 3px 0; font-size: 12.5px; cursor: default;
}
label.cand { cursor: pointer; }
label.cand:hover { border-color: var(--accent); }
.costbox { margin-top: 14px; }

/* ---------- toasts ---------- */
#toastRoot { position: fixed; right: 14px; bottom: 14px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #20242e; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; max-width: 340px; font-size: 12.5px;
  opacity: 0; transform: translateX(20px); transition: all .3s;
  box-shadow: 0 6px 24px #000a;
}
.toast.show { opacity: 1; transform: none; }
.toast.warn { border-left-color: var(--orange); }
.toast.ok { border-left-color: var(--green); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2e3442; border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }
