:root {
  --bg: #eef3f8;
  --panel: #fff;
  --text: #071426;
  --muted: #5d6f88;
  --border: #cbd8e6;
  --green: #17a34a;
  --teal: #0f766e;
  --blue: #2563eb;
  --slate: #475569;
  --red: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-weight: 650;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; border-radius: 8px; padding: 13px 22px; font-weight: 800; }
.hidden { display: none !important; }
.primary { background: var(--green); color: #fff; }
.teal { background: var(--teal); color: #fff; }
.blue { background: var(--blue); color: #fff; }
.slate { background: var(--slate); color: #fff; }
.danger { background: var(--red); color: #fff; }
.wide { width: 100%; }
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid #94a3b8;
  padding: 30px 34px;
}
.login-logo { display: block; width: 300px; max-width: 90%; margin: 0 auto 18px; }
.login-card h1 { text-align: center; margin: 6px 0 28px; font-size: 28px; }
label { display: block; margin: 12px 0; }
input, select, textarea {
  width: 100%;
  border: 1px solid transparent;
  background: #f6f8fb;
  padding: 12px;
  margin-top: 7px;
  min-height: 42px;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--green);
}
textarea { resize: vertical; min-height: 64px; }
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  margin: 18px 0 6px;
  cursor: pointer;
}
.check-line span { line-height: 1; }
.fill-check {
  margin: 2px 0 14px;
  font-size: 16px;
}
.fill-check input {
  margin-top: 1px;
}
.status { text-align: center; color: var(--green); min-height: 48px; white-space: pre-line; }
.app {
  min-height: 100vh;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: 8px; }
.brand img { width: 52px; height: 52px; object-fit: contain; }
.brand h1 { font-size: 34px; margin: 0; white-space: nowrap; }
nav { display: flex; gap: 16px; }
.clock { margin-left: auto; font-size: 20px; white-space: nowrap; }
.shift-banner {
  width: calc(100% - 36px);
  margin: 14px 18px 0;
  background: #dc2626;
  color: #fff;
  animation: blink 1s infinite;
  font-size: 24px;
}
.shift-banner.saved { background: #16a34a; animation: none; }
@keyframes blink { 50% { opacity: .45; } }
.top-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  width: 100%;
  min-width: 0;
}
.top-grid > div { min-width: 0; }
h2 { margin: 0 0 12px; font-size: 24px; }
.process-tanks { display: grid; gap: 10px; }
.process-card, .empty-card, .tank-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}
.process-card {
  padding: 12px 14px;
  height: 164px;
  overflow: hidden;
}
.process-card h3, .empty-card h3, .tank-card h3 { text-align: center; margin: 0 0 10px; font-size: 19px; }
.process-card input {
  text-align: center;
  color: var(--green);
  font-size: 20px;
  min-height: 46px;
  padding: 8px;
  margin-top: 0;
}
.process-card textarea {
  height: 56px;
  min-height: 56px;
  padding: 7px 8px;
  margin-top: 8px;
  overflow: auto;
  resize: none;
}
.empty-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 152px);
  grid-auto-columns: 184px;
  gap: 12px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  touch-action: pan-x pan-y;
}
.empty-card {
  padding: 12px 16px;
  height: 140px;
  display: flex;
  flex-direction: column;
}
.tank-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 12px;
  min-height: 30px;
}
.tank-icon {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}
.amount-badge { background: #22c55e; color: #04130a; padding: 8px 14px; font-weight: 900; }
.empty-card button {
  width: 100%;
  padding: 10px;
  margin-top: auto;
  line-height: 1.1;
}
.section { padding: 0 18px 18px; }
.product-header { display: flex; align-items: center; gap: 18px; margin: 14px 0 10px; }
.product-header h2 { margin: 0; }
.product-total { font-size: 20px; }
.tank-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 250px;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  touch-action: pan-x pan-y;
}
.tank-card {
  min-height: 420px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  border-width: 2px;
  scroll-snap-align: start;
}
.tank-card.ready { animation: borderPulse 1s infinite; }
@keyframes borderPulse { 50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, .18); } }
.product-name { text-align: center; color: var(--green); font-size: 18px; margin-bottom: 10px; }
.date-line { text-align: center; color: var(--muted); margin-bottom: 12px; }
.countdown { text-align: center; color: var(--green); font-size: 24px; line-height: 1.35; margin: 10px 0; animation: blink 1.2s infinite; }
.ready-label { text-align: center; background: #22c55e; padding: 7px; color: #020617; margin: 3px 0 8px; }
.small-text { color: var(--muted); font-size: 13px; margin: 8px 0; }
.measure-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.measure-grid label, .note-label { margin: 4px 0; font-size: 12px; color: #506382; }
.measure-grid input, .note-label textarea { padding: 8px; min-height: 28px; margin-top: 4px; }
.note-label textarea { min-height: 40px; height: 40px; }
.card-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.card-actions button { padding: 9px 8px; }
.filling-card {
  align-items: center;
  justify-content: center;
  min-height: 310px;
  max-height: 310px;
}
.clock-icon { color: var(--green); font-size: 64px; margin: 18px 0 8px; }
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .18);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 20px;
}
.modal {
  background: #fff;
  border: 1px solid var(--border);
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, .25);
}
.modal.large { width: min(1420px, 98vw); }
.modal h2 { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.tabs { display: flex; gap: 10px; margin: 12px 0 18px; }
.tabs button.active { background: var(--green); color: #fff; }
.report-filter { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.report-body {
  border: 1px solid var(--border);
  padding: 16px;
  max-height: 66vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.location-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.report-box { border: 1px solid var(--border); padding: 14px; background: #f8fafc; min-height: 180px; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th, .report-table td { padding: 8px; text-align: left; border-bottom: 1px solid #dbe4ef; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.settings-grid.single { grid-template-columns: minmax(420px, 760px); }
.muted { color: var(--muted); }
.empty-grid,
.tank-row,
.report-body,
.modal {
  scrollbar-color: #94a3b8 #e2e8f0;
  scrollbar-width: auto;
}
.empty-grid::-webkit-scrollbar,
.tank-row::-webkit-scrollbar {
  height: 18px;
}
.report-body::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 18px;
  height: 18px;
}
.empty-grid::-webkit-scrollbar-track,
.tank-row::-webkit-scrollbar-track,
.report-body::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 999px;
}
.empty-grid::-webkit-scrollbar-thumb,
.tank-row::-webkit-scrollbar-thumb,
.report-body::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border: 4px solid #e2e8f0;
  border-radius: 999px;
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .top-grid, .location-grid, .settings-grid { grid-template-columns: 1fr; }
  .brand h1 { font-size: 26px; }
  nav { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  .topbar {
    gap: 10px;
    padding: 10px;
  }
  .brand {
    width: 100%;
    gap: 8px;
  }
  .brand img {
    width: 44px;
    height: 44px;
  }
  .brand h1 {
    font-size: 24px;
    white-space: normal;
  }
  nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  nav button,
  #settingsOpen {
    padding: 11px 8px;
  }
  .clock {
    margin-left: 0;
    font-size: 16px;
  }
  .top-grid,
  .section {
    padding-left: 12px;
    padding-right: 12px;
  }
  .empty-grid {
    grid-template-rows: repeat(2, 152px);
    grid-auto-columns: minmax(158px, 46vw);
    padding-bottom: 24px;
    margin-bottom: 6px;
  }
  .tank-row {
    grid-auto-columns: calc(100vw - 36px);
    gap: 14px;
    padding: 0 4px 24px 0;
    margin-bottom: 10px;
  }
  .tank-card {
    width: calc(100vw - 36px);
    min-height: 0;
  }
  .card-actions {
    gap: 8px;
  }
  .card-actions button {
    padding: 12px 6px;
    min-width: 0;
  }
  .modal-root {
    align-items: start;
    padding: 10px;
  }
  .modal {
    width: 100%;
    max-height: 94vh;
    padding: 18px;
  }
  .form-row,
  .location-grid {
    grid-template-columns: 1fr;
  }
}
