/* ==========================================================================
   kleinanzeigen-ai — shared design system
   MOBILE-FIRST: base styles target the smallest screens (~320px phones);
   min-width media queries progressively enhance for tablet and desktop.
   ========================================================================== */

:root {
  --color-bg: #f7f7f9;
  --color-surface: #ffffff;
  --color-border: #e7e7ec;
  --color-border-strong: #d8d8e0;
  --color-text: #16161d;
  --color-text-muted: #6b6b76;
  --color-text-subtle: #9a9aa4;

  --color-accent: #3b5bfd;
  --color-accent-hover: #2c47d9;
  --color-accent-soft: #eef1ff;
  --color-accent-soft-border: #d9e0ff;

  --color-success-bg: #e7f7ee;
  --color-success-text: #16794c;
  --color-success-border: #bfe8d2;

  --color-error-bg: #fdecec;
  --color-error-text: #b3261e;
  --color-error-border: #f6c6c3;

  --color-warning-bg: #fff8e6;
  --color-warning-text: #8a6100;
  --color-warning-border: #f5dfa0;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 26, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 20, 26, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* bottom nav height used to reserve body padding on mobile */
  --bottom-nav-height: 60px;
}

/* ---------- reset & base ---------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

p {
  line-height: 1.55;
}

a {
  color: var(--color-accent);
}

a:hover {
  color: var(--color-accent-hover);
}

/* ---------- form elements ----------------------------------------------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  margin-top: 8px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select {
  width: 100%;
  padding: 11px 13px;
  margin: 4px 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom-on-focus */
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px; /* Apple HIG minimum touch target */
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b6b76'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.293l3.71-4.06a.75.75 0 111.08 1.04l-4.24 4.65a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 34px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

button {
  font-family: inherit;
}

button[type="submit"] {
  width: 100%;
  background: var(--color-accent);
  color: #fff;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  min-height: 46px;
  transition: background 0.15s ease;
}

button[type="submit"]:hover {
  background: var(--color-accent-hover);
}

/* ---------- shared surfaces --------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md); /* tighter on mobile */
  box-shadow: var(--shadow-sm);
  padding: 18px 16px;              /* compact on mobile */
  margin-bottom: 24px;
}

.card h3 {
  font-size: 16px;
  color: var(--color-text);
  margin-bottom: 18px;
}

@media (min-width: 561px) {
  .card {
    padding: 28px;
    border-radius: var(--radius-lg);
  }
}

/* ---------- auth pages (login / register) -------------------------------- */

/* Mobile-first: full-screen modal on small phones */
body.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

.login-container,
.register-container {
  background: var(--color-surface);
  width: 100%;
  min-height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
  padding: 40px 22px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 421px) {
  body.auth-page {
    align-items: center;
    padding: 24px;
  }

  .login-container,
  .register-container {
    width: 380px;
    max-width: 100%;
    min-height: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 44px 38px;
    display: block;
  }
}

.login-container h2,
.register-container h2 {
  font-size: 22px;
}

.subtitle {
  color: var(--color-text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.form-group {
  text-align: left;
  margin-bottom: 6px;
  position: relative;
}

.login-btn,
.register-btn {
  width: 100%;
  padding: 13px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  min-height: 46px;
  transition: background 0.15s ease;
}

.login-btn:hover,
.register-btn:hover {
  background: var(--color-accent-hover);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 18px;
  width: 40px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-subtle);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--color-text-muted);
}

.error-msg {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin: 0 0 18px;
  font-size: 13.5px;
  text-align: left;
}

.hint {
  font-size: 12px;
  color: var(--color-text-subtle);
  margin: -8px 0 4px;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--color-text-subtle);
  font-size: 13px;
  margin: 22px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--color-border);
}

