:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --border: #e5e9f0;
  --border-strong: #d3dae6;
  --accent: #25d366;
  --accent-dark: #128c4a;
  --accent-soft: #e7f9ee;
  --danger: #ef4444;
  --danger-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.18);
  --radius: 16px;
  --radius-lg: 22px;
  --radius-sm: 11px;
  --header-h: 60px;
  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Author display rules must never override the native hidden state. */
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font-family: inherit; }
h1, h2, h3, p { margin: 0; }

.app-shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

/* ---------- HEADER ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(244, 246, 249, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(229, 233, 240, 0.9);
}

.header-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #25d366, #0e9f52);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.32);
}
.brand-logo svg { width: 22px; height: 22px; }

.brand-text { min-width: 0; }
.brand-text h1 { font-size: 18px; font-weight: 750; letter-spacing: -0.3px; line-height: 1.1; }
.brand-text p {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 11px;
  border-radius: 999px;
  min-height: 36px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform 0.15s ease, background 0.2s ease;
}
.header-status:active { transform: scale(0.95); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex: 0 0 8px;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}
.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.22);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.22); }
  50% { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0.05); }
}

/* ---------- MAIN ---------- */
.app-main {
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 28px);
}

.screen { display: none; animation: fade 0.24s ease; }
.screen.is-active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- API BANNER ---------- */
.api-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.api-banner.is-online { border-color: rgba(37, 211, 102, 0.35); background: var(--accent-soft); }
.api-banner-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.api-banner-text strong { font-size: 14px; font-weight: 700; }
.api-banner-text span { font-size: 12.5px; color: var(--text-2); }
.api-banner.is-online .api-banner-text span { color: var(--accent-dark); font-weight: 600; }
.api-banner.is-degraded { border-color: #f3c96b; background: #fffbeb; }
.api-banner.is-degraded .api-banner-text span { color: #92400e; font-weight: 650; }
.mode-notice {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  margin: -4px 0 16px;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  background: #f8fafc;
}
.mode-notice strong { font-size: 12.5px; color: var(--text-2); }
.mode-notice span { font-size: 12px; color: var(--text-3); line-height: 1.45; }

/* ---------- STATS GRID ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.stat-card.accent { background: linear-gradient(150deg, #f0fdf5, #e7f9ee); border-color: rgba(37, 211, 102, 0.3); }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 600; letter-spacing: 0.01em; }
.stat-value { font-size: 26px; font-weight: 780; letter-spacing: -0.8px; line-height: 1.1; }
.stat-value-sm { font-size: 16px; font-weight: 720; letter-spacing: -0.2px; word-break: break-word; }

/* ---------- SECTION HEAD ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 11px;
}
.section-head h2 { font-size: 16px; font-weight: 720; letter-spacing: -0.2px; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 13.5px;
  font-weight: 650;
  padding: 7px 4px;
  min-height: 34px;
  cursor: pointer;
}
.link-btn:active { opacity: 0.6; }
.count-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
}

/* ---------- CARDS ---------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.automation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 15px;
  animation: fade 0.24s ease;
}
.automation-card.is-disabled { opacity: 0.72; }

.ac-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.ac-keyword {
  font-size: 15.5px;
  font-weight: 740;
  letter-spacing: -0.2px;
  word-break: break-word;
  min-width: 0;
}
.ac-campaign {
  font-size: 13px;
  color: var(--text-2);
  word-break: break-word;
  margin-bottom: 11px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  white-space: nowrap;
  flex: 0 0 auto;
}
.status-badge.off { background: #f1f5f9; color: var(--text-3); }
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.ac-metrics {
  display: flex;
  gap: 8px;
  margin-bottom: 13px;
}
.metric {
  flex: 1;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
}
.metric span { display: block; font-size: 10.5px; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.metric strong { font-size: 15px; font-weight: 720; }

.ac-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.act-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease;
  padding: 6px 2px;
}
.act-btn:active { transform: scale(0.94); }
.act-btn svg { width: 18px; height: 18px; }
.act-btn.act-qr { background: var(--accent-soft); border-color: rgba(37, 211, 102, 0.3); color: var(--accent-dark); }
.act-btn.act-del { color: var(--danger); background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.2); }

/* ---------- BAR (stats) ---------- */
.bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 2px;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #25d366, #0e9f52);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- QUICK ACTION ---------- */
.quick-action {
  width: 100%;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(140deg, #25d366, #0e9f52);
  color: #fff;
  font-size: 15.5px;
  font-weight: 720;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 211, 102, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quick-action:active { transform: scale(0.975); box-shadow: 0 5px 14px rgba(37, 211, 102, 0.25); }
.qa-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: grid; place-items: center;
  font-size: 19px; line-height: 1; font-weight: 600;
}

/* ---------- SEARCH ---------- */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}
.search-bar input {
  width: 100%;
  min-height: 48px;
  padding: 0 44px 0 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.13); }
.search-icon {
  position: absolute; left: 14px;
  width: 19px; height: 19px;
  color: var(--text-3);
  pointer-events: none;
}
.search-icon svg { width: 100%; height: 100%; }
.search-clear {
  position: absolute; right: 8px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- FORM ---------- */
.form-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow-sm);
}
.form-group legend {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-dark);
  padding: 0 7px;
  margin-left: -4px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field input,
