/* PONG QSA — Mobile-first PWA Stylesheet */

/* Prevent pull-to-refresh and accidental swipe navigation */
html {
  overscroll-behavior-y: none;
  overflow: hidden;
  height: 100%;
}
body {
  overscroll-behavior-y: none;
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
}
#main-content {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}
/* Extra protection against pull-to-refresh on iOS/Android.
   OBS: sätts på #main-content (som är scroll-containern), INTE på
   .feed-create-screen — om inner-container blir scroll-container och
   har overscroll-behavior:contain så sväljs wheel-events på desktop. */
.feed-create-screen {
  touch-action: pan-y;
}

/* ============================================================
   CSS VARIABLES / BRAND
   ============================================================ */
:root {
  --navy: #1a1a2e;
  --navy-light: #252547;
  --navy-dark: #12122a;
  --gold: #d4a843;
  --gold-light: #e8c36a;
  --gold-dark: #b8902e;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f0f1f3;
  --gray-200: #e2e4e8;
  --gray-300: #c8ccd2;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --green: #22c55e;
  --green-light: #dcfce7;
  --red: #ef4444;
  --red-light: #fef2f2;
  --orange: #f59e0b;
  --orange-light: #fffbeb;
  --blue: #3b82f6;
  --blue-light: #eff6ff;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);

  --header-height: 56px;
  --nav-height: 72px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --transition: 0.2s ease;
  --transition-slow: 0.35s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  height: -webkit-fill-available;
  background: var(--white);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--white);
  color: var(--gray-700);
  line-height: 1.5;
  overflow: hidden;
  height: 100%;
  height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* RTL support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: var(--white);
}

/* Header */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--navy);
  padding-top: var(--safe-top);
  height: calc(var(--header-height) + var(--safe-top));
}

.header-inner {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 1px;
}

.header-logo-accent {
  color: var(--gold);
}

.header-restaurant {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 6px 12px;
  color: var(--white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.header-restaurant:active {
  background: rgba(255,255,255,0.2);
}

/* Main content */
#main-content {
  flex: 1;
  padding: 16px;
  padding-top: calc(var(--header-height) + var(--safe-top) + 16px);
  transition: opacity var(--transition);
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  min-height: 0;
  transform: translateZ(0);
}

#main-content.fade-out {
  opacity: 0;
}

/* Bottom nav */
#bottom-nav {
  position: relative;
  z-index: 100;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
}
/* In browser mode (not PWA), browser toolbar provides bottom spacing — minimal padding */
.browser-mode #bottom-nav {
  padding-bottom: 4px !important;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px 6px;
  border: none;
  background: none;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
  color: var(--gold);
}

.nav-tab.active svg {
  stroke: var(--gold);
}

.nav-tab:active {
  transform: scale(0.95);
}

.nav-tab svg {
  transition: stroke var(--transition);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--header-height) - var(--safe-top));
  padding: 32px 24px;
  text-align: center;
}

