/* ============================================================
   Cormorant Garamond — locally hosted
   ============================================================ */

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/cormorant-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/cormorant-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/cormorant-500italic.woff2') format('woff2');
}

/* ============================================================
   Wine Cellar — dark theme, mobile-first
   ============================================================ */

:root {
  --bg:        #0f0a0d;
  --surface:   #1a1217;
  --surface2:  #221829;
  --border:    #2d1f28;
  --primary:   #8b1a4a;
  --primary-h: #a8215b;
  --accent:    #c44478;
  --text:      #e8dde4;
  --muted:     #9a8892;
  --success:   #4a7c59;
  --warning:   #8b6914;
  --error:     #8b2222;
  --info:      #1a5276;

  --radius:    6px;
  --shadow:    0 2px 8px rgba(0,0,0,.45);
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary-h); }

img { max-width: 100%; height: auto; display: block; }

/* ============================================================
   Nav
   ============================================================ */

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo-icon { font-size: 1.3rem; }

.nav-links {
  display: flex;
  gap: .5rem;
  flex: 1;
}

.nav-link {
  padding: .35rem .75rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .9rem;
  transition: color .15s, background .15s;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--surface2);
}

.nav-link--add {
  background: var(--primary);
  color: var(--text) !important;
  font-weight: 600;
}

.nav-link--add:hover { background: var(--primary-h); }

.nav-user {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* ============================================================
   Main layout
   ============================================================ */

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ============================================================
   Flash messages
   ============================================================ */

.flashes { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  border-left: 3px solid;
}

.flash--success { background: rgba(74,124,89,.15); border-color: var(--success); }
.flash--error   { background: rgba(139,34,34,.18); border-color: var(--error); }
.flash--warning { background: rgba(139,105,20,.15); border-color: var(--warning); }
.flash--info    { background: rgba(26,82,118,.18); border-color: var(--info); }

/* ============================================================
   Page header
   ============================================================ */

.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  color: var(--muted);
  font-size: .9rem;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-family: var(--font);
  font-weight: 500;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary   { background: var(--primary); color: var(--text); }
.btn--primary:hover { background: var(--primary-h); color: var(--text); }

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover { border-color: var(--muted); color: var(--text); }

.btn--sm { padding: .3rem .65rem; font-size: .82rem; }

.btn--danger { background: var(--error); color: var(--text); }
.btn--danger:hover { opacity: .85; }

/* ============================================================
   Forms
   ============================================================ */

.form { display: flex; flex-direction: column; gap: 1.5rem; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  gap: .75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .form-row--2 { grid-template-columns: 1fr 1fr; }
  .form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: .3rem; }

.form-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
}

.form-label .required { color: var(--accent); }

.form-input,
.form-select,
.form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  padding: .5rem .75rem;
  width: 100%;
  transition: border-color .15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-select option { background: var(--surface2); }

.form-textarea { resize: vertical; min-height: 80px; }

.form-input.error,
.form-select.error { border-color: var(--error); }

.form-error { font-size: .8rem; color: #d64a4a; }

.form-hint { font-size: .78rem; color: var(--muted); }

/* ============================================================
   Cellar list
   ============================================================ */

.cellar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.cellar-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.cellar-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  padding: .5rem .75rem .5rem 2.2rem;
  width: 100%;
}

.cellar-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.cellar-search-icon {
  position: absolute;
  left: .65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .95rem;
}

.cellar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  padding: .4rem .65rem;
  cursor: pointer;
}

.filter-select:focus { outline: none; border-color: var(--accent); }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .65rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}

.filter-chip:hover, .filter-chip.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Location switches */
.cellar-loc-switches {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}

.loc-switch {
  padding: .3rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .85rem;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}

.loc-switch:hover { border-color: var(--muted); color: var(--text); }
.loc-switch.active { border-color: var(--accent); color: var(--accent); background: rgba(196,68,120,.08); }

.cellar-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: .75rem;
  font-size: .85rem;
  color: var(--muted);
}

/* Jump-to dropdown (phone) */
.jump-to-wrap {
  margin-bottom: .75rem;
}

.jump-to-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  padding: .45rem .75rem;
  width: 100%;
  cursor: pointer;
}

