/* ============================================================
   Gearnomic — stylesheet
   Design: warm expedition-log aesthetic
   Fonts: Fraunces (display) + DM Sans (UI)
============================================================ */

:root {
  --bg:           #EDE8DF;
  --surface:      #FFFFFF;
  --surface-2:    #F7F3ED;
  --surface-3:    #F0EAE0;

  --primary:      #2A4032;
  --primary-h:    #1E3025;
  --primary-l:    #3D6B4F;

  --accent:       #B87B0A;
  --accent-l:     #FDF3E0;

  --text-1:       #18181A;
  --text-2:       #5A5A52;
  --text-3:       #9A9A87;

  --border:       #DDD6C8;
  --border-2:     #EDE7DC;

  --success:      #2A7048;
  --success-bg:   #EAF4EE;
  --success-text: #1C5736;

  --warning:      #B87B0A;
  --warning-bg:   #FDF3E0;
  --warning-text: #8C5D06;

  --danger:       #B03030;
  --danger-bg:    #FDEAEA;
  --danger-text:  #8C2020;

  --info:         #1A5C8A;
  --info-bg:      #E8F2FA;
  --info-text:    #124471;

  --r-sm:  4px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.04);

  --header-h: 56px;
  --content-max: 1200px;
  --font-ui:   'DM Sans', system-ui, -apple-system, sans-serif;
  --font-disp: 'Fraunces', Georgia, serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-disp);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .02em;
}
.logo-name {
  font-family: var(--font-disp);
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -.01em;
}
.main-nav {
  display: flex;
  gap: 2px;
  flex: 1;
}
.nav-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 400;
  transition: all .15s;
  white-space: nowrap;
}
.nav-tab:hover { background: var(--surface-2); color: var(--text-1); }
.nav-tab.active { background: var(--primary); color: #fff; font-weight: 500; }
.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Main content ── */
#main-content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-title {
  font-family: var(--font-disp);
  font-size: 26px;
  font-weight: 400;
  color: var(--text-1);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.page-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 3px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
}
.card-sub {
  font-size: 12px;
  color: var(--text-3);
}

/* ── Grids ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .875rem;
  margin-bottom: 1rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.metric-val {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.1;
}
.metric-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .875rem;
  flex-wrap: wrap;
}
.toolbar-left {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Form controls ── */
.input, .select, textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,64,50,.12);
}
.select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239A9A87' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }

/* Trip notes textarea */
/* Replace-flag indicator on gear items */
.replace-flag-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  opacity: .65;
  margin-left: 6px;
  vertical-align: middle;
  cursor: default;
  flex-shrink: 0;
}

/* Feedback rows in completed-trip gear table */
tr.trip-feedback-row td {
  padding-top: 0;
  background: var(--surface);
}
tr.trip-feedback-row:hover td { background: var(--surface) !important; }

.trip-notes-textarea {
  height: auto !important;
  padding: .75rem !important;
  min-height: 120px;
  line-height: 1.5;
  border: .5px solid var(--border) !important;
  resize: vertical;
}
.trip-notes-textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(184, 123, 10, .08) !important;
}


/* full-width form input variant */
.input-full { width: 100%; }

/* ── Form layout ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .875rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; margin-bottom: .875rem; }
.form-row { margin-bottom: .75rem; }
.form-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 500;
}
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.form-actions { display: flex; gap: .5rem; padding-top: .875rem; border-top: 1px solid var(--border-2); margin-top: .875rem; width: 100%; position: sticky; bottom: 0; background: var(--surface); padding-bottom: .5rem; z-index: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13.5px;
  font-weight: 400;
  white-space: nowrap;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: #c8c1b4; }
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text-1); }

.btn-danger { color: var(--danger); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text-2); font-size: 15px; }
.btn-icon:hover { background: var(--surface-2); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge-green  { background: var(--success-bg);  color: var(--success-text); }
.badge-blue   { background: var(--info-bg);      color: var(--info-text); }
.badge-amber  { background: var(--warning-bg);   color: var(--warning-text); }
.badge-red    { background: var(--danger-bg);    color: var(--danger-text); }
.badge-gray   { background: var(--surface-3);    color: var(--text-2); }
.badge-dark   { background: var(--primary);      color: #fff; }

/* ── Progress bars ── */
.prog-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.prog-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }
.prog-green  { background: var(--success); }
.prog-amber  { background: var(--accent); }
.prog-red    { background: var(--danger); }

