* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: #f4f6f5;
  color: #1f2a25;
  line-height: 1.4;
}

a { color: #2a5d3a; }

/* Header */
header {
  background: #2a5d3a;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
header a { color: white; text-decoration: none; }
header .brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
header .brand-mark { width: 30px; height: 30px; display: block; }
header nav a { padding: 6px 12px; border: 1px solid rgba(255,255,255,0.4); border-radius: 5px; font-size: 13px; }
header nav a:hover { background: rgba(255,255,255,0.1); }

/* Layout */
main { max-width: 900px; margin: 28px auto; padding: 0 20px; }
footer { text-align: center; color: #888; font-size: 12px; padding: 32px 20px; }

h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 28px 0 14px; font-size: 17px; font-weight: 600; color: #2a5d3a; }
.empty { color: #888; padding: 24px; background: white; border: 1px dashed #d0d4d2; border-radius: 6px; text-align: center; }
.meta { color: #555; font-size: 13px; margin: 4px 0; }
.small { color: #999; font-size: 12px; }

/* Page header (title + actions) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header > div:first-child { flex: 1; min-width: 0; }

/* Status badge */
.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
}
.status-badge.active { background: #d8efde; color: #1f6b35; }
.status-badge.paused { background: #f0e9d8; color: #8a6f1c; }

/* Buttons */
button, .button-link {
  background: white;
  border: 1px solid #c8cdca;
  padding: 9px 14px;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
  color: #1f2a25;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
  font-family: inherit;
  white-space: nowrap;
  min-height: 40px;
}
button:focus-visible, .button-link:focus-visible, a:focus-visible {
  outline: 2px solid #2a5d3a;
  outline-offset: 2px;
}
header a:focus-visible { outline-color: white; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #2a5d3a;
  outline-offset: 1px;
}
button:hover, .button-link:hover { background: #f4f6f5; border-color: #9da5a0; }
button.primary, .button-link.primary { background: #2a5d3a; color: white; border-color: #2a5d3a; font-weight: 600; }
button.primary:hover, .button-link.primary:hover { background: #234d30; }
button.danger { color: #a83232; border-color: #d6c2c2; }
button.danger:hover { background: #fbeded; border-color: #a83232; }
form { display: inline; margin: 0; }

/* Search card list */
.search-list { display: flex; flex-direction: column; gap: 10px; }

.search-card {
  background: white;
  border: 1px solid #e1e5e3;
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  flex-wrap: wrap;
}
.search-card.inactive { opacity: 0.6; }
.search-card-main { flex: 1; min-width: 280px; }
.search-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.search-card-title a { text-decoration: none; color: #1f2a25; }
.search-card-title a:hover { color: #2a5d3a; }
.search-card-meta {
  font-size: 13px;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 6px;
}
.search-card-meta b { color: #1f2a25; font-weight: 600; }
.search-card-stats {
  font-size: 12px;
  color: #888;
}
.search-card-stats .stat b { color: #2a5d3a; font-weight: 700; }
.stat-sep { margin: 0 6px; color: #ccc; }
.search-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}
/* Push destructive actions away so they're not mis-tapped next to Edit/Pause */
.search-card-actions .delete-form,
.page-header .search-card-actions .delete-form {
  margin-left: 14px;
}

/* Edit/new form */
.search-form {
  background: white;
  padding: 22px 24px;
  border: 1px solid #e1e5e3;
  border-radius: 8px;
  max-width: 640px;
}
.search-form label { display: block; margin-bottom: 14px; }
.search-form label span { display: block; font-size: 12px; color: #666; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.search-form input[type="text"],
.search-form input[type="number"],
.search-form input[type="date"],
.search-form input[type="email"],
.search-form input[type="tel"],
.search-form input[type="search"],
.search-form select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #c8cdca;
  border-radius: 5px;
  font-size: 16px;       /* >=16px so iOS Safari doesn't zoom on focus */
  font-family: inherit;
  background: white;
}
.search-form input:focus, .search-form select:focus {
  outline: none;
  border-color: #2a5d3a;
  box-shadow: 0 0 0 2px rgba(42,93,58,0.15);
}
.search-form .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 0; }
.search-form .row label { margin-bottom: 14px; }

fieldset { border: 1px solid #e1e5e3; border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; }
fieldset legend { font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; padding: 0 6px; }
label.checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
label.checkbox span { text-transform: none; letter-spacing: normal; font-weight: normal; color: #1f2a25; font-size: 14px; display: inline; margin: 0; }
label.checkbox input { width: auto; margin: 0; }

.help-text { font-size: 12px; color: #666; margin: 0 0 12px; }

details.park-picker { margin-bottom: 8px; border: 1px solid #e1e5e3; border-radius: 6px; padding: 0; background: #fafbfb; }
details.park-picker > summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1f2a25;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.park-picker > summary::-webkit-details-marker { display: none; }
details.park-picker > summary::before {
  content: "▸";
  color: #999;
  font-size: 10px;
  display: inline-block;
  transition: transform 0.15s;
}
details.park-picker[open] > summary::before { transform: rotate(90deg); }
details.park-picker > summary:hover { background: #f0f3f1; }
.park-count { color: #888; font-weight: 400; font-size: 12px; }
.park-controls {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px;
  border-top: 1px solid #e1e5e3;
  background: white;
  flex-wrap: wrap;
}
.park-controls .park-filter {
  flex: 1 1 200px;
  padding: 8px 10px;
  border: 1px solid #c8cdca;
  border-radius: 5px;
  font-size: 14px;
  min-height: 36px;
}
.link-btn {
  background: none;
  border: none;
  padding: 6px 8px;
  color: #2a5d3a;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  min-height: 0;
}
.link-btn:hover { color: #234d30; }
.park-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
  padding: 8px 12px 12px;
  background: white;
}
.park-grid label.checkbox { margin-bottom: 4px; font-size: 14px; min-height: 32px; align-items: center; }

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

/* Itinerary list (detail page) */
.itinerary-list { display: flex; flex-direction: column; gap: 10px; }
.itinerary {
  background: white;
  border: 1px solid #e1e5e3;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.itinerary.multi-park { border-left: 3px solid #d2a23a; }
.itinerary.single-park { border-left: 3px solid #2a5d3a; }
.itinerary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.hop-badge {
  display: inline-block;
  background: #f0f3f1;
  color: #2a5d3a;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.itinerary.multi-park .hop-badge { background: #faf2dd; color: #8a6f1c; }
.itinerary-header .meta { font-size: 11px; color: #999; margin: 0; }

.leg { padding: 4px 0; }
.park-name {
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: #2a5d3a;
}
.park-name:hover { text-decoration: underline; }
.leg-meta {
  font-size: 12px;
  color: #666;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 2px;
}
.leg-meta b { color: #1f2a25; font-weight: 600; }
.region { color: #999; text-transform: capitalize; }
.hop-divider { color: #999; font-size: 14px; padding: 4px 0; text-align: center; }

/* Auth pages */
body.auth-page { background: #2a5d3a; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: white;
  padding: 32px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-width: 380px;
  width: 100%;
}
.auth-logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; }
.auth-card h1 { text-align: center; color: #2a5d3a; margin-bottom: 8px; }
.auth-card .meta { text-align: center; margin-bottom: 20px; }
.auth-card .small { text-align: center; color: #888; font-size: 12px; margin-top: 16px; }
.auth-form label { display: block; margin-bottom: 12px; }
.auth-form label span { font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; display: block; margin-bottom: 4px; }
.auth-form input { width: 100%; padding: 12px; border: 1px solid #c8cdca; border-radius: 5px; font-size: 16px; box-sizing: border-box; }
.auth-form input:focus { outline: none; border-color: #2a5d3a; box-shadow: 0 0 0 2px rgba(42,93,58,0.15); }
.auth-form button { width: 100%; padding: 10px; font-size: 14px; font-weight: 600; }

.error { background: #fbeded; color: #a83232; padding: 10px 14px; border-radius: 5px; border: 1px solid #f0d4d4; margin-bottom: 14px; font-size: 13px; }

/* Settings */
.settings-section { background: white; border: 1px solid #e1e5e3; border-radius: 8px; padding: 18px 22px; margin-bottom: 16px; }
.settings-section h2 { margin-top: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.inline-form input { padding: 11px 12px; border: 1px solid #c8cdca; border-radius: 5px; font-size: 16px; flex: 0 0 220px; min-height: 40px; }

.admin-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 14px; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th, .admin-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
.admin-table th { background: #fafafa; font-size: 12px; text-transform: uppercase; color: #666; letter-spacing: 0.04em; font-weight: 600; }
.admin-table td form { display: inline; }
.admin-table tr.row-error td { background: #fdf3f3; }
.admin-table code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; background: #f4f6f5; padding: 1px 5px; border-radius: 3px; }

/* Mobile tweaks */
@media (max-width: 640px) {
  header { padding: 10px 16px; }
  header nav a { padding: 8px 10px; font-size: 13px; }
  main { padding: 0 14px; margin: 18px auto; }
  .search-card { padding: 14px; }
  .search-card-actions {
    width: 100%; margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .search-card-actions a,
  .search-card-actions button { width: 100%; text-align: center; }
  /* Put Delete on its own row so it's not adjacent to Edit */
  .search-card-actions .delete-form {
    grid-column: 1 / -1; margin-left: 0;
  }
  .search-form .row { grid-template-columns: 1fr; }
  .park-grid { grid-template-columns: 1fr; }
  .park-grid label.checkbox { min-height: 40px; }
}
