:root {
  --green: #0a5c44;
  --green-light: #1a8c6a;
  --green-pale: #e6f4ef;
  --amber: #d97706;
  --amber-pale: #fef3c7;
  --red: #dc2626;
  --red-pale: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --white: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --header-h: 60px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; overscroll-behavior: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 16px;
  line-height: 1.5;
}

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* Loading */
#loading-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--green);
}
.loading-inner { text-align: center; color: white; }
.ice-icon { font-size: 56px; margin-bottom: 16px; animation: bounce 1s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Auth screens */
.auth-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--green); padding: 24px;
}
.auth-card {
  background: white; border-radius: var(--radius); padding: 32px 24px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .emoji { font-size: 48px; }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--green); margin-top: 8px; }
.auth-logo p { color: var(--gray-400); font-size: 14px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: 16px; background: white; color: var(--gray-800);
  appearance: none; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--green);
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: var(--radius-sm); border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s; width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover { background: var(--green-light); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1.5px solid var(--gray-200); }
.btn-danger { background: var(--red-pale); color: var(--red); border: 1.5px solid #fca5a5; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* App shell */
#app-header {
  height: var(--header-h); background: var(--green); color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 10;
  padding-top: env(safe-area-inset-top, 0px);
}
.header-info { display: flex; flex-direction: column; }
.header-name { font-size: 15px; font-weight: 600; }
.header-sub { font-size: 12px; opacity: 0.75; }
.header-timer { font-size: 15px; font-weight: 700; font-family: monospace; }
.header-badge {
  background: rgba(255,255,255,0.2); border-radius: 20px;
  padding: 4px 10px; font-size: 12px;
}
.location-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.location-dot.on { background: #4ade80; }
.location-dot.off { background: #f87171; }
.location-dot.unknown { background: #fbbf24; }

#app-content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

#app-nav {
  height: var(--nav-h); background: white; border-top: 1px solid var(--gray-200);
  display: flex; align-items: stretch; flex-shrink: 0;
  padding-bottom: var(--safe-bottom); z-index: 10;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#app-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 0 0 64px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; background: transparent; border: none;
  cursor: pointer; color: var(--gray-400); padding: 6px 2px;
  border-top: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.nav-btn.active { color: var(--green); border-top-color: var(--green); }
.nav-btn .nav-icon { font-size: 20px; line-height: 1; }
.nav-btn .nav-label { font-size: 10px; font-weight: 500; }

/* Screens */
.screen { padding: 16px; }
.screen-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: var(--gray-800); }

/* Cards */
.card {
  background: white; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--gray-600); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Segmented control */
.seg-control {
  display: flex; gap: 4px; background: var(--gray-100); border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 16px;
}
.seg-btn {
  flex: 1; padding: 9px 8px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; background: transparent; color: var(--gray-400);
  transition: all 0.15s;
}
.seg-btn.active { background: white; color: var(--green); box-shadow: var(--shadow); }

/* Progress bar */
.progress-bar { background: var(--gray-200); border-radius: 4px; height: 6px; margin-bottom: 4px; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width 0.3s; }
.progress-fill.complete { background: var(--green); }
.progress-text { font-size: 12px; color: var(--gray-400); }

/* Checklist items */
.task-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px;
  background: white; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  margin-bottom: 6px; cursor: pointer; transition: all 0.15s; user-select: none;
}
.task-item.done { background: var(--green-pale); border-color: #6ee7b7; }
.task-check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.15s;
}
.task-item.done .task-check { background: var(--green); border-color: var(--green); }
.task-check svg { display: none; }
.task-item.done .task-check svg { display: block; }
.task-text { font-size: 15px; }
.task-item.done .task-text { text-decoration: line-through; color: var(--gray-400); }

/* Rating emojis */
.rating-row { display: flex; justify-content: center; gap: 20px; margin: 20px 0; }
.rating-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 20px; border-radius: var(--radius); border: 2px solid var(--gray-200);
  background: white; cursor: pointer; transition: all 0.15s; font-size: 40px; min-width: 80px;
}
.rating-btn span.label { font-size: 11px; color: var(--gray-400); font-weight: 500; }
.rating-btn.selected-3 { border-color: #16a34a; background: #f0fdf4; }
.rating-btn.selected-2 { border-color: var(--amber); background: var(--amber-pale); }
.rating-btn.selected-1 { border-color: var(--red); background: var(--red-pale); }

/* Status badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-green { background: var(--green-pale); color: var(--green); }
.badge-amber { background: var(--amber-pale); color: var(--amber); }
.badge-red { background: var(--red-pale); color: var(--red); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Missing items */
.missing-chip {
  display: inline-flex; align-items: center; padding: 7px 12px;
  background: var(--gray-100); border-radius: 20px; border: 1.5px solid var(--gray-200);
  font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.missing-chip:active { background: var(--green-pale); border-color: var(--green); }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.missing-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; background: var(--amber-pale); border: 1.5px solid #fcd34d;
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.missing-item .mi-name { font-weight: 600; font-size: 15px; }
.missing-item .mi-meta { font-size: 12px; color: var(--amber); margin-top: 2px; }
.missing-item.resolved { background: var(--gray-50); border-color: var(--gray-200); opacity: 0.5; }
.missing-item.resolved .mi-name { text-decoration: line-through; }

/* Bowl grid */
.bowls-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.bowl-card {
  background: white; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 10px 8px; text-align: center; cursor: pointer; transition: all 0.15s; min-height: 80px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.bowl-card:active { transform: scale(0.97); }
.bowl-card.st-genug { background: var(--green-pale); border-color: #6ee7b7; }
.bowl-card.st-fast { background: var(--amber-pale); border-color: #fcd34d; }
.bowl-card.st-leer { background: var(--red-pale); border-color: #fca5a5; }
.bowl-num { font-size: 11px; font-weight: 700; color: var(--gray-400); }
.bowl-flavor { font-size: 13px; font-weight: 600; color: var(--gray-800); text-align: center; word-break: break-word; }
.bowl-status { font-size: 10px; }
.bowl-card .no-flavor { font-size: 13px; color: var(--gray-400); }

/* Instructions */
.instruction-card { background: white; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }
.instruction-header {
  padding: 16px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
.instruction-title { font-size: 16px; font-weight: 600; }
.instruction-category { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.instruction-body { padding: 0 16px 16px; display: none; }
.instruction-body.open { display: block; }
.instruction-text { font-size: 14px; line-height: 1.7; color: var(--gray-600); white-space: pre-wrap; }
.instruction-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.instruction-imgs img { width: 100px; height: 80px; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* Shift review */
.review-item {
  background: white; border-radius: var(--radius-sm); padding: 14px;
  margin-bottom: 8px; border: 1.5px solid var(--gray-200);
}
.review-shift { font-weight: 600; margin-bottom: 4px; }
.review-rating { font-size: 28px; }
.review-comment { font-size: 14px; color: var(--gray-600); margin-top: 8px; }
.review-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.review-imgs img { width: 80px; height: 64px; object-fit: cover; border-radius: 6px; cursor: pointer; }

/* Image upload */
.img-upload-area {
  border: 2px dashed var(--gray-200); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; cursor: pointer; color: var(--gray-400);
  font-size: 14px; margin-bottom: 12px;
}
.img-upload-area:active { border-color: var(--green); background: var(--green-pale); }
.img-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.img-preview-wrap { position: relative; width: 80px; height: 80px; }
.img-preview-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.img-preview-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  background: var(--red); color: white; border-radius: 50%; border: none;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Admin */
.admin-section { margin-bottom: 24px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; background: white; border-radius: var(--radius-sm);
  margin-bottom: 8px; border: 1.5px solid var(--gray-200);
}
.user-name { font-weight: 600; font-size: 15px; }
.user-role { font-size: 12px; color: var(--gray-400); }

/* Shift end screen */
.shift-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: white; border-radius: var(--radius-sm); padding: 14px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--gray-400); margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--gray-800); }

/* Toast notifications */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-800); color: white;
  padding: 12px 20px; border-radius: 24px; font-size: 14px;
  opacity: 0; transition: all 0.25s; z-index: 100; white-space: nowrap;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--green); }
#toast.error { background: var(--red); }

/* Fullscreen image */
#img-viewer {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 200; align-items: center; justify-content: center;
}
#img-viewer.open { display: flex; }
#img-viewer img { max-width: 95vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
#img-viewer-close {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px;
  background: rgba(255,255,255,0.2); border: none; border-radius: 50%;
  color: white; font-size: 20px; cursor: pointer;
}

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: white; border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-drag { width: 36px; height: 4px; background: var(--gray-200); border-radius: 2px; margin: 0 auto 16px; }

/* Confirm dialog */
.confirm-shift {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: var(--green);
}
.confirm-card {
  background: white; border-radius: var(--radius); padding: 32px 24px;
  width: 100%; max-width: 380px; text-align: center;
}
.confirm-avatar {
  width: 72px; height: 72px; border-radius: 50%; background: var(--green-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 16px;
}
.confirm-name { font-size: 24px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.confirm-date { font-size: 14px; color: var(--gray-400); margin-bottom: 28px; }
.location-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; margin-bottom: 24px; padding: 10px; background: var(--gray-50); border-radius: 8px; }

/* Helpers */
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--gray-400); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .emoji { font-size: 40px; margin-bottom: 12px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; margin-top: 20px; }
