:root { color-scheme: light; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #172033; background: #eef3f8; }
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(150deg, #e8f0fa 0%, #f8fafc 45%, #eaf5f1 100%); min-height: 100vh; }
button, input, select { font: inherit; }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 34px auto 64px; }
.page-header { margin-bottom: 24px; }
.user-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.user-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-nav a { color: #1d4ed8; font-weight: 700; text-decoration: none; }
.user-nav form, .admin-actions form { margin: 0; }
.eyebrow { margin: 0 0 6px; color: #2563eb; font-size: .78rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.04em; }
.page-header > p:last-child { color: #526175; max-width: 680px; }
.composition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.composition-grid.single-composition { grid-template-columns: 1fr; }
.card, .ratio-card, .results { background: rgba(255,255,255,.94); border: 1px solid #dbe4ee; border-radius: 18px; box-shadow: 0 16px 38px rgba(30, 55, 85, .08); }
.card { padding: 22px; }
.card-heading, .results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading h2 { margin: 0; font-size: 1.25rem; }
.card-heading span { color: #64748b; font-size: .86rem; }
.material-select-label { display: block; margin-top: 18px; color: #526175; font-size: .86rem; font-weight: 700; }
#inert-material-select { width: 100%; margin-top: 7px; border: 1px solid #b9c7d8; border-radius: 10px; padding: 10px 12px; background: #fff; }
.selected-material { margin: 6px 0 0; color: #526175; }
.sieve-table { margin-top: 18px; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.table-head, .table-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; min-height: 42px; padding: 7px 12px; }
.table-head { color: #64748b; background: #f8fafc; font-size: .76rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.table-row + .table-row { border-top: 1px solid #edf1f5; }
.table-row output { text-align: right; font-variant-numeric: tabular-nums; }
.input-table input { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 9px; text-align: right; background: #fff; }
input:focus { outline: 3px solid rgba(37,99,235,.16); border-color: #2563eb; }
.ratio-card { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 24px; margin-top: 20px; padding: 22px; }
.field-label { margin-bottom: 7px; color: #526175; font-size: .86rem; font-weight: 700; }
#sludge-percent { width: 150px; border: 1px solid #b9c7d8; border-radius: 10px; padding: 11px 12px; }
#inert-percent { display: block; min-height: 46px; padding: 11px 0; font-size: 1.15rem; font-weight: 800; }
button { min-height: 46px; border: 0; border-radius: 11px; padding: 0 28px; color: white; background: #2563eb; font-weight: 800; cursor: pointer; box-shadow: 0 8px 18px rgba(37,99,235,.24); }
button:hover { background: #1d4ed8; }
.button-secondary { min-height: 38px; padding: 0 16px; color: #1e40af; background: #dbeafe; box-shadow: none; }
.button-secondary:hover { background: #bfdbfe; }
.button-danger { min-height: 36px; padding: 0 14px; background: #b91c1c; box-shadow: none; }
.message { margin: 14px 0 0; padding: 12px 15px; border-radius: 10px; }
.error-message { color: #991b1b; background: #fee2e2; border: 1px solid #fecaca; }
.sludge-fallback-warning { color: #854d0e; background: #fef9c3; border: 1px solid #fde68a; }
.results { margin-top: 24px; padding: 24px; scroll-margin-top: 20px; }
.results-heading { align-items: flex-start; }
.status { border-radius: 999px; padding: 10px 14px; font-size: .9rem; font-weight: 800; }
.status-pass { color: #166534; background: #dcfce7; }
.status-fail { color: #991b1b; background: #fee2e2; }
.result-table-wrap { margin-top: 20px; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 820px; font-size: .9rem; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid #edf1f5; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th:last-child, td:last-child { text-align: left; }
th { color: #526175; background: #f8fafc; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
.cell-pass { color: #166534; font-weight: 700; }
.cell-fail { color: #b91c1c; font-weight: 700; }
.violations { margin-top: 18px; padding: 16px 18px; color: #7f1d1d; background: #fff1f2; border-radius: 12px; }
.violations h3 { margin-bottom: 8px; }
.violations ul { margin: 0; padding-left: 22px; }
.chart-card { height: 430px; margin-top: 22px; padding: 14px; border: 1px solid #e2e8f0; border-radius: 12px; }
[hidden] { display: none !important; }
.auth-shell { width: min(440px, calc(100% - 32px)); margin: 10vh auto; }
.auth-card { padding: 30px; }
.auth-form { display: grid; gap: 18px; margin-top: 24px; }
.auth-form label, .inline-form label { display: grid; gap: 7px; color: #526175; font-weight: 700; }
.auth-form input, .inline-form select { width: 100%; border: 1px solid #b9c7d8; border-radius: 10px; padding: 11px 12px; background: #fff; }
.admin-create-card, .admin-users-card, .credentials-card { margin-top: 20px; }
.inline-form { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; }
.credentials-card { border-color: #86efac; background: #f0fdf4; }
.credentials-card dl { display: grid; gap: 10px; }
.credentials-card dl div { display: grid; grid-template-columns: 130px 1fr; }
.credentials-card dd { margin: 0; font-family: ui-monospace, monospace; font-weight: 800; overflow-wrap: anywhere; }
.admin-actions { display: flex; gap: 8px; min-width: 300px; }
@media (max-width: 760px) {
  .page-shell { width: min(100% - 20px, 680px); margin-top: 22px; }
  .composition-grid, .ratio-card { grid-template-columns: 1fr; }
  .ratio-card { align-items: stretch; gap: 14px; }
  button { width: 100%; }
  .results-heading { display: block; }
  .user-header { display: block; }
  .user-nav { margin-top: 16px; }
  .status { display: inline-block; margin-bottom: 14px; }
  .chart-card { height: 340px; }
}

.prediction-card { margin-top: 24px; }
.prediction-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.prediction-field { display: grid; gap: 6px; }
.prediction-field span { font-size: 0.88rem; font-weight: 600; }
.prediction-field select, .prediction-field input {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
}
.prediction-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
}
.prediction-result { font-weight: 700; color: #166534; }
.recipe-summary { margin: 20px 0; padding: 18px; border: 1px solid #bfdbfe; border-radius: 14px; background: #eff6ff; }
.recipe-summary dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0; }
.recipe-summary dl div { padding: 12px; border-radius: 10px; background: white; }
.recipe-summary dt { color: #64748b; font-size: .82rem; }
.recipe-summary dd { margin: 5px 0 0; font-size: 1.05rem; font-weight: 800; }
.dmax-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.dmax-summary div { padding: 12px; border-radius: 10px; background: #f8fafc; }
.dmax-summary dt { color: #64748b; font-size: .82rem; }
.dmax-summary dd { margin: 5px 0 0; font-weight: 800; }
@media (max-width: 800px) {
  .prediction-form { grid-template-columns: 1fr; }
  .recipe-summary dl { grid-template-columns: 1fr 1fr; }
}
