:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --muted: #6b7280;
  --text: #111827;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --border: #e5e7eb;
  --accent: #16a34a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px calc(56px + env(safe-area-inset-bottom));
}

.page-header h1 { margin: 0 0 4px; font-size: 24px; }
.page-header .subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.hero-logo { display: block; width: 80%; max-width: 100%; height: auto; margin: 8px auto 12px; }

.section-title { font-size: 16px; margin: 16px 0 12px; color: var(--muted); font-weight: 600; }

/* 表单提示样式 */
.form-hint {
  margin: -8px 0 16px 0;
  padding: 8px 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 8px;
}

.hint-text {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  overflow-x: auto; /* mobile tables scroll */
  -webkit-overflow-scrolling: touch;
}

.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border); }
.data-table tbody tr:nth-child(odd) { background: rgba(0,0,0,0.015); }
.data-table tbody tr:hover { background: rgba(37,99,235,0.06); }
.data-table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); z-index: 1; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table input[type="number"], .data-table input[type="text"] {
  width: 100%;
}

/* Morning table: responsive, no horizontal scroll */
#morningTableContainer { overflow-x: visible; }
#morningTable { min-width: 0; width: 100%; table-layout: fixed; }
#morningTable th:nth-child(1),
#morningTable td:nth-child(1) { width: 46%; }
#morningTable th:nth-child(2),
#morningTable td:nth-child(2) { width: 54%; text-align: center; }

/* Ensure 5-digit values visible for lift strips and car speed */
#controlTable td:nth-child(3) input[type="number"], /* 提升机条数（5位） */
#controlTable td:nth-child(6) input[type="number"] { /* 车速（5位） - 列位左移一格 */
  width: 9ch;
  min-width: 9ch;
  text-align: center;
}
#controlTable td:nth-child(4) input[type="number"] { /* 人工装箱数（3位） */
  width: 6ch;
  min-width: 6ch;
  text-align: center;
}
#controlTable td:nth-child(5) input[type="number"] { /* VARIOS 百分比（2位） */
  width: 5ch;
  min-width: 5ch;
  text-align: center;
}

/* Ensure all table inputs are centered by default */
.data-table input[type="number"],
.data-table input[type="text"] { text-align: center; }

/* Two-line display for remaining minutes and target time */
#controlTable td:nth-child(2), /* 计划生产箱数列 */
#controlTable td:nth-child(8), /* 还需生产分钟数列 */
#controlTable td:nth-child(9) { /* 关烟丝时间列 */
  white-space: pre-line;
  line-height: 1.2;
  font-size: 13px;
}

.page-note {
  position: static; /* place at bottom in normal flow */
  margin: 16px 12px calc(24px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  background: transparent;
  padding: 4px 0;
  border: 0;
  box-shadow: none;
}

.empty-hint { color: var(--muted); padding: 12px 0 0; }

.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; }
.meta-text { color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 12px; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; color: var(--muted); }

/* 机台月末模式勾选框样式 */
.machine-month-end {
  margin-top: 8px;
  padding: 4px 0;
}

.machine-month-end .checkbox-label {
  font-size: 12px;
  color: var(--muted);
}

.form-option { margin-bottom: 16px; }
.checkbox-field { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  cursor: pointer; 
  padding: 8px 0;
}
.checkbox-field input[type="checkbox"] { 
  width: 18px; 
  height: 18px; 
  cursor: pointer; 
  accent-color: var(--primary);
}
.checkbox-label { 
  font-size: 14px; 
  color: var(--text); 
  user-select: none;
}
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  outline: none;
  font-size: 16px; /* prevent iOS zoom */
  height: 40px;
}
input[type="number"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.data-table input[type="text"] {
  font-size: 16px;
  height: 40px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}

.form-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:hover { border-color: #cfd6e4; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary-600);
  color: #ffffff;
}
.btn-primary:hover { background: var(--primary-600); color: #ffffff; }

.btn-secondary {
  background: #f3f4f6;
  color: #111827;
}


/* wizard */
#wizardOverlay { position: fixed; inset: 0; z-index: 1000; }
.wizard-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.wizard-modal { position: relative; width: min(92vw, 440px); margin: 8vh auto; }
.wizard-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.wizard-header h3 { margin: 0; font-size: 18px; }
.wizard-step { color: var(--muted); font-size: 13px; }
.wizard-body { padding: 6px 0 4px; }
.form-error { color: #ef4444; font-size: 12px; margin-top: 6px; }

@media (max-width: 720px) {
  .container { padding: 16px 12px calc(72px + env(safe-area-inset-bottom)); }
  .page-header h1 { font-size: 20px; }
  .page-header .subtitle { font-size: 13px; }
  .section-title { font-size: 15px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 48%; }
}