.login-logo {
  font-size: 40px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.login-logo-accent {
  color: var(--gold);
}

.login-subtitle {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 40px;
}

.login-form {
  width: 100%;
  max-width: 320px;
}

.login-label {
  display: block;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
}

[dir="rtl"] .login-label {
  text-align: right;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  text-align: center;
  letter-spacing: 1px;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.login-input:focus {
  outline: none;
  border-color: var(--gold);
}

.login-input::placeholder {
  color: var(--gray-300);
  letter-spacing: 0;
}

/* Code input boxes */
.code-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.code-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.code-digit:focus {
  outline: none;
  border-color: var(--gold);
}

.login-hint {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}

.btn-primary:hover {
  background: var(--gold-light);
}

.btn-primary:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border: 2px solid var(--gray-200);
}

.btn-success {
  background: var(--green);
  color: var(--white);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  min-height: 40px;
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
}

.btn + .btn {
  margin-top: 12px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card + .card {
  margin-top: 12px;
}

.card-tap {
  cursor: pointer;
}

.card-tap:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.greeting {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.greeting-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* Progress ring */
.progress-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress-ring-container {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.progress-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.progress-info h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 2px;
}

.progress-info p {
  font-size: 13px;
  color: var(--gray-500);
}

/* Checklist cards on home */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.checklist-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.checklist-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checklist-card-icon.opening { background: var(--blue-light); color: var(--blue); }
.checklist-card-icon.closing { background: var(--orange-light); color: var(--orange); }
.checklist-card-icon.hygiene { background: var(--green-light); color: var(--green); }
.checklist-card-icon.haccp { background: var(--red-light); color: var(--red); }
.checklist-card-icon.safety { background: #fef3c7; color: #d97706; }
.checklist-card-icon.inventory { background: #e0e7ff; color: #4f46e5; }
.checklist-card-icon.training { background: #fce7f3; color: #db2777; }
.checklist-card-icon.custom { background: var(--gray-100); color: var(--gray-600); }

.checklist-card-info {
  flex: 1;
  min-width: 0;
}

.checklist-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checklist-card-meta {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

.checklist-card-status {
  flex-shrink: 0;
}

.checklist-locked {
  opacity: 0.45;
}
.checklist-locked .checklist-card-meta {
  color: var(--orange);
}

.locked-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--orange-light, #fff3cd);
  color: #856404;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 14px;
}

.all-done-banner {
  text-align: center;
  padding: 2rem 1rem;
}
.all-done-banner h3 {
  color: #27ae60;
  margin-top: 0.75rem;
  font-size: 1.1rem;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.pending {
  background: var(--orange-light);
  color: var(--orange);
}

.status-badge.completed {
  background: var(--green-light);
  color: var(--green);
}

.status-badge.overdue {
  background: var(--red-light);
  color: var(--red);
}

.status-badge.in_progress {
  background: var(--blue-light);
  color: var(--blue);
}

.chevron-right {
  width: 20px;
  height: 20px;
  color: var(--gray-300);
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
}

/* ============================================================
   CHECKLIST FILL SCREEN
   ============================================================ */
.checklist-header {
  margin-bottom: 20px;
}

.checklist-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.checklist-header p {
  font-size: 14px;
  color: var(--gray-500);
}

/* Progress bar at top */
.checklist-progress {
  background: var(--gray-100);
  border-radius: 6px;
  height: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 6px;
  transition: width 0.4s ease;
}

.checklist-progress-text {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
  text-align: right;
}

/* Checklist items */
.checklist-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  transition: border-color var(--transition);
  border: 2px solid transparent;
}

.checklist-item.completed {
  border-color: var(--green);
  background: #f0fdf4;
}

.checklist-item.deviation {
  border-color: var(--red);
  background: var(--red-light);
}

.checklist-item-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.checklist-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  flex: 1;
}

.checklist-item-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.checklist-item-required {
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
}

/* Checkbox item */
.check-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.check-btn.checked {
  border-color: var(--green);
  background: var(--green);
  animation: checkPop 0.3s ease;
}

.check-btn.checked svg {
  opacity: 1;
}

.check-btn svg {
  opacity: 0;
  transition: opacity var(--transition);
}

@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Temperature / number input */
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-700);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.input-field:focus {
  outline: none;
  border-color: var(--gold);
}

.input-field.error {
  border-color: var(--red);
  background: var(--red-light);
}

.input-field.valid {
  border-color: var(--green);
}

.input-unit {
  font-size: 14px;
  color: var(--gray-500);
  white-space: nowrap;
}

.input-range {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.input-range.error {
  color: var(--red);
  font-weight: 600;
}

/* Textarea */
.textarea-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-700);
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.textarea-field:focus {
  outline: none;
  border-color: var(--gold);
}

/* Photo button */
.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.photo-btn:active {
  background: var(--navy-light);
}

.photo-btn.has-photo {
  background: var(--green);
}

.photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.photo-input {
  display: none;
}

/* Signature canvas */
.signature-container {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.signature-canvas {
  width: 100%;
  height: 150px;
  display: block;
  background: var(--white);
}

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

/* Repeatable group */
.repeat-group {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
}

.repeat-group + .repeat-group {
  margin-top: 8px;
}

.repeat-group-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 10px;
}

/* Deviation note */
.deviation-note {
  margin-top: 8px;
  padding: 8px;
  background: var(--red-light);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.2);
}

.deviation-note textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  min-height: 60px;
  resize: vertical;
  background: var(--white);
}

.deviation-note label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 4px;
}

/* Submit button area */
.submit-area {
  position: sticky;
  bottom: 0;
  padding: 16px 0;
  background: linear-gradient(transparent, var(--gray-50) 20%);
  margin-top: 16px;
}

/* Back button */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--gold-dark);
  cursor: pointer;
  margin-bottom: 12px;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   HISTORY SCREEN
   ============================================================ */
.history-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0 4px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.history-item-meta {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ============================================================
   PROFILE SCREEN
   ============================================================ */
.profile-header {
  text-align: center;
  padding: 24px 16px;
}

.profile-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  overflow: hidden;
}
.profile-camera-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.profile-phone {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Avatar picker grid */
.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 12px;
}
.avatar-picker-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 3px solid transparent;
}
.avatar-picker-item:active {
  transform: scale(0.9);
}
.avatar-picker-item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--navy), 0 2px 8px rgba(0,0,0,0.15);
  transform: scale(1.1);
}

.settings-group {
  margin-top: 20px;
}

.settings-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px 8px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--white);
  min-height: 48px;
}

.settings-item:first-of-type {
  border-radius: var(--radius) var(--radius) 0 0;
}

.settings-item:last-of-type {
  border-radius: 0 0 var(--radius) var(--radius);
}

.settings-item:only-of-type {
  border-radius: var(--radius);
}

.settings-item + .settings-item {
  border-top: 1px solid var(--gray-100);
}

.settings-item-label {
  font-size: 15px;
  color: var(--gray-700);
}

.settings-item-value {
  font-size: 14px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-200);
  border-radius: 16px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--green);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* Select dropdown */
.select-field {
  padding: 10px 12px;
  font-size: 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-700);
  -webkit-appearance: none;
  cursor: pointer;
}

/* Logout */
.logout-btn {
  margin-top: 32px;
  text-align: center;
}