/* ── Data tables ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
  color: var(--text-1);
  background: var(--surface);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tbody tr.expandable { cursor: pointer; }
.data-table .detail-row td { background: var(--surface-2); padding: 0; }
.detail-inner { padding: 12px 16px; font-size: 13px; border-top: 1px dashed var(--border); }

.item-name { font-weight: 500; line-height: 1.3; }
.item-sub  { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.mono { font-family: 'DM Mono', 'Fira Mono', ui-monospace, monospace; font-size: 12px; }

/* ── Category header rows — tan bg matches page, white rows pop out ── */
.cat-header-row td {
  background: var(--bg) !important;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.cat-header-row:hover td { background: var(--surface-3) !important; }

/* ── Weight bar (mini inline) ── */
.w-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.w-bar-label { font-size: 12px; color: var(--text-2); width: 130px; flex-shrink: 0; }
.w-bar-track { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.w-bar-fill  { height: 100%; border-radius: 3px; }
.w-bar-vals  { font-size: 11px; color: var(--text-3); font-family: monospace; width: 120px; text-align: right; flex-shrink: 0; }
@media (max-width: 640px) {
  .w-bar-label { width: 90px; }
  .w-bar-vals  { width: 70px; font-size: 10px; }
}

/* ── Trips grid ── */
.trips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .875rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) {
  .trips-grid { grid-template-columns: 1fr; gap: .625rem; }
}
.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
}
.trip-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.trip-card.active { border-color: var(--primary); border-width: 2px; }
.trip-card-name { font-size: 15px; font-weight: 500; margin-bottom: 3px; }
.trip-card-meta { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.trip-card-stats { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }

/* ── Gear picker (trip detail) ── */
.picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
  padding: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: .875rem;
}
.picker-item {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.picker-item:hover { border-color: var(--primary-l); color: var(--primary); }
.picker-item.in { background: var(--success-bg); border-color: var(--success); color: var(--success-text); }

/* ── Dashboard trip list ── */
.dash-trip-row {
  padding: .625rem 0;
  border-bottom: 1px solid var(--border-2);
  cursor: pointer;
}
.dash-trip-row:last-child { border-bottom: none; }
.dash-trip-row:hover { opacity: .75; }
.dash-trip-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.dash-trip-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }

/* ── Category weight bars (dashboard) ── */
.cat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.cat-bar-name { font-size: 12px; color: var(--text-2); width: 150px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar-track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.cat-bar-fill  { height: 100%; border-radius: 3px; }
.cat-bar-val   { font-size: 11.5px; color: var(--text-3); font-family: monospace; width: 60px; text-align: right; flex-shrink: 0; }
@media (max-width: 640px) {
  .cat-bar-name { width: 90px; }
  .cat-bar-val  { width: 48px; font-size: 10.5px; }
}

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-2);
}
.modal-title {
  font-family: var(--font-disp);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-1);
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  line-height: 1;
  padding-bottom: 2px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }
.modal-body { padding: 1.25rem 1.5rem 1.5rem; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-xl);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ── Gear summary bar ── */
.gear-summary {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: .625rem;
}
.gear-summary strong { color: var(--text-1); font-weight: 500; }

/* ── Section dividers ── */
.section-divider {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: .875rem 0 .375rem;
  font-weight: 500;
}

/* ── Utility ── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.mt-sm { margin-top: .5rem; }
.mt-md { margin-top: 1rem; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-3); font-size: 14px; }
.empty-state p { margin-bottom: .875rem; }
.changelog-dot { position:absolute; top:-2px; right:-10px; width:6px; height:6px; border-radius:50%; background:var(--warning); }

/* ── Analytics target bars ── */
.target-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.target-label { font-size: 12.5px; color: var(--text-2); width: 170px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-bar { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.target-fill { height: 100%; border-radius: 3px; }
.target-vals { font-size: 11px; font-family: monospace; color: var(--text-3); width: 140px; text-align: right; flex-shrink: 0; }

/* ── Info label pairs ── */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: .875rem; }
.info-pair { font-size: 12px; }
@media (max-width: 640px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
}
.info-key { color: var(--text-3); margin-bottom: 2px; }
.info-val { font-weight: 500; color: var(--text-1); }

/* ── Templates grid ── */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .875rem;
  margin-bottom: 1rem;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.template-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.template-card.active { border-color: var(--accent); border-width: 2px; }
.template-card-accent {
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
}
.template-card-name { font-size: 15px; font-weight: 500; margin-bottom: 3px; padding-left: 4px; }
.template-card-desc { font-size: 12px; color: var(--text-3); margin-bottom: 10px; padding-left: 4px; }
.template-card-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); padding-left: 4px; }
.template-card-stat strong { color: var(--text-1); font-weight: 500; }
.template-card-actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-2);
}

