* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6f8;
  color: #1f2933;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #111827;
  color: #fff;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; }
.topnav { display: flex; gap: 18px; flex: 1; }
.topnav a { color: #cbd5e1; font-weight: 500; }
.topnav a:hover { color: #fff; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-login { color: #9ca3af; font-size: 14px; }
.btn-logout { color: #f87171; }

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

h1 { font-size: 24px; margin-bottom: 6px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.subtitle { color: #6b7280; margin-bottom: 20px; }

.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px;
  margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e5e7eb; font-size: 14px; }
th { color: #6b7280; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn-secondary { background: #e5e7eb; color: #1f2933; }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.row-actions { display: flex; gap: 8px; align-items: center; }

.top-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

form.inline { display: inline; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
label { display: block; font-size: 13px; color: #374151; margin-bottom: 5px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
input:focus, select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.hint { color: #9ca3af; font-size: 12.5px; margin-top: 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.badge-labor { background: #dbeafe; color: #1e40af; }
.badge-overhead { background: #fef3c7; color: #92400e; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

.login-wrap {
  max-width: 360px;
  margin: 80px auto;
  background: #fff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.login-wrap h1 { text-align: center; margin-bottom: 20px; }
.login-wrap .btn { width: 100%; margin-top: 8px; }

.recipe-row, .costitem-row {
  display: grid;
  grid-template-columns: 2fr 1fr 32px;
  gap: 10px;
  margin-bottom: 8px;
  align-items: center;
}
.remove-row {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 6px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-weight: 700;
}

.cost-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 14px;
  margin: 16px 0;
}
.cost-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
}
.cost-box .label { font-size: 12.5px; color: #6b7280; margin-bottom: 4px; }
.cost-box .value { font-size: 20px; font-weight: 700; }
.cost-box.final { background: #eff6ff; border-color: #bfdbfe; }
.cost-box.final .value { color: #1d4ed8; }

.empty-state { text-align: center; padding: 40px 20px; color: #6b7280; }

/* Переключатель (toggle switch) */
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.switch-label { font-weight: 600; font-size: 15px; }
.switch-desc { color: #6b7280; font-size: 13px; margin-top: 2px; }
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d1d5db;
  transition: 0.2s;
  border-radius: 28px;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background-color: #16a34a; }
.switch input:checked + .slider:before { transform: translateX(22px); }

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.tech-item { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 14px; }
.tech-item .k { font-size: 12px; color: #6b7280; }
.tech-item .v { font-size: 14px; font-weight: 600; word-break: break-all; }

.dup-warning {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 12.5px;
}
.density-hints {
  font-size: 12.5px;
  color: #6b7280;
  margin-top: 6px;
}
.density-hints button {
  border: none;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 100px;
  padding: 2px 9px;
  font-size: 12px;
  cursor: pointer;
  margin: 2px 3px 2px 0;
}
.resource-fields { display: none; }
.resource-fields.active { display: grid; }

.recipe-row.with-unit {
  grid-template-columns: 2fr 1fr auto 32px;
}
.unit-label { align-self: center; }

/* Участки производства */
.rate-block {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #fafafa;
}
.rate-block-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
  color: #374151;
}
.rate-preview {
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 14px 16px;
}
.rate-preview-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
  color: #4b5563;
}
.rate-preview-row.total {
  border-top: 1px solid #dbeafe;
  margin-top: 6px;
  padding-top: 10px;
  font-weight: 700;
  font-size: 16px;
  color: #1d4ed8;
}