.divider span {
  padding: 0 12px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  min-height: 44px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.google-btn:hover {
  background: #f6f7fb;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.register-link,
.login-link {
  margin-top: 24px;
  font-size: 13.5px;
  color: var(--color-text-muted);
}

.register-link a,
.login-link a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.register-link a:hover,
.login-link a:hover {
  text-decoration: underline;
}

/* ---------- dashboard ----------------------------------------------------- */

/* Mobile-first: reserve space for fixed bottom nav */
body.dashboard-page {
  padding: 0;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 561px) {
  body.dashboard-page {
    padding-bottom: 0; /* no bottom nav on wider screens */
  }
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 32px; /* compact on mobile */
}

@media (min-width: 561px) {
  .container {
    padding: 48px 24px 96px;
  }
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Mobile: sticky header that hides on scroll-down and reveals on
     scroll-up (JS toggles .header-hidden). Negative margins bleed it
     across the container padding so it spans the full viewport width. */
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--color-bg);
  margin: -20px -16px 18px;
  padding: 14px 16px 10px;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.header-row.header-hidden {
  transform: translateY(-110%);
}

.header-row.header-scrolled {
  box-shadow: 0 1px 0 var(--color-border);
}

.header-row h2 {
  font-size: 18px; /* slightly smaller on mobile */
}

@media (min-width: 561px) {
  .header-row {
    position: static;
    margin: 0 0 28px;
    padding: 0;
    box-shadow: none;
  }

  .header-row.header-hidden {
    transform: none;
  }

  .header-row h2 {
    font-size: 21px;
  }
}

.logout-link {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
}

.logout-link:hover {
  color: var(--color-text);
}

/* Admin link in header (rare destination, not in bottom nav) */
.admin-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 12px;
  margin-right: 10px;
}

.admin-link:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

/* form grid: single column on mobile, 2-column on wider screens */
.form-grid {
  display: grid;
  grid-template-columns: 1fr; /* mobile: stack */
  gap: 4px 16px;
  margin-bottom: 16px;
}

@media (min-width: 561px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.form-field {
  min-width: 0;
}

.form-full {
  grid-column: 1 / -1;
}

.form-field label {
  display: block;
}

.hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--color-text-subtle);
}

.price-range-field .price-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-range-inputs input {
  flex: 1;
  min-width: 0;
}

.price-range-sep {
  color: var(--color-text-subtle);
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- essentials / advanced-filter accordion ----------------------- */

.wizard-essentials {
  display: block;
}

.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #f8f9fb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 4px 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  min-height: 44px;
}

.filter-toggle:hover {
  background: #f1f3f7;
}

.filter-toggle .filter-toggle-count {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  margin-left: 8px;
}

.filter-toggle-chevron {
  transition: transform 0.15s ease;
  color: var(--color-text-subtle);
  flex-shrink: 0;
}

.filter-toggle[aria-expanded="true"] .filter-toggle-chevron {
  transform: rotate(180deg);
}

.filter-panel {
  display: none;
  padding-top: 2px;
}

.filter-panel.open {
  display: block;
}

/* ---------- wizard -------------------------------------------------------- */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

.wizard-step-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--color-text-subtle);
  font-size: 13px;
  font-weight: 600;
}

.wizard-step-indicator.active,
.wizard-step-indicator.done {
  color: var(--color-accent);
}

.wizard-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-border-strong);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.wizard-step-indicator.active .wizard-step-num,
.wizard-step-indicator.done .wizard-step-num {
  background: var(--color-accent);
}

.wizard-step-line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
  max-width: 60px;
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
}

.wizard-inline-warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning-text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin: 4px 0 14px;
}

.wizard-next-btn {
  width: 100%;
  background: var(--color-accent);
  color: #fff;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  min-height: 46px;
  transition: background 0.15s ease;
}

.wizard-next-btn:hover {
  background: var(--color-accent-hover);
}

.wizard-summary {
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-soft-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  color: #33395b;
  margin-bottom: 18px;
}

.wizard-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.wizard-actions button[type="submit"] {
  flex: 1;
  margin-top: 0;
}

.wizard-back-btn {
  background: #f1f3f5;
  color: #344054;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 46px;
}

.wizard-back-btn:hover {
  background: #e2e6ea;
}

/* Collapsed <details> disclosure — one line when closed so wizard step 2
   stays short; expands on tap for the curious. */
.promo-box {
  display: block;
  background: linear-gradient(135deg, #eef1ff, #f5f0ff);
  border: 1px solid var(--color-accent-soft-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 18px 0 6px;
}

.promo-box summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  min-height: 28px;
}

.promo-box summary::-webkit-details-marker {
  display: none;
}

.promo-box summary::after {
  content: "+";
  margin-left: auto;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-subtle);
}

.promo-box[open] summary::after {
  content: "\2013";
}

.promo-icon {
  font-size: 18px;
  line-height: 1;
}

.promo-box strong {
  font-size: 13.5px;
  color: #33395b;
}

.promo-box p {
  margin: 8px 0 2px;
  font-size: 12.5px;
  color: var(--color-text-muted);
}