/* ── Apply template modal ── */
.apply-option {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: .5rem;
}
.apply-option:hover { border-color: var(--accent); background: var(--accent-l); }
.apply-option.selected { border-color: var(--accent); background: var(--accent-l); border-width: 2px; }
.apply-option-title { font-weight: 500; margin-bottom: 3px; }
.apply-option-desc { font-size: 12px; color: var(--text-2); }

/* ── Template detail ── */
.template-gear-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 5px;
  margin-bottom: 1rem;
}
.template-gear-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  font-size: 12px;
}
.template-gear-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Category tag pills in template ── */
.cat-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: .875rem; }
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.cat-pill-dot { width: 7px; height: 7px; border-radius: 50%; }
/* ============================================================
   MOBILE — bottom nav, cards, touch targets
============================================================ */

/* Bottom nav — hidden on desktop */
#mobile-bottom-nav {
  display: none;
}
.mobile-header-actions {
  display: none;
}

/* Meal day grid — responsive */
.meal-day-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  /* ── Layout ── */
  #main-content {
    padding: 1rem .875rem 5rem; /* extra bottom for nav bar */
  }
  .page-title { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .metrics-row { grid-template-columns: 1fr 1fr; }

  /* ── Modal — sheet from bottom ── */
  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }
  #modal-overlay { align-items: flex-end; padding: 0; }

  /* ── Header — compact ── */
  .header-inner { padding: 0 1rem; gap: .75rem; }
  .logo-name { display: none; }
  .main-nav { display: none; } /* replaced by bottom nav */
  .header-actions { display: none; } /* replaced by mobile-header-actions */
  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
  }
  .mobile-account-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
  }
  .mobile-unit-btn {
    height: 36px;
  }

  /* ── Bottom nav ── */
  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }
  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 10px;
    font-family: var(--font-ui);
    padding: 6px 4px;
    transition: color .15s;
    cursor: pointer;
  }
  .mob-tab svg { transition: stroke .15s; }
  .mob-tab.active { color: var(--primary); }
  .mob-tab.active svg { stroke: var(--primary); }

  /* ── More drawer buttons ── */
  .mob-drawer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    font-size: 14px;
    font-family: var(--font-ui);
    color: var(--text-1);
    cursor: pointer;
    width: 100%;
    text-align: left;
  }
  .mob-drawer-btn:active { background: var(--surface-2); }

  /* ── Page headers — stack on mobile ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .625rem;
    margin-bottom: 1rem;
  }
  .page-header > :last-child {
    width: 100%;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }
  .page-header button,
  .page-header > :last-child > button {
    flex: 1;
    min-height: 40px;
  }

  /* ── Toolbar ── */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }
  .toolbar-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .375rem;
  }
  .toolbar-left input {
    grid-column: 1 / -1;
    width: 100% !important;
    height: 42px;
  }
  .toolbar-left select,
  .toolbar > select {
    height: 42px;
    font-size: 13px;
  }
  .toolbar > .btn,
  .toolbar > button {
    height: 40px;
  }
  /* Toolbar right-side buttons row */
  .toolbar > :not(.toolbar-left):not(select) {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* ── Gear cards (already built, polish here) ── */
  .gear-card { padding: .875rem 1rem; }
  .gear-card-main { gap: 10px; }

  /* ── Food planning grid — 1-col on mobile ── */
  .meal-day-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* ── Trip cards ── */
  .trip-detail-grid { grid-template-columns: 1fr; }

  /* ── Metrics row — 2x2 ── */
  .metrics-row { gap: .625rem; }
  .metric-card { padding: .875rem; }
  .metric-val { font-size: 24px; }

  /* ── Touch targets — all interactive rows ── */
  .data-table td { padding: 10px 10px; }
  .data-table th { padding: 8px 10px; }
  .btn-sm { min-height: 34px; padding: 6px 12px; }
  .input, .select { height: 42px; font-size: 15px; }
  .form-row { margin-bottom: .875rem; }
  .form-label { font-size: 13px; margin-bottom: 5px; }

  /* ── Gear table — hide less-essential columns on mobile ── */
  .gear-table-wrap .data-table th:nth-child(n+5):not(:last-child),
  .gear-table-wrap .data-table td:nth-child(n+5):not(:last-child) {
    display: none;
  }

  /* ── Auth modal ── */
  .auth-modal-inner { padding: 1.5rem 1.25rem; }

  /* ── Footer ── */
  .footer-inner { flex-direction: column; gap: 1.5rem; }
  .footer-links { justify-content: flex-start; gap: 2rem; flex-wrap: wrap; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 6px; }
}
[id$="-new-type-row"] { align-items: center; }

