/* ============================================================
   SNergie Hausmeister PWA — Mobile-First Styles
   Dark theme · CSS Custom Properties · Safe-area support
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-base:        #080c18;
  --bg-card:        #0d1330;
  --bg-card-hover:  #111840;
  --border:         #1e2a5a;
  --text-primary:   #e8eaf0;
  --text-secondary: #8b90a8;
  --text-muted:     #555a72;

  --accent:         #ffbd00;
  --accent-dim:     #cc9700;
  --grid-red:       #f87171;

  --color-pv:       #ffbd00;
  --color-load:     #f87171;
  --color-battery:  #34d399;
  --color-grid-in:  #fb923c;
  --color-grid-out: #60a5fa;
  --color-ok:       #34d399;

  --radius: 12px;
  --gap:    0.875rem;
  --font:   'Outfit', system-ui, -apple-system, sans-serif;

  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);

  --tab-bar-h: 60px;
  --header-h:  52px;
}

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

html {
  background: var(--bg-base);
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

/* ---- App Header ---- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: calc(1rem + var(--safe-left));
  padding-right: calc(1rem + var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 12, 24, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.app-title span { color: var(--accent); }

.header-logo {
  height: 28px;
  width: auto;
  display: block;
}

.header-product {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.header-last-seen {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Status dot ---- */

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.ok    { background: var(--color-ok); box-shadow: 0 0 6px var(--color-ok); }
.status-dot.stale { background: var(--color-grid-in); }

/* ---- Tab Content ---- */

.tab-content {
  padding: var(--gap);
  padding-bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + var(--gap) + 0.5rem);
  padding-left: calc(var(--gap) + var(--safe-left));
  padding-right: calc(var(--gap) + var(--safe-right));
  max-width: 860px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Bottom Tab Bar ---- */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--tab-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background: rgba(26, 29, 39, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 0.45rem;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  padding: 0.2rem 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.active { color: var(--color-pv); }

/* ---- Section labels ---- */

.section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  margin-top: 1rem;
}
.section-label:first-child { margin-top: 0.25rem; }

/* ---- Error Banner ---- */

.error-banner {
  background: rgba(248, 113, 113, 0.1);
  border-bottom: 1px solid var(--color-load);
  color: var(--color-load);
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  display: none;
}
.error-banner.visible { display: block; }

/* ---- Metric Cards ---- */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  position: relative;
  overflow: hidden;
  transition: background 0.15s;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--card-accent, var(--border));
}

.card-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.card-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.card-sublabel {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.card-pv      { --card-accent: var(--color-pv); }
.card-load    { --card-accent: var(--color-load); }
.card-battery { --card-accent: var(--color-battery); }
.card-autarky { --card-accent: var(--color-pv); }
.card-grid         { --card-accent: var(--text-muted); }
.card-grid.card-grid-in  { --card-accent: var(--color-grid-in); }
.card-grid.card-grid-out { --card-accent: var(--color-grid-out); }

/* ---- Section Cards ---- */

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: var(--gap);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.section-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.muted-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Finance history chart: horizontal scroll for many months */
.finance-chart-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.finance-chart-inner {
  height: 260px;
  min-width: 100%;
  position: relative;
}

.chart-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.chart-day-wrap { height: 260px; }
.chart-soc-wrap { height: 130px; margin-top: 0.75rem; }

.sun-times-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.6rem;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.soc-chart-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

/* ---- Period Toggle ---- */

.period-toggle {
  display: flex;
  gap: 0.15rem;
  background: var(--bg-base);
  border-radius: 8px;
  padding: 0.18rem;
}
.period-btn {
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.period-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ---- Date Navigation ---- */

.day-chart-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.date-nav input[type="date"] {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  max-width: 126px;
}
.date-nav input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.6); }

.date-nav button {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.date-nav button:active { background: var(--bg-card-hover); color: var(--text-primary); }

/* ---- Status Bar ---- */

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.1rem;
  padding: 0.7rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.status-item strong { color: var(--text-primary); font-weight: 600; }

/* ---- Weather Widget ---- */

.weather-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.weather-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.weather-icon {
  font-size: 2rem;
  line-height: 1;
}
.weather-info {
  flex: 1;
  min-width: 100px;
}
.weather-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.weather-temp {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}
.weather-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.weather-forecast-preview {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-left: auto;
  text-align: right;
}
.weather-forecast-item {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
}
.weather-forecast-item.secondary {
  color: var(--text-secondary);
  font-weight: 400;
}

/* ---- Daily Report ---- */

.daily-report {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: var(--gap);
}

.daily-report-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }

.daily-report-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

.daily-report-badge {
  font-size: 0.7rem; font-weight: 700; color: #0f1117;
  background: #34d399; border-radius: 20px; padding: 0.15rem 0.6rem; white-space: nowrap;
}

.daily-report-summary { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 0.5rem; }

.daily-report-highlights { margin: 0; padding-left: 1.1rem; list-style: disc; }
.daily-report-highlights li { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.7; }

/* ---- Anomalie-Panel ---- */

.anomaly-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: var(--gap);
}

.anomaly-header { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.6rem; }

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

.anomaly-item {
  border-left: 3px solid var(--border);
  padding: 0.55rem 0.8rem;
  border-radius: 0 8px 8px 0;
  background: rgba(255,255,255,.025);
}
.anomaly-critical { border-left-color: #f87171; }
.anomaly-warning  { border-left-color: #fb923c; }
.anomaly-info     { border-left-color: #60a5fa; }

.anomaly-item-title { font-weight: 600; font-size: 0.85rem; color: var(--text-primary); margin-bottom: 0.2rem; }
.anomaly-item-desc  { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }
.anomaly-item-meta  { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ---- Empfehlungen ---- */

.recommendations-panel { margin-bottom: var(--gap); }

.recommendations-grid { display: flex; flex-direction: column; gap: 0.6rem; }

.rec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.8rem 0.9rem;
}
.rec-high   { border-left-color: #f87171; }
.rec-medium { border-left-color: #fb923c; }
.rec-low    { border-left-color: #64748b; }

.rec-title  { font-weight: 600; font-size: 0.85rem; color: var(--text-primary); margin-bottom: 0.3rem; }
.rec-desc   { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }
.rec-savings { font-size: 0.75rem; color: #34d399; font-weight: 600; margin-top: 0.35rem; }

/* ---- Finance Cards ---- */

.finance-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: var(--gap);
}
.card-finance { border-left: 3px solid #34d399; }
.card-finance .card-label {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
}

/* ---- Autarky Donuts ---- */

.donut-wrapper { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; padding: 0.25rem 0; }
.donut-item    { display: flex; flex-direction: column; align-items: center; }
.donut-canvas  { position: relative; width: 150px; height: 150px; flex-shrink: 0; overflow: hidden; }
.donut-label   { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; margin-top: 0.55rem; text-align: center; }

/* ---- Flow Diagram ---- */

.flow-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0 0.5rem;
  flex-wrap: wrap;
}

.flow-date-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
}

.nav-btn {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover:not(:disabled) { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

.flow-date-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
}

.flow-period-select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}
.flow-period-select:focus { outline: none; border-color: #60a5fa; }

.flow-summary {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.5rem 0 0.1rem;
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
}
.flow-summary-item { white-space: nowrap; }
.flow-summary-val  { color: var(--text-primary); font-weight: 600; }

#flow-diagram { width: 100%; padding: 0.25rem 0; }
#flow-diagram svg { width: 100%; height: auto; display: block; }

/* ---- Amortisation Widget ---- */

.amort-widget { padding: 0.25rem 0; display: flex; flex-direction: column; gap: 0.8rem; }
.amort-row { display: flex; justify-content: space-between; align-items: baseline; }
.amort-label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; }
.amort-val { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.amort-val-savings { color: #34d399; }

.amort-progress-wrap { width: 100%; height: 10px; background: var(--bg-base); border-radius: 5px; overflow: hidden; }
.amort-progress-fill { height: 100%; background: linear-gradient(90deg, #34d399, #facc15); border-radius: 5px; transition: width .6s ease; }

.amort-progress-label { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); text-align: center; }
.amort-remaining      { font-size: 0.82rem; color: var(--text-secondary); text-align: center; }
.amort-monthly        { font-size: 0.82rem; color: var(--text-primary); font-weight: 600; text-align: center; }
.amort-install        { font-size: 0.72rem; color: var(--text-muted); text-align: center; }
.amort-forecast-note  { font-size: 0.7rem; color: var(--text-muted); font-style: italic; text-align: center; line-height: 1.5; }
.amort-no-data { font-size: 0.82rem; color: var(--text-secondary); padding: 1.25rem 0; text-align: center; line-height: 1.7; }

/* ---- Settings ---- */

.settings-hint { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.5; }
.settings-form { display: flex; flex-direction: column; gap: 0.875rem; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"] {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.12s;
}
.form-group input:focus { outline: none; border-color: var(--color-pv); }
.form-group input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.6); }

.btn-primary {
  background: var(--color-pv); color: var(--bg-base); border: none; border-radius: 8px;
  padding: 0.6rem 1.25rem; font-size: 0.88rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; align-self: flex-start; transition: opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: 0.8; }

.settings-msg { padding: 0.65rem 1rem; border-radius: var(--radius); font-size: 0.82rem; margin-bottom: 0.75rem; }
.settings-msg-success { background: rgba(52, 211, 153, .12); border: 1px solid var(--color-battery); color: var(--color-battery); }
.settings-msg-error   { background: rgba(248, 113, 113, .12); border: 1px solid var(--color-load); color: var(--color-load); }

.badge-default {
  background: var(--bg-base); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.12rem 0.45rem; font-size: 0.65rem; color: var(--text-muted); font-weight: 500;
}


/* ---- Auto-discovery & PR display ---- */
.settings-auto-hint {
  display: none;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 3px;
  font-style: italic;
}
.pr-info-box {
  background: var(--surface-2, #1a1f2e);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}
.pr-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.pr-info-row:last-of-type { border-bottom: none; }
.pr-info-label { font-size: 0.82rem; color: var(--text-secondary); }
.pr-info-value { font-size: 0.88rem; font-weight: 600; color: var(--color-pv); }

/* ---- Standalone settings.html page ---- */

.page { max-width: 860px; margin: 0 auto; padding: 1.25rem 1rem; }
.settings-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.back-link { color: var(--text-secondary); text-decoration: none; font-size: 0.82rem; transition: color 0.12s; }
.back-link:hover { color: var(--text-primary); }
.settings-link { color: var(--text-secondary); text-decoration: none; font-size: 0.82rem; transition: color 0.12s; }

/* ============================================================
   Responsive — tablet / desktop
   ============================================================ */

@media (min-width: 600px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
  .finance-cards { grid-template-columns: repeat(4, 1fr); }
  .recommendations-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
  .chart-day-wrap { height: 300px; }
  .chart-soc-wrap { height: 150px; }
  .donut-canvas { width: 170px; height: 170px; }
}

@media (min-width: 860px) {
  :root { --gap: 1.25rem; }
  .tab-content { padding-top: 1.25rem; }
}

/* ============================================================
   Demo banner
   ============================================================ */

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  background: rgba(34, 211, 238, 0.08);
  border-bottom: 1px solid rgba(255, 189, 0, 0.2);
  font-size: 0.82rem;
  color: var(--accent);
  position: sticky;
  top: var(--header-h);
  z-index: 80;
}

.demo-banner-text {
  opacity: 0.85;
}

.demo-banner-cta {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 20px;
  transition: background 0.15s;
  white-space: nowrap;
}

.demo-banner-cta:hover {
  background: rgba(34, 211, 238, 0.12);
}

/* ── PWA install banners ─────────────────────────────────────────────── */
#install-banner,
#install-banner-android,
#install-banner-ios {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  background: rgba(245, 196, 44, 0.10);
  border-bottom: 1px solid rgba(245, 196, 44, 0.25);
  font-size: 0.82rem;
  color: var(--text-primary);
  position: sticky;
  top: var(--header-h);
  z-index: 80;
}
#install-banner button,
#install-banner-android button,
#install-banner-ios button {
  padding: 3px 12px;
  border: 1px solid rgba(245, 196, 44, 0.5);
  border-radius: 20px;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
#install-banner button:first-of-type,
#install-banner-android #install-btn-android { font-weight: 600; }
#install-banner button:hover,
#install-banner-android button:hover,
#install-banner-ios button:hover { background: rgba(245, 196, 44, 0.12); }

/* Demo: disable settings inputs */
.demo-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* Demo: settings locked notice banner */
.demo-settings-notice {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--grid-red);
  text-align: center;
}

.demo-settings-notice a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* Finance: historical pre-start estimate breakdown */
.amort-estimate-notice {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 6px 0 2px;
}

.amort-estimate-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 2px 0;
}

.amort-estimate-val {
  font-weight: 500;
}

.amort-estimate-text {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0.8;
  font-style: italic;
}

/* ============================================================
   Chat widget — FAB + window
   ============================================================ */

.chat-fab {
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #080c18;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.35);
  z-index: 200;
  transition: transform 0.15s, box-shadow 0.15s;
}

.chat-fab:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(255, 189, 0, 0.5);
}

.chat-fab.open {
  background: #475569;
  box-shadow: none;
}

.chat-window {
  position: fixed;
  bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 80px);
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(34, 211, 238, 0.07);
  border-bottom: 1px solid var(--border);
}

.chat-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

.chat-close:hover { color: var(--text-primary); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-msg {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg-user {
  align-self: flex-end;
  background: rgba(34, 211, 238, 0.12);
  color: var(--text-primary);
  border-bottom-right-radius: 3px;
}

.chat-msg-bot {
  align-self: flex-start;
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-bottom-left-radius: 3px;
}

.chat-msg-error {
  align-self: flex-start;
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  border-bottom-left-radius: 3px;
}

.chat-thinking {
  align-self: flex-start;
  background: var(--bg-card-hover);
  border-radius: 10px;
  border-bottom-left-radius: 3px;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 4px;
}

.chat-thinking span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: chatBounce 1.2s infinite ease-in-out;
}

.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.45rem 0.7rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
  background: var(--accent);
  border: none;
  color: #080c18;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chat-send:hover   { background: var(--accent-dim); }
.chat-send:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ── Channel Buttons ─────────────────────────────────────────────────────── */
.chat-channels {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat-channels::-webkit-scrollbar { display: none; }

.channel-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.channel-btn.active {
  background: rgba(34, 211, 238, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.channel-btn.disabled { opacity: 0.4; cursor: default; }
.channel-btn:not(.disabled):hover { border-color: var(--accent); }

.channel-icon  { font-size: 0.85rem; }
.channel-label { font-weight: 500; }
.channel-status { font-size: 0.7rem; }
.channel-status.connected { color: var(--load, #4ade80); }
.channel-status.locked    { color: var(--text-muted); }

.telegram-connect {
  display: none;
  padding: 14px 16px;
  background: var(--surface-2, var(--surface));
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.telegram-connect.show { display: block; }
.telegram-connect a { color: var(--accent); font-weight: 600; text-decoration: none; }
.telegram-connect a:hover { text-decoration: underline; }

.whatsapp-tooltip {
  display: none;
  padding: 10px 16px;
  background: var(--surface-2, var(--surface));
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}
.whatsapp-tooltip.show { display: block; }

/* ============================================================
   Einstellungen — neue Struktur
   ============================================================ */

.settings-section { margin-bottom: 0; }

.settings-heading {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

/* Toggle rows */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }

.setting-info { flex: 1; margin-right: 16px; }

.setting-label {
  display: block;
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 2px;
  color: var(--text-primary);
}

.setting-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Input groups */
.input-group { margin-bottom: 14px; }
.input-group:last-child { margin-bottom: 0; }

.input-group label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.input-group input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.input-group input:focus { outline: none; border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-muted); }
.input-group input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.5); }

.input-with-unit { display: flex; align-items: center; gap: 8px; }
.input-with-unit input { flex: 1; }
.input-unit { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; min-width: 42px; }

.input-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Buttons */
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(255,189,0,0.06); }
.btn-secondary:active { opacity: 0.8; }

.btn-full { width: 100%; margin-top: 16px; display: block; }
.btn-small { padding: 8px 14px; font-size: 0.8rem; margin-top: 8px; }

.save-status {
  text-align: center;
  padding: 8px 0;
  font-size: 0.82rem;
  color: var(--color-battery);
  min-height: 28px;
}

/* Info section */
.settings-info-section { margin-top: 8px; }

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }

/* Admin link */
.admin-link { margin-top: 12px; }

/* ============================================================
   PWA Install Hint
   ============================================================ */

.install-hint {
  background: linear-gradient(90deg, rgba(255,189,0,0.12), rgba(255,189,0,0.04));
  border-bottom: 1px solid rgba(255,189,0,0.25);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-primary);
  gap: 8px;
}

.install-hint-text { flex: 1; line-height: 1.4; }

.install-hint-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.install-hint-close:hover { color: var(--text-primary); }

/* ============================================================
   Daily Report Navigation
   ============================================================ */

.daily-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.report-title-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.report-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 5px 9px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}
.report-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.report-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* ============================================================
   Settings input hint
   ============================================================ */

.input-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.3;
}

/* ── Session expired overlay ───────────────────────────────── */
.session-expired-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-expired-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 320px;
}