.field textarea,
.settings-card input,
.settings-card textarea {
  width: 100%;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  min-height: 48px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea, .settings-card textarea { min-height: 64px; line-height: 1.5; }
.field input:focus, .field textarea:focus,
.settings-card input:focus, .settings-card textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.13);
}
.field input.invalid, .field textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1); }
.field-hint { font-size: 12px; color: var(--text-3); margin: -4px 0 12px; }
.field-hint:last-child { margin-bottom: 0; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.toggle-text { display: flex; flex-direction: column; min-width: 0; }
.toggle-text strong { font-size: 14.5px; font-weight: 700; }
.toggle-text span { font-size: 12.5px; color: var(--text-3); }
.toggle { position: relative; flex: 0 0 auto; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-track {
  display: block;
  width: 54px; height: 32px;
  border-radius: 999px;
  background: var(--border-strong);
  padding: 3px;
  transition: background 0.22s ease;
  pointer-events: none;
}
.toggle-thumb {
  display: block;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.22);
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(22px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.2); }

button:focus-visible,
.nav-item:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.35);
  outline-offset: 2px;
}

/* ---------- BUTTONS ---------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}
.btn-primary:active, .btn-secondary:active, .btn-danger:active, .btn-ghost:active { transform: scale(0.975); }
.btn-primary { background: linear-gradient(140deg, #25d366, #0e9f52); color: #fff; box-shadow: 0 8px 20px rgba(37, 211, 102, 0.28); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 8px 20px rgba(239, 68, 68, 0.22); }
.btn-ghost { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-block + .btn-block { margin-top: 10px; }
.btn-sm { min-height: 38px; padding: 0 13px; font-size: 13px; border-radius: 11px; }

/* ---------- SETTINGS ---------- */
.settings-group { margin-bottom: 20px; }
.settings-group h3 {
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin: 0 4px 9px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.settings-card .field { margin-bottom: 14px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
  min-width: 0;
}
.settings-row:first-child { border-top: none; padding-top: 0; }
.settings-row > span:first-child { color: var(--text-2); flex: 0 0 auto; }
.settings-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-all;
  text-align: right;
  min-width: 0;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  padding: 5px 11px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-3);
  white-space: nowrap;
}
.status-chip.online { background: var(--accent-soft); color: var(--accent-dark); }
.status-chip.online .status-dot { background: var(--accent); box-shadow: none; animation: none; }
.settings-note { font-size: 12px; color: var(--text-3); margin-top: 12px; line-height: 1.55; }

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 42px 22px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.empty-icon {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: grid; place-items: center;
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { font-size: 16.5px; font-weight: 730; margin-bottom: 5px; }
.empty-state p { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; }

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 650;
  padding: 7px 2px;
  min-height: 52px;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.15s ease;
  position: relative;
}
.nav-item .nav-icon { width: 23px; height: 23px; display: block; }
.nav-item .nav-icon svg { width: 100%; height: 100%; }
.nav-item.is-active { color: var(--accent-dark); }
.nav-item:active { transform: scale(0.92); }