/* ── More drawer buttons (desktop fallback) ── */
.mob-drawer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: 14px;
  font-family: var(--font-ui);
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
}
.mob-drawer-btn:hover { background: var(--surface-2); }

/* ── Drag & drop — gear rows ── */
.gear-row-dragging { opacity: 0.3; }

/* Section highlight — entire category group glows when dragging into it */
tr.cat-section-highlight td {
  background: var(--accent-l) !important;
}
tr.cat-header-row.cat-section-highlight td {
  background: var(--accent-l) !important;
  border-left: 3px solid var(--accent);
}
/* Handle cell */
.gear-handle-cell {
  width: 28px;
  padding: 0 4px !important;
  text-align: center;
  cursor: grab;
  color: var(--text-3);
  user-select: none;
}
.gear-handle-cell:active { cursor: grabbing; }
.gear-handle-cell:hover .gear-handle { color: var(--text-2); }
.gear-handle {
  font-size: 15px;
  display: inline-block;
  line-height: 1;
  transition: color .1s;
}

/* On mobile (touch devices), show handle as a tap target */
@media (hover: none) {
  .gear-handle-cell { cursor: pointer; }
  .gear-handle { color: var(--text-2); font-size: 17px; }
}

/* ── Category management modal ── */
.cat-mgmt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 4px;
  background: var(--surface);
  user-select: none;
}
.cat-mgmt-row.cat-drag-over {
  border-color: var(--accent);
  background: var(--accent-l);
  border-style: dashed;
}
.cat-mgmt-handle {
  cursor: grab;
  color: var(--text-3);
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}
.cat-mgmt-handle:active { cursor: grabbing; }
.cat-color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform .1s;
}
.cat-color-dot:hover { transform: scale(1.25); }
.cat-mgmt-name {
  flex: 1;
  font-size: 13px;
  cursor: text;
  min-width: 0;
}
.cat-mgmt-name:hover { text-decoration: underline; text-decoration-style: dotted; }
.cat-mgmt-target {
  width: 80px;
  height: 28px;
  font-size: 12px;
  padding: 0 7px;
  text-align: right;
}
.color-swatches {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .1s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: var(--text-1); }
.drag-hint {
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Inline-editable gear cells ── */
.editable-cell {
  cursor: text;
  position: relative;
}
.editable-cell:hover::after {
  content: '✎';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-3);
  pointer-events: none;
}
.data-table td.editable-cell:hover {
  background: var(--accent-l);
}
/* ── Gear row edit button (rightmost column) ── */
.gear-edit-col {
  width: 36px;
  text-align: center;
  padding: 4px;
}
.gear-edit-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 15px;
  padding: 4px 6px;
  border-radius: var(--r-md);
  line-height: 1;
  transition: color .12s, background .12s;
}
.gear-edit-btn:hover { color: var(--text-1); background: var(--surface-3); }

/* ── Drag reorder drop-line indicators ── */
tr.drop-line-before td { box-shadow: inset 0 2px 0 0 var(--accent); }
tr.drop-line-after  td { box-shadow: inset 0 -2px 0 0 var(--accent); }

/* ── Category header drag handle ── */
.cat-drag-handle {
  opacity: 0;
  transition: opacity .12s;
  cursor: grab;
  font-size: 14px;
  color: var(--text-3);
  user-select: none;
  display: inline-block;
}
.cat-header-row:hover .cat-drag-handle { opacity: 1; }
.cat-drag-handle:active { cursor: grabbing; }

/* ── Site footer ── */
#site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.footer-brand { flex-shrink: 0; }

