/* =======================================================================
   NeuroMoney unified theme (static site + web app)
   - Header + footer match the marketing site
   - Auth (login/signup) uses the same card + form layout
   - Dark mode continues to work via body.dark-mode
   ======================================================================= */

:root {
  --bg: #f3f4f6;
  --bg-alt: #e5e7eb;
  --text: #111827;
  --muted: #353c46;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --input-bg: #f9fafb;
  --input-border: #d1d5db;
  --error: #b91c1c;

  --brand-blue: #1D5074;

  /* Select chevron icon (overridden in dark mode) */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, #e5f3ff 0, var(--bg) 55%, var(--bg-alt) 100%);
}

/* Dark mode uses CSS variables so header/footer + auth pages update automatically */
body.dark-mode {
  --bg: #0b1220;
  --bg-alt: #111827;
  --text: #e5e7eb;
  --muted: #cbd5e1;
  --border: rgba(148, 163, 184, 0.22);
  --card-bg: rgba(17, 24, 39, 0.92);
  --input-bg: rgba(15, 23, 42, 0.8);
  --input-border: rgba(148, 163, 184, 0.35);
  --error: #fca5a5;

  /* Select chevron icon for dark mode */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  background: radial-gradient(circle at top, #0b2540 0, var(--bg) 55%, var(--bg-alt) 100%);
}

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
}

body.dark-mode header {
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-logo .site-logo-text {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.5rem;
  color: var(--brand-blue);
  line-height: 1;
}

.site-logo .site-logo-text span { color: var(--accent); }

body.dark-mode .site-logo .site-logo-text {
  color: #ffffff;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

.nav-link.active {
  color: var(--brand-blue);
  text-decoration: none;
}

.nav-separator { color: var(--muted); font-size: 0.85rem; }

main {
  flex: 1;
  padding: 8px 20px 20px;
}

/* Footer matches the static site */
footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1rem 1.5rem 1.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(249, 250, 251, 0.92);
}

body.dark-mode footer { background: rgba(15, 23, 42, 0.92); }

footer a {
  color: var(--brand-blue);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

footer a:hover { color: var(--accent-hover); text-decoration: underline; }

.footer-separator { color: var(--muted); }

.footer-note {
  font-size: 0.75rem;
  color: #6b7280;
  margin-left: 0.4rem;
}

body.dark-mode .footer-note { color: rgba(226, 232, 240, 0.78); }

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .main-nav { font-size: 0.82rem; }

  footer { flex-wrap: wrap; }
}

/* Pills (used on auth cards too) */
.pill {
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background-color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  width: fit-content;
}

.pill--green {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--accent);
  background-color: rgba(240, 253, 244, 0.9);
}

body.dark-mode .pill { background-color: rgba(15, 23, 42, 0.55); }
body.dark-mode .pill--green { background-color: rgba(20, 83, 45, 0.25); }

/* =======================================================================
   Auth (Login / Sign up)
   ======================================================================= */

.auth-section {
  display: flex;
  justify-content: center;
  padding: 2.5rem 1.5rem 3rem;
}

.auth-shell { width: 100%; max-width: 520px; }

.auth-card {
  background: var(--card-bg);
  border-radius: 1.25rem;
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

body.dark-mode .auth-card {
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.auth-card h2 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.35rem;
  color: var(--text);
}

.auth-card h1 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.35rem;
  color: var(--text);
}

.auth-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.auth-form {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-form label {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.auth-form input,
.auth-form select {
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.auth-form input::placeholder { color: #9ca3af; }

.auth-form input:focus,
.auth-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
  background: #ffffff;
}

body.dark-mode .auth-form input:focus,
body.dark-mode .auth-form select:focus {
  background: rgba(15, 23, 42, 0.95);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.2rem;
}

.btn {
  padding: 0.8rem 1.2rem;
  border-radius: 0.75rem;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
}

/* Shared busy/disabled state for every app button. */
button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.62;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
  filter: grayscale(0.2);
}

button:disabled:hover,
button:disabled:active,
button[aria-disabled="true"]:hover,
button[aria-disabled="true"]:active {
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--brand-blue);
  color: #f9fafb;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-blue);
  border: 1px solid rgba(209, 213, 219, 0.9);
}

body.dark-mode .btn-secondary {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.25);
  color: var(--text);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.status {
  font-size: 0.9rem;
  margin-top: 0.2rem;
  min-height: 1.2em;
  color: var(--error);
}

/* =======================================================================
   General form defaults for the rest of the app (keeps behaviour unchanged)
   ======================================================================= */

#new-product-form,
#new-subscription-form,
#new-bill-form,
#edit-profile-form {
  display: flex;
  flex-direction: column;
}

#new-product-form label,
#new-subscription-form label,
#new-bill-form label,
#edit-profile-form label {
  margin-bottom: 5px;
  font-weight: bold;
}

#new-product-form input,
#new-subscription-form input,
#new-bill-form input,
#edit-profile-form input,
#edit-profile-form select {
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 16px;
}

body.dark-mode #new-product-form input,
body.dark-mode #new-subscription-form input,
body.dark-mode #new-bill-form input,
body.dark-mode #edit-profile-form input,
body.dark-mode #edit-profile-form select {
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text);
}

#new-product-form button,
#new-subscription-form button,
#new-bill-form button,
#edit-profile-form button {
  padding: 10px;
  background-color: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 10px;
}

#new-product-form button:hover,
#new-subscription-form button:hover,
#new-bill-form button:hover,
#edit-profile-form button:hover {
  background-color: var(--accent-hover);
}

#signup-error-message,
#error-message,
#product-error-message,
#sub-error-message,
#bills-error-message,
#otp-error-message,
#forgot-email-error-message,
#reset-error-message,
#delete-error-message,
#edit-error-message {
  color: var(--error) !important;
  margin-top: 10px;
}

.form-error-message {
  min-height: 1.25rem;
  margin: 0 0 1rem;
  color: var(--error) !important;
  font-weight: 600;
}

.form-error-message:empty {
  min-height: 0;
  margin-bottom: 0;
}


.shopping-products-container {
    height: auto;
    max-height: calc(100vh - 300px);
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
}

body.dark-mode .shopping-products-container {
    border: 1px solid #555;
    background-color: #1e1e1e;
}

.shopping-products {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.product-widget {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
    flex: 1 1 calc(50% - 10px);  /* Adjusts width to fit two per row */
    box-sizing: border-box;
}

body.dark-mode .product-widget {
    background-color: var(--card-bg);
    color: #e0e0e0;
}

.product-image {
    width: 100%;
    height: 150px;  /* Placeholder size for future product image */
    background-color: #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
}

@media (min-width: 600px) {
    .product-widget {
        width: calc(50% - 10px);  /* Ensure two per row */
    }
}

@media (min-width: 900px) {
    .product-widget {
        width: calc(50% - 10px);  /* Ensure two per row */
    }
}

/* Settings Panel */
#settings-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    height: 100%;
    background-color: var(--card-bg);
    color: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    padding: 20px;
    transition: right 0.3s ease;
}

body.dark-mode #settings-panel {
    background-color: #444;
}

#settings-panel h3 {
    margin-top: 0;
}

#settings-panel button {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background-color: var(--accent-hover);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

#settings-panel button:hover {
    background-color: #777;
}

#settings-panel.active {
    right: 0;
}

#floating-settings {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

/* Sign Out Confirmation Popup */
#signout-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;  /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

#popup-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

body.dark-mode #popup-content {
    background-color: var(--card-bg);
    color: #e0e0e0;
}

.popup-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.popup-buttons button {
    padding: 10px;
    background-color: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100px;
}

.popup-buttons button:hover {
    background-color: var(--accent-hover);
}

/* Sign out popup: keep Cancel green-hover, make Confirm Sign Out red-hover */
#signout-popup #confirm-signout:hover {
    background-color: #dc2626;
}

.remove-product, .remove-sub {
    background-color: red;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

.remove-product:hover, .remove-sub:hover {
    background-color: darkred;
}

#country-select, #shop-select, #sub-type, #bill-type {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 16px;
    width: 100%;
}

body.dark-mode #country-select, body.dark-mode #shop-select, body.dark-mode #sub-type, body.dark-mode #bill-type, body.dark-mode #shop-select {
    background-color: #121212;
    border: 1px solid #555;
    color: #f5f5f5;
}

/* Ensure hidden sections stay hidden */
#shopping-list,
#coming-soon-section {
    display: none;
}

#edit-profile-section, #accessibility-tools-section, #subscription-section {
    max-width: 400px;
    margin: auto;
    padding: 20px;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.dark-mode #edit-profile-section, body.dark-mode #accessibility-tools-section, body.dark-mode #subscription-section  {
    background-color: #1e1e1e;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#edit-profile-form {
    display: flex;
    flex-direction: column;
}

#edit-profile-form label {
    margin-bottom: 5px;
    font-weight: bold;
}

#edit-profile-form input, #edit-profile-form select {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 16px;
}