/* frequency group: single column on mobile */
.frequency-group {
  margin: 6px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.frequency-group-compact {
  margin: 6px 0 4px;
  display: grid;
  grid-template-columns: 1fr; /* mobile: single column */
  gap: 2px 16px;
}

@media (min-width: 561px) {
  .frequency-group-compact {
    grid-template-columns: 1fr 1fr;
  }
}

.frequency-option {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 400;
  font-size: 14px;
  color: var(--color-text);
  min-height: 44px;
}

/* ---------- notification opt-in card ------------------------------------- */

.notify-card {
  background: var(--color-accent-soft);
  border: 1.5px solid var(--color-accent-soft-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 18px 0;
}

.notify-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  color: #23285c;
  margin-bottom: 4px;
}

.notify-card-sub {
  font-size: 12.5px;
  color: #4a5080;
  margin: 0 0 14px;
}

.notify-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--color-accent-soft-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  min-height: 44px;
}

.notify-option:last-child {
  margin-bottom: 0;
}

.notify-option-label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text);
}

.notify-option-detail {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-subtle);
  margin-top: 1px;
}

/* Compact variant once the user has opted in before (JS adds .compact):
   the pitch is dropped, only the toggles remain. */
.notify-card.compact {
  padding: 12px 14px;
  margin: 14px 0;
}

.notify-card.compact .notify-card-sub {
  display: none;
}

.notify-card.compact .notify-card-title {
  font-size: 13.5px;
  margin-bottom: 10px;
}

/* ---------- flash / quota bars ------------------------------------------- */

.warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-top: 4px;
  margin-bottom: 8px;
  font-size: 13.5px;
  display: none;
  color: var(--color-warning-text);
}

/* Mobile-first: compact text/padding as base */
.flash-success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: var(--color-success-text);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 13px;
}

.flash-error {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  color: var(--color-error-text);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 13px;
}

.quota-bar {
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-soft-border);
  color: #33395b;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 13px;
}

@media (min-width: 561px) {
  .flash-success,
  .flash-error,
  .quota-bar {
    font-size: 13.5px;
    padding: 13px 16px;
  }
}

/* ---------- tab navigation (top tabs: hidden on mobile, shown on tablet+) - */

/* Mobile-first: hidden — bottom nav takes over */
.tab-nav {
  display: none;
}

@media (min-width: 561px) {
  .tab-nav {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 28px;
    gap: 4px;
  }
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 4px;
  margin-right: 26px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ---------- fixed bottom navigation (mobile-first: visible by default) --- */

/* Base: shown on mobile */
.bottom-nav {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--color-border);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(20, 20, 26, 0.05);
}

@media (min-width: 561px) {
  /* Hidden on tablet/desktop — top tab-nav takes over */
  .bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--color-text-subtle);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px 4px;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.active {
  color: var(--color-accent);
}

/* Middle "new search" item: raised accent circle */
.bottom-nav-item.primary .bottom-nav-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -18px;
  box-shadow: 0 4px 10px rgba(59, 91, 253, 0.35);
}

.bottom-nav-item.primary.active .bottom-nav-icon-wrap,
.bottom-nav-item.primary .bottom-nav-icon-wrap {
  background: var(--color-accent);
}

.bottom-nav-item.primary {
  color: var(--color-accent);
}

/* ---------- tables -------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: transparent;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
}

tbody tr:hover td {
  background: #fafafb;
}

/* ---------- responsive-table: card layout as base (mobile-first) ---------- */
/* On small screens the 9-column table is rendered as a stack of cards.
   At min-width 641px it reverts to a proper table. */

.responsive-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.responsive-table,
.responsive-table tbody,
.responsive-table tr,
.responsive-table td {
  display: block;
  width: 100%;
}

.responsive-table tr {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  padding: 4px 14px;
  box-shadow: var(--shadow-sm);
}

.responsive-table td {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
}

.responsive-table td:last-child {
  border-bottom: none;
  justify-content: flex-end;
  padding-top: 12px;
}

.responsive-table td::before {
  content: attr(data-label);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  text-align: left;
  flex-shrink: 0;
}

/* keyword cell acts as the card header */
.responsive-table td.row-title {
  padding-top: 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
}

.responsive-table td.row-title::before {
  content: "";
}

/* Mobile: row actions are full-size thumb-friendly buttons in a 2-column
   grid (Anzeigen | Löschen, Abbrechen spans below), not small text links. */
.responsive-table td.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 0 14px;
}

.responsive-table td.row-actions::before {
  display: none;
}

.responsive-table .row-actions form {
  display: contents;
}