.nav-primary { justify-content: flex-end; }
.nav-primary .nav-primary-circle {
  width: 52px; height: 52px;
  margin-top: -24px;
  border-radius: 50%;
  background: linear-gradient(140deg, #25d366, #0e9f52);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.38);
  border: 4px solid var(--bg);
  transition: transform 0.18s ease;
}
.nav-primary .nav-primary-circle svg { width: 25px; height: 25px; }
.nav-primary:active .nav-primary-circle { transform: scale(0.9); }
.nav-primary.is-active { color: var(--accent-dark); }

/* ---------- SHEET / MODAL ---------- */
.sheet-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 9px auto 2px;
  flex: 0 0 auto;
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 18px calc(20px + var(--safe-bottom));
}
.qr-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.qr-head h3 { font-size: 17px; font-weight: 750; letter-spacing: -0.2px; }
.qr-head p { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.icon-btn {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn svg { width: 19px; height: 19px; }

.qr-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.qr-target { width: 100%; max-width: 260px; display: grid; place-items: center; }
.qr-target img, .qr-target canvas {
  width: 100% !important;
  height: auto !important;
  display: block;
  border-radius: 8px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.qr-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 14px;
  margin-bottom: 12px;
}
.qr-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.qr-meta-row:first-child { border-top: none; }
.qr-meta-row span { font-size: 13px; color: var(--text-2); flex: 0 0 auto; }
.qr-meta-row strong {
  font-size: 13.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
  min-width: 0;
}

.qr-link-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 10px 10px 13px;
  margin-bottom: 16px;
}
.qr-link-wrap .settings-mono { flex: 1; text-align: left; font-size: 11.5px; color: var(--text-2); }
.qr-link-wrap .icon-btn { width: 36px; height: 36px; flex: 0 0 36px; }

.preview-wrap { margin-bottom: 18px; }
.preview-label {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin: 0 0 8px 4px;
}
.wa-preview {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.wa-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: #075e54;
  color: #fff;
}
.wa-avatar {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
}
.wa-top-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.wa-top-text strong { font-size: 14px; font-weight: 650; }
.wa-top-text span { font-size: 11px; opacity: 0.75; }
.wa-thread {
  background: #e4ddd4;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 90px;
}
.wa-bubble {
  max-width: 86%;
  padding: 8px 11px;
  border-radius: 11px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  animation: fade 0.3s ease;
}
.wa-bubble.out { align-self: flex-end; background: #dcf8c6; border-top-right-radius: 3px; }
.wa-bubble.in { align-self: flex-start; background: #fff; border-top-left-radius: 3px; }
.wa-bubble .wa-time {
  display: block;
  font-size: 10px;
  color: rgba(15, 23, 42, 0.45);
  text-align: right;
  margin-top: 3px;
}
.wa-bubble .wa-link { color: #1d6fd6; text-decoration: underline; overflow-wrap: anywhere; }

.qr-actions { display: flex; flex-direction: column; gap: 10px; }
.qr-actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- CONFIRM MODAL ---------- */
.modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 61;
  width: calc(100% - 44px);
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: pop 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal h3 { font-size: 17px; font-weight: 750; margin-bottom: 7px; }
.modal p { font-size: 13.5px; color: var(--text-2); line-height: 1.55; margin-bottom: 20px; overflow-wrap: anywhere; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- TOAST ---------- */
.toast-wrap {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
  max-width: 520px;
  margin: 0 auto;
}
.toast {
  width: 100%;
  max-width: 440px;
  background: #0f172a;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 15px;
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toastIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.leaving { animation: toastOut 0.24s ease forwards; }
.toast .t-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--accent); }
.toast.err .t-dot { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }

/* ---------- DESKTOP (secondary) ---------- */
@media (min-width: 720px) {
  body { background: #eef1f6; }
  .app-shell {
    box-shadow: 0 0 0 1px var(--border), 0 24px 60px rgba(15, 23, 42, 0.1);
    border-radius: 0;
    min-height: 100vh;
  }
  .stats-grid { gap: 13px; }
  .brand-text p { max-width: 260px; }
}

@media (max-width: 359px) {
  .app-main { padding-left: 12px; padding-right: 12px; }
  .ac-actions { gap: 6px; }
  .act-btn { font-size: 10px; }
  .stat-value { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
