:root {
  --bg: #241E1A;
  --surface: #332B24;
  --surface-raised: #3D342B;
  --border: #5A4B3C;
  --text: #F2E9DC;
  --text-dim: #C7B9A6;
  --rust: #C1502E;
  --gold: #D4A017;
  --sage: #8A9A5B;
  --slate: #7A8FA6;
  --danger: #B84C3E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

.sticky-header-group { position: sticky; top: 0; z-index: 500; }
.sticky-header-bar {
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.sticky-header-inner {
  max-width: 1180px; margin: 0 auto; padding: 8px 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
}
h1 { font-family: 'Roboto Slab', serif; font-weight: 700; margin: 0; }
.sticky-header-title { font-family: 'Roboto Slab', serif; font-size: 17px; font-weight: 700; margin: 0; }
.sticky-header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.15em; color: var(--gold); text-transform: uppercase; }
.today { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.conn-indicator { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); transition: background-color 0.2s; }
.conn-dot.online { background: var(--sage); }
.conn-dot.offline { background: var(--rust); }
.conn-dot.local { background: var(--slate); }
.coop-banner { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.coop-banner-name { font-family: 'Roboto Slab', serif; font-size: 22px; font-weight: 700; color: var(--gold); }
.coop-pill {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px;
}
.coop-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.coop-card.active { border-color: var(--rust); }

.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  color: var(--text-dim); padding: 10px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; border-radius: 6px 6px 0 0; font-family: 'Inter', sans-serif;
  display: flex; align-items: center; gap: 6px;
}
.tab-icon { font-size: 15px; line-height: 1; }
.tab.active { background: var(--surface); color: var(--text); border-bottom: 3px solid var(--rust); }

/* Mobile only: turn the tab bar into a fixed bottom nav, native-app style.
   Desktop layout above is untouched. */
@media (max-width: 700px) {
  .wrap { padding-bottom: 100px; } /* keep content clear of the fixed bar */

  .tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    margin-bottom: 0;
    background: var(--surface);
    border-bottom: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.35);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    gap: 2px;
    z-index: 50;
    justify-content: space-between;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 60px;
    border-bottom: none;
    border-radius: 10px;
    padding: 10px 4px;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
  }
  .tab-icon { font-size: 22px; }
  .tab.active {
    background: var(--surface-raised);
    border-bottom: none;
    border-top: 3px solid var(--rust);
    color: var(--gold);
  }
  .tab.active .tab-icon { transform: scale(1.08); }

  /* Sub-navs (Coop/Flock/Eggs) stack directly above the main tab bar,
     matching Settings' own sub-nav positioning exactly -- same bottom
     offset, same horizontal-scroll-instead-of-wrap handling, so labels
     like "Year Review" or "All-Time Stats" scroll rather than wrapping to
     a second line and throwing off the fixed height. Compound selector
     (not just .sub-nav-fixed) so this reliably wins over .range-select's
     own base rules regardless of source order -- same specificity, and
     .range-select happens to be defined later in this file, so without
     this the base flex-wrap:wrap and margin-bottom:14px would win instead. */
  .range-select.sub-nav-fixed {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(76px + env(safe-area-inset-bottom));
    margin-bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 12px 10px;
    z-index: 48;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.card-title { font-family: 'Roboto Slab', serif; font-size: 15px; font-weight: 700; margin-bottom: 10px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.grid-stats-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-stats-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-stats-3 { grid-template-columns: 1fr; } }
@media (max-width: 360px) { .grid-stats-2 { gap: 6px; } .grid-stats-2 .stat { padding: 12px 10px; } }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }

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

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.chart-box { position: relative; height: 260px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  border-left: 4px solid var(--rust);
}
.stat.tone-gold { border-left-color: var(--gold); }
.stat.tone-sage { border-left-color: var(--sage); }
.stat.tone-slate { border-left-color: var(--slate); }
.stat.tone-rust { border-left-color: var(--rust); }
.stat-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-family: 'Roboto Slab', serif; font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-dim); }