.footer-links {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 110px;
}

.footer-col-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-2);
  margin-bottom: 2px;
}

.footer-col a {
  font-size: 13px;
  color: var(--text-3);
  text-decoration: none;
  cursor: pointer;
  transition: color .12s;
  line-height: 1;
}

.footer-col a:hover { color: var(--primary); }

.footer-bottom {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: .875rem 1.5rem;
  border-top: .5px solid var(--border-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 640px) {
  .footer-inner { flex-direction: column; gap: 1.5rem; }
  .footer-links { justify-content: flex-start; gap: 2rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 6px; padding-bottom: calc(.875rem + 60px); }
}

/* ── Bulk selection highlight ── */
tr.bulk-selected td { background: var(--accent-l) !important; }
.gear-card.bulk-selected { background: var(--accent-l); border-color: var(--primary); }

/* ── Gear mobile cards ── */
.gear-cards { display: none; }
.gear-card {
  display: flex;
  flex-direction: column;
  padding: .75rem 1rem;
  border-bottom: .5px solid var(--border-2);
  cursor: pointer;
  transition: background .1s;
  background: var(--surface);
}
.gear-card:last-child { border-bottom: none; }
.gear-card:hover { background: var(--surface-2); }
.gear-card:active { background: var(--accent-l); }
.gear-card.cat-section-highlight { background: var(--accent-l); opacity: 0.6; }
.gear-card-main { display: flex; align-items: center; }

.gear-cards-cat-header {
  display: flex;
  align-items: center;
  padding: .5rem 1rem;
  margin-top: 0.5rem;
  background: var(--surface-2);
  border-bottom: .5px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  cursor: grab;
  user-select: none;
  transition: background .1s;
}
.gear-cards-cat-header.cat-section-highlight {
  background: var(--accent-l);
  color: var(--text-1);
}

@media (max-width: 640px) {
  .gear-table-wrap { display: none; }
  .gear-cards { display: block; }
  .toolbar { gap: .5rem; }
  .toolbar-left { gap: .375rem; }
  .toolbar-left input { width: 100% !important; }
  .toolbar-left select { font-size: 12px; }
  #bulk-bar { font-size: 12px; }
}

/* ── Shopping list panel ──────────────────────────────────── */
#shopping-list-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sl-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.sl-header-name {
  font-family: var(--font-disp);
  font-size: 16px;
  font-weight: 400;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sl-counter {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.sl-body {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: .75rem 0 2rem;
}

.sl-summary {
  font-size: 12px;
  color: var(--text-3);
  padding: .25rem 1rem .75rem;
}

.sl-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1rem;
  min-height: 48px;
  border-bottom: .5px solid var(--border-2);
  cursor: pointer;
  user-select: none;
  transition: background .08s;
}
.sl-item:active { background: var(--surface-2); }

.sl-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, border-color .1s;
}
.sl-item.checked .sl-check {
  background: var(--primary);
  border-color: var(--primary);
}
.sl-check-mark {
  display: none;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  margin-top: -1px;
}
.sl-check-mark::before { content: '✓'; }
.sl-item.checked .sl-check-mark { display: block; }

.sl-text {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  color: var(--text-1);
  display: flex;
  align-items: baseline;
  gap: .625rem;
  flex-wrap: wrap;
}
.sl-item.checked .sl-text {
  text-decoration: line-through;
  color: var(--text-3);
}
.sl-item.checked .sl-qty { color: var(--text-3); }

.sl-qty {
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Print styles (shopping list) ─────────────────────────── */
@media print {
  body > *                { display: none !important; }
  body > #shopping-list-panel {
    display: block !important;
    position: static !important;
    overflow: visible !important;
  }
  .sl-header              { position: static !important; border: none !important;
                            padding: 0 0 .5rem !important; }
  .sl-header-actions      { display: none !important; }
  .sl-body                { padding: 0 !important; }
  .sl-item                { page-break-inside: avoid; min-height: 0 !important;
                            padding: 4px 0 !important; }
  .sl-item.checked .sl-text { text-decoration: none !important; color: #000 !important; }
  .sl-check               { border: 1px solid #999 !important; border-radius: 2px !important; }
  .sl-item.checked .sl-check { background: none !important; border-color: #999 !important; }
  .sl-check-mark          { display: none !important; }
  * { color: #000 !important; background: #fff !important; }
}

