:root {
  --ink: #172316;
  --muted: #63715c;
  --line: #dfe9d6;
  --panel: #ffffff;
  --band: #f7fbf2;
  --brand: #245f22;
  --brand-dark: #123f18;
  --brand-2: #f9bd24;
  --brand-3: #f68a17;
  --danger: #b73737;
  --focus: #4d8d1d;
  --rail: 72px;
  --content-max: 1440px;
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --shadow: 0 18px 46px rgba(23, 35, 22, .08);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #f3f7ed;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font: inherit;
  max-width: 100%;
}

img, svg {
  max-width: 100%;
}

.login-screen,
.password-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(18px, var(--safe-top)) max(16px, var(--safe-right)) max(18px, var(--safe-bottom)) max(16px, var(--safe-left));
  background: radial-gradient(circle at 50% 30%, rgba(249, 189, 36, .22), transparent 30%), linear-gradient(140deg, var(--brand-dark), var(--brand) 58%, #8bbf2d);
}

.login-screen.hidden { display: none; }
.password-screen.hidden { display: none; }
body.auth-loading .login-screen,
body.auth-loading .password-screen { display: none; }
body.auth-loading .app-header,
body.auth-loading .tabs,
body.auth-loading main,
body.auth-locked .app-header,
body.auth-locked .tabs,
body.auth-locked main { display: none; }

.password-screen {
  z-index: 1100;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  padding: 28px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}

.login-logo {
  width: 118px;
  height: 118px;
  object-fit: contain;
  justify-self: center;
  border-radius: 50%;
  background: #fff;
}

.login-card h1 {
  color: var(--ink);
  text-align: center;
  font-size: 26px;
  line-height: 1.12;
  margin-bottom: 8px;
}

.login-slogan {
  margin: -2px 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
}

.cloud-mode-hint {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  background: var(--band);
  font-size: 13px;
  line-height: 1.35;
}

.cloud-mode-hint.warning {
  border-color: #f3d18c;
  color: #6f4300;
  background: #fff7e3;
}

.api-diagnostic {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  margin: 0;
  padding: max(18px, var(--safe-top)) max(16px, var(--safe-right)) max(18px, var(--safe-bottom)) max(16px, var(--safe-left));
  background: linear-gradient(140deg, var(--brand-dark), var(--brand) 58%, #8bbf2d);
}

.api-diagnostic .login-card {
  text-align: center;
}

.api-diagnostic code {
  display: block;
  padding: 10px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: var(--band);
  white-space: normal;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-pill {
  align-self: center;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--brand-dark);
  background: var(--band);
  font-size: 13px;
}

.user-menu {
  display: inline-grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 190px;
  max-width: 260px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--band);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  font-weight: 700;
}

.user-meta {
  display: grid;
  min-width: 0;
  text-align: left;
}

.user-meta span,
.user-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  color: var(--muted);
  font-size: 11px;
}

.admin-only.hidden,
.role-hidden,
.settings-hidden,
.vent-field.hidden {
  display: none !important;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-left: var(--rail);
  padding: calc(18px + var(--safe-top)) max(clamp(16px, 4vw, 42px), var(--safe-right)) 18px clamp(16px, 4vw, 42px);
  color: var(--ink);
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: window-controls-overlay) {
  body {
    background: var(--panel);
    user-select: none;
  }

  input,
  select,
  textarea,
  .print-report {
    user-select: text;
  }

  .app-header {
    padding-top: max(14px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 6px 22px rgba(18, 63, 24, .08);
  }

  .band {
    box-shadow: none;
  }
}

.eyebrow, .status, .muted { color: var(--muted); }
.app-header .eyebrow, .app-header .status { color: var(--muted); }
.eyebrow { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
h1 { margin: 0; font-size: clamp(22px, 2.8vw, 34px); letter-spacing: 0; }
h2 { margin: 0 0 16px; font-size: 20px; letter-spacing: 0; }
h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: 0; }
.status { display: none; margin: 6px 0 0; }

.brand-block {
  display: grid;
  grid-template-columns: 54px minmax(0, auto);
  gap: 12px;
  align-items: center;
}

.brand-block .status {
  grid-column: 2;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 24px rgba(36, 95, 34, .14);
}

.header-actions, .form-actions, .backup-actions, .history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

button, .file-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: var(--tap);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

button:hover, .file-btn:hover {
  border-color: rgba(36, 95, 34, .38);
}

button:active, .file-btn:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

button.ghost, .file-btn {
  background: #fff;
}

button.danger {
  border-color: #f0cccc;
  color: var(--danger);
  background: #fff6f6;
}

button.small { min-height: 38px; padding: 7px 10px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(46, 125, 182, .28);
  outline-offset: 1px;
}

.tabs {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: var(--rail);
  padding: max(12px, var(--safe-top)) 10px max(12px, var(--safe-bottom)) max(10px, var(--safe-left));
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  border-right: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 10px 0 28px rgba(18, 63, 24, .16);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-brand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 24px rgba(18, 63, 24, .18);
  flex: 0 0 auto;
  overflow: hidden;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 50%;
}

.tab {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-color: rgba(255, 255, 255, .18);
  border-radius: 14px;
  color: rgba(255, 255, 255, .84);
  background: rgba(255, 255, 255, .08);
  flex: 0 0 auto;
}

.tab.active {
  color: var(--brand-dark);
  background: linear-gradient(145deg, var(--brand-2), #fff2a5);
  border-color: rgba(255, 255, 255, .6);
}

.daily-tab::after {
  content: "+";
  position: absolute;
  top: 6px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: var(--brand-dark);
  background: var(--brand-2);
  border: 2px solid currentColor;
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
}

.daily-tab.active::after {
  background: #fff;
}

.tab svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.tab span {
  position: absolute;
  left: 64px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: max-content;
  max-width: 210px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-dark);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  font-size: 13px;
}

.tab:hover span,
.tab:focus-visible span {
  opacity: 1;
  transform: translate(4px, -50%);
}

main {
  margin-left: var(--rail);
  padding: 18px max(clamp(12px, 3vw, 34px), var(--safe-right)) calc(42px + var(--safe-bottom)) max(clamp(12px, 3vw, 34px), var(--safe-left));
  min-width: 0;
}

.view { display: none; }
.view.active { display: block; }

.band {
  width: min(var(--content-max), 100%);
  margin: 0 auto 16px;
  padding: clamp(14px, 2.6vw, 24px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
}

.galpon-picker-band {
  padding-bottom: clamp(12px, 2vw, 18px);
}

.galpon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.galpon-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 9px 10px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, var(--band));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
}