body.dark-mode #edit-profile-form input,
body.dark-mode #edit-profile-form select {
    background-color: var(--card-bg);
  border: 1px solid #555;
    color: #e0e0e0;
}

#edit-profile-form button, #close-accessibility {
    padding: 10px;
    background-color: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

#edit-profile-form button:hover, #close-accessibility button:hover {
    background-color: var(--accent-hover);
}

#edit-error-message {
    color: red;
    margin-top: 10px;
}

#edit-confirm-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

#edit-popup-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.popup-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.popup-buttons button {
    padding: 10px;
    background-color: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100px;
}


/* Delete account button style */
#delete-account-btn {
    background-color: red;
    color: #fff;
}

#delete-account-btn:hover {
    background-color: darkred;
}

/* Delete account popup */
#delete-account-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

#delete-popup-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
}

body.dark-mode #delete-popup-content {
    background-color: var(--card-bg);
  color: #e0e0e0;
}

#delete-confirm-input {
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    box-sizing: border-box;
}

#delete-error-message {
    color: red;
    margin-top: 10px;
}

/* Make delete account button red, override default button styles */
#edit-profile-form #delete-account-btn {
    background-color: red;
    color: #fff;
}

#edit-profile-form #delete-account-btn:hover {
    background-color: darkred;
}


#new-subscription-form, #new-bill-form {
    width: 100%;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
}

body.dark-mode #new-subscription-form, body.dark-mode #new-bill-form {
}

.list-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.6rem;
}

.list-heading-row h2 {
    margin: 0;
}

.list-sort-select {
    width: auto;
    min-width: 125px;
    max-width: 210px;
    padding: 0.55rem 2rem 0.55rem 0.8rem;
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    background-color: var(--input-bg);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
}

.list-sort-select:hover {
    border-color: rgba(29, 80, 116, 0.55);
}

.list-sort-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
}

body.dark-mode .list-sort-select {
    background-color: rgba(15, 23, 42, 0.8);
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text);
}

@media (max-width: 640px) {
    .list-heading-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.45rem;
        margin-bottom: 0.6rem;
    }

    .list-heading-row h2 {
        width: 100%;
        white-space: nowrap;
    }

    .list-sort-select {
        justify-self: end;
        min-width: 105px;
        max-width: 145px;
        padding: 0.45rem 1.8rem 0.45rem 0.65rem;
        font-size: 0.78rem;
    }
}

#monthly-sub-list,
#yearly-sub-list,
#monthly-bills-list,
#yearly-bills-list {
    height: auto;
    max-height: calc(100vh - 300px);

    /* Always reserve/show the vertical scrollbar area so card widths match */
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-gutter: stable;

    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
}

.list-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100px;
    margin: 0;
    padding: 1rem;
    border: 1px dashed rgba(148, 163, 184, 0.45);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
}

.shopping-products .list-empty-state {
    flex: 1 0 100%;
    min-height: 270px;
}

body.dark-mode .list-empty-state {
    border-color: rgba(148, 163, 184, 0.28);
}

body.dark-mode #monthly-sub-list, body.dark-mode #yearly-sub-list,
 body.dark-mode #monthly-bills-list body.dark-mode #yearly-bills-list {
    border: 1px solid #555;
    background-color: #1e1e1e;
}

.sub-widget {
    background-color: var(--card-bg);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

body.dark-mode .sub-widget {
    background-color: var(--card-bg);
  color: #e0e0e0;
}

.subscription-summary-bill {
    border: 2px solid #4BC0C0;
}

body.dark-mode .subscription-summary-bill {
    border-color: #4BC0C0;
}

/* Chart container */
#chart-cards-section,
#bills-chart-cards-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 20px;
}

/* Individual chart cards */
.chart-card {
    width: 90%;
    max-width: 430px;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    overflow: visible;
}

.chart-card h2 {
    font-size: 18px;
}

/* Stable Chart.js canvas box.
   This fixes iOS Safari canvas sizing issues by giving Chart.js
   a real height to measure instead of height:auto. */
.chart-canvas-box {
    position: relative;
    width: 100%;
    height: 260px;
    min-height: 260px;
}

/* Only target NeuroMoney Chart.js canvases.
   Do not globally force every canvas to height:auto. */
#subscriptionDonutChart,
#subscriptionDonutChart-2,
#billsMonthlyDonutChart,
#billsYearlyDonutChart {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
}

/* Scrollable clickable HTML legend shown under each doughnut chart */
.chart-html-legend {
    margin-top: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.35rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(249, 250, 251, 0.72);
    -webkit-overflow-scrolling: touch;
}

.chart-html-legend-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chart-legend-item {
    width: 100%;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    border: 0;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.chart-legend-item:hover {
    background: rgba(22, 163, 74, 0.08);
}

.chart-legend-item.is-hidden {
    opacity: 0.45;
    text-decoration: line-through;
}

.chart-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.chart-legend-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chart-legend-value {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* Dark mode adjustments */
body.dark-mode .chart-card {
    background-color: #1e1e1e;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

body.dark-mode .chart-html-legend {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(148, 163, 184, 0.25);
}

body.dark-mode .chart-legend-item:hover {
    background: rgba(34, 197, 94, 0.12);
}

body.dark-mode .chart-legend-value {
    color: rgba(226, 232, 240, 0.78);
}

@media (max-width: 480px) {
    .chart-card {
        width: 100%;
        max-width: 100%;
        padding: 12px;
    }

    .chart-canvas-box {
        height: 235px;
        min-height: 235px;
    }

    .chart-html-legend {
        max-height: 165px;
    }
}

/* When the screen is landscape (width > height), place charts side by side */
@media (orientation: landscape) and (min-width: 768px) {
    #chart-cards-section, #bills-chart-cards-section {
        flex-direction: row; /* Display charts side by side */
        justify-content: center;
    }

    .chart-card {
        width: 45%; /* Give both charts equal space */
        max-width: 500px; /* Limit width for better spacing */
    }
}

/* Scale up charts as the screen gets larger */
@media (min-width: 1024px) {
    .chart-card {
        max-width: 600px; /* Make the charts larger */
    }
}

/* Extra large screens */
@media (min-width: 1440px) {
    .chart-card {
        max-width: 700px; /* Make charts even larger on wide screens */
    }
}

.chart-total-spend {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
}

/* Dark mode adjustments */
body.dark-mode .chart-total-spend {
    color: white;
}




/* =======================================================================
   App page shells (match marketing site cards)
   ======================================================================= */

.app-shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.page-shell {
  width: 100%;
  max-width: 960px;
  margin: 1.25rem auto 0;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 1.25rem;
  padding: 2rem 1.75rem 2.25rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

body.dark-mode .page-shell {
  background: var(--card-bg);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.page-shell h1,
.page-shell h2 {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.page-shell h1 { font-size: 1.55rem; }
.page-shell h2 { font-size: 1.25rem; }

.page-shell h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.page-shell p,
.page-shell li {
  color: var(--muted);
  line-height: 1.65;
}

/* Top bar link used on login/sign-up cards */
.auth-topbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 0.6rem;
}

.back-home-link {
  font-weight: 600;
  color: var(--brand-blue);
  text-decoration: none;
  font-size: 0.92rem;
}

.back-home-link:hover,
.back-home-link:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* =======================================================================
   App tabs (Shopping / Subscriptions / Bills) – match site styling
   ======================================================================= */

#main-nav {
  width: 100%;
  max-width: 960px;
  margin: 1.25rem auto 0;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(209, 213, 219, 0.9);
  border-radius: 1rem;
  padding: 0.65rem 0.75rem;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.06);
}

body.dark-mode #main-nav {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.25);
}

#main-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

#main-nav ul li { margin: 0; }

#main-nav ul li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, color 0.15s ease;
}

body.dark-mode #main-nav ul li a {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.25);
}

#main-nav ul li a:hover,
#main-nav ul li a:focus-visible {
  background: rgba(240, 253, 244, 0.9);
  color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.28);
}

#main-nav ul li a.active {
  background: var(--brand-blue);
  border-color: rgba(29, 80, 116, 0.55);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(29, 80, 116, 0.24);
}

.app-nav-icon {
  display: none;
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 1.15rem;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.app-nav-icon--dashboard {
  -webkit-mask-image: url("images/dashboard-icon.6e5d44f1f2cc57aa.svg");
  mask-image: url("images/dashboard-icon.6e5d44f1f2cc57aa.svg");
}

.app-nav-icon--subscriptions {
  -webkit-mask-image: url("images/subscriptions-icon.cf33abcaf880afb1.svg");
  mask-image: url("images/subscriptions-icon.cf33abcaf880afb1.svg");
}

.app-nav-icon--bills {
  -webkit-mask-image: url("images/bills-icon.74dfe228c8710513.svg");
  mask-image: url("images/bills-icon.74dfe228c8710513.svg");
}

.app-nav-icon--shopping {
  -webkit-mask-image: url("images/shopping-icon.3b9a2ed8c7c4388b.svg");
  mask-image: url("images/shopping-icon.3b9a2ed8c7c4388b.svg");
}

.app-nav-menu-icon {
  display: block;
  line-height: 1;
}

@media (min-width: 641px) {
  #main-nav .settings-nav-link {
    min-width: 3rem;
    padding: 0.55rem 0.9rem;
  }

  #main-nav .app-nav-menu-icon {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 1.25rem;
    line-height: 1.25rem;
    text-align: center;
  }
}

