/* Updated: 2025-11-14 16:30 - Søk renamed to Måltid, dynamic carbfree list */

/* Auth guard — hide page until auth verified */
html.auth-pending body { visibility: hidden !important; }

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: #f5f7fa;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* PWA standalone: account for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Keyboard focus indicators */
a:focus-visible, button:focus-visible, .tab:focus-visible, .btn:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Header & Navigation */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.5rem 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 768px) {
  .header-content {
    padding: 1.25rem 1rem;
  }
}

.logo {
  font-size: 1.8rem;
  font-weight: bold;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.user-info {
  display: none;
  align-items: center;
  gap: 1rem;
}

.user-info.logged-in {
  display: flex;
}

.user-name {
  font-size: 0.9rem;
  opacity: 0.9;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hamburger Menu */
.hamburger-menu {
  position: relative;
}

.menu-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.3rem;
  transition: all 0.2s ease;
  line-height: 1;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 200px;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: #2d3748;
  text-decoration: none;
  transition: background 0.2s;
  border-bottom: 1px solid #e2e8f0;
}

.dropdown-menu a:last-child {
  border-bottom: none;
}

.dropdown-menu a:hover {
  background: #f7fafc;
  color: #667eea;
}

nav {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

nav ul {
  list-style: none;
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

nav li {
  flex: 1;
}

nav a {
  display: block;
  padding: 0.75rem 1rem;
  color: white;
  text-decoration: none;
  text-align: center;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.15);
  border-bottom-color: rgba(255, 255, 255, 0.8);
}

nav a.active {
  background: rgba(255, 255, 255, 0.2);
  border-bottom-color: white;
}

nav a.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

nav a.locked::after {
  content: " 🔒";
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.page {
  display: none;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  display: none;
}

/* Login Page */
.login-container {
  max-width: 400px;
  margin: 4rem auto;
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.login-container h1 {
  border: none;
  text-align: center;
  color: #667eea;
}

/* Cards */
.card {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
}

.card h3 {
  color: #667eea;
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  font-weight: 500;
  width: 100%;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Forms */
.form-group {
  margin: 1rem 0;
}

label {
  display: block;
  color: #4a5568;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 1rem;
}

input:focus, select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
  color: #ff6b6b;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
}

.error-message.show {
  display: block;
}

/* Status indicators - shared styles */
.status, .sugar-level, .mysql-status {
  background: white;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #4a5568;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border-left: 4px solid #f59f0b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

/* Green = connected */
.status.connected, .sugar-level.connected, .mysql-status.connected {
  border-left-color: #51cf66;
  color: #2d3748;
}

/* Red = error/offline */
.status.error, .sugar-level.error, .mysql-status.error {
  border-left-color: #ff6b6b;
  color: #2d3748;
}

/* System bottom button */
.system-bottom-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  margin-top: 2rem;
}

.system-bottom-btn a {
  display: block;
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  padding: 0.5rem;
}

.system-bottom-btn a.locked::after {
  content: " 🔒";
}

.access-denied {
  text-align: center;
  padding: 3rem;
}

.access-denied h2 {
  color: #ff6b6b;
  margin-bottom: 1rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e2e8f0;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #718096;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tab:hover {
  color: #667eea;
  background: #f7fafc;
}

.tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Food Input Rows */
.food-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 1rem;
  margin-bottom: 0.5rem;
  align-items: end;
  padding: 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.food-row.has-value {
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-left: 4px solid #667eea;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.desktop-only {
  display: block;
}

.food-row input {
  margin: 0;
}

.remove-btn {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: #ff5252;
}

.add-row-btn {
  background: #51cf66;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  transition: all 0.2s ease;
}

.add-row-btn:hover {
  background: #40c057;
}

.total-display {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-top: 1.5rem;
  text-align: center;
}

.total-display h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.total-display .total-number {
  font-size: 2.5rem;
  font-weight: bold;
}

.total-display .total-unit {
  font-size: 1rem;
  opacity: 0.9;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Search Results */
.search-results {
  margin-top: 1rem;
  max-height: 400px;
  overflow-y: auto;
}

.search-item {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-item:hover {
  background: #edf2f7;
  border-color: #667eea;
}

.search-item-info {
  flex: 1;
}

.search-item-name {
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 0.25rem;
}

.search-item-carbs {
  color: #667eea;
  font-size: 0.9rem;
}

.add-item-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.add-item-btn:hover {
  background: #5568d3;
}

.calculator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Food Database Management */
.food-db-item {
  padding: 1rem;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.food-db-item input {
  margin: 0;
}

.food-db-item .delete-btn:hover {
  background: #c53030;
  transform: scale(1.15);
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */
@media (max-width: 768px) {
  /* Compact header */
  .header-content {
    padding: calc(0.4rem + 4px) 0.5rem !important;
  }

  nav {
    padding: 3px 0;
  }

  .logo {
    font-size: 1rem;
    font-weight: 700;
  }

  /* Ultra-compact navigation */
  nav ul {
    justify-content: space-evenly;
  }

  nav a {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
  }

  /* Hide "Hjem" and "Karbohydratfritt" on mobile to save space */
  nav ul li:first-child,
  nav ul li.hide-mobile {
    display: none;
  }

  /* Compact status indicators */
  .header-right {
    gap: calc(0.3rem + 2px);
  }

  .status, .sugar-level, .mysql-status {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
    border-left-width: 2px;
    gap: 0.25rem;
    height: 32px;
    width: auto;
    max-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    flex: none;
    min-width: 0;
  }

  .menu-btn {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: 1.1rem;
    padding: 0;
    transition: transform 0.2s ease;
  }

  .menu-btn[aria-expanded="true"] {
    transform: rotate(90deg);
  }

  /* Dropdown menu scrollable on mobile */
  .dropdown-menu {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .status span:first-child,
  .sugar-level span:first-child {
    font-size: 0.75rem;
  }

  /* Minimal main padding */
  main {
    margin: 0;
    padding: 0.5rem 0.5rem 1rem 0.5rem;
  }

  .page {
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /* Hide page titles */
  h1 {
    display: none;
  }

  /* Compact cards with modern shadows */
  .card {
    background: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 10px;
  }

  .card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    font-weight: 700;
  }

  .card > p {
    font-size: 0.8rem;
    margin-bottom: 0.5rem !important;
    line-height: 1.4;
  }

  /* Compact form elements */
  .form-group {
    margin: 0.5rem 0;
  }

  .form-group label {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
  }

  .form-group small {
    font-size: 0.7rem !important;
    line-height: 1.3;
    margin-bottom: 0.25rem !important;
    display: block;
  }

  input, select {
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  /* Single column grid */
  .calculator-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem !important;
  }

  .calculator-grid .form-group {
    margin-bottom: 0.5rem;
  }

  /* Compact food rows */
  .food-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.6rem;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 0.5rem;
  }

  .food-row .form-group {
    margin: 0;
  }

  .food-row label {
    font-size: 0.8rem;
  }

  .remove-btn {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.8rem;
    border-radius: 8px;
  }

  /* Compact total display */
  .total-display {
    padding: 0.75rem;
    margin-top: 0.75rem;
    border-radius: 10px;
  }

  .total-display h3 {
    font-size: 0.85rem;
  }

  /* Buttons */
  .btn {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  /* Database items — card layout handles this in the dedicated section below */

  /* Selected food items - compact */
  .selected-food-item {
    padding: 0.6rem !important;
    margin-bottom: 0.5rem !important;
    border-radius: 8px;
  }

  .selected-food-item > div {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
  }

  .selected-food-controls {
    justify-content: space-between !important;
    gap: 0.5rem !important;
  }

  /* Autocomplete - show above on mobile */
  .autocomplete-dropdown {
    bottom: 100%;
    margin-bottom: 0.25rem;
    top: auto;
    max-height: 180px;
    border-radius: 8px;
  }

  /* Search items - compact */
  .search-item {
    padding: 0.7rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
  }

  .search-item-name {
    font-size: 0.9rem;
  }

  .search-item-carbs {
    font-size: 0.8rem;
  }

  .add-item-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
  }

  /* System button - compact */
  .system-bottom-btn {
    padding: 0.6rem;
    margin-top: 1rem;
  }

  .system-bottom-btn a {
    font-size: 0.9rem;
    padding: 0.3rem;
  }

  /* Tabs - compact */
  .tabs {
    margin-bottom: 1rem;
    gap: 0.3rem;
  }

  .tab {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }

  /* Category filters - compact */
  #category-filters {
    gap: 0.4rem !important;
  }

  #category-filters button {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
  }
}

/* Extra small devices (< 400px) - even more compact */
@media (max-width: 400px) {
  nav a {
    font-size: 0.75rem;
    padding: 0.45rem 0.3rem;
  }

  .logo {
    font-size: 0.9rem;
  }

  .status, .sugar-level, .mysql-status {
    font-size: 0.65rem;
    padding: 0.2rem 0.3rem;
    height: 28px;
    width: auto;
    max-width: 80px;
  }

  /* Hide text labels, show only icons on very small screens */
  .status span:last-child,
  .sugar-level span:last-child,
  .mysql-status span:last-child {
    display: none;
  }

  .status, .sugar-level, .mysql-status {
    max-width: none;
    padding: 0.2rem 0.4rem;
  }

  .menu-btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 1rem;
  }

  .card {
    padding: 0.6rem;
  }

  .card h3 {
    font-size: 0.9rem;
  }

  input, select {
    font-size: 0.85rem;
    padding: 0.55rem 0.6rem;
  }
}

/* ==================== DATABASE PAGE GRID FIX ==================== */
.food-db-item {
  overflow-x: auto;
  max-width: 100%;
}

/* Desktop: field labels hidden, wrapper divs transparent */
.db-field-label {
  display: none;
}

.db-grid-row > div {
  min-width: 0;
}

.db-grid-row > div > input,
.db-grid-row > div > select {
  width: 100%;
  box-sizing: border-box;
}

/* Ensure database grid header and items have same width */
#food-database-list > div {
  min-width: 900px; /* Minimum width to prevent squishing */
}

/* Make database page scrollable horizontally on medium screens */
@media (max-width: 1024px) and (min-width: 769px) {
  #food-database-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #food-database-list > div {
    min-width: 800px;
  }
}

/* ==================== DATABASE PAGE MOBILE CARD LAYOUT ==================== */
@media (max-width: 768px) {
  /* Remove min-width and horizontal scroll */
  #food-database-list {
    overflow-x: visible !important;
  }

  #food-database-list > div {
    min-width: 0 !important;
  }

  /* Hide the desktop grid header */
  .db-grid-header {
    display: none !important;
  }

  /* Card layout for each food item */
  .food-db-item {
    position: relative !important;
    padding: 1rem !important;
    padding-top: 1.2rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 10px !important;
    background: #f7fafc !important;
    border: 1px solid #e2e8f0;
    overflow: visible !important;
  }

  /* Override the 6-column grid to a 2-column card */
  .db-grid-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  /* Food name spans full width */
  .db-field-name {
    grid-column: 1 / -1;
  }

  .db-field-name input {
    font-size: 1rem !important;
    font-weight: 600;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 0.6rem !important;
  }

  /* Carbs and unit side by side */
  .db-field-carbs input,
  .db-field-unit select {
    font-size: 0.9rem !important;
    padding: 0.55rem !important;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
  }

  /* Category and producer side by side */
  .db-field-category select,
  .db-field-produsent input {
    font-size: 0.85rem !important;
    padding: 0.5rem !important;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
  }

  /* Image URL spans full width */
  .db-field-image {
    grid-column: 1 / -1;
  }

  .db-field-image input {
    font-size: 0.8rem !important;
    padding: 0.5rem !important;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
  }

  /* Show field labels on mobile */
  .db-field-label {
    display: block !important;
    font-size: 0.7rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
  }

  /* Delete button - 44px touch target */
  .food-db-item > .delete-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 20px !important;
    top: -10px !important;
    right: -10px !important;
    border: 2px solid white !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  }

  /* Inputs and selects - good touch targets */
  #food-database-list input,
  #food-database-list select {
    min-height: 44px;
    font-size: 0.9rem;
  }

  /* Category filter buttons */
  #category-filters {
    gap: 0.4rem !important;
  }

  #category-filters button {
    font-size: 0.8rem !important;
    padding: 0.5rem 0.75rem !important;
    min-height: 44px;
  }
}