.logout-btn button {
  background: none;
  border: none;
  color: var(--red);
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.modal-content {
  position: relative;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Restaurant list in modal */
.restaurant-list {
  display: flex;
  flex-direction: column;
}

.restaurant-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 15px;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  min-height: 48px;
}

[dir="rtl"] .restaurant-option {
  text-align: right;
}

.restaurant-option:active {
  background: var(--gray-50);
}

.restaurant-option.selected {
  background: var(--gold);
  background: rgba(212, 168, 67, 0.1);
  color: var(--gold-dark);
  font-weight: 600;
}

.restaurant-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
}

.restaurant-option.selected .restaurant-option-dot {
  background: var(--gold);
}

/* ============================================================
   PULL TO REFRESH
   ============================================================ */
.pull-indicator {
  text-align: center;
  padding: 12px;
  color: var(--gray-400);
  font-size: 13px;
  transition: opacity var(--transition);
  opacity: 0;
}

.pull-indicator.visible {
  opacity: 1;
}

.pull-indicator .spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   LOADING / TOASTS
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--navy);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 250;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: var(--green);
}

/* ============================================================
   PHOTO VIEW (HISTORY)
   ============================================================ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ============================================================
   RESPONSIVE — larger phones / small tablets
   ============================================================ */
@media (min-width: 420px) {
  .code-digit {
    width: 52px;
    height: 60px;
  }
}

@media (min-width: 768px) {
  #main-content {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
  /* Chat room is always fullscreen, override max-width */
  #main-content.chat-active,
  #main-content:has(.chat-room) {
    max-width: none;
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.3s ease;
}

/* Screen transitions */
.screen-enter {
  animation: fadeIn 0.25s ease;
}

/* ============================================================
   CHAT STYLES
   ============================================================ */

/* Chat badge on nav tab */
.nav-tab { position: relative; }
.chat-badge, .nav-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(18px);
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* Chat header row (messages list title + compose btn) */
.chat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}
.chat-compose-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(212,168,67,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-compose-btn:active { transform: scale(0.92); }

/* Chat list */
.chat-list { display: flex; flex-direction: column; gap: 0; }
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.12s;
}
.chat-list-item:active { background: var(--gray-50); }
.chat-list-item:last-child { border-bottom: none; }
.chat-list-info { flex: 1; min-width: 0; }
.chat-list-name-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.chat-list-name { font-weight: 600; font-size: 15px; color: var(--gray-700); }
.chat-list-time { font-size: 12px; color: var(--gray-400); white-space: nowrap; }
.chat-list-preview { font-size: 13px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-badge {
  background: var(--gold);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}

/* Chat avatar */
.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.chat-avatar.group {
  background: linear-gradient(135deg, var(--navy) 0%, #2d2d5e 100%);
}
.chat-avatar.small { width: 36px; height: 36px; font-size: 14px; }

/* Chat room — fill entire available space */
/* Chat room: fixed overlay, height set by JS via visualViewport */
.chat-room-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--navy, #1a1f36);
  box-sizing: border-box;
  transform: translateX(100%);
}
.chat-room-overlay.chat-ready {
  animation: chatSlideIn 0.35s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
  box-shadow: -4px 0 16px rgba(0,0,0,0.15);
}
.chat-room-overlay.chat-sliding-out {
  animation: chatSlideOut 0.35s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
@keyframes chatSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes chatSlideOut {
  from { transform: translateX(var(--slide-x, 0)); }
  to { transform: translateX(100%); }
}
/* Safe area spacer — navy background behind status bar */
.chat-room-safe-area {
  flex-shrink: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--navy, #1a1f36);
}
.chat-room-overlay .chat-header {
  flex-shrink: 0;
  z-index: 20;
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: var(--navy, #1a1f36) !important;
  color: white !important;
}
.chat-room-overlay .chat-messages {
  background: #f0f0f5;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.chat-back-btn, .chat-settings-btn {
  background: none;
  border: none;
  padding: 4px;
  color: white;
  cursor: pointer;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 600; font-size: 16px; color: white; }
.chat-header-members { font-size: 12px; color: rgba(255,255,255,0.7); }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: scroll;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #f0f0f5;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}
.chat-messages::before {
  content: '';
  flex: 1 1 auto;
  overflow-anchor: none;
}
.chat-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 40px 0;
  font-style: italic;
}

/* Message bubbles */
.message-bubble {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  position: relative;
}
.message-bubble.own {
  align-self: flex-end;
  background: var(--gold);
  color: white;
  border-bottom-right-radius: 4px;
}
.message-bubble.other {
  align-self: flex-start;
  background: white;
  color: var(--gray-700);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.message-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 2px;
}
.message-text { font-size: 15px; line-height: 1.4; }
.message-time {
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
}
.message-bubble.own .message-time { color: rgba(255,255,255,0.7); }
.message-bubble.other .message-time { color: var(--gray-400); }

/* Chat input bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom, 0px));
  background: white;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--gray-200);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  background: var(--gray-50);
  transition: border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
  max-height: 100px;
  resize: none;
}
.chat-input:focus { border-color: var(--gold); background: white; }
.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s;
}
.chat-send-btn:active { transform: scale(0.9); }

/* Attach button */
.chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-attach-btn:active { color: var(--gold); }

/* Attachment preview above input — multiple items */
.chat-attach-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
  overflow-x: auto;
  flex-wrap: wrap;
}
.chat-preview-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border-radius: 10px;
  padding: 6px;
  border: 1px solid var(--gray-200);
}
.chat-preview-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
}
.chat-preview-file-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--gold);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  max-width: 120px;
}
.chat-preview-info span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.chat-preview-size { color: var(--gray-400); font-size: 11px; }
.chat-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-600);
  border: 2px solid white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Attachment picker popup */