.responsive-table .row-actions .view-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  border: 1.5px solid var(--color-accent-soft-border);
  background: var(--color-accent-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
}

.responsive-table .row-actions .delete-btn {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--color-error-border);
  border-radius: var(--radius-sm);
  background: var(--color-error-bg);
  color: var(--color-error-text);
  font-size: 13.5px;
  font-weight: 600;
}

.responsive-table .row-actions .cancel-btn {
  grid-column: 1 / -1;
  min-height: 44px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-weight: 600;
}

@media (min-width: 641px) {
  /* Restore full table layout on wider screens */
  .responsive-table {
    display: table;
    width: 100%;
  }

  .responsive-table thead {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    display: table-header-group;
  }

  .responsive-table tbody {
    display: table-row-group;
  }

  .responsive-table tr {
    display: table-row;
    background: none;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    padding: 0;
    box-shadow: none;
  }

  .responsive-table td {
    display: table-cell;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
  }

  .responsive-table td:last-child {
    border-bottom: 1px solid var(--color-border);
    padding-top: 12px;
  }

  .responsive-table td::before {
    display: none;
  }

  .responsive-table td.row-title {
    padding-top: 12px;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
  }

  .responsive-table td.row-actions {
    display: table-cell;
    padding: 12px 14px;
  }

  .responsive-table .row-actions form {
    display: inline;
  }

  .responsive-table .row-actions .view-link {
    display: inline;
    min-height: 0;
    margin-right: 14px;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 500;
  }

  .responsive-table .row-actions .delete-btn {
    width: auto;
    min-height: 0;
    border: none;
    border-radius: 4px;
    background: var(--color-error-text);
    color: #fff;
    font-size: 12px;
    font-weight: 400;
  }

  .responsive-table .row-actions .cancel-btn {
    min-height: 32px;
    border: none;
    border-radius: 0;
    background: none;
    color: var(--color-error-text);
    font-size: 12px;
    font-weight: 500;
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  background: transparent;
  color: var(--color-text-subtle);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- badges -------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-pending {
  background: #f1f1f5;
  color: #5b5b66;
}

.badge-running {
  background: #e5efff;
  color: #1655c4;
}

/* Animated dot signals "working" while a scrape is in flight */
.badge-running::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
  animation: badge-pulse 1.2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.badge-completed {
  background: #e3f7ec;
  color: #177a4b;
}

.badge-failed {
  background: #fdeceb;
  color: #b3261e;
}

.badge-cancelled {
  background: #f1f1f5;
  color: #6b6b76;
}

/* ---------- empty states -------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--color-text-subtle);
  font-size: 14px;
}

.empty-state-cta {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state-cta .empty-state-icon {
  font-size: 34px;
  margin-bottom: 10px;
}

.empty-state-cta p {
  font-size: 14px;
  margin: 0 0 18px;
  color: var(--color-text-muted);
}

.empty-state-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 46px;
}

.empty-state-cta-btn:hover {
  background: var(--color-accent-hover);
  color: #fff;
}

/* ---------- skeleton loading states ---------------------------------------- */
/* Shown in "Meine Ergebnisse" while a search is still running and no
   results have arrived yet — signals "working" instead of "empty". */

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, #ebedf1 25%, #f7f8fa 50%, #ebedf1 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: 6px;
  color: transparent;
}

.skeleton-line {
  display: block;
  height: 12px;
  margin: 4px 0;
}

.skeleton-note {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 4px 0 14px;
}

/* ---------- action buttons ------------------------------------------------ */

.cancel-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-error-text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  min-height: 32px;
}

.cancel-btn:hover {
  text-decoration: underline;
}

.view-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  margin-right: 14px;
}

.view-link:hover {
  text-decoration: underline;
}

/* button.delete-btn (element + class) so this outranks the generic
   button[type="submit"] accent styling — a destructive action must never
   look like the primary CTA. */
button.delete-btn {
  width: auto;
  background: var(--color-error-text);
  color: white;
  border: none;
  padding: 6px 12px;
  margin: 0;
  min-height: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  transition: background-color 0.2s;
}

button.delete-btn:hover {
  background: #921d17;
}

/* Same specificity trick for the cancel action (also type="submit") */
button.cancel-btn {
  width: auto;
  background: none;
  color: var(--color-error-text);
  border: none;
  padding: 0;
  margin: 0;
  min-height: 32px;
  font-size: 12px;
  font-weight: 500;
}

/* ---------- location suggestions ------------------------------------------ */

.suggest-wrap {
  position: relative;
}

