/* ============================================================
   HORU STUDIO — SHARED STYLESHEET
   Imported by all platform HTML files.
   Pure CSS, no frameworks. Mobile-first. Swiss precision.
   ============================================================ */

:root {
  --bg: #F5F0E8;
  --bg-dark: #2c2720;
  --bg-card: #ede7dc;
  --bg-card-dark: #3a342d;
  --accent: #0F6E56;
  --accent-light: #e8f4f0;
  --text-primary: #2c2720;
  --text-secondary: #5a5247;
  /* --text-muted is only legible on the DARK surface (#2c2720 -> 4.96:1).
     On --bg it is 2.63:1 and on white 2.99:1 — both fail WCAG AA (needs 4.5).
     Use --text-muted-on-light for muted text on any light surface. */
  --text-muted: #9e9486;
  --text-muted-on-light: #6b6357; /* 5.22:1 on --bg, 5.92:1 on white — AA */
  --border: #d9d2c5;
  --white: #ffffff;
  --alert-red: #c0392b;
  /* --alert-orange is a FILL colour (dots, borders, badge backgrounds), where
     the 3:1 non-text threshold applies. As TEXT it is 2.51:1 on --bg — use
     --alert-orange-text instead. #b5651d still fails (3.82:1); #a8571a is the
     closest hue to the brand orange that actually clears AA on both surfaces. */
  --alert-orange: #e67e22;
  --alert-orange-text: #a8571a; /* 4.58:1 on --bg, 5.19:1 on white — AA */
  --alert-green: #0F6E56;
  /* SEMANTIC STATUS COLORS — use ONLY for these purposes:
     success: connected, positive trend, CTA buttons, success toasts, approved badges
     warning: pending, needs attention, warning banners, unanswered reviews
     error:   errors, urgent/crisis alerts, destructive actions, critical churn risk
     info:    informational messages, scheduled post badges, in-progress states
     neutral: published/done states, inactive items, secondary info */
  --color-success: #0F6E56;
  --color-warning: #e67e22;
  --color-error: #c0392b;
  --color-info: #2980b9;
  --color-neutral: #9e9486;
  --font-heading: 'Fraunces', serif;
  --font-body: 'Inter', sans-serif;
  /* ONE display weight for the big Fraunces headings (h1/h2). 300 is what the
     marketing pages always asked for inline — it was just never loaded, so the
     browser faked it and every page rendered slightly differently. The font is
     now requested as a variable range (300..700), so this is a real weight.
     h3/h4 stay at --font-heading-weight: at card-title sizes 300 is too thin
     to read comfortably in the data-dense platform UI. */
  --font-display-weight: 300;
  --font-heading-weight: 600;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(44,39,32,0.08);
  --shadow-lg: 0 8px 32px rgba(44,39,32,0.12);
  --transition: all 0.2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg, video { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { opacity: 0.8; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
/* Display headings: one weight, one scale, everywhere. */
h1, h2 { font-weight: var(--font-display-weight); }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h4 { font-size: 1.15rem; }
p { margin-bottom: 1rem; color: var(--text-secondary); }
.lead { font-size: 1.2rem; color: var(--text-secondary); }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-weight: 600; }
.text-muted { color: var(--text-muted-on-light); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
strong, b { font-weight: 600; color: var(--text-primary); }

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.container-narrow { max-width: 780px; }
.section { padding: 3.5rem 0; }
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-sm { gap: 0.5rem; } .gap-md { gap: 1rem; } .gap-lg { gap: 2rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 0.95rem; transition: var(--transition); text-align: center;
  white-space: nowrap; line-height: 1.2; min-height: 44px; border: 2px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: #0c5a46; opacity: 1; }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-light); opacity: 1; }
.btn-danger { background: var(--alert-red); color: var(--white); }
.btn-danger:hover { background: #a93226; opacity: 1; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); opacity: 1; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.9rem; min-height: 36px; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
  transition: var(--transition);
}
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-dark { background: var(--bg-card-dark); color: var(--bg); border-color: #4a433a; }
.card-dark h1, .card-dark h2, .card-dark h3, .card-dark h4 { color: var(--bg); }
.card-dark p { color: #cfc7ba; }
.card-accent { border-color: var(--accent); border-width: 2px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.card-title { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 600; }
.stat-value { font-family: var(--font-heading); font-size: 2rem; font-weight: 600; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted-on-light); margin-top: 0.35rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.65rem;
  border-radius: 999px; font-size: 0.75rem; font-weight: 600; line-height: 1.4;
  white-space: nowrap;
}
.badge-green { background: var(--accent-light); color: var(--accent); }
.badge-orange { background: #fdf0e4; color: var(--alert-orange-text); }
.badge-red { background: #fbeae8; color: var(--alert-red); }
.badge-grey { background: var(--bg-card); color: var(--text-muted-on-light); }
.badge-info { background: #eaf2f8; color: var(--color-info); }

/* ---------- Icons ----------
   Inline SVG from assets/js/icons.js. stroke=currentColor, so an icon takes the
   colour of whatever text it sits in. vertical-align keeps it on the text
   baseline instead of sitting low like an inline-block image. */
.horu-icon { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.icon-lead { color: var(--accent); margin-right: .5rem; vertical-align: -0.2em; }

/* ---------- Status dots ---------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.dot-green { background: var(--alert-green); box-shadow: 0 0 0 3px rgba(15,110,86,0.15); }
.dot-orange { background: var(--alert-orange); box-shadow: 0 0 0 3px rgba(230,126,34,0.15); }
.dot-red { background: var(--alert-red); box-shadow: 0 0 0 3px rgba(192,57,43,0.15); }
/* "unknown / still checking" — the only status state the set was missing. */
.dot-grey { background: var(--text-muted-on-light); box-shadow: 0 0 0 3px rgba(107,99,87,0.15); }

/* ---------- Alerts / Banners ---------- */
.alert {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 1rem 1.25rem;
  border-radius: var(--radius-sm); border-left: 4px solid var(--accent);
  background: var(--white); box-shadow: var(--shadow); margin-bottom: 1rem;
}
.alert-title { font-weight: 600; margin-bottom: 0.15rem; }
.alert-green { border-left-color: var(--alert-green); background: var(--accent-light); }
.alert-orange { border-left-color: var(--alert-orange); background: #fdf0e4; }
.alert-red { border-left-color: var(--alert-red); background: #fbeae8; }
.alert-info { border-left-color: var(--color-info); background: #eaf2f8; }
.banner {
  background: var(--bg-dark); color: var(--bg); padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm); text-align: center; font-weight: 500; font-size: 0.9rem;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.15rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--white); color: var(--text-primary);
  transition: var(--transition); min-height: 44px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,110,86,0.12);
}
.form-textarea { min-height: 96px; resize: vertical; }
.form-hint { font-size: 0.78rem; color: var(--text-muted-on-light); margin-top: 0.3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; background: var(--border); min-height: auto; padding: 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: var(--shadow); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left; padding: 0.85rem 1rem; background: var(--bg-card);
  font-weight: 600; color: var(--text-secondary); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
tbody td { padding: 0.85rem 1rem; border-top: 1px solid var(--border); color: var(--text-secondary); }
tbody tr:hover { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Modal / Overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(44,39,32,0.55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1.25rem;
}
.overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg); border-radius: var(--radius); width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); padding: 1.75rem; max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.modal-close { font-size: 1.5rem; line-height: 1; color: var(--text-muted-on-light); width: 32px; height: 32px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--bg-card); color: var(--text-primary); }

/* ---------- Top navigation ---------- */
.topnav {
  position: sticky; top: 0; z-index: 500; background: rgba(245,240,232,0.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topnav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-family: var(--font-heading); font-weight: 600; font-size: 1.2rem; color: var(--text-primary); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--white);
  display: grid; place-items: center; font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem;
}
.topnav-links { display: flex; align-items: center; gap: 1.5rem; }
.topnav-links a { color: var(--text-secondary); font-weight: 500; font-size: 0.92rem; }
.topnav-links a:hover, .topnav-links a.active { color: var(--accent); opacity: 1; }

/* ---------- Sidebar navigation ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-dark); color: var(--bg); padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 0.25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: var(--bg); margin-bottom: 1.5rem; padding: 0 0.5rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm); color: #cfc7ba; font-weight: 500; font-size: 0.92rem; transition: var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--white); opacity: 1; }
.nav-item.active { background: var(--accent); color: var(--white); }
.nav-icon { width: 20px; text-align: center; flex-shrink: 0; }
/* On the DARK sidebar — --text-muted is 4.96:1 here, which passes. Do not swap. */
.nav-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: 1rem 0.75rem 0.4rem; }
.main-content { padding: 1.75rem; overflow-x: hidden; }

/* ---------- Swiss number formatting ---------- */
.chf { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chf::before { content: "CHF "; }
.num-tabular { font-variant-numeric: tabular-nums; }

/* ---------- Loading spinner ---------- */
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tooltip ---------- */
.tooltip { position: relative; cursor: help; border-bottom: 1px dotted var(--text-muted); }
.tooltip::after {
  content: attr(data-tip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  background: var(--bg-dark); color: var(--bg); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  font-size: 0.78rem; font-weight: 400; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease; z-index: 100; box-shadow: var(--shadow);
}
.tooltip:hover::after { opacity: 1; }

/* ---------- Toast notifications ---------- */
.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.6rem; max-width: 360px; }
.toast {
  display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm); background: var(--white); box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent); animation: slideInRight 0.25s ease; font-size: 0.9rem;
}
.toast-success { border-left-color: var(--alert-green); }
.toast-error { border-left-color: var(--alert-red); }
.toast-info { border-left-color: var(--alert-orange); }
.toast.hide { animation: slideOutRight 0.25s ease forwards; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { to { transform: translateX(120%); opacity: 0; } }
.fade-in { animation: fadeIn 0.4s ease; }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive breakpoints ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform 0.25s ease; z-index: 600; }
  .sidebar.open { transform: translateX(0); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .section { padding: 2.5rem 0; }
  .topnav-links { gap: 1rem; }
  .main-content { padding: 1.15rem; }
  .toast-container { left: 1rem; right: 1rem; max-width: none; }
}

/* ============================================
   TYPOGRAPHY SYSTEM
   Fraunces: headings & display only (never < 18px).
   Inter: all body, labels, buttons, data, tables.
   ============================================ */
h1, h2, h3 { font-family: 'Fraunces', serif; }
h4, h5, h6 { font-family: 'Inter', sans-serif; font-weight: 600; }

/* Force Inter for all data / control elements */
table, td, th,
.badge, .status-badge,
.stat-label, .kpi-label, .kpi-sub,
.card-subtitle, .meta-text, .text-muted, .text-secondary,
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-sm,
input, select, textarea,
.filter-tab, .nav-item, .mobile-nav-item,
.toast, .toast-message, .tooltip-text {
  font-family: 'Inter', sans-serif;
}

/* Fraunces reserved for display headings only */
.page-title, .card-title, .section-title,
.hero-headline, .modal-title,
.stat-value, .kpi-value, .score-value {
  font-family: 'Fraunces', serif;
}

.table-header, thead th { font-size: 11px; font-family: 'Inter', sans-serif; font-weight: 600; letter-spacing: 0.05em; }
.badge { font-size: 11px; font-family: 'Inter', sans-serif; }
.meta-text { font-size: 12px; font-family: 'Inter', sans-serif; color: var(--text-muted-on-light); }

/* ============================================
   MOBILE FIXES — 390px iPhone optimization
   ============================================ */
@media (max-width: 768px) {
  /* Main content clears the bottom tab bar + is full-width and centred (no sidebar offset) */
  .main-content {
    margin-left: 0 !important; margin-right: 0 !important;
    width: 100% !important; max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px !important; padding-bottom: 80px !important;
    overflow-x: hidden !important;
  }
  .page-container, .content-wrapper, [class*="content-wrap"] {
    width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; overflow-x: hidden !important;
  }
  /* Agent/card grids collapse to a single column */
  .agent-grid, .agents-grid, [class*="agent-grid"] { grid-template-columns: 1fr !important; gap: 12px !important; }
  /* Cards never exceed the viewport */
  .card, [class*="card"] { max-width: 100% !important; box-sizing: border-box !important; }

  /* Top bars stack */
  .topbar-mobile, .top-bar { flex-wrap: wrap; gap: 8px; }
  .top-bar h1 { font-size: 22px !important; }

  /* KPI cards: 2 columns */
  .kpi-grid, .kpi-row, .stat-grid, .stats3, .grid-4 { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi, .kpi-card { padding: 14px !important; }
  .kpi .stat-value, .kpi-card .kpi-value { font-size: 24px !important; }

  /* Cards: reduced padding */
  .card { padding: 16px !important; border-radius: 10px !important; }

  /* Tables scroll horizontally inside their wrapper */
  .table-wrap, .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table, table.rate-comparison-table { min-width: 500px; }
  .rate-table { font-size: 12px !important; }
  .rate-comparison-table th, .rate-comparison-table td { padding: 8px 6px !important; font-size: 11px !important; }

  /* Large buttons full width (keep small/inline buttons inline) */
  .btn-primary:not(.btn-sm), .btn-secondary:not(.btn-sm), .btn-lg { width: 100%; justify-content: center; margin-bottom: 8px; }

  /* Modals & bottom-sheet dialogs */
  .overlay .modal, #horu-feedback-modal {
    width: 100% !important; max-width: 100% !important; margin: 0 !important;
    border-radius: 16px 16px 0 0 !important; position: fixed !important;
    bottom: 0 !important; top: auto !important; left: 0 !important; transform: none !important;
    max-height: 90vh; overflow-y: auto;
  }

  /* Filter tabs / tools tabs: horizontal scroll */
  .filter-tabs, .tools-tabs, .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; gap: 6px; }
  .filter-tabs::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .filter-tab { white-space: nowrap; flex-shrink: 0; padding: 6px 12px !important; font-size: 12px !important; }

  /* Single-column grids */
  .chan-grid, .channels-grid, .intel-grid, .pkg-grid, .pricing-grid, .qr-grid, .flow-grid, .grid-2, .grid-3 { grid-template-columns: 1fr !important; }

  .review-card { padding: 14px !important; }
  .flow-card { margin-bottom: 10px; }
  .demand-calendar { font-size: 10px !important; }

  /* Floating help button above the tab bar */
  #horu-help-btn { padding: 10px 14px !important; font-size: 12px !important; bottom: 72px !important; }
  #horu-feedback-btn { bottom: 120px !important; }

  /* Cookie banner stacks */
  #horu-cookie-banner { flex-direction: column !important; text-align: center; }

  /* First-login overlay scrolls full screen */
  #first-login-overlay > div { padding: 24px 16px !important; overflow-y: auto; max-height: 100vh; }

  /* Onboarding tooltip full width */
  #horu-onboarding-tooltip { left: 8px !important; right: 8px !important; max-width: none !important; width: auto !important; }

  /* Lang toggle compact */
  .lang-toggle { padding: 2px 6px !important; font-size: 11px !important; }

  /* Referral / summary rows stack */
  .referral-section { flex-direction: column !important; gap: 12px !important; }
  .nrr-value { font-size: 28px !important; }
}

/* ---------- Mobile bottom tab bar (populated by nav.js) ---------- */
.bottomnav { display: none; }
.mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #cfc7ba; text-decoration: none; font-size: 10px; font-family: 'Inter', sans-serif; position: relative; background: none; border: none; cursor: pointer; padding: 0; min-height: 60px; }
.mobile-nav-item.active { color: #7fd8bf; }
.mobile-nav-icon { font-size: 20px; line-height: 1; }
.mobile-nav-label { font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
.mobile-nav-badge { position: absolute; top: 6px; right: calc(50% - 20px); background: var(--alert-red); color: #fff; border-radius: 10px; font-size: 9px; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 600; }

@media (max-width: 768px) {
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
    background: var(--bg-dark); border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 1000; flex-direction: row; align-items: stretch; overflow: hidden;
  }
}

/* ---------- Touch targets: 44px minimum on mobile (Apple HIG) ---------- */
@media (max-width: 768px) {
  .btn, button, .filter-tab, input, select, textarea, .clickable {
    min-height: 44px;
  }
  .btn-sm { min-height: 40px; }
  .nav-item { min-height: 44px; display: flex; align-items: center; }
  input[type="checkbox"], .toggle-switch, .switch { min-width: 44px; min-height: 28px; }
  .table-action-btn, td .btn-sm { padding: 10px 12px !important; min-height: 40px !important; }
}

/* ---------- Extra small screens (SE / older phones) ---------- */
@media (max-width: 375px) {
  .kpi-grid, .kpi-row, .stat-grid, .stats3, .grid-4 { grid-template-columns: 1fr !important; }
  .kpi .stat-value, .kpi-card .kpi-value { font-size: 20px !important; }
  h1, .page-title { font-size: 20px !important; }
}

/* ---------- iOS safe-area support ---------- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .bottomnav { padding-bottom: env(safe-area-inset-bottom); height: calc(60px + env(safe-area-inset-bottom)); }
    .main-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
  }
}

/* ---------- Print ---------- */
@media print {
  body { background: var(--white); color: #000; }
  .no-print, .topnav, .sidebar, .toast-container, .btn, .overlay { display: none !important; }
  .layout { display: block; }
  .main-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  @page { margin: 1.5cm; }
}

/* Performance */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0ece6 25%, #e8e3dc 50%, #f0ece6 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
}

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

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 24px; margin-bottom: 12px; width: 60%; }
.skeleton-value { height: 36px; margin-bottom: 8px; width: 80%; }

/* ============================================
   Mobile top bar (logo + ☰ Menü) — global so EVERY platform page shows it
   on mobile, not just dashboard. Base hidden; shown ≤768px. (FIX 4)
   ============================================ */
.topbar-mobile { display: none; }
@media (max-width: 768px) {
  .topbar-mobile {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; background: var(--bg-dark); color: var(--bg);
    position: sticky; top: 0; z-index: 700; width: 100%; box-sizing: border-box;
  }
  .topbar-mobile .brand { color: var(--white); font-size: 1.1rem; }
  /* Sidebar drawer sits below the top bar so the logo stays visible */
  .sidebar { z-index: 600 !important; }
  /* FIX 3: wide tables (e.g. reports Buchungsquellen) scroll horizontally
     instead of overflowing the viewport in portrait */
  .main-content table {
    display: block; max-width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .main-content canvas, .chart-container { max-width: 100% !important; height: auto !important; }
  /* Action/header button rows wrap instead of overflowing the viewport */
  .main-content .flex-between,
  .main-content .flex.gap-md,
  .main-content .flex.gap-lg,
  .main-content .flex-center.gap-md { flex-wrap: wrap; gap: 8px; }
  /* KPI grids: single column on phones (overrides inline repeat(N,1fr)); grid children
     must be allowed to shrink below min-content, else 1fr columns overflow the viewport */
  .main-content .kpi3 { grid-template-columns: 1fr !important; }
  .main-content [class*="grid"] > *, .main-content .kpi3 > * { min-width: 0; }
  /* Wide inline SVG charts (e.g. booking-source bar) scale down to fit */
  .main-content svg { max-width: 100%; }
}

/* BUG3: radar / chart labels need breathing room on mobile so they aren't clipped */
@media (max-width: 768px) {
  .main-content canvas, canvas { max-width: 100% !important; }
  #radar, [id*="radar"], .chart-container, [class*="chart-container"] {
    padding: 8px 24px; overflow: visible; box-sizing: border-box; width: 100%;
  }
  #radar svg { overflow: visible; }
}

/* BUG5: mobile sidebar drawer uses LEFT-based sliding (a transform transition was
   getting stuck under prefers-reduced-motion). Appended last → wins the cascade.
   The topbar "☰ Menü" button toggles .open; nav.js adds the dimming backdrop. */
@media (max-width: 900px) {
  .sidebar { transform: none !important; left: -260px !important; transition: left .28s ease; }
  .sidebar.open { left: 0 !important; }
}
/* Reduced-motion: no transition (a near-zero transition can stick mid-slide) — snap instead */
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .sidebar { transition: none !important; }
}
