:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1f242e;
  --line: #2a2f3a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #38bdf8;
  --accent2: #22c55e;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
header .tabs { display: flex; gap: 6px; }
header .actions { margin-left: auto; display: flex; gap: 6px; }

button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: var(--accent); }
button.active { background: var(--accent); color: #04222e; border-color: var(--accent); font-weight: 600; }
button.primary { background: var(--accent2); color: #04220f; border-color: var(--accent2); font-weight: 600; width: 100%; }
button.danger { border-color: var(--danger); color: #fca5a5; }
button.danger:hover { background: var(--danger); color: #fff; }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr 340px;
  min-height: 0;
}

.sidebar, .finance {
  background: var(--panel);
  overflow-y: auto;
  padding: 10px;
}
.sidebar { border-right: 1px solid var(--line); }
.finance { border-left: 1px solid var(--line); }

.section {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; }
.row span { color: var(--muted); }
.row input[type="number"] { width: 92px; }
input {
  background: #0d1016;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 6px;
}
select {
  width: 100%;
  background: #0d1016; color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 6px; margin-bottom: 6px;
}

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.chip { text-align: left; border-left-width: 4px; line-height: 1.2; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.typeedit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px solid var(--line); }
.mini { display: flex; flex-direction: column; font-size: 10px; color: var(--muted); }
.mini input { width: 52px; padding: 2px 4px; }

.canvaswrap { position: relative; display: flex; flex-direction: column; min-width: 0; }
.selbar { padding: 6px 10px; background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.selbar button { padding: 3px 8px; font-size: 12px; }
.canvas { flex: 1; min-height: 0; background: #0b0d11; }

.flash {
  position: fixed; top: 54px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--accent2); color: #04220f; padding: 8px 16px; border-radius: 8px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
}
.flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* compare-options modal */
.modal-overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 10000; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; width: min(580px, 94vw); max-height: 86vh; overflow: auto; }
.modal h3 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.modal .closebtn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.modal .applybtn { width: auto; padding: 4px 12px; }
.modal tr.best td { color: var(--accent2); font-weight: 700; }

/* finance panel */
.profitbox { background: linear-gradient(135deg,#06351f,#0d1016); border: 1px solid var(--accent2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.profitbox .plabel { font-size: 12px; margin-bottom: 4px; }
.profitbox .prow { display: flex; gap: 14px; }
.profitbox .prow span { font-size: 22px; font-weight: 800; color: var(--accent2); }
.profitbox .prow small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.profitbox .pnote { font-size: 11px; margin-top: 6px; line-height: 1.4; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.kpi { background: #0d1016; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.kpi .kv { font-size: 16px; font-weight: 700; }
.kpi .kl { font-size: 11px; color: var(--muted); }
.finance h4 { margin: 14px 0 6px; font-size: 13px; color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th, .tbl td { padding: 3px 5px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 45vh auto; overflow-y: auto; }
  .sidebar, .finance { max-height: none; }
}