.jump-to-select:focus { outline: none; border-color: var(--accent); }

/* Cellar table */
.cellar-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: .25rem;
}

.cellar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.cellar-table thead th {
  padding: .55rem 1rem;
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}

.cellar-table thead th a {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

.cellar-table thead th a:hover { color: var(--text); }
.cellar-table thead th a.sort-active { color: var(--accent); }

.cellar-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background .1s;
}

.cellar-table tbody td {
  padding: .6rem 1rem;
  vertical-align: middle;
}

/* Country band */
.band-country td {
  padding: .6rem 1rem;
  background: var(--surface2);
  border-top: 2px solid var(--border);
  cursor: pointer;
}

.band-country:first-child td { border-top: none; }

.band-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .85rem;
  cursor: pointer;
  padding: 0 .3rem 0 0;
  transition: transform .2s;
  vertical-align: middle;
}

.band-country.collapsed .band-toggle { transform: rotate(-90deg); }

.band-country-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .01em;
  vertical-align: middle;
}

.band-country-stats {
  float: right;
  font-size: .8rem;
  color: var(--muted);
  font-weight: 400;
  padding-top: .15rem;
}

/* Region band */
.band-region td {
  padding: .45rem 1rem .45rem 2rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.band-region-name {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  color: var(--muted);
  font-variant: small-caps;
}

.band-region-stats {
  float: right;
  font-size: .78rem;
  color: var(--muted);
}

/* Wine rows */
.wine-row:hover td { background: rgba(255,255,255,.025); }

.col-appellation {
  width: 160px;
  min-width: 120px;
}

.appellation-name {
  font-family: var(--font-serif);
  font-size: .95rem;
  font-weight: 500;
  color: var(--muted);
  font-style: italic;
}

.col-wine a {
  color: var(--text);
  text-decoration: none;
  display: inline;
}

.col-wine a:hover { color: var(--accent); }

.wine-producer { font-weight: 600; }
.wine-cuvee { font-weight: 400; color: var(--muted); }

.col-vintage { white-space: nowrap; color: var(--muted); font-size: .85rem; }

.num { text-align: right; }

.at-cost { color: var(--muted); font-style: italic; }

.consumed-count { cursor: default; border-bottom: 1px dashed var(--muted); }

/* Phone two-line layout */
.wine-row-phone td { padding: .55rem 1rem; }

.phone-row { display: flex; flex-direction: column; gap: .2rem; }

.phone-line1, .phone-line2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
}

.phone-wine-name {
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-wine-name:hover { color: var(--accent); }

.phone-right { flex-shrink: 0; font-size: .85rem; color: var(--muted); text-align: right; }

.phone-line2 { font-size: .8rem; }

/* Responsive show/hide */
@media (min-width: 760px) {
  .hide-desktop { display: none !important; }
  .show-phone   { display: none !important; }
}

@media (max-width: 759px) {
  .hide-phone { display: none !important; }

  .cellar-table-wrap { border: none; border-radius: 0; margin-left: -1rem; margin-right: -1rem; }

  .band-country td { padding: .55rem 1rem; }
  .band-country-name { font-size: 1rem; }
  .band-region td { padding: .4rem 1rem; }

  .band-region-stats,
  .band-country-stats { float: none; display: inline; margin-left: .4rem; }
}

/* Wine cards grid */
.wines-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.wine-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}

.wine-card:hover { background: var(--surface2); }

.wine-card-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--surface2);
  flex-shrink: 0;
}

.wine-card-thumb-placeholder {
  width: 40px;
  height: 56px;
  background: var(--surface2);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  font-size: 1.3rem;
}

.wine-card-body { flex: 1; min-width: 0; }

.wine-card-name {
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wine-card-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .15rem;
}

