/* ============================================
   LastCork Account Area Styles
   ============================================ */

/* --- Plan usage counter (wishlist, rules, etc.) --- */
.plan-usage-counter {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.plan-usage-counter a {
  text-decoration: none;
}
.plan-usage-counter a:hover {
  text-decoration: underline;
}

/* --- Layout --- */
.account-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(201, 168, 76, 0.06);
  border-left-color: var(--accent);
}

/* Expandable section header (e.g. Matches / Rules / Account).
   Rendered as a <button> so clicking toggles the sub-menu rather than navigating. */
.sidebar-nav button.nav-item,
.sidebar-nav .nav-item-expandable {
  width: 100%;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
}
.sidebar-nav .nav-item-expandable .nav-label {
  flex: 1;
}
.sidebar-nav .nav-caret {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.55;
  transition: transform var(--transition), opacity var(--transition);
  margin-right: 2px;
}
.sidebar-nav .nav-item-expandable.expanded .nav-caret {
  transform: rotate(45deg);
  opacity: 0.9;
}
.sidebar-nav .nav-item-expandable:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-nav .nav-item-expandable.active {
  color: var(--accent);
}

/* Sub-navigation group — hidden by default, expanded via JS toggle */
.sidebar-nav .nav-sub-group {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.sidebar-nav .nav-sub-group.expanded {
  max-height: 500px; /* big enough for any expected sub-list */
}

/* Individual sub-items — clearly indented under their parent */
.sidebar-nav .nav-subitem {
  display: block;
  padding: 0.5rem 1.5rem 0.5rem 2.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.35;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-nav .nav-subitem:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-nav .nav-subitem.active {
  color: var(--accent);
  background: rgba(201, 168, 76, 0.06);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ── Matches tab switcher (My Matches / Wishlist / Personalized) ── */
.matches-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 1rem;
}
.matches-tab {
  padding: 0.625rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.matches-tab:hover {
  color: var(--text);
}
.matches-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Admin View-As Bar (appears above the layout for admins only) ── */
:root {
  --admin-bar-height: 44px;
}
.admin-bar {
  background: linear-gradient(90deg, #3a1a1a 0%, #2a1a2e 100%);
  border-bottom: 2px solid #C9A84C;
  color: #e8e8e8;
  padding: 0;
  font-size: 0.875rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  min-height: var(--admin-bar-height);
  display: flex;
  align-items: center;
}
/* When the admin bar is present, push the fixed sidebar and the mobile
   sidebar-toggle button down so they don't sit behind the bar. */
body.has-admin-bar .sidebar {
  top: var(--admin-bar-height);
}
body.has-admin-bar .sidebar-toggle {
  top: calc(var(--admin-bar-height) + 0.75rem);
}
/* Give the main content area room for the bar so the first section heading
   isn't tucked under it. */
body.has-admin-bar .account-layout,
body.has-admin-bar .admin-layout {
  padding-top: var(--admin-bar-height);
}
.admin-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.admin-bar-badge {
  background: #C9A84C;
  color: #1a1a2e;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.admin-bar-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8125rem;
}
.admin-bar-select {
  background: rgba(255, 255, 255, 0.08);
  color: #e8e8e8;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.875rem;
  cursor: pointer;
}
.admin-bar-select:focus {
  outline: none;
  border-color: #C9A84C;
}
.admin-bar-link {
  margin-left: auto;
  color: #C9A84C;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.875rem;
}
.admin-bar-link:hover {
  color: #e0c060;
}

/* Admin link: visual divider + distinctive color so it's clearly separate */
.sidebar-nav .nav-item-admin {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem !important;
  color: #b91c1c;
}
.sidebar-nav .nav-item-admin:hover {
  color: #e24343;
  background: rgba(185, 28, 28, 0.08);
}
.sidebar-nav .nav-item-admin.active {
  color: #ff4d4d;
  background: rgba(185, 28, 28, 0.12);
  border-left-color: #b91c1c;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-plan {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem;
  min-width: 0;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* --- Mobile sidebar toggle --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: block;
  }
  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 4rem 1.5rem 2rem;
  }
}

/* --- Dashboard Stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.25rem 1.5rem;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
}

.stat-card .stat-change {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.stat-card .stat-change.positive { color: #27ae60; }
.stat-card .stat-change.negative { color: #e74c3c; }

/* --- Dashboard Sections --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.dash-section {
  padding: 1.5rem;
}

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.dash-section-header h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
}

/* --- Match List --- */
.match-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.match-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.match-item .wine-color {
  width: 8px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
}

.match-item .wine-color.red { background: #8B0000; }
.match-item .wine-color.white { background: #C9A84C; }
.match-item .wine-color.rose { background: #d4837f; }

.match-info {
  flex: 1;
  min-width: 0;
}

.match-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.match-price {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--accent);
  white-space: nowrap;
}

.match-action {
  flex-shrink: 0;
}

/* --- Rules List --- */
.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.rule-item + .rule-item {
  margin-top: 0.5rem;
}

.rule-info h4 {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
}

.rule-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.875rem;
}

/* --- Toggle Switch (for rules) --- */
.toggle-sm {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-sm.on {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-sm::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text);
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-sm.on::after {
  transform: translateX(18px);
}

/* ── Match / Rating cards (shared list format) ── */
.match-card,
.rating-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  padding: 14px;
  background: var(--surface, #16213e);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin-bottom: 10px;
  align-items: start;
}
.match-card .match-img-wrap {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
}
.match-card .match-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.match-card .match-img.no-image {
  font-size: 1.75rem;
  opacity: 0.35;
}
.match-card .match-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.match-card .match-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Ratings card specifics */
.rating-card .rating-overall-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.85rem;
}
.rating-card .rating-overall-stars {
  font-size: 1rem;
  letter-spacing: 1px;
}
.rating-card .rating-sub-count {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.rating-card .rating-sub-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.8125rem;
}
.rating-card .rating-sub-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rating-card .rating-sub-label {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}
.rating-card .rating-sub-stars {
  color: var(--accent);
  letter-spacing: 1px;
}
.rating-card .ratings-community-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-left: 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.rating-card .ratings-community-inline .stars-community {
  color: var(--text-muted);
  opacity: 0.85;
}
.rating-card .rating-entry-count {
  color: rgba(255, 255, 255, 0.3);
}
.rating-card .rating-overall-row {
  flex-wrap: wrap;
}

/* --- Sidebar footer buttons (main site link + logout) --- */
.btn-logout,
.btn-main-site {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
}
.btn-main-site {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.75rem;
  margin-bottom: 0.25rem;
}
.btn-main-site:hover {
  color: #C9A84C;
}
.btn-logout:hover {
  color: #e74c3c;
}
.btn-main-site .nav-icon,
.btn-logout .nav-icon {
  font-size: 1rem;
}

/* --- Page Header Row --- */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* --- Loading State --- */
.loading-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
}

/* --- Form Sections --- */
.form-section {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-section h3 {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.form-section p.text-muted {
  margin-bottom: 1rem;
}

.form-actions {
  margin-top: 1rem;
  margin-bottom: 2rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

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

.section-title {
  font-size: 1.25rem;
  margin: 2rem 0 1.25rem;
}

/* --- Custom Toggle Switch --- */
.toggle-switch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.toggle-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch-track {
  display: block;
  width: 44px;
  height: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  position: relative;
}

.toggle-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

.toggle-switch-input:checked + .toggle-switch-track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch-input:checked + .toggle-switch-track::after {
  transform: translateX(20px);
  background: #fff;
}

.toggle-switch-input:focus-visible + .toggle-switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Large toggle for master switch */
.toggle-track-lg {
  width: 56px;
  height: 30px;
}

.toggle-track-lg::after {
  width: 24px;
  height: 24px;
}

.toggle-switch-input:checked + .toggle-track-lg::after {
  transform: translateX(26px);
}

/* Toggle row (label + switch) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0;
  cursor: pointer;
  gap: 1rem;
}

.toggle-label {
  font-size: 0.9375rem;
  color: var(--text);
}

/* Master toggle section */
.master-toggle-section {
  border: 1px solid var(--primary);
}

.master-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* --- Chip / Tag Input --- */
.chip-input-wrap {
  margin-bottom: 0.5rem;
}

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
  min-height: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: rgba(201, 168, 76, 0.12);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
}

.chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.chip-remove:hover {
  opacity: 1;
}

/* --- Checkbox Grid --- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.checkbox-grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.checkbox-card:hover {
  border-color: var(--accent);
  color: var(--text);
}

.checkbox-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-card:has(input:checked) {
  background: rgba(201, 168, 76, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.checkbox-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Range Slider --- */
.form-range {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--card);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.threshold-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

/* --- Sites Grid --- */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.25rem;
}

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

.site-card {
  padding: 1.25rem 1.5rem;
}

.site-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.site-card-name {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.site-card-url {
  font-size: 0.75rem;
  word-break: break-all;
}

.site-login-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  font-size: 0.8125rem;
}

.site-card-toggles {
  margin-bottom: 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.25rem 0;
}

.site-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* --- Rule Cards --- */
.rule-card {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.rule-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.rule-card-info h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.rule-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.rule-card-actions {
  display: flex;
  gap: 0.25rem;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* --- Purchase Table --- */
.purchase-wine-name {
  font-weight: 500;
}

/* --- Plan Cards (Subscription) --- */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.plan-card {
  padding: 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
}

.plan-card-header {
  margin-bottom: 1.25rem;
}

.plan-card-header h3 {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.plan-price {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
}

.plan-period {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
}

.plan-features {
  flex: 1;
  margin-bottom: 1.5rem;
}

.plan-features li {
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  position: relative;
  padding-left: 1.25rem;
}

.plan-features li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.plan-featured {
  border-color: var(--accent);
}

/* VIP-locked button — looks interactive, opens Palate Profile info modal */
.btn-vip-locked {
  font-size: 0.8125rem !important;
  line-height: 1.3;
  padding: 0.625rem 0.75rem !important;
  white-space: normal;
  color: #C9A84C !important;
  border-color: rgba(201, 168, 76, 0.4) !important;
  cursor: pointer;
}
.btn-vip-locked:hover {
  background: rgba(201, 168, 76, 0.08) !important;
  border-color: rgba(201, 168, 76, 0.7) !important;
}

.plan-badge {
  position: absolute;
  top: -10px;
  right: 1rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}

.plan-current {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.08);
}

/* --- Current Plan Row --- */
.current-plan-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.current-plan-meta {
  text-align: right;
  font-size: 0.875rem;
}

.current-plan-meta > div {
  margin-bottom: 0.25rem;
}

/* --- Friends Page --- */
.friend-code-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.friend-code-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  user-select: all;
}

.add-friend-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .add-friend-row {
    flex-direction: column;
    align-items: stretch;
  }
}

.form-feedback {
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

.form-feedback.success {
  color: #27ae60;
}

.form-feedback.error {
  color: #e74c3c;
}

.subsection-label {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}

.subsection-label:first-child {
  margin-top: 0;
}

.friend-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.friend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.friend-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.friend-name {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
}

.badge-muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.badge-success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-warning {
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
}

/* ============================================
   Wines App Iframe
   ============================================ */

.app-iframe {
  width: 100%;
  height: calc(100vh - 60px);
  border: none;
  background: #1a1a2e;
}

/* When iframe is the main content, no padding */
.main-content.app-container {
  padding: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  .main-content.app-container {
    padding: 0;
  }

  .app-iframe {
    height: calc(100vh - 48px);
  }
}

/* --- Wines Nav Item (prominent) --- */
.sidebar-nav a.wines-nav {
  color: var(--accent);
  font-weight: 700;
  background: rgba(201, 168, 76, 0.08);
  border-left-color: var(--accent);
  font-size: 1rem;
}

.sidebar-nav a.wines-nav:hover {
  background: rgba(201, 168, 76, 0.14);
  color: var(--accent);
}

.sidebar-nav a.wines-nav.active {
  background: rgba(201, 168, 76, 0.12);
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ============================================
   Subscription / Billing Styles
   ============================================ */

/* --- Billing Cycle Toggle Row --- */
.billing-cycle-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.billing-cycle-toggle {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.cycle-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.cycle-save-badge {
  display: inline-block;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

/* --- Plan Card Current Badge --- */
.plan-badge-current {
  background: var(--accent);
  color: var(--bg);
}

.plan-current {
  border-color: var(--accent);
  background: rgba(201, 168, 76, 0.06);
  box-shadow: 0 0 0 1px var(--accent);
}

/* --- Cancel / Danger Buttons --- */
.btn-danger {
  background: var(--brand-red);
  color: #fff;
}

.btn-danger:hover {
  background: var(--brand-red);
  filter: brightness(1.1);
}

.btn-danger-outline {
  color: var(--brand-red);
  border-color: var(--brand-red);
}

.btn-danger-outline:hover {
  background: rgba(var(--brand-red-rgb), 0.12);
  color: var(--brand-red);
  filter: brightness(1.1);
}

/* --- Test Mode Banner --- */
.test-mode-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.3);
  color: #facc15;
  border-radius: var(--radius-sm, 6px);
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

/* --- Upgrade Modal Summary --- */
.upgrade-plan-summary {
  text-align: center;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border);
}

.upgrade-plan-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.upgrade-plan-price {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.upgrade-plan-final {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: #4ade80;
}

.promo-discount {
  font-size: 0.8125rem;
  color: #4ade80;
  margin-top: 0.375rem;
}

/* --- CC Form --- */
.cc-form {
  margin-bottom: 1.25rem;
}

/* --- Promo Code Row --- */
.promo-row {
  margin-bottom: 0.75rem;
}

.promo-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.promo-input-row .form-input {
  flex: 1;
}

.promo-result {
  font-size: 0.8125rem;
  padding: 0.375rem 0;
  margin-bottom: 0.5rem;
}

.promo-result-success {
  color: #4ade80;
}

.promo-result-error {
  color: #ef4444;
}

/* --- Billing History Table --- */
.billing-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.billing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.billing-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.billing-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.billing-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* --- Signup Billing Section --- */
.signup-billing-section {
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}

.signup-billing-section h2 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.signup-plan-price {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* --- Responsive tweaks for subscription page --- */
@media (max-width: 768px) {
  .billing-cycle-toggle-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .plans-grid {
    grid-template-columns: 1fr;
  }

  .current-plan-row {
    flex-direction: column;
  }

  .current-plan-meta {
    text-align: left;
  }
}

/* ============================================
   Upgrade Success (InAppBrowser return)
   ============================================ */
.upgrade-success-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg, #1a1a2e);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2rem;
}

.upgrade-success-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.upgrade-success-icon {
  font-size: 64px;
  margin-bottom: 1rem;
}

.upgrade-success-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold, #d4a843);
  margin: 0 0 0.75rem;
}

.upgrade-success-plan {
  font-size: 1.125rem;
  color: var(--text-primary, #e8e8e8);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.upgrade-success-plan strong {
  color: var(--gold, #d4a843);
}

.upgrade-success-hint {
  font-size: 1rem;
  color: var(--text-primary, #e8e8e8);
  opacity: 0.8;
  margin: 0 0 0.5rem;
}

.upgrade-success-subhint {
  font-size: 0.875rem;
  color: var(--text-muted, #999);
  margin: 0;
  font-style: italic;
}
