:root {
  --primary: #1a3a6e;
  --primary-dark: #122a52;
  --danger: #dc2626;
  --warn: #ea580c;
  --warn-bg: #fff7ed;
  --warn-border: #fdba74;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Login */
.login-container {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center; padding: 24px;
}
.logo-wrapper { text-align: center; margin-bottom: 32px; }
.logo { width: 150%; max-width: 150%; margin-left: -25%; margin-bottom: 24px; }

#login-form { width: 100%; max-width: 340px; }
#login-form input {
  width: 100%; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 16px; margin-bottom: 12px;
  background: var(--card);
}
#login-form input:focus { outline: none; border-color: var(--primary); }

.btn {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-icon {
  background: none; border: none; font-size: 22px; cursor: pointer;
  padding: 8px; color: var(--text);
}

.error-msg { color: var(--danger); text-align: center; margin-top: 12px; font-size: 14px; }

/* Header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--card);
}
header h2 { font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 2px; }
.btn-icon-small { font-size: 20px; color: var(--text-light); }

/* Day tabs */
.day-tabs {
  display: flex; overflow-x: auto; gap: 6px; padding: 10px 12px;
  background: var(--card); border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex-shrink: 0; padding: 8px 14px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--card);
  font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap; display: flex; flex-direction: column;
  align-items: center; gap: 2px; min-width: 64px; position: relative;
}
.day-tab-date { font-weight: 700; font-size: 14px; }
.day-tab-name { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.day-tab-check { position: absolute; top: -4px; right: -4px; background: #22c55e;
  color: #fff; border-radius: 50%; width: 16px; height: 16px;
  font-size: 10px; display: flex; align-items: center; justify-content: center; }
.day-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.day-tab.ordered { border-color: #22c55e; }
.day-tab.skipped { border-color: #94a3b8; }
.day-tab-skip { position: absolute; top: -4px; right: -4px; background: #94a3b8;
  color: #fff; border-radius: 50%; width: 16px; height: 16px;
  font-size: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.day-tab.past { opacity: 0.5; }
.day-tab.past.ordered { opacity: 0.8; }
.day-tab.past.skipped { opacity: 0.6; }

/* Menu list */
.menu-list { flex: 1; padding: 16px; overflow-y: auto; }
.menu-item {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; transition: border-color 0.15s;
  display: flex; gap: 12px; align-items: flex-start;
}
.menu-item:active { background: #f1f5f9; }
.menu-item.selected {
  border-color: var(--primary); background: #dbeafe;
  box-shadow: inset 4px 0 0 var(--primary);
}
.menu-item.selected .option-number { color: #fff; background: var(--primary);
  border-radius: 50%; width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center; font-size: 14px; }
.menu-item.selected .option-name { color: var(--primary); }
.menu-item.locked { cursor: default; opacity: 0.7; }
.menu-item.locked:active { background: var(--card); }
.menu-item .option-number { font-weight: 700; font-size: 16px; color: var(--primary); min-width: 24px; }
.menu-item .option-body { flex: 1; }
.menu-item .option-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.menu-item .option-desc { font-size: 12px; color: var(--text-light); }

/* Allergens */
.option-desc.allergen-line { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.al-chip {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-align: center;
  background: #f1f5f9; color: var(--text-light); border: 1px solid var(--border);
}
.al-chip.hit { background: var(--warn); color: #fff; border-color: var(--warn); }
.menu-item.allergen-warn, .soup-item.allergen-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.menu-item.allergen-warn:active { background: #ffedd5; }
.menu-item.allergen-warn.selected { background: #ffedd5; border-color: var(--primary); }
.allergen-warn-text { color: var(--warn); font-weight: 600; font-size: 12px; margin-right: 2px; }

.al-list { list-style: none; }
.al-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.al-list li:last-child { border-bottom: none; }
.al-list li.hit { color: var(--warn); font-weight: 600; }
.al-list .al-num { min-width: 28px; font-weight: 700; color: var(--primary); }
.al-list li.hit .al-num { color: var(--warn); }

/* Settings: allergen toggles */
.allergen-row { padding: 10px 0; }
.allergen-row span { font-size: 15px; }
.allergen-row .al-num { font-weight: 700; color: var(--primary); margin-right: 8px; min-width: 24px; display: inline-block; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 75vh; overflow-y: auto;
  background: var(--card); border-radius: 16px 16px 0 0; padding: 8px 20px calc(20px + var(--safe-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15); animation: sheet-up 0.2s ease-out;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 12px; }
.sheet-panel h3 { font-size: 16px; margin-bottom: 8px; }
.sheet-panel .info-text { margin-top: 10px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Soup */
.soup-divider { height: 1px; background: var(--border); margin: 16px 0; }
.soup-item {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 14px 16px;
}
.soup-label { font-size: 11px; text-transform: uppercase; color: var(--text-light);
  font-weight: 600; letter-spacing: 0.5px; margin-bottom: 4px; }
.soup-name { font-weight: 600; font-size: 15px; }

/* Cancel button */
.cancel-divider { border: none; border-top: 2px dashed var(--border); margin: 20px 0 16px; }
.btn-cancel {
  width: 100%; padding: 12px; border: 2px solid var(--danger); border-radius: var(--radius);
  background: #fff; color: var(--danger); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn-cancel:active { background: #fee2e2; }
.btn-skip {
  width: 100%; padding: 12px; border: 2px solid #94a3b8; border-radius: var(--radius);
  background: #fff; color: #64748b; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn-skip:active { background: #f1f5f9; }

/* Holiday */
.holiday-msg { display: flex; justify-content: center; align-items: center;
  min-height: 200px; text-align: center; padding: 24px; }

.order-status {
  padding: 16px 20px; background: var(--card);
  border-top: 1px solid var(--border); text-align: center;
}
.order-status .btn { max-width: 400px; margin: 0 auto; }

/* Settings */
.settings-body { padding: 20px; flex: 1; }
.setting-group { margin-bottom: 24px; }
.setting-group h3 { font-size: 14px; text-transform: uppercase; color: var(--text-light); margin-bottom: 12px; }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.toggle-row span { font-size: 16px; }

.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
}
.setting-row label { font-size: 16px; }
.setting-row select, .setting-row input[type="time"] {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; background: var(--card);
}

.info-text { font-size: 13px; color: var(--text-light); line-height: 1.4; }
.setting-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; margin-bottom: 8px;
  background: var(--card);
}
.setting-input:focus { outline: none; border-color: var(--primary); }

/* Loading spinner */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Splash screen */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #fff; display: none;
  justify-content: center; align-items: center;
}
.splash.active { display: flex; }
.splash video {
  width: 100%;
  object-fit: contain;
}
.splash.fade-out {
  animation: fadeOut 0.4s ease forwards;
}
@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; }
}
