:root {
  --navy: #0a2450;
  --blue: #0b6eea;
  --blue-2: #2f88f5;
  --blue-soft: #eaf3ff;
  --line: #d9e3f0;
  --line-strong: #c7d5e7;
  --text: #132a4d;
  --muted: #667b99;
  --bg: #f4f7fb;
  --card: #ffffff;
  --kraft: #d9b786;
  --kraft-2: #cda975;
  --success: #16a36b;
  --success-soft: #e8f8f1;
  --warning: #d89411;
  --shadow: 0 8px 24px rgba(26, 60, 104, 0.07);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

button, input, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-block { display: flex; align-items: center; gap: 20px; min-width: 0; }
.brand {
  white-space: nowrap;
  font-size: 29px;
  font-weight: 850;
  letter-spacing: -1.4px;
  color: var(--navy);
}
.brand span { color: var(--navy); }
.brand b { color: #7f91ab; font-weight: 700; }
.product-title {
  border-left: 1px solid var(--line);
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.product-title strong { font-size: 14px; }
.product-title small { color: var(--muted); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 12px; }
.top-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 12px; border-left: 1px solid var(--line); }
.user-chip > span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.user-chip div { display: flex; flex-direction: column; gap: 2px; }
.user-chip small { color: var(--muted); font-size: 11px; }

.primary-button, .secondary-button {
  border-radius: 9px;
  padding: 11px 16px;
  font-weight: 750;
  cursor: pointer;
  transition: .15s ease;
}
.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 14px rgba(11, 110, 234, .2);
}
.primary-button:hover { background: #075fcf; }
.secondary-button {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.secondary-button:hover { border-color: var(--blue-2); color: var(--blue); }

.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: calc(100vh - 120px); }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  min-height: 48px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  color: #355071;
  font-weight: 650;
}
.nav-item > span { color: var(--blue); font-size: 18px; text-align: center; }
.nav-item small { color: #9aa9bd; font-weight: 600; font-size: 10px; }
.nav-item.active { background: #e4f0ff; color: var(--navy); }
.nav-item:disabled { opacity: .72; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 15px 10px 2px; display: flex; justify-content: space-between; align-items: center; }
.mini-mark { font-weight: 800; color: #405a79; }
.version { color: #93a2b6; font-size: 11px; }

.workspace {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(370px, 480px) minmax(520px, 1fr);
  gap: 14px;
  align-items: start;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.title-icon {
  width: 38px;
  height: 38px;
  border: 2px solid var(--blue);
  border-radius: 9px;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
}
h1, h2, p { margin: 0; }
h1 { font-size: 22px; letter-spacing: -.3px; }
.card-title-row p, .preview-head p { color: var(--muted); margin-top: 4px; font-size: 12px; }

.form-section { padding: 16px 20px 18px; border-bottom: 1px solid var(--line); }
.section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--blue);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.section-title em {
  margin-left: auto;
  font-style: normal;
  color: #8798ad;
  background: #f1f4f8;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 750;
}
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { display: flex; flex-direction: column; gap: 6px; color: #536b8a; font-size: 12px; font-weight: 650; min-width: 0; }
input, select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border .12s ease, box-shadow .12s ease;
}
input:focus, select:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(47,136,245,.11); }
input[readonly] { background: #f5f7fa; color: #60728a; }
input::placeholder { color: #b1bece; }

.tech-details { border-top: 1px dashed #dce5f0; margin-top: 15px; }
.subsection-head {
  margin: 0;
  padding: 13px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.subsection-head::-webkit-details-marker { display: none; }
.tech-summary-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.tech-summary-copy strong { font-size: 12px; color: var(--text); }
.tech-summary-copy small { font-size: 10px; color: var(--muted); font-weight: 500; }
.tech-toggle {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  position: relative;
  background: #fff;
}
.tech-toggle::before,
.tech-toggle::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 13px;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
}
.tech-toggle::after { transform: rotate(90deg); transition: transform .15s ease; }
.tech-details[open] .tech-toggle::after { transform: rotate(0); }
.tech-details:not([open]) .subsection-head { padding-bottom: 13px; }
.tech-details:not([open]) .tech-summary-copy small { display: none; }
.tech-grid label { font-size: 10px; }
.tech-grid input { padding: 0 8px; }

.muted-section { background: #fbfcfe; }
.helper-note {
  background: #f1f5fa;
  color: #71839a;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 11px;
  line-height: 1.35;
}

.print-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.choice-group { display: flex; align-items: center; gap: 10px; }
.choice-label { color: #536b8a; font-size: 12px; font-weight: 650; }
.segmented { display: flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; background: #fff; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  min-width: 38px;
  height: 36px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: #40597a;
  cursor: pointer;
  font-weight: 750;
}
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--blue); color: #fff; }
.segmented.wide span { min-width: 58px; }

.form-bottom { padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fbfcfe; }
.input-hint { color: var(--muted); font-size: 11px; line-height: 1.3; }

.preview-card { padding-bottom: 14px; }
.preview-head {
  min-height: 86px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.preview-head h2 { font-size: 21px; margin-top: 2px; }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: .7px; }
.live-badge {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f1f4f8;
  color: #71839a;
  font-size: 11px;
  font-weight: 750;
}
.live-badge span { width: 7px; height: 7px; border-radius: 50%; background: #aab5c3; }
.live-badge.ready { background: var(--success-soft); color: #14754f; }
.live-badge.ready span { background: var(--success); box-shadow: 0 0 0 4px rgba(22,163,107,.1); }
.live-badge.error { background: #fff4e2; color: #9b6500; }
.live-badge.error span { background: var(--warning); }

.drawing-stage {
  min-height: 490px;
  padding: 18px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(180deg, rgba(11,110,234,.03), rgba(11,110,234,0)) border-box;
}
.empty-state { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--muted); }
.empty-state .empty-icon { width: 54px; height: 54px; border-radius: 14px; border: 2px dashed #b8c7d9; display: grid; place-items: center; color: #9fb0c4; font-size: 30px; }
.empty-state strong { color: #526a89; font-size: 15px; }
.empty-state span { font-size: 12px; }
#dieline { width: 100%; height: 455px; overflow: visible; }

.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 16px 10px; }
.result-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  min-height: 66px;
  background: #fbfcfe;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.result-card.accent { background: #f2f7ff; border-color: #cfe1f8; }
.result-card span { color: var(--muted); font-size: 11px; }
.result-card strong { font-size: 18px; letter-spacing: -.2px; }

.tech-results { padding: 0 16px 10px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tech-results > div { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; min-width: 0; }
.tech-results span { display: block; color: var(--muted); font-size: 9px; margin-bottom: 4px; }
.tech-results strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

.status-panel { margin: 0 16px; background: #f6f9fd; border: 1px solid #e2eaf3; border-radius: 8px; padding: 10px 12px; display: grid; grid-template-columns: auto auto 1fr; gap: 14px; color: #60738e; font-size: 10px; }
.status-panel strong { color: #3f5878; }

.formula-strip {
  min-height: 48px;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px 0 248px;
  color: #5e7491;
  font-size: 11px;
  flex-wrap: wrap;
}
.formula-strip strong { color: var(--text); }

.svg-body, .svg-flap, .svg-joint {
  stroke: #26384f;
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}
.svg-body, .svg-flap { fill: var(--kraft); }
.svg-joint { fill: #ebd7b8; }
.svg-trim { fill: url(#trimPattern); stroke: #7f91a6; stroke-width: 1; vector-effect: non-scaling-stroke; }
.svg-score { stroke: #607288; stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.svg-cut { stroke: #0b6eea; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.svg-dim { stroke: #213a5e; stroke-width: 1; vector-effect: non-scaling-stroke; }
.svg-panel-text { fill: #162b48; font-weight: 750; text-anchor: middle; dominant-baseline: middle; }
.svg-panel-extension { stroke: #526a89; stroke-width: .75; vector-effect: non-scaling-stroke; }
.svg-panel-dim { stroke: #213a5e; stroke-width: 1; vector-effect: non-scaling-stroke; }
.svg-panel-dim-text {
  fill: #0a2450;
  font-weight: 850;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .9);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.svg-subtext { fill: #526a89; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
.svg-dim-text { fill: #203b60; font-weight: 750; text-anchor: middle; }
.svg-note-text { fill: #59708e; font-weight: 650; }
.svg-flute { stroke: #0b6eea; stroke-width: 2; vector-effect: non-scaling-stroke; marker-end: url(#blueArrow); }

@media (max-width: 1220px) {
  .workspace { grid-template-columns: 420px minmax(0, 1fr); }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tech-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-panel { grid-template-columns: 1fr; gap: 5px; }
  .formula-strip { padding-left: 24px; }
}

@media (max-width: 980px) {
  .topbar { position: static; height: auto; padding: 14px 16px; align-items: flex-start; }
  .product-title, .top-link, .user-chip { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { grid-template-columns: 1fr; padding: 10px; }
  .drawing-stage { min-height: 390px; }
  #dieline { height: 360px; }
  .formula-strip { padding: 12px 14px; gap: 12px 20px; }
}

@media (max-width: 620px) {
  .brand { font-size: 24px; }
  .primary-button { padding: 9px 11px; font-size: 12px; }
  .grid.three, .grid.two, .grid.four { grid-template-columns: 1fr; }
  .preview-head { align-items: flex-start; flex-direction: column; }
  .drawing-stage { min-height: 330px; padding: 8px; }
  #dieline { height: 310px; }
  .result-grid { grid-template-columns: 1fr; }
  .tech-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-bottom { align-items: flex-start; flex-direction: column; }
}