.suggest-list {
  position: absolute;
  top: calc(100% - 10px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  margin: 0;
  padding: 6px;
  list-style: none;
  display: none;
}

.suggest-list li {
  padding: 10px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.suggest-list li:hover,
.suggest-list li.active {
  background: var(--color-accent-soft);
}

/* ---------- notification bar (mobile-first: stacked/wrapped) -------------- */

.notif-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-soft-border);
  border-radius: var(--radius-md);
  padding: 12px 14px; /* compact on mobile */
  margin-bottom: 20px;
  font-size: 13.5px;
  color: #33395b;
  flex-wrap: wrap; /* stack on mobile */
}

@media (min-width: 561px) {
  .notif-bar {
    flex-wrap: nowrap;
    padding: 13px 18px;
  }
}

.notif-bar button {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  min-height: 38px;
  transition: background 0.15s ease;
}

.notif-bar button:hover {
  background: var(--color-accent-hover);
}

.notif-bar button:disabled {
  background: #c7c7d1;
  cursor: default;
}

.toggle-on {
  color: #177a4b;
  font-weight: 600;
}

.toggle-off {
  color: var(--color-text-subtle);
}

.action-btn {
  font-size: 12px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.action-btn:hover {
  text-decoration: underline;
}

.action-btn.danger {
  color: var(--color-error-text);
}

.action-btn.muted {
  color: var(--color-text-muted);
}

/* ---------- token stats ---------------------------------------------------- */

.token-stats {
  display: flex;
  gap: 20px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--color-text-muted);
  flex-wrap: wrap; /* wraps on narrow screens */
}

.token-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.token-stat-value {
  font-weight: 700;
  color: var(--color-text);
}

/* ---------- sub-tabs (results filter by search) ---------------------------- */

.sub-tab-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.sub-tab-bar::-webkit-scrollbar {
  display: none;
}

.sub-tab-bar button {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  border: 1.5px solid var(--color-border);
  transition: all 0.15s;
}

.sub-tab-bar button:hover {
  border-color: var(--color-border-strong);
  background-color: #f8f9fa;
}

.sub-tab-bar button.active {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

/* ---------- sticky results toolbar (mobile) -------------------------------- */
/* Wraps the sub-tab bar + sort controls in "Meine Ergebnisse" so they stay
   reachable while scrolling a long result list. Negative margins bleed it
   to the card edges so scrolling content disappears cleanly under it. */

.results-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-surface);
  margin: 0 -16px;
  padding: 0 16px 2px;
}

@media (min-width: 561px) {
  .results-toolbar {
    position: static;
    margin: 0;
    padding: 0;
  }
}

/* ---------- sorting controls (mobile-first: full-width) ------------------- */

.sort-controls {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
  align-items: center;
  width: 100%; /* mobile: full width */
}

.sort-controls select {
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background-color: white;
  cursor: pointer;
  margin: 0;
  flex: 1; /* mobile: fill available space */
  min-height: 38px;
}

@media (min-width: 401px) {
  .sort-controls {
    width: auto;
  }

  .sort-controls select {
    flex: none;
    width: auto;
  }
}

/* ---------- favorite button ------------------------------------------------ */

.favorite-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  color: #ccc;
  transition: color 0.2s;
}

.favorite-btn:hover {
  color: #ff6b6b;
}

.favorite-btn.favorited {
  color: #ff6b6b;
}

.result-card-wrapper {
  position: relative;
}

/* Mobile: the favorite heart floats over the card's top-right corner
   instead of occupying its own row above the card. */
