.nearby-input-row{
  display:flex;
  gap:10px;
  align-items:center;
}

.nearby-input-row input{
  flex:1 1 auto;
}

.nearby-geo-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

.nearby-geo-btn:hover{ filter: brightness(.98); }

.nearby-geo-btn:disabled{
  opacity:.65;
  cursor:not-allowed;
}

.nearby-geo-icon{ font-size: 16px; line-height: 1; }

@media (max-width: 480px){
  .nearby-input-row{ flex-direction: column; align-items: stretch; }
  .nearby-geo-btn{ width: 100%; justify-content: center; }
}
/* === Global tokens ======================================================= */
:root{
  --bg: #f8fafc;                 /* page background */
  --panel: #ffffff;              /* cards/panels */
  --ink: #0f172a;                /* primary text */
  --muted: #64748b;              /* secondary text */
  --brand: #2dce89;              /* MenuShield green */
  --accent: #2563eb;             /* blue accent */
  --danger: #ef4444;
  --ring: rgba(45,206,137,.35);
  --shadow: 0 10px 30px rgba(2,6,23,.08);
  --radius: 14px;
}

/* === Logo and Branding ========================================== */
.logo {
  display: block;
  margin: 40px auto 20px;
  max-width: 300px;   /* Keeps logo under control on desktop */
  width: 60%;         /* Scales down nicely on tablets/mobiles */
  height: auto;
  object-fit: contain;
}