/* ==================== MÅLTID PAGE REMOVE BUTTON ==================== */
.remove-food-btn:hover {
  background: #c53030 !important;
  transform: scale(1.05);
}

/* ==================== RESPONSIVE FOOD ITEM LAYOUT ==================== */
/* Desktop: show single-row layout, hide two-row mobile layout */
.selected-food-desktop {
  display: flex !important;
}

.selected-food-mobile {
  display: none !important;
}

/* Mobile: hide single-row layout, show two-row mobile layout */
@media (max-width: 768px) {
  .selected-food-desktop {
    display: none !important;
  }

  .selected-food-mobile {
    display: block !important;
  }
}

/* ==================== RECIPE INGREDIENT ROWS ==================== */
/* Recipe page needs 4-column grid: ingredient, amount, carbs, remove */
#recipe-ingredients-list .food-row {
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  #recipe-ingredients-list .food-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  #recipe-ingredients-list .food-row .form-group:first-child {
    grid-column: 1 / -1;
  }
}

/* ==================== ERSTATNINGSMAT PAGE HORIZONTAL LAYOUT ==================== */
/* Desktop: horizontal layout for the two input boxes */
.erstatningsmat-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Mobile: vertical layout */
@media (max-width: 768px) {
  .erstatningsmat-inputs {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* ==================== TOUCH FEEDBACK ==================== */
.btn:active { opacity: 0.8; transform: scale(0.98); }
button:active { opacity: 0.85; }
.tab:active { opacity: 0.8; }
.home-card:active { transform: scale(0.97); }

/* ==================== HOVER & INTERACTIVE STATES (DESKTOP) ==================== */

/* Database row hover */
.food-db-item:hover {
  background: #f0f4f8;
  border-color: #cbd5e0;
}

/* Status indicator hover */
.status:hover, .sugar-level:hover, .mysql-status:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* History item hover (matpakker) */
.bhg-history-item:hover {
  transform: translateX(2px);
}

/* Footer link hover */
footer a:hover {
  color: #e2e8f0 !important;
}

/* Global transition on interactive elements */
a, button, .btn, .tab, .card, select {
  transition: all 0.15s ease;
}

/* Preserve existing longer transitions where set */
nav a {
  transition: all 0.3s ease;
}

.logout-btn, .menu-btn, .remove-btn, .add-row-btn {
  transition: all 0.2s ease;
}

/* ==================== DESKTOP OPTIMIZATIONS ==================== */
@media (min-width: 1024px) {
  /* Wider main content area */
  main { max-width: 1400px; }

  /* Constrain input widths — exclude search/amount inputs that should stay full-width */
  input:not([type="checkbox"]):not([type="radio"]):not(.bhg-search-input):not(.bhg-amount-input) {
    max-width: 400px;
  }

  /* Constrain button widths */
  .btn { max-width: 300px; }

  /* Info page paragraph readability */
  .card p, .card li, .card ul, .card ol { max-width: 800px; }

  /* System page calculator grid — 3 columns */
  .calculator-grid { grid-template-columns: repeat(3, 1fr); }

  /* Card shadow enhancement */
  .card, .page { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

  /* Autocomplete dropdown — taller on desktop */
  .autocomplete-dropdown { max-height: 350px; }

  /* Database grid — remove min-width, let it expand naturally */
  #food-database-list > div { min-width: 0; width: 100%; }

  /* ===== Desktop Navigation Layout ===== */

  /* Hide hamburger button */
  .menu-btn {
    display: none;
  }

  /* Show dropdown as a second nav row */
  .dropdown-menu {
    display: flex !important;
    position: static;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0;
    box-shadow: none;
    padding: 0.25rem 1rem;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    min-width: 0;
    overflow: visible;
  }

  .dropdown-menu a {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: none;
    border-radius: 6px;
    white-space: nowrap;
    color: white;
  }

  .dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
  }

  .dropdown-menu a.active {
    background: rgba(255, 255, 255, 0.2);
  }

  /* Remove the separator border in the logout div */
  .dropdown-menu div[style*="border-top"] {
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* Show "Hjem" on desktop */
  nav ul li:first-child {
    display: list-item;
  }

  /* Nav items: natural width instead of flex: 1 */
  nav li {
    flex: 0 0 auto;
  }

  nav a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  /* Larger logo */
  .logo {
    font-size: 2rem;
  }

  /* Status indicators: slightly larger */
  .status, .sugar-level, .mysql-status {
    font-size: 0.85rem;
    padding: 0.5rem 0.9rem;
  }
}

