:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --c-mat: #2563eb;
  --c-elec: #f59e0b;
  --c-dep: #8b5cf6;
  --c-def: #ef4444;
  --c-lab: #10b981;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

header.app-header {
  padding: 8px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
header.app-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
header.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.drop {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--muted);
}
.drop:hover, .drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.drop input { display: none; }
.drop-title { font-weight: 600; color: var(--ink); }
.drop-sub { font-size: 12px; margin: 6px 0; }
.drop-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin: 4px 0;
}
.drop-btn:hover { opacity: 0.9; }
.drop-hint { font-size: 11px; margin-top: 6px; }
.help { color: var(--muted); cursor: help; font-size: 11px; }
.ctx-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b22;
    --ink: #f3f4f6;
    --muted: #9ca3af;
    --line: #2a2f3a;
    --accent: #3b82f6;
    --accent-soft: #1e2a44;
    --danger: #f87171;
    --c-mat: #60a5fa;
    --c-elec: #fbbf24;
    --c-dep: #a78bfa;
    --c-def: #f87171;
    --c-lab: #34d399;
  }
  body { background: var(--bg); color: var(--ink); }
  .mini, .inrow, .chip, select.printer-select { background: var(--card); }
  .drop:hover, .drop.over { background: var(--accent-soft); }
}

.models { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.model-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.model-row .m-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  word-break: break-all;
}
.model-row .m-meta { font-size: 12px; color: var(--muted); }
.model-row .m-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.mf { display: flex; flex-direction: column; gap: 2px; }
.mf label { font-size: 11px; color: var(--muted); text-transform: lowercase; }
.mini {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.mini input {
  border: 0;
  outline: none;
  padding: 6px 8px;
  width: 64px;
  font-size: 13px;
  background: transparent;
}
.mini span { padding: 0 8px; color: var(--muted); font-size: 12px; border-left: 1px solid var(--line); }
.mini.time input { width: 40px; text-align: center; }
.m-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
}
.m-del:hover { background: #fee2e2; color: var(--danger); }
.add-manual {
  margin-top: 10px;
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  width: 100%;
}
.add-manual:hover { border-color: var(--accent); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  gap: 6px;
  align-items: center;
}
.chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip .px { color: var(--muted); font-size: 11px; }
.chip.active .px { color: var(--accent); }

.ess { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .ess { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.inrow {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.inrow input {
  border: 0; outline: none; flex: 1; padding: 8px 10px; font-size: 14px; background: transparent;
}
.inrow .unit { padding: 0 10px; color: var(--muted); font-size: 12px; border-left: 1px solid var(--line); white-space: nowrap; }

.slider-block { margin-top: 12px; }
.slider-block .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.slider-block label { font-size: 12px; color: var(--muted); }
.slider-block .v { font-weight: 600; font-size: 13px; }
.slider-block .v small { color: var(--muted); font-weight: 400; }
.slider-block input[type=range] { width: 100%; }
.slider-block .scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }

details.adv { border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; }
details.adv summary {
  cursor: pointer;
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary .caret { margin-left: auto; color: var(--muted); }
details.adv .adv-body { padding: 0 0 14px; display: flex; flex-direction: column; gap: 14px; }
.adv-group { display: flex; flex-direction: column; gap: 8px; }
.adv-group .gt { font-size: 12px; font-weight: 600; color: var(--ink); }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }

.ctx-link { font-size: 12px; color: var(--accent); text-decoration: none; }
.ctx-link:hover { text-decoration: underline; }

.results .r-cost { font-size: 52px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.results .r-price .pv, .results .r-profit .pv { font-size: 26px; font-weight: 700; }
.bar span { transition: width 0.45s ease; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
header.app-header { animation: fadeInUp 0.5s ease both; }
.card { animation: fadeInUp 0.5s ease both; }
.card:nth-of-type(1) { animation-delay: 0.05s; }
.card:nth-of-type(2) { animation-delay: 0.12s; }
.card:nth-of-type(3) { animation-delay: 0.19s; }
@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.bump { animation: bump 0.35s ease; display: inline-block; }
.results .r-cost .cur { font-size: 18px; color: var(--muted); margin-left: 4px; }
.results .r-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.results .r-per { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 8px 0; }
.bar span { display: block; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend .lg { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 6px; align-items: center; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .nm { color: var(--ink); }
.legend .pc { color: var(--muted); text-align: right; }
.legend .am { font-weight: 600; text-align: right; }
.r-price, .r-profit { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.r-price .pl, .r-profit .pl { font-size: 12px; color: var(--muted); }
.r-price .pv, .r-profit .pv { font-size: 22px; font-weight: 700; }
.r-profit .pv.green { color: #059669; }
.r-lead { margin-top: 14px; padding: 14px; background: var(--accent-soft); border-radius: 10px; }
.r-lead h4 { margin: 0 0 4px; font-size: 13px; }
.r-lead p { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.r-lead button {
  border: 0; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.r-cta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.r-cta a {
  font-size: 12px; color: var(--accent); text-decoration: none; border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px;
}
.r-cta a:hover { border-color: var(--accent); }
.r-note { font-size: 11px; color: var(--muted); margin-top: 10px; }

.src-tip { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 8px; }
.src-tip h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; }
.src-tip ol { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.src-tip li { margin-bottom: 4px; }
.src-tip .src-warn { font-size: 11px; color: var(--muted); margin-top: 6px; }
.src-tip b { color: var(--ink); }

.m-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--line); color: var(--muted); text-transform: uppercase; }
.m-badge.stl { background: #dbeafe; color: #1d4ed8; }
.m-badge.mf { background: #fce7f3; color: #be185d; }
.m-badge.man { background: #f3f4f6; color: #4b5563; }
.m-good { color: #059669; font-size: 11px; }

select.printer-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}
