:root {
  --ink: #14212b;
  --muted: #5d6b76;
  --line: #d9e2ea;
  --paper: #f4f7fa;
  --card: #ffffff;
  --accent: #0f7a6c;
  --accent-deep: #0a554c;
  --warm: #c45c26;
  --good: #1f7a4d;
  --bad: #b42318;
  --shadow: 0 18px 40px rgba(20, 33, 43, 0.08);
  --radius: 18px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 122, 108, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(196, 92, 38, 0.10), transparent 28%),
    linear-gradient(180deg, #eef3f7 0%, var(--paper) 48%, #e8eef3 100%);
}

button, input, select { font: inherit; }
a { color: var(--accent-deep); }

.app {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
}
.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.brand-mark {
  display: grid;
  gap: 6px;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-deep);
}
.brand h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.lead {
  margin: 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: rgba(255,255,255,.72); border-color: var(--line); color: var(--ink); }
.btn-warm { background: var(--warm); color: #fff; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid rgba(217, 226, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid input,
.form-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}
.form-grid input:focus,
.form-grid select:focus {
  outline: 2px solid rgba(15, 122, 108, 0.25);
  border-color: var(--accent);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f7fafb);
}
.kpi .value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.kpi .label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi.accent .value { color: var(--accent-deep); }
.kpi.warm .value { color: var(--warm); }

.table-card { margin-bottom: 16px; }
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 14px;
}
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  background: #eef4f7;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}
td.product-col, th.product-col {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  min-width: 180px;
  white-space: normal;
  box-shadow: 4px 0 10px rgba(20,33,43,.05);
}
th.product-col { background: #eef4f7; z-index: 3; }
tbody tr:nth-child(even) td { background: #f8fbfd; }
tbody tr:nth-child(even) td.product-col { background: #f8fbfd; }
.money, .num {
  font-family: var(--mono);
  text-align: right;
}
.cell-input {
  width: 96px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  text-align: right;
  font-family: var(--mono);
  background: #fff;
}
.cell-input.is-cost { color: var(--bad); }
.cell-input.is-qty { color: var(--accent-deep); }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.stack { display: grid; gap: 10px; }
.row-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.row-line strong { font-family: var(--mono); }
.row-line.total {
  border-bottom: 0;
  margin-top: 4px;
  padding-top: 12px;
  font-size: 16px;
}
.row-line.neg strong { color: var(--bad); }
.row-line.pos strong { color: var(--good); }

.model-bar {
  margin: 0;
  padding: 16px;
}
.model-grid {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  align-items: end;
}
.model-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 100%;
}
.model-actions .btn { width: 100%; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.footer-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 960px) {
  .panel-grid, .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .model-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .app { width: min(100% - 20px, 1280px); padding-top: 18px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 140px; }
}