/* =======================================================================
   Dashboard
   ======================================================================= */

#dashboard-section {
  display: block;
}

.dashboard-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.dashboard-heading-row h1 {
  margin: 0.7rem 0 0.35rem;
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.dashboard-filters {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.4rem 0.55rem;
  flex: 0 0 auto;
}

.dashboard-filters label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.dashboard-filters .list-sort-select {
  width: 155px;
  min-width: 155px;
  margin: 0;
  padding-block: 0.48rem;
  font-size: 0.84rem;
}

#dashboard-status {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.dashboard-block {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.dashboard-block h2 {
  margin: 0 0 0.7rem;
  font-size: 1.15rem;
}

.dashboard-list-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.dashboard-list-heading-row h2 {
  margin: 0;
}

.dashboard-payment-rail {
  display: flex;
  align-items: stretch;
  gap: 0.7rem;
  min-height: 132px;
  max-height: 132px;
  padding: 0.7rem 0.7rem 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 0.75rem;
  background: rgba(29, 80, 116, 0.075);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 80, 116, 0.48) transparent;
}

body.dark-mode .dashboard-payment-rail {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(2, 6, 23, 0.32);
}

.dashboard-payment-rail:focus-visible {
  outline: 3px solid rgba(22, 163, 74, 0.2);
  outline-offset: 3px;
  border-radius: 0.6rem;
}

.dashboard-payment-card {
  flex: 0 0 190px;
  min-width: 0;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--card-bg);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
}

.dashboard-payment-card h3 {
  margin: 0 0 0.35rem;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-payment-card strong {
  display: block;
  color: var(--brand-blue);
  font-size: 0.95rem;
}

body.dark-mode .dashboard-payment-card strong {
  color: #93c5fd;
}

.dashboard-payment-card p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.dashboard-empty {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 0.7rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.dashboard-view-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0;
  padding: 0.3rem 0.45rem;
  border-radius: 0.4rem;
  color: var(--brand-blue);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-view-link:hover,
.dashboard-view-link:focus-visible {
  background: rgba(240, 253, 244, 0.9);
  color: var(--accent-hover);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.28);
  text-decoration: underline;
}

body.dark-mode .dashboard-view-link {
  color: #93c5fd;
}

body.dark-mode .dashboard-view-link:hover,
body.dark-mode .dashboard-view-link:focus-visible {
  background: rgba(20, 83, 45, 0.3);
  color: #86efac;
}

.dashboard-calendar-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dashboard-calendar-heading-row h2 {
  margin: 0;
}

.dashboard-calendar-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.dashboard-calendar-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.payment-dot {
  display: inline-block;
  flex: 0 0 0.58rem;
  width: 0.58rem;
  min-width: 0.58rem;
  height: 0.58rem;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.payment-dot--subscription {
  background: #eab308;
}

.payment-dot--bill {
  background: #f97316;
}

.dashboard-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 0.8rem;
  background: rgba(29, 80, 116, 0.075);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.dark-mode .dashboard-calendar {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(2, 6, 23, 0.32);
}

.dashboard-calendar[data-period="daily"] {
  grid-template-columns: 1fr;
}

.dashboard-weekday {
  padding: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.dashboard-calendar-day {
  position: relative;
  min-height: 88px;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--card-bg);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-calendar-day.has-payment {
  border-color: rgba(234, 179, 8, 0.38);
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.05);
}

.dashboard-calendar-day.is-today {
  z-index: 1;
  border-color: var(--accent);
  background: rgba(240, 253, 244, 0.96);
  transform: scale(1.045);
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.2);
}

body.dark-mode .dashboard-calendar-day.is-today {
  background: rgba(20, 83, 45, 0.34);
}

.dashboard-calendar[data-period="daily"] .dashboard-calendar-day.is-today {
  transform: none;
}

.dashboard-calendar-day > strong {
  display: block;
  font-size: 0.9rem;
}

.dashboard-calendar-day > span:not(.dashboard-day-dots) {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.64rem;
}

.dashboard-day-dots {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.3rem;
  min-width: max-content;
}

.dashboard-day-dots .payment-dot {
  display: block;
  flex-shrink: 0;
}

.dashboard-calendar-spacer {
  min-height: 1px;
}

@media (max-width: 680px) {
  .dashboard-heading-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-filters {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-filters label {
    align-self: end;
  }

  .dashboard-filters .list-sort-select {
    width: 100%;
    min-width: 0;
  }

  .dashboard-calendar {
    gap: 0.25rem;
  }

  .dashboard-calendar-day {
    min-height: 66px;
    padding: 0.38rem;
  }

  .dashboard-calendar-day > span:not(.dashboard-day-dots) {
    display: none;
  }

  .dashboard-day-dots {
    right: 0.35rem;
    bottom: 0.35rem;
    gap: 0.2rem;
  }

  .payment-dot {
    width: 0.48rem;
    height: 0.48rem;
  }
}

/* =======================================================================
   Unified app form styling (shopping/subscriptions/bills/edit profile)
   ======================================================================= */

#new-product-form,
#new-subscription-form,
#new-bill-form,
#edit-profile-form {
  gap: 0.85rem;
}

#new-product-form label,
#new-subscription-form label,
#new-bill-form label,
#edit-profile-form label {
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

#new-product-form input,
#new-subscription-form input,
#new-bill-form input,
#edit-profile-form input,
#edit-profile-form select,
#new-product-form select {
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  margin: 0 0 0.35rem 0;
}

#new-product-form input:focus,
#new-subscription-form input:focus,
#new-bill-form input:focus,
#edit-profile-form input:focus,
#edit-profile-form select:focus,
#new-product-form select:focus {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

#new-product-form button,
#new-subscription-form button,
#new-bill-form button,
#edit-profile-form button,
.shopping-products button,
#main-nav button {
  border-radius: 0.75rem;
  border: none;
  font-weight: 700;
  cursor: pointer;
  padding: 0.75rem 1rem;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

#new-product-form button,
#new-subscription-form button,
#new-bill-form button,
#edit-profile-form button {
  background: var(--brand-blue);
  color: #ffffff;
}

#new-product-form button:hover,
#new-subscription-form button:hover,
#new-bill-form button:hover,
#edit-profile-form button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.3);
}

#download-data-btn {
  background: rgba(29, 80, 116, 0.14);
  color: var(--brand-blue);
  border: 1px solid rgba(29, 80, 116, 0.22);
}

#download-data-btn:hover {
  background: rgba(29, 80, 116, 0.2);
  box-shadow: none;
}

#delete-account-btn {
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.22);
}

#delete-account-btn:hover {
  background: rgba(185, 28, 28, 0.18);
  box-shadow: none;
  transform: translateY(-1px);
}

#back-to-main,
#close-accessibility {
  background: rgba(229, 231, 235, 0.85);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

body.dark-mode #back-to-main,
body.dark-mode #close-accessibility {
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
}

#back-to-main:hover,
#close-accessibility:hover {
  background: rgba(229, 231, 235, 1);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

body.dark-mode #back-to-main:hover,
body.dark-mode #close-accessibility:hover {
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

/* =======================================================================
   Widgets / lists / charts (colour consistency)
   ======================================================================= */

.shopping-products-container,
#monthly-sub-list,
#yearly-sub-list,
#monthly-bills-list,
#yearly-bills-list {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 0.95rem;
}

body.dark-mode .shopping-products-container,
body.dark-mode #monthly-sub-list,
body.dark-mode #yearly-sub-list,
body.dark-mode #monthly-bills-list,
body.dark-mode #yearly-bills-list {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
}

.app-content-divider {
  width: 100%;
  margin: 1.5rem 0 1.25rem;
  border-top: 1px solid var(--border);
}

/* Keep chart cards equal when a legend has fewer than three entries. */
.chart-html-legend {
  height: 150px;
  min-height: 150px;
}

/* =======================================================================
   Small-screen containment and compact navigation
   ======================================================================= */

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

header,
main,
footer {
  min-width: 0;
  max-width: 100%;
}

.header-inner,
.app-shell,
.app-panel {
  min-width: 0;
}

header,
footer {
  width: 100%;
}

