/* ── VARIABLES ─────────────────────────────────────── */
:root {
  --bg:        #f2ede8;
  --bg-card:   #ffffff;
  --accent:    #6e1f2e;
  --accent-lt: #8c2d3f;
  --text:      #1a1410;
  --text-2:    #6b5c52;
  --text-3:    #a8978e;
  --border:    #e0d8d2;
  --shadow:    0 2px 12px rgba(110,31,46,0.08);
  --shadow-lg: 0 8px 32px rgba(110,31,46,0.14);
  --radius:    12px;
  --radius-sm: 8px;
  --header-h:  56px;
  --bnav-h:    72px;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'DM Sans', system-ui, sans-serif;
}

/* ── RESET ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── HEADER ────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}
.logo-text {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.nav {
  display: flex;
  gap: 4px;
}
.nav-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-2);
  transition: all 0.15s;
}
.nav-btn:hover { color: var(--accent); }
.nav-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

/* Hide top nav on mobile, show hamburger instead */
.hamburger-btn {
  display: none;
  font-size: 22px;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: var(--bg); }

@media (max-width: 767px) {
  .nav { display: none; }
  .hamburger-btn { display: block; }
}

/* ── MAIN ──────────────────────────────────────────── */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 16px) 16px 32px;
}

/* ── PAGES ─────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── PAGE HEADER ───────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stats-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 13px;
}
.stat-dot { color: var(--border); }

/* ── BUTTONS ───────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-lt); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--text-2);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ── FILTERS ───────────────────────────────────────── */
.filters { margin-bottom: 16px; }
.search-wrap { margin-bottom: 10px; }
.search-input {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-3); }

.filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.filter-row .filter-select {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  padding-right: 22px;
  font-size: 12px;
  background-position: right 7px center;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 13px;
  color: var(--text-2);
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a8978e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.filter-select:focus { border-color: var(--accent); }

/* ── WINE LIST ─────────────────────────────────────── */
.wine-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wine-card {
  padding: 14px 16px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.1s;
  box-shadow: 0 1px 4px rgba(110,31,46,0.04);
}
.wine-card:hover { background: #fdfbf9; }

/* Row 1: vintage + winery bold + wine name */
.wine-card-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  min-width: 0;
}
.wine-vintage {
  font-size: 13px;
  color: var(--text-3);
  flex-shrink: 0;
  min-width: 34px;
}
.wine-winery-inline {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.wine-name-inline {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row 2: winery · region · score */
.wine-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wine-score-you { color: #5a7a5a; font-weight: 500; }

/* Row 3: badge + bottles + actions */
.wine-card-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wine-btl-count {
  font-size: 12px;
  color: var(--text-3);
  flex: 1;
}
.wine-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}
.action-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  color: var(--text-3);
}
.action-btn:hover { background: var(--bg); color: var(--accent); }

.cellar-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.badge-NY   { background: #e8f0f8; color: #2d5a8c; }
.badge-Lima { background: #f0e8e8; color: var(--accent); }

.dot-Red      { background: #8c2d3f; }
.dot-White    { background: #c4a84f; }
.dot-Sparkling{ background: #7eb8c9; }
.dot-Rosé     { background: #d4778a; }
.dot-Dessert  { background: #c4874f; }

/* ── LOADING / EMPTY ───────────────────────────────── */
.loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-3);
  font-size: 14px;
}
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-3);
}
.empty-state p { font-size: 14px; margin-top: 8px; }
.coming-soon {
  text-align: center;
  padding: 64px 16px;
  color: var(--text-3);
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
}

/* ── NAV DRAWER ────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,20,16,0.45);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.drawer-overlay.open { display: block; }

.nav-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(280px, 80vw);
  height: 100%;
  background: white;
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -6px 0 32px rgba(110,31,46,0.16);
}
.nav-drawer.open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 15px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.nav-drawer-close:hover { background: var(--bg); color: var(--text); }

.nav-drawer-links {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
  flex: 1;
}
.drawer-nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 400;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
  letter-spacing: 0.01em;
}
.drawer-nav-btn:hover { background: var(--bg); color: var(--text); }
.drawer-nav-btn.active {
  background: #f0e8e8;
  color: var(--accent);
  font-weight: 600;
}

/* ── MODALS ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,20,16,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
@media (min-width: 641px) {
  .modal-overlay { align-items: center; }
}
.modal {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.25s ease;
}
@media (min-width: 641px) {
  .modal {
    border-radius: var(--radius);
    max-height: 88vh;
  }
}
.modal-sm { max-width: 420px; }

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 16px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── FORMS ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: 0.03em; text-transform: uppercase; }
.form-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: white;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 72px; }

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a8978e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.consume-wine-name {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  margin-bottom: 4px;
}

/* ── CELLARS PAGE ──────────────────────────────────── */
.cellars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cellar-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.cellar-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0e8e8;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cellar-info { flex: 1; min-width: 0; }
.cellar-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.cellar-stats {
  font-size: 12px;
  color: var(--text-3);
}
.cellar-actions { display: flex; gap: 4px; }

/* ── LOG PAGE ──────────────────────────────────────── */
.log-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.log-stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.log-stat-value {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.log-stat-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.log-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.log-type-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.log-type-icon.consumption { background: #f0e8e8; color: var(--accent); }
.log-type-icon.transfer    { background: #e8f0f8; color: #2d5a8c; }
.log-type-icon.added       { background: #e8f4ec; color: #2d7a4f; font-weight: 600; }

.log-info { flex: 1; min-width: 0; }
.log-wine-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.log-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.log-notes {
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
}

.log-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.log-date {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.log-actions { display: flex; gap: 4px; }

.btn-danger {
  background: transparent;
  color: #c0392b;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  border: 1px solid #c0392b;
  transition: all 0.15s;
  margin-right: auto;
}
.btn-danger:hover { background: #c0392b; color: white; }

.form-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.form-input:disabled {
  background: var(--bg);
  color: var(--text-3);
  cursor: not-allowed;
  border-color: var(--border);
}

/* ── DASHBOARD PAGE ────────────────────────────────── */
.dash-section {
  margin-bottom: 28px;
}
.dash-section-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.dash-section-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dash-subtitle {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 300;
  font-style: italic;
  font-family: var(--font-sans);
}
.dash-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: #f0e8e8;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}
.dash-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(110,31,46,0.04);
}
.dash-row-left {
  flex: 1;
  min-width: 0;
}
.dash-row-name {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.dash-vintage {
  color: var(--text-3);
  font-size: 13px;
}
.dash-row-meta {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.dash-btl {
  font-size: 12px;
  color: var(--text-3);
}
.dash-date {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── DASHBOARD STATS ROW ───────────────────────────── */
.dash-stats-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  margin-bottom: 20px;
}
.dash-stats-row::-webkit-scrollbar { display: none; }
.dash-stats-row .log-stat-card {
  flex: 1 0 0;
  min-width: 76px;
  padding: 10px 8px;
}
.dash-stats-row .log-stat-value { font-size: 22px; }

/* ── INTELLIGENCE PAGE ─────────────────────────────── */
.intel-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.intel-page-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}
.intel-section { margin-bottom: 36px; }
.intel-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
}
.intel-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 4px rgba(110,31,46,0.04);
}
.intel-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.intel-card-sub-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
  font-style: italic;
}
.intel-cards-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 540px) {
  .intel-cards-2col { grid-template-columns: 1fr; }
}
.intel-donut-wrap {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.intel-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: center;
  min-width: 0;
}
.intel-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}
.intel-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.intel-legend-label {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.intel-legend-val {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.intel-legend-pct {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}
.intel-blend-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.intel-empty {
  color: var(--text-3);
  font-size: 13px;
  padding: 8px 0;
}
.intel-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.intel-bar-row:last-child { margin-bottom: 0; }
.intel-bar-label {
  font-size: 12px;
  color: var(--text-2);
  width: 110px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.intel-bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.intel-bar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 20px;
}
.intel-bar-count {
  font-size: 12px;
  color: var(--text-2);
  min-width: 28px;
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
}
.intel-bar-row.clickable { cursor: pointer; }
.intel-bar-row.clickable:hover .intel-bar-label { color: var(--accent); }
.intel-bar-row.active .intel-bar-label { color: var(--accent); font-weight: 600; }

/* Intel section full-width cards below 2-col */
.intel-section-card-mt { margin-top: 16px; }
.intel-card-muted { opacity: 0.55; pointer-events: none; }
.intel-coming-soon { font-size: 13px; color: var(--text-3); margin: 0; font-style: italic; }
.intel-coming-soon-sub { font-size: 12px; color: var(--text-3); margin: 6px 0 0; }
.intel-score-stats-mt { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── SETTINGS PAGE ─────────────────────────────────── */
.settings-section { margin-bottom: 4px; }

.settings-section-hd {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  background: none;
  border-radius: 0;
  user-select: none;
}
.settings-section-hd:hover .settings-section-label { color: var(--text-2); }

.settings-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.settings-chevron {
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
}
.settings-section.open .settings-chevron { transform: rotate(0deg); }

.settings-section-body {
  display: none;
  padding-top: 14px;
}
.settings-section.open .settings-section-body { display: block; }

.settings-cellars-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }

.settings-desc {
  font-size: 13px;
  color: var(--text-3);
  margin: 0 0 20px;
  line-height: 1.5;
}
.settings-table-wrap { overflow-x: auto; }
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.settings-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.settings-table td {
  padding: 11px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}
.settings-table tr:last-child td { border-bottom: none; }
.settings-table tbody tr:hover td { background: var(--bg); }
.settings-examples { color: var(--text-3); font-style: italic; }

.settings-export-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-export-item:last-child { border-bottom: none; }
.settings-export-info { flex: 1; min-width: 0; }
.settings-export-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}
.settings-export-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}
.btn-export {
  display: inline-block;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: all 0.15s;
  text-align: center;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); background: #fdf8f9; }

/* Import preview modal */
.modal-import { max-width: 680px; }
.import-preview-summary {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.import-preview-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 20px 8px;
}
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.import-preview-table th {
  text-align: left;
  padding: 10px 8px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.import-preview-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.import-preview-table tr:last-child td { border-bottom: none; }
.import-td-trunc { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-row-warn td { background: #fff8f0; }

.import-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.import-badge-new   { background: #eaf5ea; color: #2d7a2d; }
.import-badge-merge { background: #e8f0f8; color: #2d5a8c; }
.import-badge-warn  { background: #fff0e0; color: #a06020; margin-left: 4px; }

/* Ratings & Scores — Summary stats */
.intel-score-stat { margin-bottom: 20px; }
.intel-score-stat:last-child { margin-bottom: 0; }
.intel-score-stat-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.intel-score-stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.intel-score-stat-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* Ratings & Scores — Top Rated list */
.intel-top-rated-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}
.intel-top-rated-row:last-child { border-bottom: none; }
.intel-top-rated-row:hover { background: var(--bg); }
.intel-top-rated-score {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  width: 34px;
  flex-shrink: 0;
  text-align: center;
}
.intel-top-rated-info { flex: 1; min-width: 0; }
.intel-top-rated-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.intel-top-rated-winery { font-weight: 600; }
.intel-top-rated-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Intel region toggle */
.intel-toggle-btn {
  margin-top: 12px;
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.intel-toggle-btn:hover { text-decoration: underline; }

/* Intel drill sub-region chips */
.drill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px 8px;
  border-bottom: 1px solid var(--border);
}
.drill-chips:empty { display: none; }
.drill-chip {
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.drill-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.drill-chip:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* Intel drill-down modal */
.modal-drill { max-width: 480px; }
.drill-wine-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.drill-wine-row:last-child { border-bottom: none; }
.drill-wine-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.drill-vintage {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
  min-width: 30px;
}
.drill-winery {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.drill-wine-name {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.drill-wine-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.drill-wine-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}
.drill-score {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: #f5eaec;
  padding: 2px 6px;
  border-radius: 10px;
}
.drill-btl {
  font-size: 12px;
  color: var(--text-3);
  margin-left: auto;
  font-weight: 500;
}
.drill-status-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  background: #f0e8e8;
  color: var(--accent);
}
.drill-status-badge.drill-status-Peak { background: #eaf5ea; color: #2d7a2d; }
.drill-status-badge.drill-status-Opening { background: #e8f0f8; color: #2d5a8c; }
.drill-status-badge.drill-status-Too-Young { background: #e8f0f8; color: #4a6a8c; }
.drill-status-badge.drill-status-Decline { background: #f5f0e8; color: #8c6b2d; }
.drill-status-badge.drill-status-Past-Peak { background: #f0e8e8; color: var(--accent); }

/* Clickable donut legend items */
.intel-legend-item.clickable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.12s;
}
.intel-legend-item.clickable:hover { background: var(--bg); }

/* Clickable SVG bar groups */
.intel-bar-clickable { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.intel-bar-clickable:hover text { fill: var(--accent) !important; }

/* ── WINE DETAIL MODAL ─────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.detail-field { display: flex; flex-direction: column; gap: 4px; }
.detail-field.full-width { grid-column: 1 / -1; }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.detail-value { font-size: 14px; color: var(--text); line-height: 1.45; }
.detail-value.empty { color: var(--text-3); }

.dash-row.clickable { cursor: pointer; }
.dash-row.clickable:hover {
  background: #fdfbf9;
  box-shadow: 0 2px 8px rgba(110,31,46,0.07);
}

/* ── AUTOFILL DROPDOWN ─────────────────────────────── */
.autofill-dropdown {
  position: fixed;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.autofill-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.autofill-item:last-child { border-bottom: none; }
.autofill-item:hover { background: var(--bg); }
.autofill-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}
.autofill-meta {
  font-size: 12px;
  color: var(--text-3);
}

/* ── TOAST ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 300;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (min-width: 768px) {
  .toast { bottom: 24px; }
}

/* ── MOBILE FIXES ──────────────────────────────────── */
@media (max-width: 480px) {
  /* Filter dropdowns: 2-column grid so each label is fully readable */
  .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow-x: visible;
  }
  .filter-row .filter-select {
    width: 100%;
    min-width: 0;
    font-size: 13px;
    padding: 7px 10px;
    padding-right: 24px;
    background-position: right 8px center;
  }

  /* Wine card name: wrap instead of truncate */
  .wine-card-top { flex-wrap: wrap; }
  .wine-winery-inline {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    flex-shrink: 1;
  }
}