.chat-attach-picker {
  position: absolute;
  bottom: 100%;
  left: 4px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  margin-bottom: 8px;
}
.chat-attach-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  width: 100%;
}
.chat-attach-option:hover {
  background: var(--gray-100);
}
.chat-attach-option svg {
  flex-shrink: 0;
  stroke: var(--gray-500);
}

/* Image in message bubble */
.message-image {
  max-width: 240px;
  max-height: 300px;
  border-radius: 12px;
  margin-bottom: 4px;
  cursor: pointer;
  display: block;
}
.message-bubble.own .message-image { margin-left: auto; }

/* File in message bubble */
.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  margin-bottom: 4px;
  text-decoration: none;
  color: inherit;
}
.message-bubble.own .message-file { background: rgba(255,255,255,0.15); }
.message-file-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--gold);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.message-file-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.message-file-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-file-size { font-size: 11px; opacity: 0.6; }

/* Message action menu (long-press) */
/* WhatsApp-style message action overlay */
.msg-action-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.msg-action-container {
  background: white;
  border-radius: 16px;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}
.msg-reaction-bar {
  display: flex;
  justify-content: space-around;
  padding: 12px 8px;
  border-bottom: 1px solid var(--gray-100);
}
.msg-reaction-emoji {
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: transform 0.15s;
}
.msg-reaction-emoji:active { transform: scale(1.3); }
.msg-action-list { padding: 4px 0; }
.msg-action-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 15px;
  color: var(--navy);
}
.msg-action-item:active { background: var(--gray-50); }
.msg-action-item svg { color: var(--gray-400); flex-shrink: 0; }
.msg-action-danger { color: #ef4444; }
.msg-action-danger svg { stroke: #ef4444; }

/* Reaction display on messages */
.msg-reactions-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 4px;
}
.msg-reaction-chip {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.reaction-names {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
}

/* Reply quote inside message bubble */
.chat-reply-quote {
  background: rgba(0,0,0,0.06);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
.chat-reply-quote-name { font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.chat-reply-quote-text { color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* Reply preview above input */
.chat-reply-preview {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: white;
  border-left: 4px solid var(--gold);
  margin: 0 12px;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.chat-reply-preview-content { flex: 1; min-width: 0; }
.chat-reply-preview-name { font-size: 13px; font-weight: 700; color: var(--gold); margin-bottom: 2px; }
.chat-reply-preview-text { font-size: 14px; color: var(--gray-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-preview-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--gray-400); font-size: 18px; border-radius: 50%; }
.chat-reply-preview-close:active { background: var(--gray-100); }

/* Forward overlay (fullscreen) */
.forward-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: white;
  display: flex;
  flex-direction: column;
}
.forward-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: var(--navy);
  color: white;
}
.forward-title { font-size: 18px; font-weight: 700; }
.forward-msg-preview {
  padding: 10px 16px;
  background: var(--gray-50);
  font-size: 13px;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.forward-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-50);
  cursor: pointer;
}
.forward-row:active { background: var(--gray-50); }
.forward-row-info { flex: 1; }
.forward-row-name { font-size: 15px; font-weight: 600; color: var(--navy); }
.forward-row-sub { font-size: 12px; color: var(--gray-400); }

/* @-mention dropdown */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
  padding: 4px 0;
}
.mention-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.mention-row:active { background: var(--gray-50); }
.mention-highlight { font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.message-bubble.other .mention-highlight { color: var(--gold); }

.message-wrapper { position: relative; }
.message-wrapper.msg-highlight {
  background: rgba(191, 163, 76, 0.25);
  border-radius: 12px;
  transition: background 0.5s ease;
}

/* Create chat / user selection */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 14px; color: var(--gray-600); margin-bottom: 6px; }
.form-input {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--gold); }
.chat-search-input {
  border-radius: 22px;
  margin-bottom: 8px;
  background: var(--gray-50);
}
.chat-search-input:focus { background: white; }

/* Selected user chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  margin-bottom: 8px;
}
.chat-chips:empty { display: none; }
.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(212,168,67,0.15);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 16px;
  animation: chipIn 0.15s ease-out;
}
.chat-chip-x {
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  margin-left: 2px;
  opacity: 0.7;
}
.chat-chip-x:hover { opacity: 1; }
@keyframes chipIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Group name area in create-chat */
.chat-groupname-area {
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Start chat button */
.chat-start-btn {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  position: sticky;
  bottom: 16px;
}

.chat-users-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--gray-100); border-radius: var(--radius); }
.chat-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-user-row:active { background: var(--gray-50); }
.chat-user-row.selected { background: rgba(212, 168, 67, 0.08); }
.chat-user-name { flex: 1; font-size: 15px; color: var(--gray-700); }
.chat-user-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
  transition: all 0.12s;
}
.chat-user-row.selected .chat-user-check {
  border-color: var(--gold);
  background: var(--gold);
  color: white;
}

