/* MessMate Control - Shared Styles
 * Dark theme, restaurant-inspired, mobile-first
 */

:root {
  --bg: #0f1419;
  --bg-elev: #1a2028;
  --bg-elev-2: #232b36;
  --border: #2d3742;
  --border-strong: #3a4553;
  --text: #e8edf2;
  --text-dim: #9ba8b8;
  --text-faint: #6b7886;
  --accent: #f59e0b;        /* warm amber - food/galley vibe */
  --accent-hover: #fbbf24;
  --accent-dim: #78530a;
  --danger: #ef4444;
  --success: #10b981;
  --info: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, select, textarea {
  font-family: inherit;
  outline: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ============ LOGIN PAGE ============ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top, #1a2028 0%, #0f1419 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-brand {
  padding: 32px 24px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.login-brand .logo {
  font-size: 32px;
  margin-bottom: 6px;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.login-brand h1 span { color: var(--accent); }

.login-brand .tag {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-faint);
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.login-tab {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  padding: 14px 10px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.login-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.login-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  color: #1a1300;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: background 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:active:not(:disabled) { transform: scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.btn-google {
  background: #fff;
  color: #1f1f1f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-google:hover:not(:disabled) { background: #f5f5f5; }
.btn-google svg { width: 18px; height: 18px; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.login-help {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
}

.msg {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

.msg.show { display: block; }

.msg.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.msg.info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.msg.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.app-version {
  position: fixed;
  bottom: 10px;
  right: 12px;
  font-size: 11px;
  color: var(--text-faint);
  opacity: 0.6;
}

/* ============ DASHBOARD SHELL ============ */

.dash {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}

.dash-header {
  grid-area: header;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.dash-header .page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.dash-header .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.user-chip .role-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-badge.superadmin { background: var(--accent-dim); color: var(--accent-hover); }
.role-badge.cook { background: #1e3a5f; color: #93c5fd; }

.dash-sidebar {
  grid-area: sidebar;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .logo { font-size: 22px; }
.sidebar-brand strong {
  font-size: 16px;
  letter-spacing: -0.3px;
}
.sidebar-brand strong span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 10px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-hover);
}

.nav-item .icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.dash-main {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}

.placeholder-card {
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
}

.placeholder-card h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 20px;
}

.placeholder-card p {
  margin: 6px 0;
  font-size: 14px;
}

/* ============ LOADING ============ */

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-screen .text {
  color: var(--text-dim);
  font-size: 14px;
}

/* ============ MOBILE ============ */

@media (max-width: 768px) {
  .dash {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main";
  }

  .dash-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand { display: none; }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px;
    gap: 4px;
  }

  .nav-section { display: none; }

  .nav-item {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .dash-main { padding: 16px; }
}

/* ============ PAGE LAYOUT ============ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}

.btn-primary {
  background: var(--accent);
  color: #1a1300;
  padding: 10px 16px;
  width: auto;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

/* ============ TOOLBAR ============ */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}
.toolbar-input:focus {
  outline: none;
  border-color: var(--accent);
}

.toolbar-select {
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.toolbar-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============ DISH GRID ============ */

.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.dish-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.dish-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.dish-card-img {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-elev-2);
  overflow: hidden;
}
.dish-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dish-card-img .no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  opacity: 0.3;
}

.src-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  backdrop-filter: blur(8px);
}
.src-ai { background: rgba(245, 158, 11, 0.85); color: #1a1300; }
.src-photo { background: rgba(16, 185, 129, 0.85); color: #002418; }

.dish-card-body {
  padding: 12px 14px 14px;
}

.dish-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.dish-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 10px;
  min-height: 34px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dish-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.cat-tag {
  padding: 3px 8px;
  background: var(--bg-elev-2);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.usage {
  font-size: 11px;
  color: var(--text-faint);
}

/* ============ EMPTY / LOADING STATES ============ */

.empty-state {
  grid-column: 1 / -1;
  padding: 60px 24px;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-dim);
}
.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
}
.empty-state p {
  margin: 4px 0;
  font-size: 14px;
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.loading-inline {
  grid-column: 1 / -1;
  padding: 60px 24px;
  display: flex;
  justify-content: center;
}

.loading-ai {
  padding: 40px 24px;
  text-align: center;
}
.loading-ai h3 {
  margin: 16px 0 6px;
  color: var(--text);
  font-size: 18px;
}
.loading-ai p {
  margin: 4px 0;
  color: var(--text-dim);
  font-size: 14px;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============ MODAL ============ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  z-index: 1000;
  overflow-y: auto;
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
  margin: auto;
}

.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.form-help {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

.muted-small {
  font-size: 12px;
  color: var(--text-faint);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.btn-row .btn {
  flex: 1;
  min-width: 120px;
}

textarea {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============ PREVIEW & DETAIL ============ */

.preview-wrap {
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 4 / 3;
}
.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-img-wrap {
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 4 / 3;
}
.detail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.info-label {
  color: var(--text-faint);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.info-row span:last-child {
  color: var(--text);
  text-align: right;
  flex: 1;
}

/* ============ MOBILE ============ */

@media (max-width: 640px) {
  .dish-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  .dish-card-title { font-size: 14px; }
  .dish-card-desc { font-size: 11px; }
  .toolbar { gap: 8px; }
  .toolbar-select { flex: 1; min-width: 0; }
  .btn-row .btn { min-width: 0; }
  .modal-body { padding: 16px; }
}

/* ============ LIST VIEWS (Vessels, Cooks) ============ */

.list-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.list-row:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.list-row:active { transform: scale(0.998); }

.list-main {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.list-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.list-arrow {
  font-size: 24px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

/* ============ STATUS PILLS ============ */

.status-pill {
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-inactive {
  background: rgba(107, 120, 134, 0.15);
  color: var(--text-faint);
  border: 1px solid rgba(107, 120, 134, 0.3);
}

/* ============ CHECKBOX ============ */

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
  text-transform: none !important;
  font-size: 14px !important;
  color: var(--text) !important;
  letter-spacing: normal !important;
  cursor: pointer;
  font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ============ SUCCESS BOX (credentials display) ============ */

.success-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 8px;
}

.success-icon {
  width: 44px;
  height: 44px;
  background: var(--success);
  color: #002418;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  margin: 0 auto 12px;
}

.success-box h3 {
  margin: 0 0 6px;
  text-align: center;
  color: var(--text);
  font-size: 17px;
}

.success-box > p {
  text-align: center;
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.cred-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  gap: 12px;
}

.cred-row:last-of-type { margin-bottom: 0; }

.cred-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
}

.cred-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.cred-value.mono {
  background: transparent;
  padding: 0;
  font-size: 14px;
}

/* ============ MOBILE ============ */

@media (max-width: 640px) {
  .list-row { padding: 12px 14px; }
  .list-title { font-size: 14px; }
}

/* ============ SETTINGS PAGE ============ */

.settings-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.settings-section-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: opacity 0.15s, border-color 0.15s;
}
.slot-row.disabled {
  opacity: 0.55;
}
.slot-row.enabled {
  border-color: var(--border-strong);
}

.slot-head { flex: 1; }
.slot-head .checkbox-label span { font-size: 14px; }

.slot-cutoff {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-cutoff .inline-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.slot-cutoff input[type="time"] {
  padding: 7px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  color-scheme: dark;
}
.slot-cutoff input[type="time"]:focus { outline: none; border-color: var(--accent); }
.slot-cutoff input[type="time"]:disabled { opacity: 0.5; }

/* ============ CREW GRID ============ */

.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.crew-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.crew-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.crew-photo {
  aspect-ratio: 1 / 1;
  background: var(--bg-elev-2);
  overflow: hidden;
}
.crew-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.crew-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
  color: var(--text-faint);
  background: linear-gradient(135deg, var(--bg-elev-2), var(--bg-elev));
}

.crew-info {
  padding: 10px 12px;
}
.crew-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crew-rank {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Crew photo edit inside modal */
.crew-photo-edit {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.crew-photo-preview {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elev-2);
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
}
.crew-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.crew-photo-preview .crew-photo-placeholder { font-size: 32px; }

.crew-photo-edit button.btn {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}

/* ============ WEEKLY PLANNER ============ */

.planner-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.planner-actions .toolbar-select {
  min-width: 220px;
}

.planner-actions .btn-primary {
  width: auto;
}

.planner-days {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.day-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
.day-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.day-date {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
}

.day-slots {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.slot-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.slot-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slot-block-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-hover);
}

.slot-block-cutoff {
  font-size: 10px;
  color: var(--text-faint);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.slot-block-dishes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 28px;
}

.slot-empty {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  padding: 4px 0;
}

.dish-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 3px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  max-width: 100%;
}
.dish-chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.dish-chip-img-fallback {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.dish-chip-name {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}
.dish-chip-x {
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.dish-chip-x:hover {
  background: var(--danger);
  color: #fff;
}

.btn-pick {
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.btn-pick:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(245, 158, 11, 0.05);
}

.status-pill.status-draft {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ============ DISH PICKER MODAL ============ */

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}

.picker-dish {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.08s;
}
.picker-dish:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.picker-dish.selected {
  border-color: var(--accent);
}

.picker-dish-img {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-elev-2);
  overflow: hidden;
}
.picker-dish-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.picker-dish-img .no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.3;
}
.picker-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #1a1300;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.15s, transform 0.15s;
}
.picker-dish.selected .picker-check {
  opacity: 1;
  transform: scale(1);
}

.picker-dish-name {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ============ MOBILE ============ */

@media (max-width: 640px) {
  .planner-actions {
    width: 100%;
  }
  .planner-actions .toolbar-select {
    flex: 1;
    min-width: 0;
  }
  .day-slots {
    grid-template-columns: 1fr;
  }
  .crew-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  .slot-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .slot-cutoff { width: 100%; }
}

/* ============ TALLY PAGE ============ */

.day-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.day-filter::-webkit-scrollbar { display: none; }

.day-filter-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.12s;
  cursor: pointer;
}

.day-filter-btn.active {
  background: var(--accent);
  color: #1a1300;
  border-color: var(--accent);
}

.tally-day {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.tally-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 18px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}

.tally-day-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.tally-day-date {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
}

.tally-day-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tally-slot {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.tally-slot.empty {
  opacity: 0.5;
}

.tally-slot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tally-slot-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-hover);
}

.tally-slot-cutoff {
  font-size: 10px;
  color: var(--text-faint);
  font-family: ui-monospace, Menlo, monospace;
}

.tally-slot-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 2px 9px;
  background: var(--bg-elev-2);
  border-radius: 10px;
}

.tally-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tally-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-elev);
  border-radius: 6px;
  gap: 10px;
}

.tally-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.tally-row-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.tally-row-img-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.tally-row-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tally-row-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-faint);
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tally-row-count[data-has="1"] {
  color: var(--accent-hover);
}

.tally-row.skip-row .tally-row-name {
  color: var(--text-dim);
  font-style: italic;
}

.tally-pending {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.pending-label {
  font-weight: 700;
  color: #93c5fd;
  margin-right: 6px;
}

/* ============ CREW URL BOX (in settings) ============ */

.url-box {
  display: flex;
  gap: 8px;
}

.url-box input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.url-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.url-box .btn {
  width: auto;
  padding: 10px 18px;
  flex-shrink: 0;
  font-size: 13px;
}

/* ============ DROP 3 — Planner slot chips ============ */

.day-slot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.slot-chip {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid;
  letter-spacing: 0.3px;
}

.slot-chip.on {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}
.slot-chip.on:hover {
  background: rgba(16, 185, 129, 0.25);
}

.slot-chip.off {
  background: var(--bg);
  color: var(--text-faint);
  border-color: var(--border-strong);
}
.slot-chip.off:hover {
  color: var(--text-dim);
  border-color: var(--text-faint);
}

.no-slots-msg {
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  font-style: italic;
}

/* ============ DROP 3 — Settings max/person control ============ */

.slot-controls {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.slot-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot-control .inline-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.slot-control input[type="time"],
.slot-control input[type="number"] {
  padding: 7px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  color-scheme: dark;
}

.slot-control input[type="number"] {
  width: 70px;
  text-align: center;
}

.slot-control input:focus {
  outline: none;
  border-color: var(--accent);
}

.slot-control input:disabled {
  opacity: 0.5;
}

/* ============ DROP 3 — Tally orderer names ============ */

.tally-row {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  background: var(--bg-elev);
  border-radius: 6px;
  gap: 6px;
}

.tally-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tally-row-orderers {
  font-size: 11px;
  color: var(--text-faint);
  padding-left: 38px;
  line-height: 1.4;
  font-style: italic;
}

/* Mobile tweaks */

@media (max-width: 640px) {
  .slot-controls {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    width: 100%;
  }
  .slot-control input[type="number"] { width: 100%; }
  .slot-row {
    flex-direction: column;
    align-items: stretch;
  }
  .day-slot-chips {
    padding: 10px 14px;
  }
}