@media (max-width: 640px) {
  .header-inner {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1.5rem;
  }

  #public-nav {
    width: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.4rem;
    white-space: nowrap;
  }

  main {
    width: 100%;
    padding: 8px 10px 16px;
  }

  #main-nav {
    width: 100%;
    min-width: 0;
    padding: 0.65rem;
  }

  #main-nav ul {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 0.25rem;
  }

  #main-nav ul li {
    min-width: 0;
  }

  #main-nav ul li a {
    min-width: 0;
    padding: 0.45rem 0.35rem;
    font-size: clamp(0.64rem, 2.7vw, 0.78rem);
    white-space: nowrap;
  }

  #main-nav ul li.nav-divider {
    margin-left: 0;
    padding-left: 0;
  }

  #main-nav ul li.nav-divider a {
    min-width: 0;
    padding: 0.55rem 0.75rem;
    font-size: 1.4rem;
    line-height: 1;
  }

  footer {
    width: 100%;
    padding: 1rem 0.9rem 1.25rem;
    gap: 0.35rem;
  }

  .footer-note {
    flex: 1 0 100%;
    width: 100%;
    margin: 0.45rem 0 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 380px) {
  #main-nav {
    padding-inline: 0.35rem;
  }

  #main-nav ul {
    gap: 0.15rem;
  }

  #main-nav ul li a {
    padding: 0.4rem 0.22rem;
    border-radius: 0.6rem;
    font-size: clamp(0.58rem, 2.75vw, 0.68rem);
  }

  #main-nav ul li.nav-divider a {
    min-width: 0;
    padding: 0.5rem 0.65rem;
    font-size: 1.25rem;
  }
}

/* Private PDF attachment control on real bill/subscription cards. */
.sub-widget .payment-document-button {
  position: absolute;
  top: 3.55rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0.65rem;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(15, 23, 42, 0.1);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.sub-widget .payment-document-button:hover:not(:disabled) {
  background: #ffffff;
  border-color: rgba(22, 163, 74, 0.65);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.12), 0 8px 20px rgba(22, 163, 74, 0.32);
}

.sub-widget .payment-document-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sub-widget .payment-document-button.has-document {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  box-shadow: 0 4px 12px rgba(29, 80, 116, 0.24);
}

.sub-widget .payment-document-button.has-document .payment-document-icon {
  filter: brightness(0) invert(1);
}

.sub-widget .payment-document-button.has-document:hover:not(:disabled) {
  border-color: #15803d;
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15), 0 9px 22px rgba(22, 163, 74, 0.38);
}

.sub-widget .payment-document-button:disabled {
  border-color: #cbd5e1;
  background: #d1d5db;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.62;
  box-shadow: none;
  filter: grayscale(1);
  transform: none;
}

.payment-document-icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  pointer-events: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#payment-document-popup .payment-document-card {
  display: flex;
  flex-direction: column;
  width: min(1100px, 94vw);
  height: min(820px, 90vh);
  padding: 1.15rem;
}

.payment-document-scan-card {
  width: min(500px, 92vw);
  text-align: center;
}

.payment-document-scan-card h3,
.payment-document-scan-card p {
  margin-top: 0;
}

#payment-document-scan-progress {
  width: 100%;
  height: 1rem;
  accent-color: #16a34a;
}

#payment-document-scan-time {
  min-height: 1.25rem;
  margin: 0.65rem 0;
}

.payment-document-scan-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0;
}

body.dark-mode #payment-document-popup .payment-document-card {
  background: var(--card-bg);
}

.payment-document-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.payment-document-heading h3,
.payment-document-heading p {
  margin: 0;
}

.payment-document-heading p {
  margin-top: 0.25rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.payment-document-viewer-shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #525659;
}

#payment-document-viewer {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #525659;
}

#payment-document-status {
  min-height: 1.25rem;
  margin: 0.55rem 0 0;
}

.payment-document-actions {
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.55rem;
}

.payment-document-actions button {
  width: auto;
  min-width: 110px;
  white-space: nowrap;
}

.payment-document-actions #remove-payment-document {
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.payment-document-remove-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
  filter: brightness(0) invert(1);
  pointer-events: none;
}

#back-payment-document:hover {
  background: #16a34a;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.3);
}

#remove-payment-document {
  background: #dc2626;
}

#remove-payment-document:hover {
  background: #b91c1c;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.28);
}

@media (max-width: 640px) {
  #payment-document-popup .payment-document-card {
    width: 96vw;
    height: 92vh;
    padding: 0.8rem;
  }

  .payment-document-actions {
    justify-content: center;
  }

  .payment-document-actions button {
    flex: 1 1 0;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  /* Put the control above the monthly heading only on compact layouts. */
  #subscriptions-section .list-heading-row,
  #bills-section .list-heading-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  #subscriptions-section .list-heading-row .list-sort-select,
  #bills-section .list-heading-row .list-sort-select {
    order: -1;
    align-self: flex-end;
    justify-self: auto;
    margin-bottom: 0.2rem;
  }

  #subscriptions-section .list-heading-row h2,
  #bills-section .list-heading-row h2 {
    order: 0;
    margin-top: 0;
  }

  /* SVG masks guarantee the same theme-aware colour for all source icons. */
  #main-nav .has-mobile-icon .app-nav-icon {
    display: block;
  }

  #main-nav .has-mobile-icon .app-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #main-nav .has-mobile-icon {
    padding: 0.55rem 0.75rem;
    color: var(--muted);
  }

  #main-nav .has-mobile-icon .app-nav-icon {
    width: 1.4rem;
    height: 1.4rem;
    flex-basis: 1.4rem;
  }

  #main-nav .settings-nav-link {
    padding: 0.55rem 0.75rem;
    color: var(--muted);
  }

  #main-nav .app-nav-menu-icon {
    width: 1.4rem;
    height: 1.4rem;
    font-size: 1.4rem;
    line-height: 1.4rem;
    text-align: center;
  }

  #main-nav .has-mobile-icon:hover,
  #main-nav .has-mobile-icon:focus-visible {
    color: var(--accent-hover);
  }

  #main-nav .has-mobile-icon.active {
    color: #ffffff;
  }
}

.product-widget,
.sub-widget {
  background: var(--card-bg);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.product-widget h3 { color: var(--text); }
.product-widget p { color: var(--muted); }

/* Buttons inside product widgets */
.product-widget button {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--brand-blue);
  color: #fff;
}

.product-widget button:hover {
  background: var(--accent-hover);
}

.product-widget .remove-product {
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.22);
}

.product-widget .remove-product:hover {
  background: rgba(185, 28, 28, 0.18);
}

.subscription-summary-bill {
  border: 2px solid rgba(29, 80, 116, 0.55);
}

/* Chart cards */
.chart-card {
  background: var(--card-bg);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 1.1rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.chart-total-spend {
  color: var(--muted);
  font-weight: 700;
}

/* Settings panel should feel like the same UI */
#settings-panel {
  background: var(--card-bg) !important;
  color: var(--text);
  border-left: 1px solid rgba(148, 163, 184, 0.22);
}

body.dark-mode #settings-panel {
  background: rgba(17, 24, 39, 0.92) !important;
}

#settings-panel a,
#settings-panel button {
  color: var(--text);
}




/* =======================================================================
   v4 polish fixes (colour consistency + auth alignment + dark-mode charts)
   ======================================================================= */

/* Auth buttons: always aligned + full-width on small screens */
.auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
@media (min-width: 560px) {
  .auth-actions { grid-template-columns: 1fr 1fr; }
}
.auth-actions .btn { width: 100%; }

.btn-full { width: 100%; }

/* Back-to-home button spacing on auth forms */
#back-home-login,
#back-home-signup {
  margin-top: 0.25rem;
}

/* Settings panel: blue buttons with green hover (match rest of UI) */
#settings-panel {
  color: var(--text) !important;
}
#settings-panel h3 { color: var(--text); }
#settings-panel button {
  background: var(--brand-blue) !important;
  color: #ffffff !important;
  border-radius: 0.75rem !important;
  border: 1px solid rgba(29, 80, 116, 0.35) !important;
}
#settings-panel button:hover {
  background: var(--accent-hover) !important;
}

/* Selects (retailer + monthly/yearly): consistent in light/dark mode */
#shop-select,
#sub-type,
#bill-type,
#signup-age,
#signup-country,
#edit-country,
#edit-age {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--input-border) !important;
  border-radius: 0.75rem !important;
}
body.dark-mode #shop-select,
body.dark-mode #sub-type,
body.dark-mode #bill-type,
body.dark-mode #signup-age,
body.dark-mode #signup-country,
body.dark-mode #edit-country,
body.dark-mode #edit-age {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border-color: var(--input-border) !important;
}

/* Help browsers render dropdown lists in dark mode more cleanly */
body.dark-mode select,
body.dark-mode option {
  color: var(--text);
}
body.dark-mode option {
  background-color: rgba(17, 24, 39, 0.98);
}

/* Some browsers need the select itself to opt into dark UI for the dropdown list */
body.dark-mode select {
  color-scheme: dark;
}

/* Charts: keep cards consistent with the dark blue UI */
body.dark-mode .chart-card {
  background: var(--card-bg) !important;
  border-color: rgba(148, 163, 184, 0.22) !important;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35) !important;
}
body.dark-mode .chart-total-spend {
  color: rgba(226, 232, 240, 0.9) !important;
}