.session-expired-card h2 { margin-bottom: 8px; }
.session-expired-card p  { color: var(--text-dim); margin-bottom: 20px; }

/* ============================================================
   LIGHT THEME — :root.light  +  @media system preference
   ============================================================ */

:root.light,
:root.system {
  /* populated by @media below; .system without media = dark (default) */
}

:root.light {
  --bg-base:        #f5f6fa;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f0f1f5;
  --border:         #e2e4ea;
  --text-primary:   #1a1f36;
  --text-secondary: #5a6178;
  --text-muted:     #9298ad;
  --accent:         #d4a000;
  --accent-dim:     rgba(212,160,0,0.12);
  --grid-red:       #dc2626;
  --color-pv:       #d4a000;
  --color-load:     #dc2626;
  --color-battery:  #059669;
  --color-grid-in:  #ea580c;
  --color-grid-out: #2563eb;
  --color-ok:       #059669;
}

@media (prefers-color-scheme: light) {
  :root.system {
    --bg-base:        #f5f6fa;
    --bg-card:        #ffffff;
    --bg-card-hover:  #f0f1f5;
    --border:         #e2e4ea;
    --text-primary:   #1a1f36;
    --text-secondary: #5a6178;
    --text-muted:     #9298ad;
    --accent:         #d4a000;
    --accent-dim:     rgba(212,160,0,0.12);
    --grid-red:       #dc2626;
    --color-pv:       #d4a000;
    --color-load:     #dc2626;
    --color-battery:  #059669;
    --color-grid-in:  #ea580c;
    --color-grid-out: #2563eb;
    --color-ok:       #059669;
  }
}

