/* Port of the desktop style.py palette. Desktop tool: light theme only, like the original. */
:root {
  --bg: #eef2f7; --card: #fff; --border: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --primary: #2563eb; --primary-dk: #1d4ed8; --primary-lt: #dbeafe;
  --bar: #0f172a; --bar2: #1e293b; --danger: #e11d48; --sub: #f8fafc;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.35 "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif; color: var(--text);
  background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
.spacer, .grow { flex: 1; }
.muted { color: var(--muted); font-size: 11.5px; }
.small { font-size: 11px; }
.row { display: flex; align-items: center; gap: 6px; }
.col { display: flex; flex-direction: column; gap: 4px; }
b { font-weight: 700; }

/* top bar */
#topbar { background: var(--bar); height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
#app-title { font-size: 16.5px; font-weight: 700; color: #fff; }
#app-sub { color: #94a3b8; font-size: 11.5px; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-btn { background: transparent; color: #cbd5e1; border: 1px solid #334155; border-radius: 16px; padding: 6px 18px; }
.stage-btn:hover { background: var(--bar2); color: #fff; }
.stage-btn.checked { background: var(--primary); border-color: var(--primary); color: #fff; }
.bar-btn { background: transparent; color: #e2e8f0; border: 1px solid #334155; }
.bar-btn:hover { background: var(--bar2); }

/* layout */
#body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px; }
.left { width: 372px; flex: none; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 6px; }
.right { width: 360px; flex: none; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.left > *, .right > * { flex: none; }
.right > .card.grow { flex: 1; }
.center { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 9px; }
.card.grow { min-height: 0; }
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 11.5px; }
.sub { background: var(--sub); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.prof { background: var(--sub); border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; display: flex; gap: 9px; align-items: center; }
.prof.active { background: #eff6ff; border-color: #93c5fd; }
.prof svg { flex: none; }
.prof .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scn { background: var(--sub); border: 1px solid var(--border); border-radius: 8px; padding: 8px 8px 10px 10px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.scn.active { background: #eff6ff; border: 1.5px solid var(--primary); cursor: default; }
.dot { font-size: 16px; color: #94a3b8; }
.scn.active .dot { color: var(--primary); }
.grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 8px; align-items: center; }
.grid .span3 { grid-column: span 3; }
.form { display: grid; grid-template-columns: auto 1fr; gap: 7px 8px; align-items: center; }
.form > .muted { text-align: right; }
h4 { margin: 4px 0 0; font-size: 13px; }

/* controls */
button { font: inherit; font-weight: 600; background: #f1f5f9; border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 12px; cursor: pointer; color: var(--text); }
button:hover { background: #e2e8f0; }
button:disabled { color: #94a3b8; background: #f1f5f9; cursor: default; }
button.primary { background: var(--primary); color: #fff; border: none; }
button.primary:hover { background: var(--primary-dk); }
button.primary:disabled { background: #93c5fd; color: #fff; }
button.tall { min-height: 42px; }
button.ghost { background: transparent; border: none; color: var(--primary); padding: 4px 6px; align-self: flex-start; }
button.ghost:hover { background: var(--primary-lt); }
button.icon { background: transparent; border: none; padding: 2px 6px; color: var(--muted); font-size: 14px; }
button.icon:hover { color: var(--danger); background: #ffe4e6; }
button.tool { background: #fff; padding: 4px 10px; border-radius: 6px; }
button.tool.checked { background: var(--primary-lt); border-color: #93c5fd; color: var(--primary-dk); }
button.export { background: #fff; border-radius: 9px; padding: 10px 12px; text-align: left; min-height: 58px; display: block; width: 100%; }
button.export:hover { border-color: #93c5fd; background: #f8fbff; }
button.export.primary { background: var(--primary); }
button.export .t { font-weight: 700; display: block; }
button.export .d { font-size: 11.5px; font-weight: 400; color: var(--muted); display: block; }
button.export.primary .d { color: #dbeafe; }
#exports { display: flex; flex-direction: column; gap: 9px; }
input[type=text], input[type=number], select, textarea { font: inherit; background: #fff; border: 1px solid #cbd5e1;
  border-radius: 6px; padding: 4px 7px; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input:disabled, select:disabled { background: #f1f5f9; color: var(--muted); }
input[type=number] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.unit { display: flex; align-items: center; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; min-width: 0; }
.unit input { border: none; flex: 1; width: 100%; }
.unit span { color: var(--muted); padding-right: 7px; white-space: nowrap; font-size: 12px; }
.unit:focus-within { border-color: var(--primary); }
textarea { resize: vertical; }

/* centre: tabs + drawing */
.tabs { display: flex; gap: 2px; }
.tab { background: transparent; border: none; border-radius: 0; color: var(--muted); padding: 7px 16px; }
.tab:hover { background: transparent; color: var(--text); }
.tab.checked { color: var(--primary-dk); border-bottom: 2px solid var(--primary); }
.pane { flex: 1; min-height: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar.pad { padding: 2px 2px; }
#canvas-wrap { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; user-select: none; }
#canvas.dragging { cursor: grabbing; }
#empty-state { position: absolute; inset: 0; background: var(--sub); border: 2px dashed #cbd5e1; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.big { font-size: 20px; font-weight: 700; }
#empty-state .primary { width: 170px; margin-top: 8px; }
#ascii { flex: 1; margin: 0 -8px -8px; overflow: auto; font: 11.5px/1.25 "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  background: #0b1220; color: #d1e3ff; padding: 10px; border-radius: 0 0 10px 10px; white-space: pre; }

/* results */
#results { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chip { background: var(--primary-lt); color: var(--primary-dk); border-radius: 6px; padding: 5px 8px; }
.view-head { font-size: 11.5px; font-weight: 800; color: var(--muted); letter-spacing: 1px; margin-top: 4px; }
.kpis { display: flex; gap: 6px; }
.kpi { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px 8px; }
.kpi .lab { color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi .val { font-size: 19px; font-weight: 700; }
.area { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px 7px;
  display: grid; grid-template-columns: 12px 1fr auto; gap: 1px 8px; align-items: center; }
.area.total { background: var(--sub); }
.area.global { background: #fff1f2; border-color: #fecdd3; }
.area.global .name { color: var(--danger); }
.sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid; }
.sw.ring { border-radius: 6px; border-width: 2px; background: #fff; }
.area .r { text-align: right; }

/* report */
.center.card { padding: 8px; }
.report-body { flex: 1; min-height: 0; display: flex; gap: 8px; }
.sheets { width: 250px; flex: none; display: flex; flex-direction: column; gap: 4px; }
#sheet-list { flex: 1; overflow-y: auto; background: var(--sub); border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
#sheet-list div { padding: 7px 8px; border-radius: 6px; margin: 1px 0; cursor: pointer; white-space: pre-line; }
#sheet-list div:hover { background: var(--border); }
#sheet-list div.sel { background: var(--primary); color: #fff; }
#sheet-view { flex: 1; min-width: 0; background: #dfe5ee; overflow: auto; cursor: grab; position: relative; }
#sheet-img { display: block; margin: 40px; box-shadow: 0 2px 18px rgba(15, 23, 42, .25); background: #fff; }
#logo-prev { width: 120px; height: 52px; background: #fff; border: 1px dashed #cbd5e1; border-radius: 6px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; }
#logo-prev img { max-width: 112px; max-height: 44px; }

/* status bar, overlays */
#statusbar { flex: none; background: #fff; border-top: 1px solid var(--border); color: var(--muted); padding: 3px 12px;
  display: flex; gap: 12px; min-height: 24px; font-size: 12px; white-space: pre; overflow: hidden; }
#coord { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#loading { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; z-index: 10; text-align: center; padding: 16px; }
#loading-bar { width: min(320px, 80vw); height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
#loading-bar > div { height: 100%; width: 0; background: var(--primary); transition: width 2.5s ease-out; }
#drop-overlay { position: fixed; inset: 12px; border: 3px dashed var(--primary); border-radius: 16px; background: rgba(219, 234, 254, .85);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; z-index: 9; pointer-events: none; }
#toast { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%); background: var(--bar); color: #fff; padding: 8px 14px;
  border-radius: 6px; z-index: 11; max-width: 80vw; white-space: pre-line; }
body.busy, body.busy * { cursor: progress !important; }

/* narrow screens: stack the three columns */
@media (max-width: 1100px) {
  body { overflow: auto; }
  #body { flex-direction: column; flex: none; }
  .left, .right { width: auto; overflow: visible; padding-right: 0; }
  .center { min-height: 70vh; }
  #topbar { height: auto; flex-wrap: wrap; }
  .sheets { width: 140px; }
}