/* Remove buttons: consistent across Shopping / Subscriptions / Bills */
.remove-product,
.remove-sub,
#confirm-delete-btn {
  background: #b91c1c !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 0.75rem !important;
  padding: 0.6rem 0.9rem !important;
  font-weight: 800 !important;
  cursor: pointer;
}
.remove-product:hover,
.remove-sub:hover,
#confirm-delete-btn:hover {
  background: #7f1d1d !important;
}

.product-widget .remove-product,
.sub-widget .remove-sub {
  width: 100%;
}

/* Accessibility + Edit profile: remove the extra outer “square box”.
   Only the inner .page-shell should render as the card. */
#edit-profile-section,
#accessibility-tools-section {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
body.dark-mode #edit-profile-section,
body.dark-mode #accessibility-tools-section {
  background: transparent !important;
  box-shadow: none !important;
}


/* Delete account button: coloured (danger) -> white text */
#delete-account-btn {
  background: #b91c1c !important;
  color: #ffffff !important;
  border: none !important;
}
#delete-account-btn:hover,
#delete-account-btn:focus-visible {
  background: #7f1d1d !important;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.3) !important;
}

#delete-account-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.22) !important;
}


/* =======================================================================
   V5 polish tweaks (spacing + selects + date icon)
   ======================================================================= */

/* Reduce the “blank band” between sticky header and the in-app tab bar */
header:has(#main-nav:not([hidden])) {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

main {
  padding-top: 8px;
}

#main-nav {
  margin-top: 0.35rem !important;
}

.page-shell {
  margin-top: 0.75rem;
}

/* Retailer dropdown: add a touch more breathing room under the label */
#dropdown-container label {
  margin-bottom: 10px !important;
}

/* Consistent selects with properly centered arrow (fixes dark-mode tiling) */
select,
#country-select,
#shop-select,
#sub-type,
#bill-type,
#signup-age,
#signup-country,
#edit-country,
#edit-age {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;

  /* Space for the chevron */
  padding-right: 2.85rem !important;

  /* Custom chevron (prevents weird tiling in dark mode) */
  background-image: var(--select-chevron) !important;
  background-repeat: no-repeat !important;
  background-position: calc(100% - 1.05rem) 50% !important;
  background-size: 16px 16px !important;
}

/* Date picker: make the calendar icon readable in dark mode */
body.dark-mode input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.9;
}

/* =========================================================
   Dark mode: custom chevron, centered, and NEVER tiled
   (high specificity + background shorthand)
   ========================================================= */

body.dark-mode select#country-select,
body.dark-mode select#shop-select,
body.dark-mode select#sub-type,
body.dark-mode select#bill-type,
body.dark-mode select#signup-age,
body.dark-mode select#signup-country,
body.dark-mode select#edit-country,
body.dark-mode select#edit-age,
body.dark-mode select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;

  /* keep dropdown menu UI dark */
  color-scheme: dark;

  /* space for chevron */
  padding-right: 2.85rem !important;

  /* one-shot background definition prevents tiling */
  background: var(--input-bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M6 8l4 4 4-4' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat
    calc(100% - 1.05rem)
    calc(50% + 1px)
    / 16px 16px !important;

  color: var(--text) !important;
  border-color: var(--input-border) !important;
}

/* =========================================
   Make Edit Profile "Back" match primary blue buttons
   ========================================= */

#back-to-main,
button#back-to-main,
a#back-to-main {
  background: var(--brand-blue) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 0.75rem !important;
  padding: 0.75rem 1rem !important;
  font-weight: 700 !important;

  /* match your other big buttons */
  width: 100%;
  max-width: none !important;

  box-shadow: none !important;
  text-decoration: none !important;
}

#back-to-main:hover,
button#back-to-main:hover,
a#back-to-main:hover {
  background: var(--accent-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.30) !important;
}

#back-to-main:active,
button#back-to-main:active,
a#back-to-main:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.20) !important;
}

/* =========================================
   Fix 1: Add 10px space between "Product Retailer" label and #shop-select
   ========================================= */
#shop-select {
  margin-top: 10px !important;
}

/* (optional safety) if your label has for="shop-select" */
label[for="shop-select"] {
  margin-bottom: 10px !important;
  display: block;
}

/* =========================================
   Fix 2: Edit Profile tooltip icons visible in dark mode
   - Works for both inline <svg> and <img src="*.svg">
   - Uses filter so hard-coded black SVGs turn white
   ========================================= */
body.dark-mode #edit-profile-form label svg,
body.dark-mode #edit-profile-form label img,
body.dark-mode #edit-profile-section label svg,
body.dark-mode #edit-profile-section label img,
body.dark-mode #edit-profile-form .tooltip svg,
body.dark-mode #edit-profile-form .tooltip img,
body.dark-mode #edit-profile-form [class*="tooltip"] svg,
body.dark-mode #edit-profile-form [class*="tooltip"] img,
body.dark-mode #edit-profile-form [class*="info"] svg,
body.dark-mode #edit-profile-form [class*="info"] img,
body.dark-mode #edit-profile-form [class*="help"] svg,
body.dark-mode #edit-profile-form [class*="help"] img {
  filter: invert(1) brightness(1.15) !important;
  opacity: 0.95;
}

#settings-panel {
  z-index: 9999 !important;              /* higher than sticky header */
  max-height: 100dvh !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* On small screens, make sure top buttons aren't trapped under the header */
@media (max-width: 680px) {
  #settings-panel {
    padding-top: max(20px, calc(env(safe-area-inset-top, 0px) + 96px)) !important;
  }
}

/* Keep the floating settings button above everything too */
#floating-settings {
  z-index: 10000 !important;
}

#main-nav ul li.nav-divider {
  position: relative;
  margin-left: 28px;      /* space after Bills */
  padding-left: 28px;     /* space before burger */
}

/* Divider between nav items and settings burger */
#main-nav ul li.nav-divider::before {
  content: " ";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted); /* light mode */
}

/* Dark mode override */
body.dark-mode #main-nav ul li.nav-divider::before {
  color: var(--muted); /* same variable, different value in dark mode */
}
/* Freemium adverts disabled: styles retained for re-enabling. */
/*
.ad-card {
  width: 100%;
  margin: 18px auto 0;
  padding: 14px 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--card-bg);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  position: relative;
}

.ad-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.ad-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  color: var(--muted);
  background: var(--input-bg);
}
*/
/* Logo pinned top-right */
/*
.ad-brand {
  position: absolute;
  top: 12px;
  right: 12px;
  height: 50px;
  width: auto;
  display: block;
}
*/
/* Default: reserve room for logo so text doesn't overlap */
/*
.ad-title,
.ad-subtitle {
  padding-right: 140px;
}

.ad-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.ad-subtitle {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.ad-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--brand-blue);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.ad-cta:hover {
  background: var(--accent-hover);
}

.ad-disclaimer {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
*/
/* ✅ Small screens: shrink logo and remove the big reserved padding */
/*
@media (max-width: 480px) {
  .ad-brand {
    height: 34px;
*/
/* smaller logo */
/*
    top: 10px;
    right: 10px;
  }

  .ad-title,
  .ad-subtitle {
    padding-right: 0;
*/
/* don't create whitespace */
/*
  }

  .ad-title {
    padding-top: 34px;
*/
/* give content a little breathing room under logo */
/*
  }
}

.ad-card { position: relative; }

.ad-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 10px;
}
*/
/* pinned, scales with screen size */
/*
.ad-brand{
  position: absolute;
  top: 12px;
  right: 12px;
*/
/* 1.25x bigger on small, much bigger on large */
/*
  height: clamp(42px, 18vw, 95px);

  width: auto;
  margin: 0;
  display: block;
}
*/
/* reserve space so title/subtitle don't sit under logo */
/*
.ad-title,
.ad-subtitle {
  padding-right: clamp(0px, 32vw, 160px);
}
*/
/* extra tweak for very small screens */
/*
@media (max-width: 360px) {
  .ad-title,
  .ad-subtitle { padding-right: 0; }

  .ad-title { padding-top: 6px; }
*/
/* tiny breathing room */
/*
}
*/
/* Compact ad style (product placement-ish) */
/*
.ad-card--compact{
  padding: 10px 10px 12px;
}

.ad-card--compact .ad-header{
  margin-bottom: 6px;
}
*/
/* override your absolute-position logo ONLY inside compact */
/* Make all compact logos the same visual size */
/*
.ad-card--compact .ad-brand{
  position: static;
  height: 40px;
*/
/* uniform height */
/*
  width: auto;
  max-width: 100px;
*/
/* prevents extra-wide logos */
/*
  object-fit: contain;
  display: block;
}

.ad-header--compact{
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ad-body--compact{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ad-card--compact .ad-title{
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.15;
  padding-right: 0;
*/
/* cancel the big-screen reserve space */
/*
}

.ad-card--compact .ad-subtitle{
  font-size: 0.82rem;
  margin: 2px 0 0;
  line-height: 1.2;
  padding-right: 0;
*/
/* keep it from growing tall */
/*
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ad-cta--sm{
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  color: #fff;
}

.ad-card--compact .ad-cta--sm {
  color: #fff !important;
}


.ad-card--compact .ad-disclaimer{
  margin-top: 6px;
  font-size: 0.7rem;
  line-height: 1.25;
}
*/
/* just spacing inside settings */
/*
.ad-card--settings{
  margin-top: 12px;
}

.ad-card--settings { margin-top: 10px; }
*/
/* Dark mode: turn ONLY the Amazon Music logo white */
/* Dark mode: make ONLY the Amazon Music SVG appear white */
/*
body.dark-mode #ad-settings-music .ad-brand,
body.darkmode  #ad-settings-music .ad-brand {
*/
/* (optional) if you ever use this class name */
/*
  filter: invert(1) brightness(1.15);
}
*/
/* Large ads: logo centered vertically with ~15px right padding */
/*
.ad-card:not(.ad-card--compact) .ad-brand {
  position: absolute;
  right: 45px;
  top: 50%;
  transform: translateY(-50%);
}
*/
/* Small screens: keep logo in the top-right like before */
/*
@media (max-width: 480px) {
  .ad-card:not(.ad-card--compact) .ad-brand {
    top: 12px;
    right: 12px;
    transform: none;
  }
}
*/