.result-card-header {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.result-card-wrapper .card-body {
  padding-right: 44px; /* keep text clear of the floating heart */
}

@media (min-width: 481px) {
  .result-card-header {
    position: static;
    display: flex;
    justify-content: flex-end;
  }

  .result-card-wrapper .card-body {
    padding-right: 16px;
  }
}

/* ---------- trust score badges -------------------------------------------- */

.trust-score-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trust-score-badge.excellent {
  background-color: #28a745;
}

.trust-score-badge.good {
  background-color: #ffc107;
  color: #333;
}

.trust-score-badge.fair {
  background-color: #ff9800;
}

.trust-score-badge.poor {
  background-color: #f44336;
}

.trust-score-badge.disabled {
  background-color: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

.trust-score-badge.disabled::after {
  content: " 🔒";
  font-size: 0.9em;
}

/* ---------- pagination (mobile-first: page-info on own line) --------------- */

.dashboard-pagination,
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.dashboard-pagination a,
.dashboard-pagination span,
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border: 1.5px solid var(--color-border);
  color: #495057;
  background: white;
  transition: all 0.15s;
  cursor: pointer;
}

.dashboard-pagination a:hover,
.pagination a:hover {
  border-color: var(--color-border-strong);
  background: #f8f9fa;
}

.dashboard-pagination .current,
.pagination .current {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: white;
  font-weight: 700;
}

.dashboard-pagination .disabled,
.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Mobile-first: page-info pushed to its own line below page numbers */
.page-info {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0.5rem;
  width: 100%;
  text-align: center;
  order: 10;
}

@media (min-width: 401px) {
  .page-info {
    order: 0;
  }
}

/* ---------- results page --------------------------------------------------- */

body.results-page {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Mobile-first: compact topbar */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}

@media (min-width: 561px) {
  .topbar {
    padding: 16px 24px;
  }
}

.topbar a.back {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.topbar a.back:hover {
  text-decoration: underline;
}

/* Mobile-first: compact wrap padding */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 561px) {
  .wrap {
    padding: 24px;
  }
}

/* Mobile-first: compact summary card */
.summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 561px) {
  .summary {
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
  }
}

/* Mobile-first: smaller h1 */
.summary h1 {
  font-size: 17px;
  line-height: 1.4;
  margin: 0 0 6px;
}

@media (min-width: 561px) {
  .summary h1 {
    font-size: 20px;
    line-height: normal;
  }
}

.summary .meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.summary .filters {
  font-size: 13px;
  color: var(--color-text);
  margin-top: 10px;
}

.count-badge {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- result grid (mobile-first: single column) --------------------- */

.grid {
  display: grid;
  grid-template-columns: 1fr; /* mobile: single column */
  gap: 14px;
}

@media (min-width: 481px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}

@media (min-width: 641px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
  }
}

.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  /* Mobile: horizontal list card — thumbnail left, content right. Matches
     kleinanzeigen.de's own mobile results and roughly doubles the number
     of listings per screen. Vertical gallery card returns at 481px+. */
  flex-direction: row;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

@media (min-width: 481px) {
  .result-card {
    flex-direction: column;
  }
}

.result-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Mobile: fixed-width thumbnail column stretching the card's height */
.thumb,
.thumb-placeholder {
  width: 108px;
  flex: 0 0 108px;
  min-height: 100px;
  align-self: stretch;
  object-fit: cover;
  background: #eee;
  display: block;
}

.thumb-placeholder {
  background: #eef0f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0b6bd;
  font-size: 11.5px;
}

@media (min-width: 481px) {
  .thumb,
  .thumb-placeholder {
    width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    align-self: auto;
    aspect-ratio: 4 / 3;
  }

  .thumb-placeholder {
    font-size: 13px;
  }
}

.card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

@media (min-width: 481px) {
  .card-body {
    padding: 14px 16px;
    gap: 5px;
  }
}

.price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-price {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text);
}

.deal {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.deal-great {
  background: #e3f7ec;
  color: #177a4b;
}

.deal-fair {
  background: #f1f1f5;
  color: #57606a;
}

.deal-high {
  background: #fdeceb;
  color: #b3261e;
}

.card-title {
  font-size: 14px;
  line-height: 1.35;
  max-height: 2.75em; /* 2 lines on the compact mobile list card */
  overflow: hidden;
}

.card-desc {
  display: none; /* hidden on mobile for list density */
  font-size: 12px;
  color: var(--color-text-muted);
  max-height: 3.2em;
  overflow: hidden;
}

@media (min-width: 481px) {
  .card-title {
    max-height: 3.7em;
  }

  .card-desc {
    display: block;
  }
}

.card-meta {
  margin-top: auto;
  font-size: 12px;
  color: var(--color-text-subtle);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
}

/* Mobile-first: compact empty state */
.empty {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  color: var(--color-text-subtle);
}

@media (min-width: 561px) {
  .empty {
    padding: 48px;
  }
}

/* ---------- results page: tab bar & new badge ------------------------------ */

.tab-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-bar a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  border: 1.5px solid var(--color-border);
  color: #495057;
  background: #fff;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  min-height: 38px;
  transition: all 0.15s;
}

.tab-bar a:hover {
  border-color: var(--color-border-strong);
  background: #f8f9fa;
}

.tab-bar a.active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
}