.stamp {
  display: inline-block; border: 2px solid var(--sage); color: var(--sage); border-radius: 4px;
  padding: 1px 8px; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; transform: rotate(-2deg); white-space: nowrap;
}
.stamp.tone-rust { border-color: var(--rust); color: var(--rust); }
.stamp.tone-gold { border-color: var(--gold); color: var(--gold); }
.stamp.tone-slate { border-color: var(--slate); color: var(--slate); }
.stamp.tone-danger { border-color: var(--danger); color: var(--danger); }
.stamp-lg { font-size: 14px; padding: 3px 10px; border-width: 2px; }

.range-select { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.range-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; font-family: 'Inter', sans-serif;
}
.range-btn.active { background: var(--rust); color: #F2E9DC; border-color: var(--rust); font-weight: 700; }

.pill-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; font-family: 'Inter', sans-serif;
}
.pill-btn:hover { border-color: var(--gold); }
.pill-btn-new { border-style: dashed; color: var(--text-dim); }

.settings-subnav { display: none; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.settings-subnav.visible { display: flex; }
@media (max-width: 700px) {
  .settings-subnav.visible {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(76px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 10px;
    margin-bottom: 0;
    z-index: 48;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .wrap.subnav-open { padding-bottom: 160px; }
}

.coop-icon-select { font-size: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px; cursor: pointer; }

.form-block { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
/* Modal form footers (Save/Delete row): a dashed divider plus real
   breathing room, so it reads as a distinct action area rather than just
   wherever the last field happened to end. */
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 20px; padding-top: 16px; border-top: 2px dashed var(--border); }
.photo-crop-frame {
  width: 100%; max-width: 320px; margin: 0 auto; border-radius: 10px;
  border: 2px solid var(--border); background-size: cover; background-repeat: no-repeat;
  cursor: grab; touch-action: none; user-select: none;
}
.photo-crop-frame.dragging { cursor: grabbing; border-color: var(--gold); }
.progress-bar-track { width: 100%; height: 10px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--rust), var(--gold)); transition: width 0.2s ease; border-radius: 5px; }
.form-head { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 700; font-family: 'Roboto Slab', serif; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
label.field span { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; line-height: 1.3; min-height: 2.6em; display: flex; align-items: flex-end; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  color: var(--text); font-size: 16px; font-family: 'Inter', sans-serif; outline: none; width: 100%;
}
textarea { min-height: 60px; resize: vertical; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--border); outline: none; cursor: pointer; margin: 10px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); cursor: pointer; border: 2px solid #1E1712;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); cursor: pointer; border: 2px solid #1E1712;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-track { background: var(--border); height: 6px; border-radius: 3px; }

.btn {
  background: var(--gold); color: #1E1712; border: 2px solid transparent; border-radius: 6px; padding: 10px 16px;
  font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif; min-height: 40px; transition: border-color 0.15s, filter 0.1s;
}
/* Gold-on-gold would make hover/click borders invisible, so gold buttons get
   their own feedback: a warm cream border on hover, a darkening dip on click. */
.btn:hover { border-color: #F2E9DC; }
.btn:active { filter: brightness(0.8); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--text-dim); border: 2px solid var(--border); }
.btn.ghost:hover { border-color: var(--gold); color: var(--text); }
.btn.ghost:active { background: var(--gold); color: #1E1712; border-color: var(--gold); }
.btn.small { padding: 8px 12px; font-size: 12px; min-height: 34px; }

/* Semantic button colors: gold (default, above) = add something new; sage =
   confirm/save; rust = close/cancel/delete. Text color is chosen per
   background for contrast, not uniformly -- white reads well on rust, but
   fails contrast on gold/sage (both too light for white text to sit on). */
.btn-confirm { background: var(--sage); color: #1E1712; }
.btn-confirm:hover { border-color: var(--gold); }
.btn-confirm:active { background: var(--gold); }
.btn-close { background: var(--rust); color: #F2E9DC; }
.btn-close:hover { border-color: var(--gold); }
.btn-close:active { background: var(--gold); color: #1E1712; }

.icon-btn { background: transparent; border: 2px solid transparent; cursor: pointer; color: var(--text-dim); padding: 8px 10px; border-radius: 4px; font-size: 15px; min-width: 38px; min-height: 38px; }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn:hover { color: var(--text); background: #5A4B3C55; border-color: var(--gold); }
.icon-btn:active { background: var(--gold); color: #1E1712; }
.icon-btn-close { background: var(--rust); color: #F2E9DC; }
.icon-btn-close:hover { border-color: var(--gold); }
.icon-btn-close:active { background: var(--gold); color: #1E1712; }

/* Finance period nav: compact selects instead of the global
   input/select/textarea width:100% default, and a visibly-bordered
   variant of .icon-btn so prev/next don't look like empty space until
   hovered -- scoped here rather than changed on .icon-btn itself, since
   that class is also used elsewhere as a deliberately subtle inline
   action (delete/edit icons, etc). */
.period-select { width: auto; min-width: 62px; max-width: 92px; padding: 8px 8px; font-size: 14px; }
.icon-btn-period { border-color: var(--border); background: var(--surface-raised); }
.icon-btn-period:hover { border-color: var(--gold); }

.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.confirm-modal {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; max-width: 380px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.confirm-message { font-size: 14px; color: var(--text); margin-bottom: 18px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--surface-raised); border-left: 4px solid var(--slate); color: var(--text);
  padding: 12px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45); opacity: 0; transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease; max-width: 300px;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-create { border-left-color: var(--sage); }
.toast-update { border-left-color: var(--slate); }
.toast-delete { border-left-color: var(--rust); }

.install-banner {
  background: var(--surface-raised); border: 1px solid var(--gold); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 13px; flex-wrap: wrap;
}

table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid #5A4B3C30; font-size: 13px; }
tr:hover td { background: var(--surface-raised); }
.group-row td { background: #3D342B55; border-bottom: 1px solid var(--border); }
.group-row:hover td { background: var(--surface-raised); }
.nested-row td { background: transparent; }
.nested-row:hover td { background: var(--surface-raised); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: auto; }

.flock-section-header { font-family: 'Roboto Slab', serif; font-weight: 700; font-size: 15px; margin: 4px 0 2px; grid-column: 1 / -1; }
.flock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; margin-bottom: 18px; }
.flock-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; position: relative; display: flex; flex-direction: column;
}
.flock-card.custom-color { border-width: 3px; }
.flock-card-group-open { border-color: var(--gold) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent), 0 0 14px color-mix(in srgb, var(--gold) 45%, transparent); }
.flock-card.selected { outline: 2px solid var(--rust); }
.flock-card-photo { position: relative; width: 100%; aspect-ratio: 1 / 1; background: var(--surface-raised); display: flex; align-items: center; justify-content: center; font-size: 30px; overflow: hidden; }
.flock-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.flock-card-status-badge {
  position: absolute; top: 6px; right: 6px; z-index: 2; transform: rotate(3deg);
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.flock-card-countdown-badge {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%) rotate(-2deg); z-index: 2;
}
.flock-card-countdown-badge .stamp { box-shadow: 0 2px 5px rgba(0,0,0,0.4); }
.stamp.stamp-on-photo.tone-sage { background: var(--sage); color: #1E1712; border-color: #1E1712; }
.stamp.stamp-on-photo.tone-rust { background: var(--rust); color: #F2E9DC; border-color: #F2E9DC; }
.stamp.stamp-on-photo.tone-gold { background: var(--gold); color: #1E1712; border-color: #1E1712; }
.stamp.stamp-on-photo.tone-slate { background: var(--slate); color: #1E1712; border-color: #1E1712; }
.stamp.stamp-on-photo.tone-danger { background: var(--danger); color: #F2E9DC; border-color: #F2E9DC; }
.flock-card-harvest-badge {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 2;
  background: rgba(30,23,18,0.72); color: #F2E9DC; font-size: 10px; font-weight: 700;
  text-align: center; padding: 3px 4px; letter-spacing: 0.03em;
}
.flock-card-check { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; z-index: 2; }
.card-selected { outline: 3px solid var(--gold); outline-offset: -1px; }
.list-card-check { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 2px; cursor: pointer; }
.egg-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.egg-tile {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; transition: transform 0.1s;
}
.egg-tile:hover { transform: scale(1.1); }
.flock-group-badge { position: absolute; bottom: 6px; right: 6px; z-index: 2; transform: rotate(3deg); }
.flock-card-info { padding: 8px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; flex: 1; }
.flock-card-name { font-family: 'Roboto Slab', serif; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--text); }
.flock-card-name-ribbon {
  display: block; width: calc(100% + 20px);
  margin: 0 -10px 4px; padding: 6px 10px;
  box-sizing: border-box; text-align: center;
}
.flock-card-breed { font-size: 11px; color: var(--gold); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.flock-card-sub { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.flock-card-actions { display: flex; justify-content: flex-end; gap: 2px; padding: 0 4px 4px; }

.list-stack { display: flex; flex-direction: column; gap: 8px; }
.list-stack-timeline { position: relative; padding-right: 104px; margin-right: 4px; }
.list-stack-timeline::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: 86px; border-right: 2px dotted var(--border);
}
.list-stack-timeline .list-card { position: relative; }
.list-stack-timeline .list-card::before {
  content: ""; position: absolute; right: -16px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg);
}
.timeline-total {
  position: absolute; right: -100px; top: 50%; transform: translateY(-50%) rotate(-2deg); width: 76px; text-align: center;
  display: inline-block; border: 2px solid var(--gold); border-radius: 4px; padding: 2px 4px; box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.supply-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 640px) { .supply-columns { gap: 10px; } }
.supply-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.supply-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; padding: 12px 14px 10px; gap: 4px; position: relative; }
.supply-card-check { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; z-index: 3; }
.supply-card-header-bar {
  display: block; width: calc(100% + 28px);
  margin: -12px -14px 4px; padding: 8px 14px 6px;
  box-sizing: border-box; text-align: center; border-radius: 9px 9px 0 0;
}
.supply-card-header-name { font-family: 'Roboto Slab', serif; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 30px; box-sizing: border-box; }
.supply-card-header-sub { font-size: 11px; font-weight: 600; opacity: 0.85; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 30px; box-sizing: border-box; }
.supply-bag-visual {
  width: 100%; aspect-ratio: 3 / 4; position: relative; margin: 6px 0;
  background: var(--bg); border: 2px solid var(--border); border-radius: 8px;
  overflow: hidden; cursor: pointer;
}
/* Photo bags: full color where product remains, greyscale + red diagonal
   dashes where it's been used up -- the reverse of dashing the whole
   thing regardless of how full it is. Three stacked layers rather than
   one, because a CSS filter on an element also grayscales its children
   with no way to opt a child back out of it -- so the greyscale photo,
   the dash pattern, and the full-color reveal all need to be independent
   siblings, not nested. */
.supply-bag-grey-base {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: grayscale(100%);
}
.supply-bag-dash-overlay {
  position: absolute; inset: 0; opacity: 0.6;
  background-image: repeating-linear-gradient(135deg, var(--rust) 0px, var(--rust) 2px, transparent 2px, transparent 9px);
}
.supply-bag-color-reveal {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transition: clip-path 0.35s ease;
}
.supply-mini-bag-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; padding: 0 6px; cursor: pointer; }
.supply-mini-bag {
  width: 100%; aspect-ratio: 3 / 4; position: relative;
  border-radius: 6px; border: 1px solid rgba(0,0,0,0.25);
}
.supply-mini-bag-more { grid-column: 1 / -1; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-top: 2px; }
.supply-bag-fill { position: absolute; bottom: 0; left: 0; right: 0; transition: height 0.35s ease, background-color 0.35s ease, border-color 0.35s ease; }
.supply-card-meta { font-size: 11px; }
.supply-status-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 2px; }
.supply-slider-wrap { padding: 0 4px; }
.supply-slider { width: 100%; margin: 4px 0 6px; cursor: pointer; }
.supply-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: currentColor; cursor: pointer; margin-top: -6px; }
.supply-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--border); }
.supply-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: currentColor; cursor: pointer; border: none; }
.supply-slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
.supply-stamp-row { text-align: center; margin: 2px 0; }
.supply-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.product-picker-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; align-items: flex-start; }
.product-brand-group { border: 2px dotted var(--border); border-radius: 8px; padding: 6px; flex: 0 0 auto; }
.product-brand-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px; text-align: center; white-space: nowrap; }
.product-brand-group-items { display: flex; gap: 8px; }
.product-picker-item { flex: 0 0 auto; width: 104px; cursor: pointer; text-align: center; border: 2px solid transparent; border-radius: 8px; padding: 3px; box-sizing: border-box; position: relative; }
.product-picker-item.selected { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.product-picker-remove {
  position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger); color: #F2E9DC; font-size: 10px; line-height: 16px; text-align: center;
  cursor: pointer; z-index: 2;
}
.product-picker-edit {
  position: absolute; top: -4px; left: -4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--slate); color: #F2E9DC; font-size: 9px; line-height: 16px; text-align: center;
  cursor: pointer; z-index: 2;
}
.product-picker-thumb { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--surface-raised); display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto; }
.product-picker-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-picker-label { font-size: 10.5px; margin-top: 3px; line-height: 1.25; white-space: normal; }
.product-picker-new { flex: 0 0 auto; width: 84px; cursor: pointer; text-align: center; }
.product-picker-new .product-picker-thumb { border: 2px dashed var(--border); background: transparent; color: var(--text-dim); }
.supply-open-one-btn {
  position: relative; overflow: hidden; width: 100%; margin-top: 8px;
  padding: 10px 12px; text-align: center; cursor: pointer; box-sizing: border-box;
  background: var(--surface-raised); border: 2px dashed var(--border); border-radius: 6px;
  font-weight: 700; color: var(--text); font-family: 'Roboto Slab', serif; font-size: 13px;
  transition: border-color 0.2s ease;
}
.supply-open-one-btn:hover { border-color: var(--gold); }
.supply-open-one-btn::before {
  /* folded-corner "dog-ear" in the top-right, using the classic diagonal border-triangle trick */
  content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 0 0 0;
  border-color: transparent var(--fold-color, var(--bg)) transparent transparent;
  filter: drop-shadow(-1px 1px 2px rgba(0,0,0,0.3));
  transition: border-width 0.25s ease;
}
.supply-open-one-btn:hover::before { border-width: 0 20px 20px 0; }
.supply-open-one-btn.tearing::before { animation: supplyTearFold 0.4s ease forwards; }
@keyframes supplyTearFold {
  0% { border-width: 0 20px 20px 0; }
  100% { border-width: 0 320px 320px 0; }
}
.list-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.list-card.tone-rust { border-left: 4px solid var(--rust); }
.list-card.tone-gold { border-left: 4px solid var(--gold); }
.list-card.tone-sage { border-left: 4px solid var(--sage); }
.list-card.tone-slate { border-left: 4px solid var(--slate); }
.list-card.tone-danger { border-left: 4px solid var(--danger); }
.list-card-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.list-card-desc { font-size: 13px; overflow-wrap: anywhere; }
.list-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.list-card-amount { font-family: 'JetBrains Mono', monospace; font-weight: 700; white-space: nowrap; text-align: right; }