/* Message wrapper + read receipts */
.message-wrapper { display: flex; flex-direction: column; margin-top: 8px; position: relative; }
.message-wrapper.own { align-items: flex-end; }
.message-wrapper.other { align-items: flex-start; }
.message-wrapper.grouped { margin-top: 2px; }

/* Swipe-to-reply */
.swipe-reply-hint {
  position: absolute;
  left: -36px;
  top: 50%;
  transform: translateY(-50%) scale(0.5);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  font-size: 14px;
  transition: transform 0.1s, opacity 0.1s;
}
.swipe-reply-hint.active {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.message-wrapper.swiping {
  transition: none !important;
}
.message-wrapper.snap-back {
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
}
/* Grouped bubble: tighter radius for consecutive messages */
.message-bubble.own.grouped { border-top-right-radius: 4px; }
.message-bubble.other.grouped { border-top-left-radius: 4px; }
.read-receipts {
  font-size: 10px;
  color: var(--gray-400);
  padding: 1px 8px 0;
  min-height: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.read-receipts:empty { display: none; }

/* ============================================================
   FAULT REPORT
   ============================================================ */
.fault-report-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s;
}
.fault-report-btn:active { transform: scale(0.98); }
.fault-report-btn svg:first-child { color: #e8a020; flex-shrink: 0; }
.fault-report-btn span { flex: 1; font-weight: 600; font-size: 15px; color: #333; }
.fault-report-btn svg:last-child { color: #999; flex-shrink: 0; }

/* Prevent accidental gestures on fault report form */
.fault-report-page {
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.fault-back-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 8px;
}

.fault-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.fault-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.fault-field .form-input,
.fault-form .form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.fault-field .form-input:focus,
.fault-form .form-input:focus {
  outline: none;
  border-color: var(--gold);
}

.fault-field textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.fault-photos-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fault-add-photo-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f5f5f5;
  border: 2px dashed #ccc;
  border-radius: 10px;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.fault-add-photo-btn:active { background: #eee; }
.fault-add-photo-btn svg { color: var(--gold); }

.fault-photo-block {
  background: #f9f9f9;
  border-radius: 10px;
  padding: 12px;
  border: 1px solid #eee;
}

.fault-photo-preview {
  position: relative;
  margin-bottom: 8px;
}

.fault-photo-img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
}

.fault-photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fault-photo-btns {
  display: flex;
  gap: 8px;
}

.fault-photo-trigger {
  flex: 1;
  padding: 14px 10px;
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 8px;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.fault-photo-trigger:active { background: #f5f5f5; }
.fault-camera-btn { border-color: var(--gold); color: var(--gold); }
.fault-camera-btn svg { color: var(--gold); }

.fault-photo-desc-input {
  margin-top: 8px;
  font-size: 13px !important;
  padding: 8px 10px !important;
}

.fault-submit-btn {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
}
.fault-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   INSTALL PROMPT
   ============================================================ */
.install-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.install-overlay.visible {
  opacity: 1;
}
.install-overlay.visible .install-modal {
  transform: translateY(0);
}
.install-modal {
  position: relative;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 24px 32px;
  max-width: 420px;
  width: 100%;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 32px rgba(0,0,0,0.2);
}
.install-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f1f1;
  border-radius: 50%;
  font-size: 20px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.install-icon {
  text-align: center;
  margin-bottom: 12px;
}
.install-icon img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.install-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #007AFF;
  margin: 0 0 4px;
}
.install-app-name {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0 0 20px;
}
.install-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.install-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: #1a1a2e;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.install-step-text {
  font-size: 15px;
  color: #333;
  line-height: 1.5;
  padding-top: 3px;
}
.install-share-icon {
  display: inline-flex;
  vertical-align: middle;
  background: #f0f0f0;
  border-radius: 6px;
  padding: 2px 4px;
}
.install-btn-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f0f0;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 500;
}
.install-hint {
  font-size: 13px;
  color: #666;
  font-weight: 600;
  margin: 0 0 16px 40px;
}
.install-footer {
  font-size: 13px;
  color: #888;
  text-align: center;
  margin: 16px 0 0;
  line-height: 1.5;
}

/* Animated arrow */
.install-arrow {
  position: fixed;
  z-index: 10001;
  animation: install-bounce 1.2s ease-in-out infinite;
}
.install-arrow-ios {
  top: 8px;
  right: 44px;
}
.install-arrow-android {
  top: 8px;
  right: 12px;
}
@keyframes install-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(12px); }
}

/* ============================================================
   NEWS FEED
   ============================================================ */

/* Create post prompt */
.feed-create-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin: 0 -16px;
  background: white;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.15s;
}
.feed-create-prompt:active { background: var(--gray-50); }
.feed-prompt-text {
  flex: 1;
  color: var(--gray-400);
  font-size: 15px;
}
.feed-avatar-sm {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* Feed list */
.feed-list { padding: 8px 0; }

/* Feed card */
.feed-card {
  background: white;
  border-radius: 12px;
  margin-bottom: 6px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.feed-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.feed-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  object-fit: cover;
}
img.feed-avatar { background: var(--gray-100); }
.feed-header-info { flex: 1; min-width: 0; }
.feed-author-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--navy);
}
.feed-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 1px;
}
.feed-pin-badge {
  flex-shrink: 0;
  margin-left: auto;
}
.feed-menu-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.feed-menu-btn:active { background: var(--gray-100); }