.tab-bar .tab-count {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.tab-bar a.active .tab-count {
  background: rgba(255, 255, 255, 0.25);
}

.badge-new {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #28a745;
  color: #fff;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 0.4rem;
  line-height: 1.4;
}

/* ---------- offline page ---------------------------------------------------- */

body.offline-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 40px;
}

.offline-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 44px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 400px;
  text-align: center;
}

.offline-card h2 {
  margin-top: 0;
  font-size: 20px;
}

.offline-card p {
  color: var(--color-text-muted);
}

.retry-btn {
  display: inline-block;
  margin-top: 18px;
  padding: 11px 26px;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
  transition: background 0.15s ease;
}

.retry-btn:hover {
  background: var(--color-accent-hover);
  text-decoration: none;
}

/* ---------- plan bar & pricing -------------------------------------------- */

.plan-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.upgrade-link {
  font-weight: 600;
  text-decoration: none;
  color: var(--color-accent);
  white-space: nowrap;
}

.upgrade-link:hover {
  text-decoration: underline;
}

.frequency-locked {
  opacity: 0.55;
}

.freq-upgrade {
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
  margin-left: 4px;
}

.freq-upgrade:hover {
  text-decoration: underline;
}

/* Mobile-first: single column pricing grid */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}

@media (min-width: 561px) {
  .pricing-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
  }
}

.plan-card {
  position: relative;
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 12px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.plan-card h3 {
  margin: 0;
}

.plan-featured {
  border-color: var(--color-accent);
  box-shadow: 0 4px 14px rgba(59, 91, 253, 0.14);
}

.plan-current {
  border-color: #28a745;
}

.plan-ribbon {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}

.plan-price {
  font-size: 28px;
  font-weight: 700;
}

.plan-per {
  font-size: 14px;
  font-weight: 400;
  color: #667085;
}

.plan-trial-note {
  font-size: 13px;
  font-weight: 600;
  color: #177a4b;
  margin: 2px 0 4px;
}

.plan-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #344054;
  font-size: 14px;
}

.plan-features li::before {
  content: "\2713\0020";
  color: #28a745;
  font-weight: 700;
}

.plan-btn {
  margin-top: auto;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
}

.plan-btn:hover {
  background: var(--color-accent-hover);
}

.plan-btn:disabled {
  background: #b6c2cf;
  cursor: not-allowed;
}

.plan-btn-secondary {
  background: #f1f3f5;
  color: #344054;
}

.plan-btn-secondary:hover {
  background: #e2e6ea;
}

.plan-current-label {
  margin-top: auto;
  text-align: center;
  font-weight: 600;
  color: #28a745;
  padding: 10px 0;
}

/* ---------- confirm action sheet ------------------------------------------- */
/* In-design replacement for the native confirm() dialog: bottom sheet on
   mobile, centered dialog on tablet/desktop. Opened by JS for any form
   carrying data-confirm-title. */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 26, 0.45);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.action-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateY(105%);
  transition: transform 0.25s ease;
  box-shadow: 0 -8px 30px rgba(20, 20, 26, 0.18);
}

.action-sheet.open {
  transform: translateY(0);
}

.action-sheet h4 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.action-sheet p {
  margin: 0;
  font-size: 13.5px;
  color: var(--color-text-muted);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.sheet-btn {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-btn-danger {
  background: var(--color-error-text);
  color: #fff;
}

.sheet-btn-danger:hover {
  background: #921d17;
}

.sheet-btn-cancel {
  background: #f1f3f5;
  color: #344054;
}

.sheet-btn-cancel:hover {
  background: #e2e6ea;
}

@media (min-width: 561px) {
  .action-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: 380px;
    max-width: calc(100vw - 48px);
    border-radius: var(--radius-lg);
    padding: 24px;
    transform: translate(-50%, -46%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: var(--shadow-md);
  }

  .action-sheet.open {
    transform: translate(-50%, -50%);
    opacity: 1;
    pointer-events: auto;
  }

  .sheet-actions {
    flex-direction: row-reverse;
  }
}

/* ---------- swipe gesture feedback ----------------------------------------- */
/* JS translates the element while the finger moves; these classes give the
   "armed past threshold" signal. */

.responsive-table tr,
.result-card-wrapper {
  touch-action: pan-y;
}

.responsive-table tr.swipe-armed {
  border-color: var(--color-error-border);
  background: var(--color-error-bg);
}

.result-card-wrapper.swipe-armed .favorite-btn {
  color: #ff6b6b;
}

@keyframes fav-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

.favorite-btn.fav-pop {
  animation: fav-pop 0.35s ease;
}

/* ---------- pull-to-refresh indicator (standalone PWA only) ---------------- */

.ptr-indicator {
  display: none; /* JS adds .ptr-enabled only in standalone PWA mode */
  position: fixed;
  top: -48px;
  left: 50%;
  margin-left: -19px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.ptr-indicator.ptr-enabled {
  display: flex;
}

.ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--color-accent-soft);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  opacity: 0.6;
}

.ptr-indicator.armed .ptr-spinner {
  opacity: 1;
}

.ptr-indicator.spinning .ptr-spinner {
  animation: ptr-rotate 0.7s linear infinite;
}

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

/* ---------- version stamp -------------------------------------------------- */
/* Keep the build stamp above the fixed bottom nav on the dashboard */

body.dashboard-page .version-stamp {
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 4px) !important;
}