.empty { color: var(--text-dim); font-size: 13px; padding: 30px 0; text-align: center; }
.note-box { background: var(--surface); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px; font-size: 12px; color: var(--text-dim); }
.mono { font-family: 'JetBrains Mono', monospace; }
.dim { color: var(--text-dim); }
.section-gap { display: flex; flex-direction: column; gap: 22px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }

#statusBannerSlot:not(:empty) { border-bottom: 1px solid var(--border); }
.status-banner-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.local-only-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold); color: #1E1712;
  font-size: 11px; font-weight: 700; line-height: 1.3;
  padding: 6px 12px; border-radius: 0 0 8px 8px;
  cursor: pointer;
}
.local-only-badge-overdue { background: var(--rust); color: #F2E9DC; animation: local-only-pulse 2.2s ease-in-out infinite; }
@keyframes local-only-pulse { 0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.3); } 50% { box-shadow: 0 2px 12px rgba(193,80,46,0.7); } }
.local-only-badge-sub {
  font-size: 9px; font-weight: 600; opacity: 0.8;
  text-transform: uppercase; letter-spacing: 0.03em;
}

.server-version-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--rust); color: #F2E9DC;
  font-size: 11px; font-weight: 700; line-height: 1.3;
  padding: 6px 12px; border-radius: 0 0 8px 8px;
  cursor: pointer;
  animation: local-only-pulse 2.2s ease-in-out infinite;
}
.server-version-badge-sub {
  font-size: 9px; font-weight: 600; opacity: 0.85;
  text-transform: uppercase; letter-spacing: 0.03em;
}