/* ── Logo swap ── */
.header-logo-dark  { display: inline; }
.header-logo-light { display: none; }

:root.light .header-logo-dark  { display: none; }
:root.light .header-logo-light { display: inline; }

@media (prefers-color-scheme: light) {
  :root.system .header-logo-dark  { display: none; }
  :root.system .header-logo-light { display: inline; }
}

/* ── App header background in light ── */
:root.light .app-header,
@media (prefers-color-scheme: light) {
  :root.system .app-header { background: rgba(245, 246, 250, 0.95) !important; }
}
:root.light .app-header { background: rgba(245, 246, 250, 0.95) !important; }

/* ── Tab bar in light ── */
:root.light .tab-bar { background: rgba(255, 255, 255, 0.97); border-top-color: #e2e4ea; }
@media (prefers-color-scheme: light) {
  :root.system .tab-bar { background: rgba(255, 255, 255, 0.97); border-top-color: #e2e4ea; }
}

/* ── Cards shadow in light ── */
:root.light .card,
:root.light .metric-card,
:root.light .section-card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
@media (prefers-color-scheme: light) {
  :root.system .card,
  :root.system .metric-card,
  :root.system .section-card {
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  }
}

/* ── Demo banner in light ── */
:root.light .demo-banner {
  background: rgba(212,160,0,0.08);
  border-bottom-color: rgba(212,160,0,0.3);
}
@media (prefers-color-scheme: light) {
  :root.system .demo-banner {
    background: rgba(212,160,0,0.08);
    border-bottom-color: rgba(212,160,0,0.3);
  }
}

/* ── Chat widget in light ── */
:root.light .chat-window {
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
:root.light .chat-fab.open { background: #94a3b8; }

/* ── Scrollbar in light ── */
:root.light ::-webkit-scrollbar-thumb { background: #c1c5d0; }
@media (prefers-color-scheme: light) {
  :root.system ::-webkit-scrollbar-thumb { background: #c1c5d0; }
}

/* ── Input / select in light (admin + settings) ── */
:root.light .settings-input,
:root.light .search-input {
  background: #f0f1f5;
  border-color: #d0d3dc;
  color: #1a1f36;
}
@media (prefers-color-scheme: light) {
  :root.system .settings-input,
  :root.system .search-input {
    background: #f0f1f5;
    border-color: #d0d3dc;
    color: #1a1f36;
  }
}

/* ── Theme toggle buttons ── */
.theme-toggle {
  display: flex;
  gap: 8px;
}

.theme-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.theme-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.theme-btn:hover:not(.active) {
  border-color: var(--text-muted);
}

.theme-icon { font-size: 1.3rem; }

/* ============================================================
   Profile Chip + Slide-over Panel
   ============================================================ */

/* ---- Profile Chip (header) ---- */

.profile-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 3px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.profile-chip:hover { border-color: var(--accent); background: var(--bg-card-hover); }

.profile-chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-base);
  font-weight: 700;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-chip-name {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Overlay ---- */

.profile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.profile-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ---- Panel ---- */

.profile-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 401;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 1.5rem);
}
.profile-panel.open { transform: translateX(0); }

.profile-panel-header {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 1rem) 1rem 1rem;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.profile-panel-header h2 { font-size: 1rem; font-weight: 600; }

.profile-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.profile-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.07); }

/* ---- Panel Sections ---- */

.profile-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.profile-section:last-child { border-bottom: none; }

.profile-section-title {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 0.875rem;
}

/* ---- Identity ---- */

.profile-identity {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.profile-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-base);
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.profile-identity-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-identity-email {
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.profile-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(255, 189, 0, 0.15);
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}
.profile-role-badge.admin {
  background: rgba(96, 165, 250, 0.15);
  color: var(--color-grid-out);
}

/* ---- WhatsApp actions ---- */

.profile-wa-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* ---- WhatsApp activation hint ---- */

.profile-wa-activate {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid rgba(37, 211, 102, 0.25);
  border-radius: 8px;
}
.wa-activate-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.4; }
.wa-activate-text { flex: 1; font-size: 0.82rem; line-height: 1.5; color: var(--text-secondary); }
.wa-activate-text strong { color: var(--text-primary); font-size: 0.88rem; }
.wa-activate-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #25d366;
  text-decoration: none;
}
.wa-activate-link:hover { text-decoration: underline; }