.wine-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--qty     { background: rgba(139,26,74,.3); color: #d4789e; }
.badge--due     { background: rgba(139,105,20,.25); color: #d4a84e; }
.badge--ready   { background: rgba(74,124,89,.25); color: #78c496; }
.badge--peak    { background: rgba(196,68,120,.25); color: #c44478; }
.badge--young   { background: rgba(100,100,140,.2); color: #9090c4; }
.badge--past    { background: rgba(90,70,70,.25); color: #a07878; }
.badge--type    { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ============================================================
   Wine detail
   ============================================================ */

.detail-header {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.detail-label {
  width: 120px;
  flex-shrink: 0;
}

.detail-label img {
  width: 120px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.detail-label-placeholder {
  width: 120px;
  height: 165px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  font-size: 2.5rem;
}

.detail-meta { flex: 1; min-width: 0; }

.detail-name {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: .5rem;
}

.detail-attrs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}

.detail-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.detail-props {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .6rem;
  margin-bottom: 1.5rem;
}

.prop {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
}

.prop-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.prop-value { font-size: .9rem; font-weight: 500; margin-top: .1rem; }

/* Vintages */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.vintage-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.vintage-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface2);
  flex-wrap: wrap;
}

.vintage-year { font-size: 1rem; font-weight: 700; }

.vintage-actions {
  margin-left: auto;
  display: flex;
  gap: .4rem;
}

.lots-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.lots-table th, .lots-table td {
  padding: .6rem .75rem;
  text-align: left;
  border-top: 1px solid var(--border);
}

.lots-table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 500;
}

.lots-table tr:hover td { background: rgba(255,255,255,.02); }

/* Photos */
.photos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.photo-thumb {
  width: 90px;
  height: 125px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.photo-upload {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  cursor: pointer;
  color: var(--muted);
  font-size: .9rem;
  transition: border-color .15s, color .15s;
}

.photo-upload:hover { border-color: var(--accent); color: var(--text); }

.photo-upload input[type="file"] { display: none; }

/* ============================================================
   Grape rows (wine form)
   ============================================================ */

.grape-rows { display: flex; flex-direction: column; gap: .5rem; }

.grape-row {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: .5rem;
  align-items: center;
}

.grape-row-remove {
  background: transparent;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 1rem;
  padding: .25rem;
  border-radius: var(--radius);
  line-height: 1;
}

.grape-row-remove:hover { background: rgba(139,34,34,.2); }

/* ============================================================
   Duplicate check banner
   ============================================================ */

.dup-banner {
  display: none;
  background: rgba(139,105,20,.18);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .9rem;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.dup-banner.visible { display: flex; }

/* ============================================================
   Display name preview
   ============================================================ */

.name-preview {
  padding: .5rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-style: italic;
  color: var(--muted);
  min-height: 2rem;
}

/* ============================================================
   Vintage range inputs
   ============================================================ */

.vintage-range {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.vintage-range input {
  width: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  padding: .4rem .6rem;
}

.vintage-range input:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   Error pages
   ============================================================ */

.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-code {
  font-size: 5rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: .5rem;
}

.error-msg {
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

/* ============================================================
   Utilities
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.hidden { display: none !important; }

/* ============================================================
   Undo toast
   ============================================================ */

.undo-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  z-index: 500;
  min-width: 280px;
  max-width: 90vw;
}

.undo-toast-msg { flex: 1; }

.undo-countdown {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   Event log
   ============================================================ */

.event-log { margin-top: .75rem; }

.event-log-header {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .5rem .75rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.event-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .4rem .75rem;
  font-size: .84rem;
  border-top: 1px solid var(--border);
}

.event-row-type {
  font-weight: 600;
  min-width: 80px;
  color: var(--text);
}

.event-row-detail { flex: 1; color: var(--muted); }
.event-row-date { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ============================================================
   Tasting notes
   ============================================================ */

.note-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: .5rem;
}

.note-card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}

.note-score {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: .15rem .5rem;
  font-size: .85rem;
  font-weight: 700;
}

.note-body { font-size: .88rem; color: var(--muted); }

/* ============================================================
   Market prices
   ============================================================ */

.price-row {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}

.price-amount { font-weight: 600; }
.price-meta { color: var(--muted); font-size: .78rem; }

.add-price-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: flex-end;
  margin-top: .75rem;
}

.add-price-form input,
.add-price-form select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  padding: .4rem .6rem;
}

.add-price-form input:focus,
.add-price-form select:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   Label scan
   ============================================================ */

.scan-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  margin-bottom: 1rem;
}
.scan-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.scan-btn { cursor: pointer; }
.scan-library { color: var(--muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }
.scan-error { flex-basis: 100%; color: #e08a8a; font-size: .85rem; }

.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,10,13,.85);
}
.scan-overlay[hidden] { display: none; }
.scan-overlay-box { text-align: center; color: var(--text); }
.scan-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto .75rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: scan-spin .9s linear infinite;
}
@keyframes scan-spin { to { transform: rotate(360deg); } }

.scan-banner {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: .9rem;
}
.scan-banner--failed { border-left-color: var(--warning); }
.scan-photo { width: 72px; max-height: 96px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.scan-note { margin-top: .35rem; color: var(--muted); font-size: .85rem; }

.scan-flag { border-left: 3px solid var(--warning); padding-left: .5rem; }
.scan-flag--inferred, .scan-flag--estimate { border-left-color: var(--info); }
.scan-flag-note { margin-top: .25rem; font-size: .75rem; color: var(--muted); }

.geo-new { margin-top: .4rem; }
.geo-new[hidden] { display: none; }
.scan-flag--new { border-left-color: var(--accent); }

/* ============================================================
   Batch scan
   ============================================================ */

.scan-batch-btn { white-space: nowrap; }
.scan-resume { color: var(--accent); font-size: .9rem; text-decoration: underline; }
.btn--lg { padding: .9rem 1.4rem; font-size: 1.05rem; min-height: 52px; }

.batch-resume, .batch-summary { max-width: 640px; }
.batch-resume-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.batch-summary-tiles { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.batch-summary .tile {
  flex: 1 1 140px; padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-align: center;
}
.tile-num { font-family: var(--font-serif); font-size: 2.2rem; color: var(--accent); line-height: 1.1; }
.batch-summary-list { padding-left: 1.2rem; line-height: 1.8; }

/* capture */
.capture { max-width: 520px; margin: 0 auto; }
.capture-counter {
  display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: .75rem;
  padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; color: var(--muted);
}
.capture-counter strong { color: var(--text); font-size: 1.15rem; }
.capture-waiting { color: #e0b46a; }
.capture-defaults { margin-bottom: 1rem; }
.capture-defaults summary { cursor: pointer; color: var(--muted); padding: .5rem 0; }
.capture-error, .bcard-problems {
  margin-bottom: 1rem; padding: .75rem 1rem; border-radius: var(--radius);
  background: rgba(139,34,34,.25); border: 1px solid var(--error); color: var(--text);
}
.capture-error[hidden], .bcard-problems[hidden] { display: none; }
.bcard-problems ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.capture-stage { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.capture-stage[hidden] { display: none; }
.capture-shoot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 220px; gap: .5rem; font-size: 3.5rem; cursor: pointer;
  background: var(--primary); color: var(--text); border-radius: 16px;
}
.capture-shoot span { font-size: 1.4rem; font-weight: 600; }
.capture-shoot:active { background: var(--primary-h); }
.capture-preview { width: 100%; max-height: 38vh; object-fit: contain; border-radius: var(--radius); background: #000; }
.capture-qty-label { font-size: 1.1rem; color: var(--muted); }
.capture-done-row { width: 100%; display: flex; justify-content: center; }
.capture-done-row .btn[hidden] { display: none; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 1.25rem; }
.stepper-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 2.4rem; line-height: 1; cursor: pointer;
}
.stepper-btn:active { background: var(--primary); }
.stepper-value { min-width: 3ch; text-align: center; font-size: 3rem; font-weight: 600; }
.stepper--sm { justify-content: flex-start; gap: .6rem; }
.stepper--sm .stepper-btn { width: 48px; height: 48px; font-size: 1.6rem; }
.stepper--sm .stepper-value { font-size: 1.6rem; }
.capture-next {
  width: 100%; min-height: 76px; font-size: 1.5rem; font-weight: 600; border: 0;
  border-radius: 16px; background: var(--primary); color: var(--text); cursor: pointer;
}
.capture-next:active { background: var(--primary-h); }
.capture-done {
  width: 100%; min-height: 56px; font-size: 1.1rem; border-radius: 12px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--border);
}

/* review */
.bcards { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 5rem; }
.bcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem;
}
.bcard--attn { border-left: 3px solid var(--warning); }
.bcard-head { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .75rem; }
.bcard-thumb img { width: 72px; max-height: 96px; object-fit: cover; border-radius: 4px; display: block; }
.bcard-title { flex: 1; min-width: 0; }
.bcard-num { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.bcard-name { font-weight: 600; overflow-wrap: anywhere; margin-bottom: .25rem; }
.bcard-tools { display: flex; flex-direction: column; gap: .35rem; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; background: var(--surface2); color: var(--muted); }
.chip--ok { color: #8fcf9f; }
.chip--warn { color: #e0b46a; }
.chip--bad { color: #e08a8a; }
.bcard-wait { display: flex; align-items: center; gap: .75rem; color: var(--muted); padding: 1rem 0; }
.bcard-wait .scan-spinner { margin: 0; width: 1.5rem; height: 1.5rem; }
.bcard-fail { margin-bottom: .75rem; padding: .6rem .8rem; border-radius: var(--radius); background: rgba(139,105,20,.18); border: 1px solid var(--warning); font-size: .9rem; }
.bcard-dup { margin-bottom: .75rem; padding: .6rem .8rem; border-radius: var(--radius); background: rgba(139,105,20,.18); border: 1px solid var(--warning); font-size: .9rem; }
.bcard-dup-choices { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: .5rem; }
.bcard-dup-choices label { display: flex; align-items: center; gap: .4rem; min-height: 44px; }
.bcard-more { margin-top: .5rem; }
.bcard-more summary { cursor: pointer; color: var(--muted); padding: .5rem 0; min-height: 44px; }
.bcard-msg { min-height: 1.1rem; margin-top: .4rem; font-size: .8rem; color: var(--muted); }
.bcard-msg--bad { color: #e08a8a; }
.scan-flag--missing { border-left-color: var(--error); }
.review-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex;
  align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: var(--surface); border-top: 1px solid var(--border);
}
.review-bar .btn--primary { flex: 1; max-width: 360px; }

/* ---- Phase 3b: AI tasting support ---- */
.ep-head { display:flex; align-items:center; justify-content:space-between; gap:.5rem; flex-wrap:wrap; margin-bottom:.5rem; }
.ep-meta { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:.5rem; }
.ep-statement { font-style: italic; margin:.25rem 0 .5rem; }
.ep-level { margin:.25rem 0 .5rem; font-size:.9rem; }
.ep-grid { display:grid; grid-template-columns: 7rem 1fr; gap:.3rem .75rem; margin:.5rem 0; }
.ep-grid dt { color: var(--muted); font-size:.85rem; }
.ep-grid dd { margin:0; }
.ep-sources { font-size:.88rem; margin-top:.5rem; }
.ep-sources ul { margin:.25rem 0 0 1.1rem; padding:0; }
.ep-sources a { word-break: break-word; }
.ep-form { margin-top:.75rem; }
.ep-source { margin-top:.5rem; }
.ep-source .form-group { margin:.4rem 0; }
.ep-wait { display:flex; align-items:center; gap:.6rem; margin-top:.6rem; }
.ep-wait .scan-spinner { margin:0; width:1.2rem; height:1.2rem; }
.ep-error { color: var(--error); margin-top:.5rem; }
.ep-older { margin-top:.75rem; }
.ep-version { border-top:1px dashed var(--border); padding-top:.5rem; margin-top:.5rem; opacity:.85; }
.ep-switch { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; margin:0 0 .75rem; }
.switch { position:relative; width:2.75rem; height:1.55rem; border-radius:1rem; border:1px solid var(--border);
  background: var(--surface, #2a2226); cursor:pointer; padding:0; flex:none; }
.switch span { position:absolute; top:2px; left:2px; width:1.15rem; height:1.15rem; border-radius:50%;
  background: var(--muted); transition: transform .15s; }
.switch--on { background: var(--primary); border-color: var(--primary); }
.switch--on span { transform: translateX(1.2rem); background: var(--text); }
.radio-row { display:flex; gap:.6rem; align-items:flex-start; margin:.4rem 0; }
.cmp-table { width:100%; border-collapse:collapse; margin-top:.75rem; }
.cmp-table th, .cmp-table td { text-align:left; vertical-align:top; padding:.5rem .6rem; border-bottom:1px solid var(--border); }
.cmp-table tbody th { color: var(--muted); font-weight:500; width:6.5rem; }
.cmp-same td:last-child { box-shadow: inset 3px 0 0 var(--success); }
.cmp-diff td:last-child { box-shadow: inset 3px 0 0 var(--warning); }
.structured { outline:2px solid var(--warning); }
.text-error { color: var(--error); }
@media (max-width: 480px) {
  .ep-grid { grid-template-columns: 5.5rem 1fr; }
  .cmp-table th, .cmp-table td { padding:.4rem .35rem; font-size:.9rem; }
  .cmp-table tbody th { width:4.5rem; }
}

/* Phone nav: keep the bar inside 375 px */
@media (max-width: 480px) {
  .nav-user { display: none; }
  .nav-inner { gap: .5rem; padding: .75rem .75rem; }
  .nav-logo-text { display: none; }
  .nav-link { padding: .35rem .5rem; }
  .cmp-table { table-layout: fixed; }
  .cmp-table td, .cmp-table th { overflow-wrap: anywhere; }
}

/* Tasting note card uses the same label grid as the expected profile */
.note-title { font-size:.8rem; text-transform:uppercase; letter-spacing:.06em; color: var(--muted); }
.note-grid { margin:0; }
.note-grid dd { overflow-wrap:anywhere; }
@media (max-width: 480px) { .note-grid { grid-template-columns: 6rem 1fr; } }

.sub-label { font-size:.8rem; margin-top:.4rem; }

/* ---- Gifts received ---- */
.seg { display:inline-flex; border:1px solid var(--border); border-radius: var(--radius); overflow:hidden; margin-bottom:.9rem; }
.seg-opt { position:relative; cursor:pointer; }
.seg-opt input { position:absolute; opacity:0; inset:0; cursor:pointer; }
.seg-opt span { display:block; padding:.55rem 1.1rem; min-height:44px; line-height:1.9; color: var(--muted); font-weight:500; }
.seg-opt input:checked + span { background: var(--primary); color: var(--text); }
.seg-opt input:focus-visible + span { outline:2px solid var(--text); outline-offset:-2px; }
.acq [data-acq-gift], .bcard [data-acq-gift] { display:none; }
.acq[data-type="gift_received"] [data-acq-gift], .bcard[data-type="gift_received"] [data-acq-gift] { display:inline; }
.acq[data-type="gift_received"] [data-acq-purchased], .bcard[data-type="gift_received"] [data-acq-purchased] { display:none; }
.acq[data-type="purchased"] .acq-gift-only, .bcard[data-type="purchased"] .acq-gift-only { display:none; }
.acq[data-type="gift_received"] .acq-purchased-only, .bcard[data-type="gift_received"] .acq-purchased-only { display:none; }
.acq[data-type="purchased"] .acq-cost > summary { display:none; }
.acq-cost { margin:.25rem 0 .75rem; }
.acq-cost > summary { cursor:pointer; color: var(--muted); padding:.4rem 0; }
.form-hint { font-size:.8rem; color: var(--muted); margin-top:.25rem; }
.origin-line { font-size:.85rem; color: var(--muted); }
.totals-strip { display:flex; flex-wrap:wrap; gap:.5rem 1.5rem; padding:.75rem 1rem; margin:0 0 .75rem;
  background: var(--surface2); border:1px solid var(--border); border-radius: var(--radius); }
.totals-strip .t-item { min-width:7rem; }
.totals-strip .t-label { display:block; font-size:.72rem; text-transform:uppercase; letter-spacing:.06em; color: var(--muted); }
.totals-strip .t-value { font-weight:600; font-size:1.05rem; }
.totals-strip .t-pos { color: var(--success); }
.totals-strip .t-neg { color: var(--error); }
.totals-note { flex-basis:100%; font-size:.8rem; color: var(--muted); }
@media (max-width: 480px) { .totals-strip { gap:.5rem 1rem; } .totals-strip .t-item { min-width:6rem; } }
.lot-origin-row td { padding-top:0; border-top:0; }
.acq { margin-top:.75rem; }