/* Mobile nav: keep tabs + burger on one row */
@media (max-width: 520px) {
  #main-nav ul{
    flex-wrap: nowrap;            /* prevent the burger wrapping under */
    justify-content: flex-start;  /* tabs left */
    gap: 0.45rem;
  }

  #main-nav ul li a{
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  /* remove the "spacer/divider" behaviour on mobile and push burger to the right */
  #main-nav ul li.nav-divider{
    margin-left: auto;   /* pushes it to far right */
    padding-left: 0;
  }

  #main-nav ul li.nav-divider::before{
    display: none;       /* hide divider on small screens */
  }

  /* make the burger a bit tighter so it fits */
  #main-nav ul li.nav-divider a{
    padding: 0.5rem 0.65rem;
    min-width: 2.25rem;
  }
}

/* Extra small phones: shrink a touch more */
@media (max-width: 360px) {
  #main-nav ul { gap: 0.35rem; }
  #main-nav ul li a { padding: 0.45rem 0.6rem; font-size: 0.85rem; }
}

/* NAV (base) */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

.nav-link.active {
  color: var(--brand-blue);
  text-decoration: none;
}

.nav-separator {
  color: var(--muted);
  font-size: 0.85rem;
}

/* DROPDOWN */
.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-caret {
  font-size: 0.8em;
  line-height: 1;
  opacity: 0.9;
}

.nav-dropdown__menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.35rem; /* slight spacing but still connected */
  min-width: 180px;
  padding: 0.35rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  display: none;
  z-index: 50;
}

/* Show on hover + keyboard focus */
.nav-dropdown:hover .nav-dropdown__menu,
.nav-dropdown:focus-within .nav-dropdown__menu {
  display: block;
}

/* Hover bridge so it doesn't collapse when moving mouse down */
.nav-dropdown::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16px;
}

.nav-dropdown__item {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 0.7rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav-dropdown__item:hover,
.nav-dropdown__item:focus-visible {
  background: rgba(22, 163, 74, 0.08);
  text-decoration: none;
}

/* Forgot password link */
.forgot-row {
  margin-top: -8px;
  margin-bottom: 12px;
}

.forgot-link {
  font-size: 0.95rem;
  color: var(--brand-blue);
  text-decoration: underline;
  cursor: pointer;
}

.forgot-link:hover {
  color: var(--accent-hover);
}

/* ===== MODALS (OTP + Reset Password) ===== */
.modal-overlay {
  display: none;                 /* hidden by default */
  position: fixed;
  inset: 0;                      /* top/right/bottom/left = 0 */
  z-index: 99999;
  background: rgba(0, 0, 0, 0.55);

  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-card {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.modal-card label,
#delete-popup-content label {
  display: block;
  margin-top: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-card input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  margin-top: 0.4rem;
}

body.modal-open {
  overflow: hidden;
}

/* hidden by default like your other overlays */
#forgot-email-popup { display: none; }
#forgot-email-popup.is-open { display: flex; }

/* === Make ALL modal inputs match normal auth-form inputs === */
#otp-code,
#forgot-email,
#reset-new-password,
#reset-confirm-password,
#delete-confirm-input {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;  /* same as your login/signup inputs */
  background: #fff;
  color: #111827;
  box-sizing: border-box;
}

#otp-code:focus,
#forgot-email:focus,
#reset-new-password:focus,
#reset-confirm-password:focus,
#delete-confirm-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

/* Optional: make these look good in dark mode too */
body.dark-mode #otp-code,
body.dark-mode #forgot-email,
body.dark-mode #reset-new-password,
body.dark-mode #reset-confirm-password,
body.dark-mode #delete-confirm-input {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.35);
  color: #e5e7eb;
}

/* === Uniform popup buttons: match the app button style === */
.popup-buttons button,
#confirm-otp, #cancel-otp,
#confirm-forgot-email, #cancel-forgot-email,
#confirm-reset, #cancel-reset,
#confirm-delete-btn, #cancel-delete-btn,
#confirm-signout, #cancel-signout {
  border-radius: 0.75rem;
}

/* If your Cancel delete is still squared, force it */
#cancel-delete-btn {
  border-radius: 0.75rem !important;
}

.popup-buttons button {
  padding: 0.7rem 1rem;
  font-weight: 700;
}

/* Force inputs inside popups to fill available width */
#otp-popup input,
#reset-password-popup input,
#forgot-email-popup input,
#delete-account-popup input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Make sure popup inner content isn't constraining width */
#otp-popup .popup-content,
#reset-password-popup .popup-content,
#forgot-email-popup .popup-content,
#delete-account-popup .popup-content {
  width: 100%;
}

/* Active Confirm OTP button */
#confirm-otp:not(:disabled) {
  background-color: var(--brand-blue) !important;
  color: #ffffff !important;
  border: none !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  filter: none !important;
}

#confirm-otp:not(:disabled):hover {
  background-color: var(--accent-hover) !important;
}

/* Cancel OTP button */
#cancel-otp {
  background-color: var(--brand-blue) !important;
  color: #ffffff !important;
  border: none !important;
  transform: none !important;
  box-shadow: none !important;
}

#cancel-otp:hover {
  background-color: #dc2626 !important;
  color: #ffffff !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Fully disabled Confirm OTP button */
#confirm-otp:disabled,
#confirm-otp[disabled] {
  background-color: #d1d5db !important;
  color: #6b7280 !important;
  border: 1px solid #cbd5e1 !important;
  opacity: 0.75 !important;
  cursor: default !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
  filter: grayscale(1) !important;
}

/* Safety: disabled button should never hover/change */
#confirm-otp:disabled:hover,
#confirm-otp[disabled]:hover {
  background-color: #d1d5db !important;
  color: #6b7280 !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Real spinner shown while OTP code is generating/sending */
#otp-error-message.otp-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.otp-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 3px solid rgba(22, 163, 74, 0.22);
  border-top-color: var(--accent);
  animation: otpSpin 0.8s linear infinite;
  flex: 0 0 auto;
}

body.dark-mode .otp-spinner {
  border-color: rgba(229, 231, 235, 0.25);
  border-top-color: #e5e7eb;
}

@keyframes otpSpin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Shopping > New Product form (wrapped rows)
   ========================================================= */

/* Each row becomes a vertical stack again */
#new-product-form #dropdown-container,
#new-product-form #asin-row,
#new-product-form #name-row,
#new-product-form #product-price-row,
#new-product-form #product-url-row,
#new-product-form #product-list-row,
#new-product-form #walmart-row,
#new-product-form #ebay-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

/* Force label to occupy full line */
#new-product-form #dropdown-container > label,
#new-product-form #asin-row > label,
#new-product-form #name-row > label {
  display: block;
  margin-bottom: 0;
}

/* Make controls stretch full width (this is what you lost) */
#new-product-form #dropdown-container > select,
#new-product-form #asin-row > input,
#new-product-form #name-row > input {
  width: 100%;
}

#new-product-form [hidden],
.widget-edit-card [hidden] {
  display: none !important;
}

.product-details {
  overflow-wrap: anywhere;
}

.product-widget .product-price {
  margin: auto 0 0;
  padding-top: 1rem;
  font-weight: 700;
}

.product-widget .product-price--unavailable {
  font-weight: 500;
}

.wishlist-total {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.5;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.product-widget h3 {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .shopping-products .product-widget {
    flex-basis: 100%;
  }
}

/* Retailer tip should not look like an error */
#retailer-hint {
  margin: 0;
  color: var(--muted);
}
body.dark-mode #retailer-hint {
  color: rgba(226, 232, 240, 0.78);
}

/* eBay block hidden by default; JS will show it */
#ebay-row {
  display: none;
}

/* Nice “coming soon” styling */
.retailer-note {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}
body.dark-mode .retailer-note {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.25);
}

.product-image {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.55);
  background: rgba(148, 163, 184, 0.18);
}
body.dark-mode .product-image {
  color: rgba(226, 232, 240, 0.7);
  background: rgba(148, 163, 184, 0.12);
}