/* === Base ================================================================ */
*{ box-sizing: border-box; }
html{
  min-height: 100%;
  background: linear-gradient(135deg, #2563eb 0%, #2dce89 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}
html, body{
  margin:0; padding:0;
  min-height: 100%;
  color: var(--ink);
}
body{
  min-height: 100vh;
  background: transparent;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* === Layout helpers ====================================================== */
.page-wrapper{
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

.section-title{
  margin: 8px 0 18px;
  font-size: 1.6rem;
  letter-spacing: .2px;
}

/* === Cards / panels ====================================================== */
.profile-dashboard{
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.profile-box{
  grid-column: span 4;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  border: 1px solid #e2e8f0;
}

.profile-box h2, .profile-box h3{
  margin-top: 0;
}

.patient-list{
  list-style: none;
  padding:0; margin:0;
}
.patient-card{
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  margin-bottom: 10px;
}

/* Full-width boxes (when you set inline grid-column 1 / -1) */
.profile-box[style*="grid-column: 1 / -1"]{
  grid-column: 1 / -1;
}

/* Avatar bits on dashboard */
.avatar-img{
  width:64px; height:64px;
  border-radius: 50%;
  object-fit: cover;
  display:block;
  margin-bottom: 10px;
  border: 3px solid var(--ring);
}
.avatar-fallback{
  width:64px; height:64px;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, var(--brand), #22c55e);
  color:#fff; font-weight:800; font-size: 24px;
  margin-bottom: 10px;
}

/* === Forms =============================================================== */
form .form-group{
  margin-bottom: 14px;
}
label{
  display:block; font-weight:600; margin-bottom: 6px; color: var(--muted);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
select, textarea{
  width:100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  background:#fff;
  transition: box-shadow .15s ease, border-color .15s ease;
}
input:focus, select:focus, textarea:focus{
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

.action-button, .btn-primary{
  background: var(--brand);
  color:#fff;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.action-button:hover, .btn-primary:hover{ filter: brightness(.95); }
.btn-secondary{
  background:#fff; color: var(--brand);
  border: 2px solid var(--brand);
  padding: 9px 14px; border-radius: 10px; font-weight:700;
}

/* === Inline search controls ============================================== */
.inline-search-panel,
.search-panel {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.search-input {
  flex: 1 1 260px;
  min-width: 220px;
}

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

.search-button,
.search-clear-button {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.search-button {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}

.search-button:hover { filter: brightness(.95); }

.search-clear-button {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: var(--ink);
}

.search-count {
  width: 100%;
  font-weight: 700;
  color: #64748b;
  font-size: 0.92rem;
}

@media (max-width: 520px) {
  .inline-search-panel,
  .search-panel {
    align-items: stretch;
  }

  .search-input,
  .search-actions,
  .search-button,
  .search-clear-button {
    width: 100%;
  }

  .search-actions {
    display: flex;
  }
}

/* Alerts (Flask flash messages) */
.alert{
  padding: 10px 12px;
  border-radius: 10px;
  margin: 8px 0 14px;
  font-weight: 600;
}
.alert-success{ background:#ecfdf5; color:#065f46; border:1px solid #a7f3d0; }
.alert-danger{  background:#fef2f2; color:#991b1b; border:1px solid #fecaca; }
.alert-warning{ background:#fffbeb; color:#92400e; border:1px solid #fde68a; }
.alert-info{    background:#eff6ff; color:#1e3a8a; border:1px solid #bfdbfe; }

/* === Lists =============================================================== */
.restaurant-list{
  list-style: none; padding:0; margin:0;
}
.restaurant-list li{
  padding: 10px 12px;
  background:#fff; border:1px solid #e5e7eb;
  border-radius: 10px; margin-bottom: 10px;
}
.restaurant-list a{ font-weight:700; color:#0f172a; }
.restaurant-list a:hover{ color: var(--brand); }

/* === Utility ============================================================= */
.text-muted{ color: var(--muted); }

/* Responsive */
@media (max-width: 1024px){
  .profile-box{ grid-column: span 6; }
}
@media (max-width: 700px){
  .profile-dashboard{ grid-template-columns: 1fr; }
  .profile-box{ grid-column: 1 / -1; }
}

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 30px;
}

/* === Allergy management cards ============================================ */
.allergy-page {
  margin-top: 24px;
}

.allergy-form {
  margin-top: 12px;
}

/* Keep allergy-page copy legible where it sits directly on the page gradient. */
.allergy-page > .text-muted,
.allergy-page > .allergy-form.mb-3 .form-group > label,
.allergy-page > .allergy-search-panel .search-count {
  color: var(--ink);
}

.allergy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.allergy-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #e2e8f0;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  transition:
    transform .12s ease,
    box-shadow .12s ease,
    border-color .12s ease;
}

.allergy-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  border-color: var(--accent);
}

.allergy-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--ring);
}

.allergy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.allergy-checkbox {
  margin-right: 8px;
}

.allergy-name {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
}

.allergy-snippet {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 10px;
  min-height: 2.6em;
}

.allergy-more {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: #0B4A6F; /* MenuShield blue */
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.allergy-more:hover {
  text-decoration: underline;
}

.allergy-actions {
  margin-top: 20px;
  text-align: right;
}

/* === Allergy details modal =============================================== */
.hidden {
  display: none !important;
}

.allergy-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.allergy-modal {
  position: relative;
  z-index: 10002;
  background: #f8fafc;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.5);
  max-width: 640px;
  width: 92%;
  max-height: 80vh;
  overflow: hidden;
}

.allergy-modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 18px solid #0B4A6F; /* MenuShield blue triangle */
  cursor: pointer;
}

.allergy-modal-body {
  padding: 26px 26px 22px 52px; /* room for triangle */
  overflow-y: auto;
  max-height: 80vh;
}

.allergy-modal-title {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.4rem;
  color: #0B4A6F;
}

.allergy-modal-section {
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 0.95rem;
  color: var(--ink);
}

.allergy-modal-body p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Slight tweaks for smaller screens */
@media (max-width: 600px) {
  .allergy-modal-body {
    padding: 24px 18px 20px 48px;
  }
}
/* === Restaurants page (cards + modal + nearby filter) ===================== */
.restaurant-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* Header row: title left, cuisine filter right */
.restaurant-header{
  display:flex;
  align-items:flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.restaurant-header-left{ min-width: 0; }

/* Keep restaurant-header copy legible where it sits directly on the page gradient. */
.restaurant-header-left > .text-muted,
.restaurant-header-right > .cuisine-filter-label {
  color: var(--ink);
}

.restaurant-header-right{
  display:flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 260px;
  max-width: 360px;
}

.cuisine-filter-label{
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}

.cuisine-filter{
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  font-weight: 800;
  color: var(--ink);
  box-shadow: var(--shadow);
  outline: none;
}

.cuisine-filter:focus{
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

@media (max-width: 900px){
  .restaurant-header{ align-items: flex-start; }
  .restaurant-header-right{ align-items: stretch; max-width: none; }
}

@media (max-width: 600px){
  .restaurant-header{ flex-direction: column; align-items: stretch; }
  .restaurant-header-right{ width: 100%; }
}

.restaurant-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

@media (min-width: 768px) {
  .restaurant-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .restaurant-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.restaurant-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #e2e8f0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}

.restaurant-card-header { display: flex; justify-content: center; margin-bottom: 8px; }
.restaurant-name { font-weight: 800; font-size: 1.02rem; text-align: center; color: var(--ink); }

.restaurant-snippet { color: var(--muted); font-size: 0.9rem; line-height: 1.35; margin: 10px 0 14px 0; }
.restaurant-snippet a { word-break: break-word; }

.restaurant-more {
  margin-top: auto;
  align-self: flex-end;
  border: none;
  background: transparent;
  color: #0B4A6F;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
}

.restaurant-more:hover { text-decoration: underline; }

.restaurant-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}

.restaurant-modal-backdrop.hidden { display: none; }

.restaurant-modal {
  width: min(920px, 96vw);
  background: #f8fafc;
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.5);
  position: relative;
  overflow: hidden;
}

.restaurant-modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 18px solid #0B4A6F;
  cursor: pointer;
}

.restaurant-modal-body { padding: 26px 26px 22px 52px; overflow-y: auto; max-height: 80vh; }
.restaurant-modal-title { margin-top: 0; margin-bottom: 14px; font-size: 1.35rem; color: #0B4A6F; font-weight: 800; }

.menu-modal-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.menu-modal-heading .restaurant-modal-title {
  margin-bottom: 0;
}

.menu-search-panel {
  justify-content: flex-end;
  margin: 0;
}

.location-list { list-style: none; padding-left: 0; margin: 0; }
.location-item {
  padding: 12px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.location-label { margin-bottom: 4px; }
.location-address { color: var(--ink); }
.location-meta, .location-phone, .location-website { color: var(--muted); font-size: 0.9rem; }
.no-locations { color: var(--muted); }

.nearby-panel {
  border: 1px solid #e2e8f0;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin: 0 auto 16px auto;
}

.nearby-fields {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 768px) {
  .nearby-fields { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; }
}

.nearby-field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
}

.nearby-field input,
.nearby-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  background: #fff;
  transition: box-shadow .15s ease, border-color .15s ease;
}

.nearby-field input:focus,
.nearby-field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

.req { color: var(--danger); }

.nearby-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

.nearby-btn {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.nearby-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}

.nearby-btn-primary:hover { filter: brightness(.95); }

.nearby-btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }

.nearby-btn-ghost {
  background: transparent;
  border-color: #cbd5e1;
  color: var(--ink);
}

.nearby-status {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 480px) {
  .nearby-actions { justify-content: flex-start; }
  #nearby-reset { width: 100%; }
}

@media (max-width: 600px) {
  .restaurant-modal-body { padding: 24px 18px 20px 48px; }
  .menu-modal-heading {
    grid-template-columns: 1fr;
  }
  .menu-search-panel {
    justify-content: stretch;
  }
}

/* Footer actions: See Menu (left) + See Locations (right) */
.restaurant-actions{
  display:flex;
  justify-content: space-between;
  align-items:center;
  margin-top: auto;
  padding-top: 8px;
}

.restaurant-menu{
  border:none;
  background: transparent;
  color:#0B4A6F;
  font-weight: 800;
  cursor:pointer;
  padding: 6px 0;
}

.restaurant-menu:hover{ text-decoration: underline; }

/* Menu modal content */
.menu-grid{
  display:grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap:12px;
}

@media (min-width: 768px){
  .menu-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px){
  .menu-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.menu-item-card{
  position: relative;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(2,6,23,.06);
}

.hit-red { outline: 3px solid #ff3b30; outline-offset: -3px; }
.hit-blue { outline: 3px solid #00e5ff; outline-offset: -3px; }
.hit-yellow { outline: 3px solid #ffd60a; outline-offset: -3px; }
.hit-green { outline: 3px solid #34c759; outline-offset: -3px; }
.hit-purple { outline: 3px solid #af52de; outline-offset: -3px; }
.hit-multi { outline: 0; }
.menu-item-card.hit-multi { border-radius: 12px; }

.subject-chip {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.subject-chip .chip-off {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.95);
  color: rgba(30,41,59,0.9);
  line-height: 1;
}

.subject-chip.is-inactive .chip-off { opacity: 1; }

.subject-chip.is-inactive {
  opacity: 0.45;
  filter: grayscale(1);
}

.subject-chip.is-inactive .label {
  text-decoration: line-through;
}

.menu-item-name{
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 8px;
}

.menu-item-description {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0 0 10px;
}

.menu-item-allergens{
  color: var(--muted);
  font-size: 0.9rem;
}

.menu-item-allergens-label{
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 6px;
}

.menu-allergen-chips{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-allergen-chip{
  border: 1px solid rgba(37,99,235,.35);
  background: rgba(37,99,235,.06);
  color: #0B4A6F;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  cursor:pointer;
  font-size: 0.82rem;
}

.menu-allergen-chip:hover{
  filter: brightness(.98);
  text-decoration: underline;
}

/* MOST IMPORTANT: patient \"avoid\" highlight */
.menu-item-danger{
  border: 4px solid #ff1a1a;
  box-shadow: 0 10px 22px rgba(255, 26, 26, 0.18);
}

/* Menu item add-allergen (+) control */
.menu-item-plus{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,.35);
  background: rgba(37,99,235,.08);
  color: #0B4A6F;
  font-weight: 1000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.menu-item-plus:hover{ filter: brightness(.98); }

.menu-item-plus-panel{
  position: absolute;
  top: 48px;
  right: 10px;
  width: min(320px, calc(100% - 20px));
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  padding: 10px;
  z-index: 10005; /* above menu modal content */
}

.menu-item-plus-panel.hidden{ display: none !important; }

.menu-item-plus-title{
  font-weight: 900;
  color: var(--ink);
  margin: 2px 0 8px;
  font-size: 0.92rem;
}

.menu-item-plus-list{
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
  border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.menu-item-plus-row{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
}

.menu-item-plus-row input{ width: 18px; height: 18px; }

.menu-item-plus-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.menu-item-plus-actions button{
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.menu-item-plus-actions .menu-item-plus-save{
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.menu-item-plus-actions .menu-item-plus-cancel{
  background: transparent;
}
.restaurant-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 6px;
}

.restaurant-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.restaurant-name {
  font-weight: bold;
  font-size: 1.1em;
}