/* Content */
.feed-content {
  font-size: 15px;
  line-height: 1.5;
  color: var(--navy);
  margin-bottom: 12px;
  word-wrap: break-word;
}

/* Images */
.feed-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
}

/* Video */
.feed-video-card {
  border-radius: 8px;
  background: linear-gradient(135deg,#1a1a2e 0%,#16213e 100%);
  margin-bottom: 12px;
  cursor: pointer;
  overflow: hidden;
}
.feed-video-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
  cursor: pointer;
}

/* Reactions */
.feed-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 0;
}
.feed-reaction-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.feed-reaction-chip:active { transform: scale(0.95); }
.feed-reaction-chip.own {
  background: #fef3e2;
  border-color: var(--gold);
}

/* Emoji picker */
.feed-emoji-picker {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-bottom: 8px;
}
.feed-emoji-option {
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: transform 0.15s;
}
.feed-emoji-option:active { transform: scale(1.3); }

/* Action bar */
/* Slide-to-confirm read receipt */
.feed-slide-wrap {
  margin: 12px 0 4px;
}
.feed-slide-track {
  position: relative;
  height: 48px;
  border-radius: 24px;
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.feed-slide-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 44px;
  background: rgba(255,255,255,0.2);
  border-radius: 24px;
  pointer-events: none;
}
.feed-slide-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 2;
  transform: translateX(0);
  transition: transform 0.3s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.feed-slide-thumb:active { cursor: grabbing; }
.feed-slide-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.feed-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  margin: 12px 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.feed-confirm-done {
  background: linear-gradient(135deg, #8ee0a8, #b5f0c8);
  color: #1a6e3a;
}
.feed-translation {
  background: #f0f4ff;
  border-left: 3px solid #5b8def;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: #1a1a2e;
}

.feed-action-bar {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--gray-100);
  padding-top: 8px;
}
.feed-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  transition: background 0.15s;
}
.feed-action-btn:active { background: var(--gray-50); }

/* Comments section */
.feed-comments-section {
  border-top: 1px solid var(--gray-100);
  margin-top: 8px;
  padding-top: 8px;
}
.feed-comments-list { margin-bottom: 8px; }
.feed-comment {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  align-items: flex-start;
}
.feed-avatar-xs {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.feed-comment-body {
  font-size: 14px;
  line-height: 1.4;
  color: var(--navy);
  background: var(--gray-50);
  padding: 8px 12px;
  border-radius: 12px;
}
.feed-comment-author {
  font-weight: 600;
  font-size: 13px;
}
.feed-comment-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
  padding-left: 12px;
}
.feed-comment-delete {
  font-size: 18px;
  color: var(--gray-300);
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  align-self: center;
}
.feed-comment-delete:hover { color: #e74c3c; }

/* Comment input */
.feed-comment-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}
.feed-comment-input {
  flex: 1;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  background: var(--gray-50);
}
.feed-comment-input:focus {
  border-color: var(--gold);
  background: white;
}
.feed-comment-send {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* CREATE POST SCREEN */
.feed-create-screen { padding: 0 16px; overflow: visible; }
.feed-create-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 8px;
}
.feed-back-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 50%;
}
.feed-back-btn:active { background: var(--gray-100); }
.feed-publish-btn { flex-shrink: 0; }

.feed-target-section {
  background: var(--gray-50);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.feed-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.feed-target-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 15px;
}
.feed-target-row input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--gold);
}
.feed-rest-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}

.feed-textarea {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  margin-bottom: 12px;
  min-height: 120px;
}
.feed-textarea:focus { border-color: var(--gold); }

.feed-attach-bar {
  margin-bottom: 12px;
}
.feed-attach-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px dashed var(--gray-300);
  border-radius: 10px;
  color: var(--gray-500);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.feed-attach-btn:active { border-color: var(--gold); }
.feed-attach-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray-600);
}

/* Multi-image preview in create post */
.feed-attach-previews {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.feed-preview-item {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--gray-100);
}
.feed-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.feed-preview-file {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  text-align: center;
  padding: 4px;
  color: var(--gray-600);
}
.feed-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
}
.feed-attach-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Image carousel in feed */
.feed-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 4px;
  background: #1a1a2e;
  aspect-ratio: 4 / 3;
}
.feed-carousel-track {
  display: flex;
  transition: transform 0.3s ease;
  height: 100%;
}
.feed-carousel-slide {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.feed-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: pointer;
}
.feed-carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.feed-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: background 0.2s;
}
.feed-carousel-dot.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================================
   DELIVERY INSPECTION — Leveranskontroll
   ============================================================ */