/* ================================
   Subscription page polish
   ================================ */

/* Remove the "double card" effect:
   #subscription-section is styled as a card in one place,
   while .page-shell is also a card. Keep only .page-shell. */
#subscription-section {
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
body.dark-mode #subscription-section {
  background: transparent;
  box-shadow: none;
}

/* Keep this page shell a bit narrower than the default 960px */
#subscription-section .page-shell {
  max-width: 560px;
}

#subscription-section {
  padding: 2.75rem 1.25rem 3.5rem;
}

#subscription-section .subscription-card {
  padding: 1.55rem 1.65rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--card-bg);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

#subscription-section [hidden] {
  display: none !important;
}

#subscription-section h2 {
  margin: 0.65rem 0 0.7rem;
  font-size: 1.2rem;
  line-height: 1.3;
}

#subscription-section .subscription-plan-line {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

#subscription-section .subscription-plan-line strong {
  color: var(--text);
}

#subscription-section .subscription-description {
  margin: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

#subscription-section .subscription-actions {
  margin-top: 1rem;
}

#subscription-section .pro-option {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card-bg);
}

#subscription-section .pro-option + .pro-option {
  margin-top: 0.85rem;
}

#subscription-section .pro-option-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

#subscription-section .pro-option-heading strong {
  color: var(--text);
  white-space: nowrap;
}

#subscription-section .pro-option-benefit {
  margin: -0.15rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

#subscription-section .pro-option-benefit span {
  margin-right: 0.35rem;
  color: var(--accent);
  font-weight: 800;
}

#subscription-section .compare-plans-link {
  display: block;
  margin-top: 0.85rem;
  padding: 0.85rem 0.1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
  text-decoration: none;
}

#subscription-section .compare-plans-link:hover,
#subscription-section .compare-plans-link:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

#subscription-section .promo-panel {
  margin-top: 0.95rem;
}

#subscription-section .promo-panel h3 {
  margin: 0 0 0.55rem;
  font-size: 1.08rem;
}

#subscription-section .promo-status {
  min-height: 1.35rem;
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
}

#subscription-section .promo-status:empty {
  display: none;
}

#subscription-section .promo-status.is-success {
  color: var(--accent-hover);
}

#subscription-section .promo-status.is-success::before {
  content: "✓ ";
}

#subscription-section .promo-status.is-error {
  color: var(--error);
}

#subscription-section .subscription-back {
  margin-top: 1.45rem;
  min-height: 2.7rem;
  color: var(--brand-blue);
  text-transform: none !important;
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

body.dark-mode #subscription-section .subscription-back {
  color: #e5e7eb;
}

/* Match the app's green hover glow on the Pro page's non-blue buttons. */
#subscription-section #promo-claim-btn,
#subscription-section .subscription-back {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
}

#subscription-section #promo-claim-btn:hover,
#subscription-section #promo-claim-btn:focus-visible,
#subscription-section .subscription-back:hover,
#subscription-section .subscription-back:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.28);
}

#subscription-section #promo-claim-btn:active,
#subscription-section .subscription-back:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Button stack spacing so hover "lift" doesn't overlap the next button */
#subscription-section .plan-btn-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}
#subscription-section .plan-btn-row .btn {
  width: 100%;
}

/* Promo row: aligned input + button with consistent sizing */
#subscription-section .promo-row {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  margin: 0.5rem 0 0.25rem;
}

#subscription-section #promo-code-input {
  flex: 1;
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
}

#subscription-section #promo-code-input:focus {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

body.dark-mode #subscription-section #promo-code-input {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--text);
}

/* Keep the promo button from shrinking oddly */
#subscription-section #promo-claim-btn {
  white-space: nowrap;
}

/* Mobile: stack promo input/button nicely */
@media (max-width: 420px) {
  #subscription-section {
    padding: 1.5rem 0.75rem 2.5rem;
  }
  #subscription-section .subscription-card {
    padding: 1.3rem 1.1rem 1.15rem;
  }
  #subscription-section .plan-btn-row,
  #subscription-section .promo-row {
    display: grid;
    grid-template-columns: 1fr;
  }
  #subscription-section #promo-claim-btn {
    width: 100%;
  }
  #subscription-section .pro-option-heading {
    gap: 0.5rem;
  }
}

/* Compact square trash button for subscription + bill cards */
.sub-widget {
    position: relative;
    padding-right: 3.4rem;
}

.sub-widget .remove-sub {
    position: absolute !important;
    top: 0.75rem !important;
    right: 0.75rem !important;

    width: 2.25rem !important;
    height: 2.25rem !important;
    min-width: 2.25rem !important;

    padding: 0 !important;
    margin: 0 !important;

    border: none !important;
    border-radius: 0.65rem !important;
    background-color: #dc2626 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    cursor: pointer;
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.18);
    transition:
        transform 0.12s ease,
        background-color 0.12s ease,
        box-shadow 0.12s ease;
}

.sub-widget .remove-sub-icon {
    width: 1rem;
    height: 1rem;
    display: block;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.sub-widget .remove-sub:hover {
    background-color: #b91c1c !important;
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(220, 38, 38, 0.25);
}

.sub-widget .remove-sub:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(220, 38, 38, 0.18);
}

.sub-widget .remove-sub:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* =======================================================================
   Signup disabled button and validation errors
   ======================================================================= */

/*
  The signup button remains visibly grey and non-interactive until the
  Terms of Service and Privacy Policy checkbox has been selected.
*/
#signup-submit:disabled,
#signup-submit:disabled:hover,
#signup-submit:disabled:focus,
#signup-submit:disabled:active {
  background: #9ca3af;
  color: #f3f4f6;
  cursor: not-allowed;
  opacity: 1;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

/*
  Text inputs and select boxes that caused a signup validation failure.
  !important ensures the red state remains visible while the field is focused.
*/
#signup-form input.is-invalid:not([type="checkbox"]),
#signup-form select.is-invalid,
#signup-form input.is-invalid:not([type="checkbox"]):focus,
#signup-form select.is-invalid:focus {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22) !important;
  background-color: #fff7f7;
  scroll-margin-top: 7rem;
}

/* Make the label belonging to the invalid field red as well. */
#signup-form .field.has-error > label,
#signup-form .clickwrap.has-error > label {
  color: #b91c1c;
}

/*
  Terms checkbox error state. This is mainly a defensive fallback because
  the disabled signup button normally prevents an unchecked submission.
*/
#signup-form .clickwrap.has-error {
  border-radius: 0.75rem;
  outline: 2px solid rgba(220, 38, 38, 0.8);
  outline-offset: 3px;
  background: rgba(254, 226, 226, 0.55);
}

#signup-form input[type="checkbox"].is-invalid {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

/* =======================================================================
   Shopping product action buttons
   ======================================================================= */

/* Place Remove, Buy Now and Edit together on one row. */
.product-widget .product-actions {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

/* Remove the old full-width product-button spacing. */
.product-widget .product-actions button {
  margin: 0 !important;
}

/* Smaller Buy Now button with a matching blue glow. */
.product-widget .product-actions .buy-product {
  flex: 1 1 auto;

  width: auto !important;
  min-width: 0;
  height: 2.25rem;

  padding: 0 1rem !important;

  border: none !important;
  border-radius: 0.65rem !important;

  background-color: var(--brand-blue) !important;
  color: #ffffff !important;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-weight: 800;
  cursor: pointer;

  box-shadow:
    0 8px 18px rgba(29, 80, 116, 0.32);

  transition:
    transform 0.12s ease,
    background-color 0.12s ease,
    box-shadow 0.12s ease;
}

/* On hover, keep the existing green background and green glow. */
.product-widget .product-actions .buy-product:hover {
  background-color:
    var(--accent-hover) !important;

  transform: translateY(-1px);

  box-shadow:
    0 12px 24px rgba(22, 163, 74, 0.38);
}

.product-widget .product-actions .buy-product:active {
  transform: translateY(0);

  box-shadow:
    0 6px 14px rgba(22, 163, 74, 0.25);
}

.product-widget .product-actions .buy-product:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Compact blue edit buttons matching the existing widget action buttons. */
.product-widget .product-actions .widget-edit-button,
.sub-widget .widget-edit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  margin: 0;
  padding: 0 !important;
  border: none;
  border-radius: 0.65rem !important;
  background: var(--brand-blue);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(29, 80, 116, 0.32);
  transition: transform 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.sub-widget.editable-widget {
  min-height: 9.35rem;
}

.sub-widget .widget-edit-button {
  position: absolute;
  top: 6.35rem;
  right: 0.75rem;
}

.widget-edit-icon {
  width: 1rem;
  height: 1rem;
  display: block;
  filter: brightness(0) invert(1);
  pointer-events: none;
}

.product-widget .product-actions .widget-edit-button:hover,
.sub-widget .widget-edit-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.38);
}

.widget-edit-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.widget-edit-card {
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  background: var(--card-bg);
  color: var(--text);
}

