:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2733;
  --muted: #6b7885;
  --line: #dfe4ea;
  --brand: #1f5f8b;
  --brand-dk: #16405e;
  --accent: #f39c12;
  --ok: #2e7d51;
  --warn: #b9770e;
  --warn-bg: #fdf3e2;
  --shadow: 0 1px 3px rgba(20,40,60,.08), 0 6px 20px rgba(20,40,60,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5;
}

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--brand-dk), var(--brand));
  color: #fff; padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  background: rgba(255,255,255,.15); font-weight: 700; letter-spacing: .5px;
}
.brand-name { font-size: 18px; font-weight: 600; }
.brand-name .ver { font-size: 12px; font-weight: 400; opacity: .8; }
.brand-sub { font-size: 12px; opacity: .85; }
.job-toggle {
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.job-toggle:hover { background: rgba(255,255,255,.24); }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-right a.job-toggle { text-decoration: none; display: inline-block; }
.user-badge { color: #fff; font-size: 13px; opacity: .9; padding: 0 2px; }
.user-badge b { font-weight: 600; }

/* job panel */
.job-panel { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 20px; }
.job-panel .grid2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; max-width: 900px; }
.job-panel label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.job-panel input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }

/* layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 118px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 12px 0; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 12px 18px 5px; }
.nav-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 18px; cursor: pointer; color: var(--ink); font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-item:hover { background: #eef3f8; }
.nav-item.active { background: #e7f0f8; border-left-color: var(--brand); color: var(--brand-dk); font-weight: 600; }

/* content */
.content { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .content { grid-template-columns: 1fr; } }
.form-panel, .result-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px; }
.form-panel h2 { margin: 0 0 2px; font-size: 18px; color: var(--brand-dk); }
.module-desc { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

#designForm { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select {
  padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,95,139,.12); }
.field .hint { font-size: 11px; color: var(--muted); }

.actions { margin-top: 16px; display: flex; gap: 10px; }
button.primary { background: var(--brand); color: #fff; border: 0; padding: 10px 22px; border-radius: 7px; font-size: 14px; cursor: pointer; font-weight: 600; }
button.primary:hover { background: var(--brand-dk); }
button.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); padding: 10px 18px; border-radius: 7px; cursor: pointer; font-size: 14px; }
button.ghost:disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; }

/* results */
.placeholder { color: var(--muted); padding: 30px 10px; text-align: center; }
.result-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.card { background: #f7fafd; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card .k { font-size: 11.5px; color: var(--muted); }
.card .v { font-size: 18px; font-weight: 700; color: var(--brand-dk); }
.card .u { font-size: 11px; color: var(--muted); }
.status-ok { color: var(--ok); font-weight: 600; }
.status-bad { color: #c0392b; font-weight: 600; }
.warnbox { background: var(--warn-bg); border: 1px solid #f0d9ac; color: var(--warn); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }
.warnbox ul { margin: 6px 0 0; padding-left: 18px; }

svg.diagram { width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }

/* report (also used for print) */
.report { font-size: 13px; color: #222; }
.rpt-head { border-bottom: 2px solid var(--brand); padding-bottom: 6px; margin-bottom: 10px; }
.rpt-title { font-size: 16px; font-weight: 700; color: var(--brand-dk); }
.rpt-sub { font-size: 12px; color: var(--muted); }
.report h4 { margin: 14px 0 5px; color: var(--brand-dk); font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
table.data, table.job { border-collapse: collapse; width: 100%; margin: 4px 0; }
table.data td, table.job td { padding: 4px 8px; border-bottom: 1px dotted var(--line); }
table.data td.k, table.job td.k { color: var(--muted); width: 45%; }
table.data td.v { font-weight: 600; text-align: right; }
table.data td.u { color: var(--muted); width: 60px; }
.warn { background: var(--warn-bg); border: 1px solid #f0d9ac; color: var(--warn); border-radius: 6px; padding: 8px 10px; margin-top: 10px; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; border-top: 1px solid var(--line); background: var(--panel); }

.spans-editor { grid-column: 1/-1; }
.span-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 8px; padding: 8px; background: #f7fafd; border: 1px solid var(--line); border-radius: 8px; }
.span-row .field { flex: 1 1 90px; min-width: 70px; }
.span-row .field label { font-size: 11px; }
.span-row .del-btn { flex: 0 0 auto; align-self: flex-end; height: 36px; }
.mini-btn { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.mini-btn:hover { background: #eef3f8; }
.del-btn { color: #c0392b; border-color: #f0c6c0; }
.supports-row { grid-column: 1/-1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.supports-row select { padding: 5px; border: 1px solid var(--line); border-radius: 5px; }

@media print {
  .topbar, .sidebar, .form-panel, .foot, .job-panel, .actions { display: none !important; }
  .layout, .content { display: block; }
  .result-panel { border: 0; box-shadow: none; }
}