.galpon-card:hover:not(:disabled),
.galpon-card:focus-visible {
  border-color: rgba(35, 95, 34, .45);
  box-shadow: 0 12px 28px rgba(22, 65, 23, .12);
}

.galpon-card.active {
  color: var(--brand-dark);
  border-color: var(--brand);
  background: linear-gradient(180deg, #f6fff2, #edf8e7);
  box-shadow: 0 0 0 2px rgba(37, 95, 34, .12);
}

.galpon-card.disabled {
  opacity: .56;
  cursor: not-allowed;
}

.galpon-card-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--brand-dark);
  background: var(--accent-soft);
  font-weight: 900;
}

.galpon-card-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.galpon-card-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.galpon-card-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.galpon-card-main small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.galpon-card-main small b {
  color: var(--brand-dark);
}

.galpon-card-main em {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-style: normal;
}

.galpon-picker-empty {
  display: grid;
  gap: 4px;
  padding: 14px;
  color: var(--muted);
  background: var(--band);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.summary-band {
  background: #fbfcf8;
  border-top: 5px solid var(--brand-2);
}

.settings-hero {
  background: linear-gradient(135deg, #fff, #f8fff0);
}

.settings-logo-preview {
  width: 82px;
  height: 82px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 10px 28px rgba(36, 95, 34, .14);
}

.settings-tabs {
  width: min(var(--content-max), 100%);
  margin: 0 auto 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.settings-tab {
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--brand-dark);
  background: #fff;
  white-space: nowrap;
}

.settings-tab.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.dashboard-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.dashboard-tab {
  flex: 0 0 auto;
  min-height: 40px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: #fff;
  white-space: nowrap;
}

.dashboard-tab.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.dashboard-panel {
  min-width: 0;
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 46%);
  gap: 16px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--band));
}

.history-heading {
  display: grid;
  gap: 5px;
}

.history-heading h3 {
  margin: 0;
  color: var(--ink);
}

.history-heading p {
  margin: 0;
  line-height: 1.45;
}

.history-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.search-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.search-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metrics span, .kpi {
  border: 1px solid var(--line);
  background: var(--band);
  border-radius: 6px;
  padding: 8px 10px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 22px; }

label {
  display: grid;
  gap: 6px;
  color: #394744;
  font-size: 13px;
  min-width: 0;
}

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid #cbd8d4;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  appearance: auto;
}