.widget-edit-card h3 {
  margin: 0 0 0.75rem;
}

#widget-edit-form input,
#widget-edit-form select {
  width: 100%;
  max-width: none;
  margin: 0.4rem 0 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--input-border);
  border-radius: 0.75rem;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
}

#widget-edit-error {
  color: var(--error);
}

#widget-edit-form .popup-buttons {
  gap: 1rem;
}

#widget-edit-cancel {
  background: #dc2626;
}

#widget-edit-cancel:hover:not(:disabled) {
  background: #b91c1c;
}

#widget-edit-save:disabled,
#widget-edit-cancel:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Compact square trash button matching subscriptions and bills. */
.product-widget .product-actions .remove-product {
  flex: 0 0 2.25rem;

  width: 2.25rem !important;
  height: 2.25rem !important;
  min-width: 2.25rem !important;

  padding: 0 !important;
  margin: 0 !important;

  border: none !important;
  border-radius: 0.65rem !important;

  background-color: #dc2626 !important;
  color: #ffffff !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  cursor: pointer;

  box-shadow:
    0 8px 18px rgba(220, 38, 38, 0.18);

  transition:
    transform 0.12s ease,
    background-color 0.12s ease,
    box-shadow 0.12s ease;
}

.product-widget .remove-product-icon {
  width: 1rem;
  height: 1rem;
  display: block;

  filter:
    brightness(0)
    invert(1);

  pointer-events: none;
}

.product-widget .product-actions .remove-product:hover {
  background-color: #b91c1c !important;

  transform: translateY(-1px);

  box-shadow:
    0 12px 24px rgba(220, 38, 38, 0.25);
}

.product-widget .product-actions .remove-product:active {
  transform: translateY(0);

  box-shadow:
    0 6px 14px rgba(220, 38, 38, 0.18);
}

.product-widget .product-actions .remove-product:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Keep the buttons usable on very narrow screens. */
@media (max-width: 420px) {
  .product-widget .product-actions {
    gap: 0.55rem;
  }

  .product-widget .product-actions .buy-product {
    padding-right: 0.65rem !important;
    padding-left: 0.65rem !important;
  }
}

/* Flat buttons across shopping, subscription and bill widgets, in every state. */
.product-widget button,
.sub-widget button {
  box-shadow: none !important;
}

/* =======================================================================
   Shared Product / Subscription / Bill form switches
   ======================================================================= */

.entry-form-heading-row {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;

  gap: 0.75rem;

  margin-bottom: 0.85rem;
}

.entry-form-heading-row h2 {
  margin: 0;
}

/* Label makes both the switch and its text clickable. */
.entry-form-switch-label {
  display: inline-flex;
  align-items: center;

  gap: 0.55rem;

  margin: 0;

  cursor: pointer;
  user-select: none;
}

.entry-form-switch-text {
  color: var(--muted);

  font-size: 0.84rem;
  font-weight: 650;
}

/* Reset native checkbox appearance. */
.entry-form-toggle {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  /* # change for size */
  width: 45px;
  height: 28px;
  flex: 0 0 45px;

  display: inline-block;
  position: relative;

  /* # change for top */
  top: 2px;

  margin: 0;

  border: 2px solid #cfd3dc;
  border-radius: 999px;

  /*
  The grey background remains underneath.
  Green fades in and out through ::before.
  */
  background:
    linear-gradient(
      180deg,
      #f5f6f8 0%,
      #e5e7ec 100%
    );

  cursor: pointer;
  overflow: hidden;

  -webkit-tap-highlight-color: transparent;

  transition:
    border-color 0.28s ease,
    box-shadow 0.28s ease,
    opacity 0.2s ease;
}

/* Smooth green layer in both directions. */
.entry-form-toggle::before {
  content: "";

  position: absolute;
  inset: 0;

  border-radius: inherit;

  background:
    linear-gradient(
      180deg,
      #22c55e 0%,
      var(--accent) 100%
    );

  opacity: 0;

  transition:
    opacity 0.28s ease;

  pointer-events: none;
}

/* White circular handle. */
.entry-form-toggle::after {
  content: "";

  position: absolute;

  top: 50%;
  left: 2px;

  /* # change for size */
  width: 20px;
  height: 20px;

  z-index: 1;

  border-radius: 50%;

  background: #ffffff;

  box-shadow:
    0 2px 5px rgba(44, 44, 44, 0.18),
    0 0 0 1px rgba(44, 44, 44, 0.05);

  transform:
    translateY(-50%);

  transition:
    transform 0.28s
      cubic-bezier(
        0.5,
        0.1,
        0.75,
        1.35
      ),
    box-shadow 0.28s ease;

  pointer-events: none;
}

/* Checked means the shared forms are open. */
.entry-form-toggle:checked {
  border-color: var(--accent);

  box-shadow:
    0 7px 18px rgba(22, 163, 74, 0.24);
}

.entry-form-toggle:checked::before {
  opacity: 1;
}

.entry-form-toggle:checked::after {
  /* # change for size */
  transform:
    translate(15px, -50%);

  box-shadow:
    0 2px 7px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(15, 23, 42, 0.06);
}

.entry-form-toggle:hover:not(:disabled) {
  border-color: var(--accent);

  box-shadow:
    0 8px 20px rgba(22, 163, 74, 0.2);
}

.entry-form-toggle:focus {
  outline: 0;
}

.entry-form-toggle:focus-visible {
  outline:
    3px solid rgba(22, 163, 74, 0.3);

  outline-offset: 4px;
}

.entry-form-toggle:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Dark-mode unchecked switch. */
body.dark-mode .entry-form-toggle {
  border-color: #475569;

  background:
    linear-gradient(
      180deg,
      #334155 0%,
      #1e293b 100%
    );
}

body.dark-mode .entry-form-toggle:checked {
  border-color: var(--accent);
}

body.dark-mode .entry-form-switch-text {
  color: var(--muted);
}

/* =======================================================================
   Smooth opening and closing animation for all three forms
   ======================================================================= */

.entry-form-panel {
  height: auto;

  opacity: 1;
  visibility: visible;

  overflow: hidden;

  transform:
    translateY(0);

  transform-origin: top;

  /*
  JavaScript supplies the real pixel height,
  allowing opening and closing to be exact reversals.
  */
  transition:
    height 0.5s
      cubic-bezier(
        0.4,
        0,
        0.2,
        1
      ),

    transform 0.5s
      cubic-bezier(
        0.4,
        0,
        0.2,
        1
      ),

    /*
    Very small fade-in near the start
    of the opening animation.
    */
    opacity 0.12s ease 0.03s,

    visibility 0s linear 0s;

  will-change:
    height,
    opacity,
    transform;
}

/*
Closing uses the same movement duration and curve.
The fade happens only near the end.
*/
.entry-form-panel.is-collapsed {
  opacity: 0;
  visibility: hidden;

  pointer-events: none;

  transform:
    translateY(-6px);

  transition:
    height 0.5s
      cubic-bezier(
        0.4,
        0,
        0.2,
        1
      ),

    transform 0.5s
      cubic-bezier(
        0.4,
        0,
        0.2,
        1
      ),

    /*
    Tiny fade-out during the final
    part of the closing movement.
    */
    opacity 0.1s ease 0.39s,

    visibility 0s linear 0.5s;
}

/*
Used while restoring the database preference.
This prevents animation during initial page loading.
*/
.entry-form-panel.entry-form-no-transition {
  transition: none !important;
}

@media (max-width: 480px) {
  .entry-form-heading-row {
    gap: 0.55rem;
  }

  .entry-form-switch-text {
    font-size: 0.8rem;
  }
}

/* Respect users who prefer reduced animation. */
@media (prefers-reduced-motion: reduce) {
  .entry-form-toggle,
  .entry-form-toggle::before,
  .entry-form-toggle::after,
  .entry-form-panel,
  .entry-form-panel.is-collapsed {
    transition-duration: 0.01ms !important;
  }
}

/* Final mobile nav override: this must follow the legacy nowrap rules above. */
@media (max-width: 640px) {
  #main-nav ul {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 0.25rem;
  }

  #main-nav ul li,
  #main-nav ul li.nav-divider {
    min-width: 0;
    margin-left: 0;
    padding-left: 0;
  }

  #main-nav ul li a {
    min-width: 0;
    padding: 0.45rem 0.35rem;
    font-size: clamp(0.64rem, 2.7vw, 0.78rem);
    white-space: nowrap;
  }

  #main-nav ul li.nav-divider a {
    min-width: 0;
    padding: 0.55rem 0.75rem;
    font-size: inherit;
  }
}

@media (max-width: 380px) {
  #main-nav ul {
    gap: 0.15rem;
  }

  #main-nav ul li a {
    padding: 0.4rem 0.22rem;
    border-radius: 0.6rem;
    font-size: clamp(0.58rem, 2.75vw, 0.68rem);
  }

  #main-nav ul li.nav-divider a {
    min-width: 0;
    padding: 0.55rem 0.75rem;
    font-size: inherit;
  }
}