.wa-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
}
.wa-qr {
  display: block;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.wa-qr-wrap small { color: var(--text-secondary); font-size: 0.75rem; }

/* ---- Status line ---- */

.profile-status {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  min-height: 1.25em;
  color: var(--text-secondary);
}
.profile-status.ok  { color: var(--color-ok); }
.profile-status.err { color: var(--grid-red); }

/* ---- Logout button ---- */

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  color: var(--grid-red);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-logout:hover { background: rgba(248, 113, 113, 0.08); border-color: var(--grid-red); }

/* ── Chat Tab (full-screen overlay between header and tab-bar) ─────────────── */

#tab-chat.active {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top));
  left: 0; right: 0;
  bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  z-index: 100;
  padding: 0;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-tab-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-tab-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #f5c42c;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.chat-tab-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.chat-tab-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}

.chat-online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.chat-tab-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  max-width: 100%;
}

.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  box-sizing: border-box;
  min-width: 0;
}
.chat-bubble-wrap-user  { align-self: flex-end;  align-items: flex-end; }
.chat-bubble-wrap-bot   { align-self: flex-start; align-items: flex-start; }
.chat-bubble-wrap-error { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  width: 100%;
  box-sizing: border-box;
}
.chat-bubble-wrap-user  .chat-bubble {
  background: #f5c42c; color: #0d1f3c;
  border-bottom-right-radius: 4px;
}
.chat-bubble-wrap-bot   .chat-bubble {
  background: var(--bg-card); color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.chat-bubble-wrap-error .chat-bubble {
  background: rgba(248,113,113,0.15); color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-bubble-time {
  font-size: 0.67rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 3px;
}

.chat-tab-thinking {
  align-self: flex-start;
  background: var(--bg-card);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 11px 14px;
  display: flex; gap: 4px;
  flex-shrink: 0;
}
.chat-tab-thinking span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: chatBounce 1.2s infinite ease-in-out;
}
.chat-tab-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-tab-thinking span:nth-child(3) { animation-delay: 0.4s; }

.chat-tab-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: auto;
  padding: 24px 16px;
  line-height: 1.5;
}

.chat-tab-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
}

.chat-tab-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}
.chat-tab-input:focus { border-color: var(--accent); }
.chat-tab-input::placeholder { color: var(--text-muted); }

.chat-tab-send {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  color: #0d1f3c;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-tab-send:hover    { background: var(--accent-dim); }
.chat-tab-send:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