@media (min-width: 561px) {
  body.dashboard-page .version-stamp {
    bottom: 4px !important;
  }
}

/* ---------- settings page -------------------------------------------------- */

.settings-page {
  background: var(--color-bg);
}

.settings-section {
  margin-bottom: 32px;
  padding: 20px 0;
  border-bottom: 1px solid var(--color-border);
}

.settings-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text-primary);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 16px;
}

.settings-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-label > span {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
}

.settings-label > small {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.settings-value {
  font-size: 14px;
  color: var(--color-text-primary);
  font-weight: 500;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 28px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--color-accent);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* Plan info card */
.plan-info {
  margin-bottom: 24px;
}

.plan-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.plan-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--color-text-primary);
}

.plan-badge {
  display: inline-block;
  background: var(--color-accent);
  color: white;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.plan-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.plan-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-soft);
}

.plan-detail-row:last-child {
  border-bottom: none;
}

.plan-detail-row span {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.plan-detail-row strong {
  font-size: 13px;
  color: var(--color-text-primary);
  font-weight: 600;
}

.plan-upgrade-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--color-accent);
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.plan-upgrade-btn:hover {
  background: #0056b3;
}

/* Credit info */
.credit-info {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.credit-info h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--color-text-primary);
}

.credit-bar {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.credit-used {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s;
}

.credit-text {
  font-size: 13px;
  color: var(--color-text-primary);
  margin: 8px 0;
  font-weight: 500;
}

.credit-info small {
  font-size: 12px;
  color: var(--color-text-secondary);
  display: block;
}

/* Badges */
.badge-success {
  display: inline-block;
  background: #d4edda;
  color: #155724;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge-warning {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* Logout link */
.logout-link {
  display: block;
  color: #dc3545;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 0;
}

.logout-link:hover {
  text-decoration: underline;
}

@media (min-width: 561px) {
  .settings-section {
    padding: 28px 0;
  }

  .plan-card {
    padding: 28px;
  }

  .credit-info {
    padding: 28px;
  }
}

/* ---------- trust indicator (compact icon in header) ----------------------- */

.trust-indicator {
  font-size: 18px;
  cursor: help;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.trust-indicator:hover {
  opacity: 1;
}

/* ---------- smart sharing --------------------------------------------------- */

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border-soft);
}

.share-btn,
.copy-link-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 600;
}

.share-btn:active,
.copy-link-btn:active {
  transform: scale(0.98);
  background: var(--color-border);
}

.notify-cta {
  display: inline-block;
  background: var(--color-accent);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  margin-top: 12px;
}

/* ---------- NEW badge on result cards ---------------------------------------- */

.new-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ff4444;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.result-card-wrapper {
  position: relative;
}

/* ---------- map view -------------------------------------------------------- */

.map-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-container.hidden {
  display: none;
}

.map-view {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 200px;
}

.close-map-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.map-toggle {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  margin-left: 8px;
  flex-shrink: 0;
}

.map-toggle:active {
  background: var(--color-border);
  transform: scale(0.95);
}

/* Quiet hours settings */
.quiet-hours {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.quiet-hours label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-primary);
}

.quiet-hours input[type="time"] {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
}

/* Test notification button */
.test-notification-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.test-notification-btn:hover {
  background: #0056b3;
}

.test-notification-btn:active {
  transform: scale(0.98);
}

/* Notification badge in header */
.notif-badge {
  position: relative;
  display: flex;
  align-items: center;
}

.notif-badge .notif-icon {
  font-size: 18px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.notif-badge .notif-icon:hover {
  transform: scale(1.1) rotate(10deg);
}

.notif-badge #notif-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.notif-badge #notif-count[style*="display: none"] {
  display: none !important;
}