.delivery-form .form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.delivery-form .form-input:focus { outline: none; border-color: var(--gold); }

.delivery-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gold);
}

/* Temperature rows */
.delivery-temp-row {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid #eee;
}
.delivery-temp-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
}
.delivery-temp-limit {
  font-size: 12px;
  color: #888;
  font-weight: 400;
}
.delivery-temp-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.delivery-na-label {
  font-size: 13px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.delivery-na-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}
.delivery-temp-input {
  width: 90px !important;
  text-align: center;
  padding: 8px !important;
}
.delivery-temp-warn {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  animation: pulse-warn 1s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Checkpoint rows */
.delivery-check-row {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 6px;
  border: 1px solid #eee;
}
.delivery-check-label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: #333;
}
.delivery-check-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.delivery-btn {
  padding: 8px 20px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.delivery-btn-yes.active {
  background: #dcfce7;
  border-color: #16a34a;
  color: #16a34a;
}
.delivery-btn-no.active {
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}
.delivery-cam-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  color: #888;
  transition: color 0.2s;
  margin-left: auto;
}
.delivery-cam-btn:hover { color: var(--gold); }

.delivery-check-preview {
  margin-top: 8px;
  position: relative;
  display: inline-block;
}
.delivery-check-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
}
.delivery-remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Verdict buttons */
.delivery-verdict-group {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.delivery-verdict-btn {
  flex: 1;
  padding: 14px;
  border: 2px solid #ddd;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.delivery-verdict-approved.active {
  background: #dcfce7;
  border-color: #16a34a;
  color: #16a34a;
}
.delivery-verdict-rejected.active {
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}

/* General photos */
.delivery-general-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.delivery-photo-thumb-wrap {
  position: relative;
  display: inline-block;
}

/* ============================================================
   DESKTOP SIDEBAR — hidden on mobile, shown on ≥1024px
   ============================================================ */
#app-sidebar {
  display: none;
}
#right-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  /* ---- CENTERED DESKTOP LAYOUT (Ziik-style) ---- */
  /* CSS custom property for the horizontal offset when viewport > max-width */
  :root {
    --desktop-max: 1400px;
    --sidebar-w: 240px;
    --rsidebar-w: 300px;
    --desktop-offset: max(0px, calc((100vw - var(--desktop-max)) / 2));
  }

  body {
    background: var(--gray-100);
  }

  /* App container: centered with max-width, still fixed full-screen */
  #app {
    flex-direction: row;
    max-width: var(--desktop-max);
    margin: 0 auto;
    left: var(--desktop-offset);
    right: var(--desktop-offset);
    width: auto;
    background: var(--gray-50);
  }

  /* Header: spans full viewport width (like Ziik) */
  #app-header {
    left: 0;
    right: 0;
  }
  /* Header inner content: centered within max-width, padded for logo in sidebar area */
  .header-inner {
    max-width: var(--desktop-max);
    margin: 0 auto;
    position: relative;
    padding-left: 16px;
  }

  /* Show sidebar — light theme, starts below header */
  #app-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--white);
    color: var(--gray-700);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 90;
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top));
    left: var(--desktop-offset);
    bottom: 0;
    padding-top: 8px;
    border-right: 1px solid var(--gray-200);
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #app-sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    padding: 0 12px;
  }

  .sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    padding: 4px 12px 6px;
  }

  .sidebar-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 8px 12px;
  }

  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    text-align: left;
    position: relative;
    width: 100%;
  }

  .sidebar-item svg {
    flex-shrink: 0;
    stroke: var(--gray-500);
  }

  .sidebar-item:hover {
    background: var(--gray-100);
    color: var(--navy);
  }
  .sidebar-item:hover svg {
    stroke: var(--navy);
  }

  .sidebar-item.active {
    background: rgba(212,168,67,0.12);
    color: var(--gold);
    font-weight: 600;
  }

  .sidebar-item.active svg {
    stroke: var(--gold);
  }

  .sidebar-icon-emoji {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
  }

  .sidebar-badge {
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: auto;
  }

  .sidebar-footer {
    padding: 12px 16px;
    font-size: 11px;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-200);
    text-align: center;
  }

  /* Center restaurant button over main content area (between sidebars) */
  #header-restaurant-btn {
    position: absolute;
    left: calc(var(--sidebar-w) + (100% - var(--sidebar-w) - var(--rsidebar-w)) / 2);
    transform: translateX(-50%);
  }

  /* Hide bottom nav on desktop */
  #bottom-nav {
    display: none !important;
  }

  /* Main content — scrollable area between sidebars */
  #main-content {
    margin-left: var(--sidebar-w);
    margin-right: var(--rsidebar-w);
    max-width: none;
    padding-bottom: 32px;
    background: var(--gray-50);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #main-content::-webkit-scrollbar {
    display: none;
  }

  /* ---- RIGHT SIDEBAR ---- */
  #right-sidebar {
    display: block;
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top));
    right: var(--desktop-offset);
    width: var(--rsidebar-w);
    height: calc(100vh - var(--header-height) - var(--safe-top));
    height: calc(100dvh - var(--header-height) - var(--safe-top));
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    padding: 16px 12px;
    z-index: 90;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #right-sidebar::-webkit-scrollbar {
    display: none;
  }
  .rs-widget {
    background: white;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
  }
  .rs-widget-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--navy);
    padding: 10px 12px 6px;
    border-bottom: 1px solid var(--gray-100);
  }
  .rs-widget-body {
    padding: 8px 12px 10px;
    font-size: 13px;
    color: var(--gray-600);
  }
  .rs-loading {
    color: var(--gray-400);
    font-size: 12px;
    padding: 4px 0;
  }
  .rs-empty {
    color: var(--gray-400);
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
  }
  /* Overview widget */
  .rs-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
  }
  .rs-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
  }
  .rs-progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.3s ease;
  }
  .rs-progress-label {
    font-size: 12px;
    color: var(--gray-500);
    min-width: 60px;
  }
  .rs-progress-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--navy);
    min-width: 36px;
    text-align: right;
  }
  .rs-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
  }
  .rs-stat-value {
    font-weight: 700;
    color: var(--navy);
  }
  /* Messages widget */
  .rs-msg-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
  }
  .rs-msg-item:last-child { border-bottom: none; }
  .rs-msg-item:hover { background: var(--gray-50); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .rs-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gold);
    color: white;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .rs-msg-content { flex: 1; min-width: 0; }
  .rs-msg-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rs-msg-text {
    font-size: 11px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rs-msg-time {
    font-size: 10px;
    color: var(--gray-400);
    flex-shrink: 0;
  }
  /* Schedule widget */
  .rs-sched-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--gray-100);
  }
  .rs-sched-item:last-child { border-bottom: none; }
  .rs-sched-icon {
    font-size: 16px;
    flex-shrink: 0;
  }
  .rs-sched-name {
    flex: 1;
    font-size: 12px;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rs-sched-time {
    font-size: 11px;
    color: var(--gray-400);
    flex-shrink: 0;
  }
  .rs-sched-done {
    color: var(--green);
    font-weight: 600;
    font-size: 11px;
  }
  /* Team widget */
  .rs-team-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
  }
  .rs-team-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .rs-team-dot.online { background: var(--green); }
  .rs-team-dot.recent { background: var(--gold); }
  .rs-team-dot.offline { background: var(--gray-300); }
  .rs-team-name {
    font-size: 12px;
    color: var(--gray-700);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rs-team-time {
    font-size: 10px;
    color: var(--gray-400);
  }
  /* Activity widget */
  .rs-act-item {
    padding: 5px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-600);
  }
  .rs-act-item:last-child { border-bottom: none; }
  .rs-act-user { font-weight: 600; color: var(--navy); }
  .rs-act-time { font-size: 10px; color: var(--gray-400); display: block; margin-top: 2px; }

  /* ---- FEED IMAGES: show full image on desktop ---- */
  .feed-image {
    max-height: none;
    object-fit: contain;
    background: var(--gray-100);
  }
  .feed-carousel-img {
    object-fit: contain;
  }

  /* ---- CHAT: desktop layout between sidebars, below header ---- */
  .chat-room-overlay {
    position: fixed !important;
    left: calc(var(--desktop-offset) + var(--sidebar-w)) !important;
    right: calc(var(--desktop-offset) + var(--rsidebar-w)) !important;
    width: auto !important;
    top: calc(var(--header-height) + var(--safe-top)) !important;
    bottom: 0 !important;
    height: auto !important;
    z-index: 100;
    overflow: hidden;
    background: white !important;
    animation: none !important;
    transform: none !important;
  }
  .chat-room-overlay.chat-ready {
    animation: none !important;
    transform: none !important;
  }
  .chat-room-overlay .chat-room-safe-area {
    display: none;
  }
  .chat-room-overlay .chat-header {
    background: white !important;
    color: var(--navy) !important;
    border-bottom: 1px solid var(--gray-200) !important;
  }
  .chat-room-overlay .chat-header .chat-back-btn {
    color: var(--navy) !important;
  }
  .chat-room-overlay .chat-header .chat-header-name {
    color: var(--navy) !important;
  }
  .chat-room-overlay .chat-header .chat-header-members {
    color: var(--gray-500) !important;
  }
  .chat-room-overlay .chat-header .chat-settings-btn {
    color: var(--navy) !important;
  }
  .chat-room-overlay .chat-messages {
    max-width: 840px;
    background: var(--gray-50) !important;
  }
  .chat-messages {
    max-width: none;
  }
  .message-bubble {
    max-width: 65%;
  }
  .message-image {
    max-width: 300px;
    max-height: 360px;
  }
  .chat-input-bar {
    max-width: 840px;
    padding-bottom: 8px !important;
    background: white !important;
  }

  /* Chat room uses full width */
  #main-content.chat-active {
    max-width: none;
  }
  #main-content .chat-room {
    max-width: none;
  }
}
