:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #9aa8b8;
  --accent: #3d8bfd;
  --ok: #3dd68c;
  --err: #ff6b6b;
  --warn: #f5a524;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
header h1 { margin: 0; font-size: 1.15rem; font-weight: 650; }
header .sub { color: var(--muted); font-size: 12px; }
.layout {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 64px);
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
input, select, textarea, button {
  font: inherit;
  color: var(--text);
}
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
}
textarea { min-height: 56px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 90px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button {
  background: #243044;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: #3a1f24; border-color: #5c2b33; }
button:disabled { opacity: .5; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text); }
.check input { width: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
tr.selected { background: #243552; }
tr:hover { background: #1f2b3d; cursor: pointer; }
td input.qty {
  width: 64px;
  padding: 4px 6px;
}
.table-wrap { max-height: 62vh; overflow: auto; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-size: 12px; }
#status {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #121820;
  border: 1px solid var(--border);
  min-height: 40px;
  white-space: pre-wrap;
}
#status.ok { border-color: var(--ok); color: var(--ok); }
#status.err { border-color: var(--err); color: var(--err); }
#preview {
  background: #fff;
  color: #111;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 8px;
}
#preview svg { max-width: 100%; height: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
/* Give the product list most of the workspace */
.layout { grid-template-columns: 270px minmax(600px, 1fr) 240px; }
main.panel { min-width: 0; }
.product-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.product-head h2 { margin-bottom:10px; }
#clearQty { padding:5px 9px; font-size:12px; white-space:nowrap; }
table { font-size:14px; }
th, td { padding:9px 10px; }
td input.qty { width:76px; padding:6px 7px; font-size:15px; }
.table-wrap { max-height:calc(100vh - 165px); }
@media (max-width: 1100px) { .layout { grid-template-columns:1fr; } .table-wrap { max-height:65vh; } }

.layout-panel { margin-top: 10px; }
.layout-panel .row input { width: 100%; }
#preview svg .el:hover rect { stroke: #3d8bfd; }
/* Layout editor: widen the preview column while editing */
body.editing-layout .layout { grid-template-columns: 270px minmax(300px, 1fr) minmax(560px, 640px); }
body.editing-layout #preview svg { max-width: none !important; width: 100%; }
body.editing-layout .layout-panel .row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