.sync-indicator {
  display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--gold);
  font-family: 'JetBrains Mono', monospace;
}
.sync-indicator-spin { display: inline-block; animation: sync-spin 1s linear infinite; }
@keyframes sync-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.undo-redo-bar {
  display: flex; gap: 2px;
}
.undo-redo-bar button {
  background: transparent; border: none; color: var(--text); font-size: 17px;
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.undo-redo-bar button:hover:not(:disabled) { background: var(--surface); }
.undo-redo-bar button:disabled { color: var(--border); cursor: default; }

.photo-lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  cursor: zoom-out;
}
.photo-lightbox-img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); cursor: default; }
.photo-lightbox-close { position: fixed; top: 16px; right: 16px; background: rgba(0,0,0,0.55); color: #F2E9DC; z-index: 2001; }
.photo-lightbox-reposition { position: fixed; top: 16px; right: 60px; background: rgba(0,0,0,0.55); color: #F2E9DC; z-index: 2001; }

/* ---------- shared modal / bottom sheet ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-panel {
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  width: 100%; max-height: 88vh; overflow-y: auto; position: relative;
  border-radius: 16px 16px 0 0;
  padding: 26px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-overlay.open .modal-panel { transform: translateY(0); }
/* Drag-handle indicator -- purely visual, there's no actual drag-to-dismiss
   gesture, but it signals "sheet" at a glance the way a close button alone
   doesn't on mobile. */
.modal-panel::before {
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; background: var(--border); border-radius: 2px;
}
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-dim); font-size: 15px; padding: 0;
}
.modal-close:hover { color: var(--text); border-color: var(--gold); }
.modal-delete {
  position: absolute; top: 10px; right: 52px; z-index: 2;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 50%;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--rust); font-size: 14px; padding: 0;
}
.modal-delete:hover { background: var(--rust); color: #F2E9DC; border-color: var(--rust); }

@media (min-width: 720px) {
  /* Desktop gets a centered dialog with a fade + slight scale-in instead
     of a sheet sliding off the bottom of the screen -- a bottom sheet
     reads as a mobile-native pattern, and would look like an accident on
     a wide viewport rather than an intentional dialog. */
  .modal-overlay { align-items: center; }
  .modal-panel {
    max-width: 560px; max-height: 85vh; border: 1px solid var(--border); border-radius: 14px;
    padding: 24px; transform: translateY(10px) scale(0.97); opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .modal-overlay.open .modal-panel { transform: translateY(0) scale(1); opacity: 1; }
  .modal-panel::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-panel { transition: none; }
}