input[readonly] { background: #edf3f1; }
textarea { resize: vertical; line-height: 1.45; }
.field-warning {
  display: block;
  margin-top: 5px;
  color: #9a5a00;
  font-size: 12px;
  font-weight: 700;
}
.inventory-zero-warning {
  border-color: #d99100 !important;
  background: #fff8e6 !important;
}
.check-label { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check-label input { width: 20px; min-height: 20px; flex: 0 0 20px; }

.egg-table, .materials, .dispatch-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.egg-tabs,
.shift-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.egg-tab,
.shift-tab {
  min-height: 42px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: var(--band);
}

.egg-tab.active,
.shift-tab.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.egg-panel,
.shift-panel {
  display: none;
  gap: 6px;
}

.egg-panel.active,
.shift-panel.active {
  display: grid;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.feeding-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.feeding-grid.total-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.egg-row, .materials .row, .dispatch-row {
  display: grid;
  grid-template-columns: 150px repeat(6, minmax(82px, 1fr));
  gap: 6px;
  align-items: center;
}

.materials .row { grid-template-columns: 180px repeat(4, minmax(110px, 1fr)); }
.dispatch-row { grid-template-columns: 94px 135px 120px repeat(3, 92px) 120px; min-width: 860px; }
.dispatch-field {
  display: grid;
  gap: 4px;
}
.dispatch-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  font-weight: 700;
  color: var(--brand-dark);
}
.dispatch-select input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}
.dispatch-row.not-selected {
  opacity: .62;
}
.dispatch-row.over-stock {
  border-color: #d97706;
  background: #fff7ed;
}

.inventory-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.inventory-tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: #fff;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.inventory-tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.inventory-panel.settings-hidden,
.inventory-catalog-editor.settings-hidden {
  display: none;
}

.inventory-intro { margin-bottom: 16px; }
.inventory-catalog-editor { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.bird-movement-panel { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.inventory-stock-panel { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.bird-movement-table-wrap { overflow-x: auto; }
.bird-movement-table { width: 100%; min-width: 700px; border-collapse: collapse; font-size: 13px; }
.bird-movement-table th, .bird-movement-table td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.bird-movement-table th:first-child, .bird-movement-table td:first-child, .bird-movement-table th:nth-child(2), .bird-movement-table td:nth-child(2) { text-align: left; }
.bird-movement-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.bird-movement-table td:last-child { color: var(--brand-dark); font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid rgba(36, 95, 34, .24); border-radius: 999px; color: var(--brand-dark); background: #f3faef; font-size: 12px; white-space: nowrap; }
.receipt-list { display: grid; gap: 8px; margin-top: 16px; }
.receipt-filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) auto minmax(130px, 1fr) minmax(130px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}
.receipt-line-editor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(130px, 1fr) auto; gap: 10px; align-items: end; margin-top: 16px; }
.receipt-lines { display: grid; gap: 8px; margin-top: 12px; }
.receipt-line { display: grid; grid-template-columns: 1fr 100px auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcf8; }
.receipt-line span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.daily-inventory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.daily-inventory-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--band); }
.daily-inventory-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.receipt-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.receipt-item:hover,
.receipt-item.active {
  border-color: rgba(36, 95, 34, .45);
  background: #f4faef;
  box-shadow: 0 8px 20px rgba(36, 95, 34, .08);
}
.receipt-item span, .receipt-item small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.receipt-item b { color: var(--brand-dark); }
.receipt-item .history-actions { justify-content: flex-end; }
.receipt-detail-table { min-width: 560px; }

.dispatch-field small {
  display: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.egg-row.header, .materials .header, .dispatch-row.header {
  font-size: 12px;
  font-weight: 700;
  color: #50625e;
}
.egg-row span, .materials span, .dispatch-row span { padding: 8px 0; }
.dispatch-metrics { margin-top: 12px; }
.dispatch-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.dispatch-actions > button {
  min-height: 44px;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.activity {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--band);
}

.activity time { font-weight: 700; color: var(--brand); }
.activity input { width: 18px; min-height: 18px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-grid.executive-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: -6px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.kpi-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.light {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04);
}

.light.good { background: var(--brand); }
.light.warn { background: #d97706; }
.light.danger { background: var(--danger); }
.light.neutral { background: #9ca3af; }

.kpi {
  position: relative;
  padding-top: 24px;
}

.kpi::before,
.galpon-kpi-metrics > div::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 72px;
  width: 10px;
  height: 10px;
  display: none;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04);
}

.kpi::after,
.galpon-kpi-metrics > div::after {
  content: attr(data-status);
  position: absolute;
  top: 8px;
  right: 10px;
  display: none;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.kpi[data-status]:not([data-status=""])::before,
.galpon-kpi-metrics > div[data-status]:not([data-status=""])::before,
.kpi[data-status]:not([data-status=""])::after,
.galpon-kpi-metrics > div[data-status]:not([data-status=""])::after {
  display: inline-flex;
}

.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi strong { display: block; margin-top: 5px; font-size: 28px; }
.kpi small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.kpi.good { border-color: rgba(31, 105, 49, .35); box-shadow: inset 4px 0 0 var(--brand); }
.kpi.warn { border-color: rgba(217, 119, 6, .42); box-shadow: inset 4px 0 0 #d97706; }
.kpi.danger { border-color: rgba(185, 28, 28, .35); box-shadow: inset 4px 0 0 var(--danger); }
.kpi.good > strong,
.galpon-kpi-metrics > div.good > strong { color: var(--brand-dark); }
.kpi.warn > strong,
.galpon-kpi-metrics > div.warn > strong { color: #9a5a00; }
.kpi.danger > strong,
.galpon-kpi-metrics > div.danger > strong { color: var(--danger); }
.kpi.neutral > strong,
.galpon-kpi-metrics > div.neutral > strong { color: #4b5563; }
.kpi-action {
  margin-top: 8px !important;
  padding-top: 7px;
  border-top: 1px solid rgba(38, 76, 45, .12);
  color: var(--ink) !important;
  font-weight: 600;
}
.kpi.good::before,
.galpon-kpi-metrics > div.good::before { background: var(--brand); }
.kpi.warn::before,
.galpon-kpi-metrics > div.warn::before { background: #d97706; }
.kpi.danger::before,
.galpon-kpi-metrics > div.danger::before { background: var(--danger); }
.kpi.neutral::before,
.galpon-kpi-metrics > div.neutral::before { background: #9ca3af; }
.kpi.good::after,
.galpon-kpi-metrics > div.good::after { color: var(--brand-dark); background: #e7f6df; }
.kpi.warn::after,
.galpon-kpi-metrics > div.warn::after { color: #8a4b00; background: #fff1d6; }
.kpi.danger::after,
.galpon-kpi-metrics > div.danger::after { color: #8f1d1d; background: #ffe0dc; }
.kpi.neutral::after,
.galpon-kpi-metrics > div.neutral::after { color: #4b5563; background: #f3f4f6; }

.galpon-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.galpon-kpi-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdf7);
}

.galpon-kpi-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.galpon-kpi-card header strong,
.galpon-kpi-card header span {
  display: block;
}

.galpon-kpi-card header span,
.galpon-kpi-metrics span,
.galpon-kpi-metrics small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.galpon-kpi-card header b {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--band);
  font-size: 12px;
}

.galpon-kpi-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.galpon-kpi-metrics > div {
  position: relative;
  min-width: 0;
  padding: 26px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.galpon-kpi-metrics strong {
  display: block;
  margin: 3px 0;
  font-size: 18px;
}

.galpon-kpi-metrics .good { border-color: rgba(31, 105, 49, .32); box-shadow: inset 3px 0 0 var(--brand); }
.galpon-kpi-metrics .warn { border-color: rgba(217, 119, 6, .35); box-shadow: inset 3px 0 0 #d97706; }
.galpon-kpi-metrics .danger { border-color: rgba(185, 28, 28, .32); box-shadow: inset 3px 0 0 var(--danger); }

.chart {
  display: grid;
  gap: 8px;
  min-height: 220px;
  min-width: 0;
}

.egg-row.compact {
  grid-template-columns: 150px repeat(3, minmax(92px, 1fr));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 14px;
}

.bi-card {
  min-width: 0;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdf7);
}

.bi-card.wide {
  grid-column: 1 / -1;
}

.bi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bi-card-head h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.bi-card-head span {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--brand-dark);
  background: var(--band);
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.bi-card-head.chart-head {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(188, 207, 181, .55);
}

.bi-card-head.chart-head > div {
  min-width: 0;
}

.chart-title-block {
  display: grid;
  gap: 7px;
}

.chart-title-block h3 {
  font-size: 16px;
  letter-spacing: 0;
}

.chart-title-block > span {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0;
  border: 1px solid rgba(188, 207, 181, .55);
  border-radius: 999px;
  background: #f3faed;
}

.chart-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.chart-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 4px;
  border: 1px solid rgba(188, 207, 181, .5);
  border-radius: 999px;
  background: rgba(246, 250, 240, .82);
}

.chart-maximize-btn {
  min-height: 36px;
  padding-inline: 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.chart-control span {
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.chart-control select {
  min-height: 30px;
  min-width: 118px;
  padding: 4px 28px 4px 10px;
  border: 0;
  border-radius: 999px;
  background-color: #f9fcf6;
  font-weight: 700;
}

.combo-chart {
  display: grid;
  gap: 9px;
  width: 100%;
  min-height: clamp(320px, 34vw, 560px);
  min-width: 0;
}

body.chart-modal-open {
  overflow: hidden;
}

.chart-maximized {
  position: fixed;
  inset: max(10px, var(--safe-top)) max(10px, var(--safe-right)) max(10px, var(--safe-bottom)) max(10px, var(--safe-left));
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-width: none;
  overflow: auto;
  padding: clamp(12px, 2vw, 20px);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #fbfdf7);
  box-shadow: 0 24px 80px rgba(10, 42, 16, .35);
}

.chart-maximized::before {
  content: none;
}

.chart-maximized .combo-chart {
  min-height: min(72vh, 680px);
}

.chart-maximized .axis-chart-wrap {
  display: grid;
  align-items: stretch;
}

.axis-drillbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 12px;
  border: 1px solid rgba(188, 207, 181, .55);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f9fcf6);
}

.axis-path {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.axis-path small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.axis-path strong {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.axis-drillbar button,
.axis-up-btn {
  width: auto;
  min-height: 32px;
  border-radius: 999px;
  white-space: nowrap;
}

.combo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.combo-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.combo-legend .legend-green {
  color: var(--brand-dark);
  font-weight: 700;
}

.combo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.combo-dot.production,
.axis-series.production,
.axis-points.production { background: var(--brand); stroke: var(--brand); fill: var(--brand); }
.combo-dot.feed,
.axis-series.feed,
.axis-points.feed { background: var(--brand-3); stroke: var(--brand-3); fill: var(--brand-3); }
.combo-dot.quality,
.axis-series.quality,
.axis-points.quality { background: var(--brand); stroke: var(--brand); fill: var(--brand); }
.axis-chart-wrap {
  width: 100%;
  overflow: hidden;
  padding-bottom: 4px;
}

.axis-chart {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: auto;
}

.axis-line {
  stroke: #718276;
  stroke-width: 1.4;
}

.grid-line {
  stroke: #dfe8dd;
  stroke-width: 1;
}

.axis-series {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.axis-series.feed {
  stroke-dasharray: 7 5;
}

.axis-points circle {
  stroke: #fff;
  stroke-width: 2;
}

.axis-drill-target {
  cursor: pointer;
}

.axis-drill-target:hover {
  filter: drop-shadow(0 2px 3px rgba(31, 105, 49, .35));
}

.axis-value {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
  font-size: 11px;
  font-weight: 800;
}

.axis-value.production {
  fill: var(--brand-dark);
}

.axis-value.feed {
  fill: #a35d00;
}

.axis-value.quality {
  fill: var(--brand-dark);
}

.axis-text,
.axis-title {
  fill: var(--muted);
  font-size: 12px;
}

.axis-title {
  font-weight: 700;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(78px, 118px) minmax(0, 1fr) minmax(54px, 70px);
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-width: 0;
}

.bar-row > span,
.bar-row > strong,
.stacked-row > span,
.stacked-row > strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 20px;
  background: #e7eeeb;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand-3));
}

.bar-fill.alt { background: linear-gradient(90deg, var(--danger), var(--brand-3)); }
.bar-fill.feed { background: linear-gradient(90deg, #2f6f73, #8fc6a3); }
.bar-fill.stock { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); }

.stacked-row {
  display: grid;
  grid-template-columns: minmax(78px, 118px) minmax(0, 1fr) minmax(58px, 78px);
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-width: 0;
}

.stacked-track {
  display: flex;
  height: 22px;
  overflow: hidden;
  border-radius: 4px;
  background: #e7eeeb;
}

.stacked-good { background: var(--brand); }
.stacked-bad { background: var(--danger); }

.sparkline {
  width: 100%;
  max-width: 100%;
  min-height: 220px;
  height: auto;
}

.inventory-chip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.inventory-chip {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.inventory-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.inventory-chip strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.daily-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.daily-summary-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.daily-summary-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.daily-summary-card strong {
  color: var(--brand-dark);
}

.daily-summary-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
}

.daily-summary-card dt {
  color: var(--muted);
  font-size: 12px;
}

.daily-summary-card dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.history-list { display: grid; gap: 10px; }
.compact-list { gap: 8px; }
.saved-date-panel {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.history-drill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: visible;
  box-shadow: 0 8px 20px rgba(23, 35, 22, .04);
  min-width: 0;
}
.history-drill summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(420px, 1.65fr);
  gap: 16px;
  align-items: center;
  padding: 13px 14px;
  cursor: pointer;
  background: var(--band);
  min-height: 54px;
}

.history-summary-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.history-drill summary strong,
.history-summary-main strong {
  color: var(--brand-dark);
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-summary-main span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  word-break: normal;
}

.history-summary-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 12px;
  min-width: 0;
}

.history-summary-metrics span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.history-summary-metrics small,
.history-summary-metrics em {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  font-style: normal;
}

.history-summary-metrics strong {
  color: var(--ink);
  font-size: 15px;
}
.history-drill-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}
.history-drill .history-drill {
  margin-left: 0;
  border-left: 3px solid rgba(31, 105, 49, .16);
}
.compact-record {
  background: #fff;
}
.inventory-list, .unit-list { display: grid; gap: 8px; margin-top: 14px; }
.role-scope-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.role-scope {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.role-scope strong {
  color: var(--brand-dark);
}

.role-scope span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.compact-record {
  grid-template-columns: 22px minmax(230px, 1.15fr) minmax(360px, 1.8fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 96px;
  border-color: rgba(36, 96, 34, .18);
  background: linear-gradient(180deg, #fff, #fffefb);
  box-shadow: 0 8px 22px rgba(23, 35, 22, .06);
}

.history-record-select {
  width: 16px;
  height: 16px;
  border: 1.6px solid rgba(31, 105, 49, .42);
  border-radius: 4px;
  background: #fff;
}

.history-record-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.history-title {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.history-status,
.history-id,
.history-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.history-status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.history-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.history-record-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 14px;
  min-width: 0;
}

.history-record-metrics span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-record-metrics small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.history-record-metrics strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.15;
}

.history-record-metrics em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.25;
}

.compact-record .history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 90px;
}

.compact-record .print {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.icon-action {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.history-empty {
  display: grid;
  gap: 6px;
  padding: 20px;
  border: 1px dashed rgba(36, 96, 34, .28);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.history-empty strong {
  color: var(--ink);
}
.user-item {
  display: grid;
  grid-template-columns: 1fr 120px 220px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}
.subscriber-item {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1.2fr) 100px 100px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}
.inventory-item {
  display: grid;
  grid-template-columns: 1fr 120px 110px 90px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}
.inventory-item.galpon-item {
  grid-template-columns: 1fr 120px 80px minmax(180px, auto);
}
.inventory-item.galpon-total {
  grid-template-columns: 1fr 120px 80px;
  border-color: rgba(36, 95, 34, .35);
  background: #f3faef;
}
.inventory-item strong { display: block; }
.inventory-item span { color: var(--muted); font-size: 13px; }
.undo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(222, 142, 24, .45);
  border-radius: 8px;
  background: #fff7e3;
  color: #6f4300;
}
.undo-banner button { width: auto; }
.unit-item {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: fit-content;
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--band);
}
.history-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.history-title,
.inventory-item strong,
.inventory-chip span,
.inventory-chip strong,
.unit-item span {
  overflow-wrap: anywhere;
}
.plain-list { margin: 0; padding-left: 20px; line-height: 1.6; }
.errors { margin-top: 12px; color: var(--danger); font-weight: 700; }
.file-btn input { display: none; }
.print-report { display: none; }

.print-sheet {
  width: 216mm;
  min-height: 279mm;
  margin: 0 auto;
  padding: 10mm 11mm;
  color: #1f1f1f;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8.5pt;
}

.print-title {
  text-align: center;
  border-bottom: 1px solid #222;
  margin-bottom: 4px;
  padding-bottom: 3px;
}

.print-title h1 {
  margin: 0 0 1px;
  font-size: 14pt;
  font-weight: 700;
  color: #1f1f1f;
}

.print-title p {
  margin: 0;
  font-size: 8.5pt;
}

.print-meta {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 4px 18px;
  margin: 5px 0;
}

.print-line {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.print-line b { font-size: 8pt; }
.print-line span {
  flex: 1;
  min-height: 14px;
  border-bottom: 1px solid #333;
  padding: 0 3px;
}

.print-section-title {
  margin-top: 5px;
  padding: 3px 6px;
  color: #fff;
  background: #2a2a2a;
  font-size: 8.5pt;
  font-weight: 700;
  text-transform: uppercase;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.print-table th,
.print-table td {
  border: 1px solid #b7b7b7;
  padding: 3px 4px;
  height: 18px;
  vertical-align: middle;
}

.print-table th {
  background: #eeeeee;
  font-weight: 700;
  text-align: center;
}

.print-table .left { text-align: left; }
.print-table .right { text-align: right; }
.print-table .center { text-align: center; }
.print-table .value { color: #111; font-weight: 700; }
.print-table .formula { color: #555; font-size: 7.5pt; }
.print-table .blank { color: transparent; }
.print-mini { font-size: 7.5pt; color: #444; font-weight: 400; }
.egg-detail-row > td {
  padding: 0;
}
.egg-detail-table {
  font-size: 6.8pt;
}
.egg-detail-table th,
.egg-detail-table td {
  padding: 2px 3px;
  height: 15px;
}
.egg-detail-table th:first-child {
  width: 22%;
}
.dispatch-print-table {
  font-size: 7.5pt;
}
.dispatch-print-table th,
.dispatch-print-table td {
  padding: 3px;
}
.print-observations {
  min-height: 44px;
  border: 1px solid #b7b7b7;
  border-top: 0;
  padding: 5px;
  white-space: pre-wrap;
}

.print-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.signature {
  border-top: 1px solid #222;
  padding-top: 3px;
  text-align: center;
  font-size: 8pt;
}

.print-version {
  margin-top: 6px;
  text-align: center;
  font-size: 7.5pt;
  color: #555;
}

@media (max-width: 980px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feeding-grid,
  .feeding-grid.total-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three, .split, .kpi-grid, .kpi-grid.executive-kpis, .dashboard-grid, .inventory-chip-grid, .checklist { grid-template-columns: 1fr; }
  .galpon-kpi-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head, .history-item, .app-header { align-items: stretch; flex-direction: column; }
  .compact-record {
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
  }
  .compact-record .history-record-metrics,
  .compact-record .history-actions {
    grid-column: 2;
  }
  .history-drill summary {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-summary-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .history-record-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .header-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .egg-row { grid-template-columns: 130px repeat(6, 88px); min-width: 700px; }
  .egg-row.compact { grid-template-columns: 130px repeat(3, minmax(88px, 1fr)); min-width: 0; }
  .materials .row { grid-template-columns: 170px repeat(4, 130px); min-width: 690px; }
  .dispatch-row { grid-template-columns: 88px 130px 110px repeat(3, 92px) 110px; min-width: 820px; }
  .inventory-item { grid-template-columns: 1fr; }
  .user-item,
  .subscriber-item { grid-template-columns: 1fr; }
  .bi-card-head { flex-direction: column; }
}

@media (max-width: 680px) {
  :root {
    --rail: 54px;
    --tap: 46px;
  }

  .app-header {
    padding: calc(10px + var(--safe-top)) max(10px, var(--safe-right)) 10px max(10px, var(--safe-left));
    margin-left: 0;
    gap: 10px;
  }

  .login-screen,
  .password-screen {
    place-items: center;
    padding: max(16px, var(--safe-top)) max(14px, var(--safe-right)) max(16px, var(--safe-bottom)) max(14px, var(--safe-left));
    overflow-y: auto;
  }

  .login-card {
    width: min(100%, 390px);
    padding: 24px 20px;
    border-radius: 18px;
    gap: 12px;
  }

  .login-logo {
    width: 112px;
    height: 112px;
  }

  .login-card h1 {
    font-size: 24px;
    margin-bottom: 6px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 15px; }

  main {
    margin-left: 0;
    padding: 10px max(8px, var(--safe-right)) calc(86px + var(--safe-bottom)) max(8px, var(--safe-left));
  }

  .tabs {
    position: fixed;
    inset: auto 0 0 0;
    flex-direction: row;
    justify-content: space-around;
    gap: 6px;
    width: 100%;
    min-height: calc(64px + var(--safe-bottom));
    padding: 8px max(8px, var(--safe-right)) max(8px, var(--safe-bottom)) max(8px, var(--safe-left));
    border-right: 0;
    border-top: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 -10px 28px rgba(18, 63, 24, .18);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-brand {
    display: none;
  }

  .tab {
    width: 52px;
    height: 44px;
    min-height: 44px;
    flex: 0 0 52px;
    border-radius: 12px;
  }

  .tab svg {
    width: 22px;
    height: 22px;
  }

  .tab span {
    left: 50%;
    top: auto;
    bottom: 54px;
    transform: translateX(-50%);
  }

  .tab:hover span,
  .tab:focus-visible span {
    transform: translateX(-50%);
  }

  .brand-block {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding-right: 54px;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .band {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 10px 24px rgba(23, 35, 22, .06);
  }

  .grid.four,
  .grid.three,
  .control-grid,
  .feeding-grid,
  .feeding-grid.total-grid,
  .split,
  .role-scope-grid,
  .daily-summary-grid,
  .kpi-grid,
  .dashboard-grid,
  .inventory-chip-grid,
  .checklist {
    grid-template-columns: 1fr;
  }

  .galpon-picker-grid {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 7px;
  }

  .galpon-card {
    min-height: 58px;
    padding: 8px;
  }

  .header-actions,
  .form-actions,
  .backup-actions,
  .history-actions {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .history-drill summary {
    grid-template-columns: 1fr;
  }

  .history-summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .history-drill .history-drill {
    margin-left: 0;
  }

  .history-toolbar,
  .history-tools,
  .history-item {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    padding: 12px;
  }

  .compact-record {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 12px;
  }

  .history-record-select {
    display: none;
  }

  .compact-record .history-record-metrics,
  .compact-record .history-actions {
    grid-column: auto;
  }

  .history-record-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .history-record-metrics strong {
    font-size: 15px;
  }

  .compact-record .history-actions {
    justify-content: stretch;
  }

  .icon-action {
    flex: 1 1 0;
  }

  .dashboard-tab {
    min-height: 38px;
    font-size: 14px;
  }

  .egg-tab,
  .shift-tab {
    min-height: 38px;
    padding-inline: 8px;
    font-size: 14px;
  }

  .compact-record .history-actions {
    justify-content: stretch;
  }

  .header-actions {
    position: absolute;
    top: max(10px, var(--safe-top));
    right: max(10px, var(--safe-right));
    display: flex;
    align-items: center;
    width: auto;
  }

  .header-actions #installBtn {
    display: none;
  }

  .header-actions .share-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    text-indent: -999px;
    position: relative;
  }

  .header-actions .share-btn::before {
    content: "↗";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-indent: 0;
    font-size: 18px;
    font-weight: 800;
  }

  .header-actions #saveBtn {
    display: none;
  }

  .header-actions #logoutBtn {
    display: none;
  }

  .form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--band);
  }

  #registro .form-actions .primary {
    grid-column: 1 / -1;
    min-height: 48px;
  }

  .dispatch-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-actions > *,
  .backup-actions > *,
  .history-actions > *,
  button,
  .file-btn {
    width: 100%;
  }

  .metrics {
    display: grid;
    grid-template-columns: 1fr;
  }

  .kpi strong {
    font-size: 24px;
  }

  .galpon-kpi-grid {
    grid-template-columns: 1fr;
  }

  .galpon-kpi-card {
    padding: 12px;
  }

  .galpon-kpi-metrics {
    grid-template-columns: 1fr;
  }

  .galpon-kpi-metrics strong {
    font-size: 16px;
  }

  .activity {
    grid-template-columns: 64px minmax(0, 1fr) 26px;
    align-items: start;
    padding: 8px;
  }

  .bar-row,
  .stacked-row {
    grid-template-columns: minmax(58px, 76px) minmax(0, 1fr) minmax(48px, 58px);
    gap: 7px;
    font-size: 12px;
  }

  .chart-control {
    width: 100%;
    justify-content: space-between;
  }

  .chart-tools {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    border-radius: 14px;
  }

  .chart-maximize-btn {
    width: 100%;
  }

  .combo-chart {
    min-height: 290px;
  }

  .chart-maximized {
    inset: max(8px, var(--safe-top)) max(8px, var(--safe-right)) max(76px, var(--safe-bottom)) max(8px, var(--safe-left));
    padding: 12px;
  }

  .chart-maximized .combo-chart {
    min-height: 62vh;
  }

  .axis-drillbar {
    align-items: stretch;
    flex-direction: column;
  }

  .axis-path {
    justify-content: space-between;
  }

  .axis-drillbar button {
    width: 100%;
  }

  .axis-chart {
    min-width: 0;
  }

  .axis-value {
    font-size: 10px;
    stroke-width: 2.5px;
  }

  .axis-text,
  .axis-title {
    font-size: 10px;
  }

  .sparkline {
    min-height: 170px;
  }

  .unit-item {
    width: 100%;
  }

  .user-menu {
    display: grid;
    grid-template-columns: 38px;
    min-width: 42px;
    width: 42px;
    height: 42px;
    padding: 2px;
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(18, 63, 24, .14);
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .user-meta {
    position: absolute;
    right: 0;
    top: 48px;
    min-width: 136px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(18, 63, 24, .12);
    opacity: 0;
    pointer-events: none;
  }

  .user-menu:focus-visible .user-meta,
  .user-menu:hover .user-meta {
    opacity: 1;
  }

  .settings-logo-preview {
    width: 68px;
    height: 68px;
  }

  .settings-tabs {
    margin-bottom: 10px;
    gap: 6px;
  }

  .settings-tab {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
  }

  .bi-card {
    padding: 10px;
  }

  .chart {
    min-height: 170px;
  }

  .sparkline {
    min-height: 170px;
  }

  .egg-table,
  .materials,
  .dispatch-table {
    margin-inline: -8px;
    padding-inline: 8px;
  }

  .dispatch-table {
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }

  .dispatch-row.header {
    display: none;
  }

  .dispatch-row {
    min-width: 0;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--band);
  }

  .dispatch-row > span {
    grid-column: 1 / -1;
    padding: 0;
    font-weight: 700;
    color: var(--brand-dark);
  }

  .dispatch-select {
    grid-column: 1 / -1;
    min-height: 34px;
  }

  .dispatch-field {
    min-width: 0;
  }

  .dispatch-field small {
    display: block;
  }

  .dispatch-field:first-of-type,
  .dispatch-field:last-of-type {
    grid-column: 1 / -1;
  }
}

@media (min-width: 681px) and (max-width: 1180px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.executive-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .receipt-filter-panel { grid-template-columns: minmax(0, 1fr) auto repeat(2, minmax(130px, 1fr)); }
  .receipt-filter-panel #receiptDateFilterBtn,
  .receipt-filter-panel #receiptClearFiltersBtn { grid-column: auto; }
}

@media (max-width: 430px) {
  :root {
    --rail: 0px;
  }

  .brand-block {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .tab {
    width: 48px;
    height: 40px;
    min-height: 40px;
    flex-basis: 48px;
  }

  .tab svg {
    width: 20px;
    height: 20px;
  }

  .egg-row { grid-template-columns: 116px repeat(6, 82px); min-width: 620px; }
  .egg-row.compact { grid-template-columns: 108px repeat(3, minmax(72px, 1fr)); min-width: 0; }
  .materials .row { grid-template-columns: 150px repeat(4, 112px); min-width: 610px; }
  .dispatch-row { grid-template-columns: 82px 116px 96px repeat(3, 82px) 100px; min-width: 740px; }
  .inventory-tab { min-height: 34px; padding: 6px 10px; font-size: 12px; }
  .receipt-item { grid-template-columns: 1fr auto; }
  .receipt-item small { grid-column: 1 / -1; }
  .receipt-item .history-actions { grid-column: 1 / -1; justify-content: stretch; }
  .receipt-item .history-actions button { width: 100%; }
  .receipt-line-editor { grid-template-columns: 1fr; }
  .receipt-filter-panel { grid-template-columns: 1fr; }
  .receipt-line { grid-template-columns: 1fr auto; }
  .receipt-line button { grid-column: 1 / -1; }
  .daily-inventory-grid { grid-template-columns: 1fr; }
  .daily-inventory-row { grid-template-columns: 1fr 90px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .tabs {
    gap: 5px;
    padding-left: max(8px, var(--safe-left));
    padding-right: max(8px, var(--safe-right));
  }

  .tab {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .app-header {
    position: static;
  }

  main {
    padding-bottom: calc(74px + var(--safe-bottom));
  }
}

@media (min-width: 1500px) {
  :root {
    --content-max: 1560px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bi-card.wide { grid-column: span 2; }
  .bi-card.wide:last-child { grid-column: 1 / -1; }
}

@media print {
  @page {
    size: letter;
    margin: 0;
  }

  body { background: #fff; }
  body > :not(.print-report) { display: none !important; }
  .print-report { display: block; }
  .print-sheet { box-shadow: none; }
}
