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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); }

/* ── App shell ─────────────────────────────────────────────── */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  max-width: 1280px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-page);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-x: visible;
  overflow-y: auto;
  padding: 0 12px;
}

.sidebar-logo {
  padding: 16px 4px 8px;
  margin-bottom: 4px;
}

.sidebar-logo-img {
  height: 30px;
  width: auto;
  display: block;
}

.sidebar-logo-icon { display: none; }

.sidebar--collapsed .sidebar-logo-full { display: none; }
.sidebar--collapsed .sidebar-logo-icon { display: block; }

.sidebar-client-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 8px;
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  margin-bottom: 1px;
}

.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

.nav-item:hover { background: var(--bg-muted); }

.nav-item.active {
  font-weight: 700;
  color: var(--text-primary);
}

.nav-item.active svg { stroke: var(--blue); }

/* ── Nav submenu ────────────────────────────────────────────── */

.nav-submenu {
  display: none;
  padding-left: 18px;
  margin-top: -2px;
  margin-bottom: 2px;
}
.nav-submenu.visible { display: block; }

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 1px;
  position: relative;
}
.nav-sub-item::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 60%;
  background: var(--border);
}
.nav-sub-item:hover { background: var(--bg-muted); color: var(--text-primary); }
.nav-sub-item.active { color: var(--text-primary); font-weight: 600; }
.nav-sub-item.active svg { stroke: var(--blue); }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 4px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue); /* overridden by inline style */
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name  { font-size: 14px; font-weight: 700; line-height: 1.3; }
.user-role  { font-size: 13px; color: var(--text-secondary); }

.logout-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--r-pill);
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.logout-btn:hover { background: var(--bg-muted); color: var(--red); }

/* ── Sidebar collapse toggle ────────────────────────────────── */

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg-muted); color: var(--text-primary); }
.sidebar-collapse-btn svg { transition: none; }

/* collapsed state */
.sidebar {
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar--collapsed {
  width: var(--sidebar-w-collapsed);
  padding: 0 8px;
}

.sidebar--collapsed .sidebar-client-name { display: none; }
.sidebar--collapsed .sidebar-logo {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0 8px;
}
.sidebar--collapsed .sidebar-collapse-btn { margin-top: 0; }
.sidebar--collapsed .nav-section { display: none; }
.sidebar--collapsed .nav-submenu { display: none !important; }

/* icon-only nav items: hide text, center icon */
.sidebar--collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  font-size: 0;   /* hides inline text nodes */
}
.sidebar--collapsed .nav-item svg { width: 20px; height: 20px; }
.sidebar--collapsed .nav-badge { display: none; }
.sidebar--collapsed .nav-alert-dot { top: 4px; right: 4px; }

/* footer: avatar + logout stacked */
.sidebar--collapsed .sidebar-footer {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0 16px;
}
.sidebar--collapsed .user-name,
.sidebar--collapsed .user-role { display: none; }
.sidebar--collapsed .logout-btn { margin-left: 0; }

/* ── Main panel ─────────────────────────────────────────────── */

.main-panel {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  min-width: 0;
}

.page-header {
  padding: 16px 36px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-content {
  padding: 16px 20px 48px;
}

.page-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 36px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

/* ── Right panel ────────────────────────────────────────────── */

.right-panel {
  width: var(--rp-w);
  flex-shrink: 0;
  background: var(--bg-page);
  overflow-y: auto;
  padding: 16px;
}

.right-panel.hidden { display: none; }

.rp-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 14px;
  text-align: center;
  background: linear-gradient(160deg, rgba(29,155,240,0.12) 0%, rgba(29,155,240,0.03) 50%, rgba(139,92,246,0.06) 100%);
  padding: 24px;
}

.rp-empty--plain { background: none; }
.rp-empty-icon { font-size: 36px; opacity: 0.3; }

.rp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.rp-title {
  font-size: 20px;
  font-weight: 700;
}

.rp-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  line-height: 1;
  font-size: 16px;
  margin-top: 2px;
  transition: color 0.15s, background 0.15s;
}

.rp-close:hover { color: var(--text-primary); background: var(--bg-muted); }

.rp-section { margin-bottom: 24px; }

.rp-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.rp-value { font-size: 14px; line-height: 1.5; }

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin: 0 36px 12px;
}

.card:last-child {
  margin-bottom: 48px;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-title svg { color: var(--blue); flex-shrink: 0; }

/* ── Page section padding ───────────────────────────────────── */

.section-pad {
  padding: 16px 20px;
}

.section-label {
  padding: 16px 36px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-label svg { flex-shrink: 0; opacity: 0.7; }

.inline-stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.emoji-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.emoji-stat--urgent { color: var(--red); }

.inline-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.inline-stat-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.inline-stat-num.green { color: var(--green); }
.inline-stat-num.red   { color: var(--red); }

.inline-stat-label {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Metrics ────────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.metric-card {
  padding: 20px 36px;
  border-right: 1px solid var(--border);
}

.metric-card:last-child { border-right: none; }

.metric-card-link { display: block; cursor: pointer; transition: background 0.15s; }
.metric-card-link:hover { background: var(--bg-muted); }

.metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.metric-value.blue   { color: var(--blue); }
.metric-value.green  { color: var(--green); }
.metric-value.red    { color: var(--red); }

/* ── Two-column grid ────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 36px 12px;
}

.grid-2 .card { margin: 0; }

.card--flush { padding: 0; }

/* ── Badges / Pills ─────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  line-height: 1.5;
}

.badge-pos { background: var(--green-tint); color: var(--green-dark); }
.badge-neg { background: var(--red-tint);   color: var(--red); }
.badge-neu { background: rgba(113,118,123,0.15); color: var(--text-secondary); }
.badge-urg { background: var(--red); color: #fff; }

/* ── Urgent bell icon ───────────────────────────────────────── */
@keyframes bell-glow {
  0%, 100% { filter: drop-shadow(0 0 0px var(--red)); opacity: 1; }
  50%       { filter: drop-shadow(0 0 4px var(--red)); opacity: 0.75; }
}
.bell-urgent {
  color: var(--red);
  stroke: var(--red);
  flex-shrink: 0;
  animation: bell-glow 1.8s ease-in-out infinite;
}
.badge-blue { background: var(--blue-tint); color: var(--blue); }

/* ── Feed rows ──────────────────────────────────────────────── */

.feed-list { padding: 0; padding-bottom: 24px; }

.feed-empty {
  padding: 20px 36px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.feed-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 36px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.feed-row:last-child { border-bottom: none; }
.feed-row:hover      { background: var(--bg-muted); }
.feed-row.selected   { background: rgba(29,155,240,0.06); }

.feed-emoji { font-size: 20px; flex-shrink: 0; line-height: 1.4; margin-top: 1px; }

.feed-body { flex: 1; min-width: 0; }

.feed-row.unread .feed-text { font-weight: 600; }

.feed-text {
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.feed-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.feed-meta .badge { font-size: 10px; padding: 1px 6px; }

.feed-meta-icon { opacity: 0.45; flex-shrink: 0; }

/* ── Bar chart rows ─────────────────────────────────────────── */

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.bar-label {
  flex: 7;
  min-width: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.bar-track {
  flex: 3;
  height: 6px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
  flex-shrink: 0;
}

.bar-fill { height: 100%; border-radius: var(--r-pill); }
.bar-fill.pos { background: var(--green); }
.bar-fill.neg { background: var(--red); }
.bar-fill.blue { background: var(--blue); }

.bar-row-clickable {
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s;
  margin: 0 -6px;
  padding-left: 6px;
  padding-right: 6px;
}

.bar-row-clickable:hover { background: var(--bg-muted); }

.bar-num {
  width: 30px;
  text-align: right;
  color: var(--text-tertiary);
  font-size: 12px;
  flex-shrink: 0;
}

/* ── Filters ────────────────────────────────────────────────── */

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 36px 16px;
}

.date-sep {
  font-size: 12px;
  color: var(--text-tertiary);
}

select.filter-select {
  font-size: 14px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-page);
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371767B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  transition: border-color 0.15s;
}

select.filter-select:focus {
  outline: none;
  border-color: var(--blue);
}

.period-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.period-btn-group {
  display: flex;
  gap: 4px;
}

.period-nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.period-btn {
  font-size: 13px;
  font-weight: 700;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn:hover { border-color: var(--text-primary); background: var(--bg-muted); }
.period-btn.active { background: #0f1419; border-color: #0f1419; color: #fff; }

.period-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}
.period-nav-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); }
.period-nav-btn.disabled { opacity: 0.3; pointer-events: none; }

.period-nav-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}

/* ── Heatmap ─────────────────────────────────────────────────── */

.heatmap-grid {
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  gap: 3px;
}

.heatmap-grid.heatmap-compact {
  grid-template-columns: 36px repeat(7, 1fr);
  gap: 2px;
}

.heatmap-grid.heatmap-compact .hm-cell {
  height: 18px;
}

.heatmap-grid.heatmap-compact .hm-label {
  font-size: 10px;
}

.heatmap-grid.heatmap-compact .hm-header {
  font-size: 10px;
}

.hm-header { font-size: 11px; color: var(--text-secondary); text-align: center; padding-bottom: 2px; font-weight: 700; }
.hm-label  { font-size: 11px; color: var(--text-secondary); text-align: right; padding-right: 6px; display: flex; align-items: center; justify-content: flex-end; }
.hm-cell   { height: 22px; border-radius: 4px; transition: opacity 0.15s, box-shadow 0.15s; }

.hm-cell.hm-dimmed    { opacity: 0.12; }
.heatmap-pos .hm-cell.hm-highlighted {
  box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--green);
  position: relative;
  z-index: 1;
}
.heatmap-neg .hm-cell.hm-highlighted {
  box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--red);
  position: relative;
  z-index: 1;
}

.heatmap-legend {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot  { width: 10px; height: 10px; border-radius: 3px; }

/* ── Topic chips ─────────────────────────────────────────────── */

.topic-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--text-primary);
  transition: opacity 0.15s;
}

.topic-chip[data-topic] { cursor: pointer; }

.topic-chip[data-topic].chip-active.pos {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--green-tint);
}
.topic-chip[data-topic].chip-active.neg {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--red-tint);
}

.topic-chip.pos {
  border-color: rgba(0,186,124, calc(0.15 + var(--i, 50) * 0.004));
  background:   rgba(0,186,124, calc(0.06 + var(--i, 50) * 0.004));
}
.topic-chip.neg {
  border-color: rgba(244,33,46, calc(0.15 + var(--i, 50) * 0.004));
  background:   rgba(244,33,46, calc(0.06 + var(--i, 50) * 0.004));
}

.chip-count { font-weight: 700; font-size: 13px; }
.chip-count.pos { color: var(--green); }
.chip-count.neg { color: var(--red); }

/* ── AI summary ─────────────────────────────────────────────── */

.ai-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.ai-box {
  border-radius: var(--r-lg);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.ai-box.pos { background: var(--green-tint); border: 1px solid rgba(0,186,124,0.3); }
.ai-box.neg { background: var(--red-tint);   border: 1px solid rgba(244,33,46,0.3); }

.ai-box-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.ai-box.pos .ai-box-label { color: var(--green); }
.ai-box.neg .ai-box-label { color: var(--red); }

.ai-point { padding-left: 12px; position: relative; margin-bottom: 4px; }
.ai-point::before { content: '•'; position: absolute; left: 0; }

.ai-loading { color: var(--text-secondary); font-size: 13px; }

/* ── AI report (paragraph + bullets) ───────────────────────── */

.ai-low-data-note {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 12px;
}

/* ── AI card header ─────────────────────────────────────────── */

.ai-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ai-card-main-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-card-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.ai-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── AI report sections ─────────────────────────────────────── */

.ai-report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-report-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 20px;
  border-radius: var(--r-lg);
}
.ai-report-section.pos {
  background: rgba(0,186,124,0.04);
  border: 1px solid rgba(0,186,124,0.25);
}
.ai-report-section.neg {
  background: rgba(244,33,46,0.04);
  border: 1px solid rgba(244,33,46,0.2);
}

.ai-report-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}
.ai-report-label.pos { color: var(--green-dark); }
.ai-report-label.neg { color: var(--red-dark); }

/* Icon circle in section header — dark filled, white icon, white ring */
.ai-label-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px white;
}
.ai-label-icon.pos { background: var(--green-dark); }
.ai-label-icon.neg { background: var(--red-dark); }

.ai-report-paragraph {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  margin: 0;
}

.ai-report-bullets { display: flex; flex-direction: column; gap: 10px; }

.ai-report-bullet {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
}

/* Checkmark/arrow in a small circle */
.ai-bullet-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.ai-bullet-icon.pos { background: rgba(0,186,124,0.18); color: var(--green-dark); }
.ai-bullet-icon.neg { background: rgba(244,33,46,0.12); color: var(--red); }
.ai-bullet-icon svg { display: block; }



/* ── Feedback citations ─────────────────────────────────────── */

.ai-citations {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-citations-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.ai-citation-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  line-height: 1.5;
}

.ai-citation-emoji { flex-shrink: 0; font-size: 13px; }

.ai-citation-text {
  color: var(--text-primary);
  font-style: italic;
  flex: 1;
  min-width: 0;
}

.ai-citation-date {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.ai-citation-row { transition: opacity .2s; }

/* Sentiment stat badges in section header */
.ai-section-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.ai-stat-item {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
  text-transform: none;
}

/* Remove old dot/SVG styles */
.ai-bullet-dot { display: none; }


/* Regen button (small inline refresh icon in card title) */
.ai-regen-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.ai-regen-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Threshold state — compact chips */
.ai-threshold-state {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ai-threshold-msg { font-size: 12px; color: var(--text-secondary); }
.ai-threshold-chips { display: flex; gap: 6px; }
.ai-thr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--red-tint);
  color: var(--red);
  border: 1px solid rgba(244,33,46,.2);
  white-space: nowrap;
}
.ai-thr-chip.met {
  background: var(--green-tint);
  color: var(--green-dark);
  border-color: rgba(0,186,124,.2);
}

/* Analytics empty state */
.analytics-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Error / retry state */
.ai-generating-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 0;
  text-align: center;
}
.ai-generating-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
  margin-bottom: 4px;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
.ai-generating-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.ai-generating-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.ai-error-state {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
}

/* ── Alerts ──────────────────────────────────────────────────── */

.alert-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.alert-item:hover { background: var(--bg-muted); }
.alert-item.trend { border-left-color: var(--blue); }

.alert-title   { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.alert-excerpt { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-style: italic; }
.alert-meta    { font-size: 12px; color: var(--text-tertiary); }

/* ── Branch list ─────────────────────────────────────────────── */

.branch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 36px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.branch-row:last-child { border-bottom: none; }
.branch-row:hover      { background: var(--bg-muted); }
.branch-row.selected   { background: var(--bg-muted); }

.branch-info  { flex: 1; min-width: 0; }
.branch-name  { font-size: 14px; font-weight: 700; }
.branch-link-icon { color: var(--text-tertiary); display: flex; flex-shrink: 0; padding: 4px; border-radius: 6px; transition: color 0.15s, background 0.15s; align-self: flex-start; margin-top: -4px; margin-left: -16px; }
.branch-link-icon:hover { color: var(--text-primary); background: var(--border); }

.branch-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 99px;
  line-height: 1.5;
}
.branch-badge--inactive {
  background: var(--bg-muted);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

.branch-addr {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-banner-wrap {
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(140deg, #0ea5e9, #0284c7);
}

.branch-banner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.42);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.branch-banner-wrap:hover .branch-banner-overlay { opacity: 1; }

.banner-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s;
}

.banner-icon-btn:hover { background: rgba(0,0,0,0.8); }

@keyframes checkPop {
  0%   { opacity: 0; transform: scale(0.5); }
  55%  { transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes checkFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Modal */
.modal-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title   { font-size: 16px; font-weight: 700; margin: 0; }
.modal-close   { background: none; border: none; cursor: pointer; color: var(--text-tertiary); padding: 4px; display: flex; }

/* ── Forms ───────────────────────────────────────────────────── */

.form-row   { margin-bottom: 16px; }
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

select.form-input { appearance: none; cursor: pointer; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 700;
  border-radius: var(--r-pill);
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  transition: background 0.15s;
  line-height: 1;
}

.btn:hover { background: var(--bg-muted); }

.btn:disabled,
.btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

.btn-primary:hover { background: #272C30; border-color: #272C30; }

.btn-blue {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-blue:hover { background: var(--blue-light); border-color: var(--blue-light); }

.btn-danger { color: var(--red); border-color: rgba(244,33,46,0.4); }
.btn-danger:hover { background: var(--red-tint); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; }

/* ── QR Designer ─────────────────────────────────────────────── */

/* Scoped layout overrides — only active when QR designer is on-screen */
.main-panel:has(.qr-designer) { overflow: hidden !important; }
.main-panel:has(.qr-designer) .main-content { overflow: hidden; display: flex; flex-direction: column; }
.main-panel:has(.qr-designer) .main-footer { display: none; }

.qr-designer {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.qr-ctrl {
  width: 360px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.qr-ctrl-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.qr-ctrl-head > svg { flex-shrink: 0; color: var(--blue); }
.qr-ctrl-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }

.qr-ctrl-body {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.qr-ctrl-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.qr-field { display: flex; flex-direction: column; gap: 6px; }

.qr-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.qr-label svg { flex-shrink: 0; }

.qr-select {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  outline: none;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.qr-select:focus { border-color: var(--blue); }

.cta-opts { display: flex; flex-direction: column; gap: 6px; }

.cta-opt {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.cta-opt:hover { border-color: var(--blue); }
.cta-opt.active { border-color: var(--blue); background: var(--blue-tint); }
.cta-opt-l1 { font-size: 12px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.cta-opt-l2 { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.cta-custom { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cta-input-wrap { display: flex; flex-direction: column; gap: 3px; }

.cta-input {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  outline: none;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  transition: border-color 0.15s;
}

.cta-input:focus { border-color: var(--blue); }

.cta-char-count { font-size: 10px; color: var(--text-tertiary); text-align: right; }
.cta-char-count.over { color: var(--red); }

.qr-print-info {
  margin-top: 10px;
}

.qr-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #dde3ea;
  overflow: hidden;
  gap: 10px;
  padding: 24px;
}

#qr-canvas {
  display: block;
  max-height: calc(100% - 40px);
  box-shadow: 0 6px 28px rgba(0,0,0,0.20);
  border-radius: 2px;
}

.qr-preview-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  text-align: center;
}

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  padding: 32px;
}

.qr-empty a { color: var(--blue); }

/* ── QR page ─────────────────────────────────────────────────── */

.qr-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.15s;
}

.qr-card:hover { background: var(--bg-muted); }

.qr-placeholder {
  width: 64px;
  height: 64px;
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.qr-info { flex: 1; min-width: 0; }
.qr-name { font-size: 14px; font-weight: 700; }
.qr-url  { font-size: 12px; color: var(--blue); margin-top: 2px; font-family: monospace; }
.qr-note { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

/* ── Settings / Billing ──────────────────────────────────────── */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.settings-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── Inbox search ───────────────────────────────────────────── */

.inbox-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  color: var(--text-tertiary);
}

.inbox-search-input {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  width: 180px;
}

.inbox-search-input::placeholder {
  color: var(--text-tertiary);
}

/* ── Emoji sentiment toggles ────────────────────────────────── */

.emoji-toggle-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.emoji-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  font-size: 17px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
  user-select: none;
  position: relative;
}

.emoji-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.emoji-toggle.is-active {
  opacity: 1;
  border-color: var(--blue);
  background: rgba(29,155,240,0.08);
}

/* ── Date range filter ──────────────────────────────────────── */

.date-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

input.filter-date {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-page);
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

input.filter-date::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
}

/* ── Scroll sentinel ─────────────────────────────────────────── */

.scroll-sentinel {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Misc ────────────────────────────────────────────────────── */

.success-msg {
  background: var(--green-tint);
  color: var(--green);
  border: 1px solid rgba(0,186,124,0.3);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.error-msg {
  background: var(--red-tint);
  color: var(--red);
  border: 1px solid rgba(244,33,46,0.3);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.section-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  margin-top: 20px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.section-header:first-child { margin-top: 0; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.text-muted { color: var(--text-secondary); }
.text-sm    { font-size: 13px; }
.mt-4       { margin-top: 4px; }
.mt-8       { margin-top: 8px; }

/* ── Login page ──────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
}

.login-box {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.login-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ── Alert banner ───────────────────────────────────────────── */

.alert-banner {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 12px;
}

.alert-banner.success {
  background: var(--green-tint);
  color: var(--green);
  border: 1px solid rgba(0,186,124,0.3);
}

.alert-banner.error {
  background: var(--red-tint);
  color: var(--red);
  border: 1px solid rgba(244,33,46,0.3);
}

/* ── Heatmap tooltip ────────────────────────────────────────── */

.hm-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12px;
  min-width: 130px;
  max-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.hm-tip-count-row {
  font-weight: 600;
  font-size: 11px;
  opacity: 0.6;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hm-tip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}

.hm-tip-count-row + .hm-tip-row {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 4px;
}

.hm-tip-row + .hm-tip-row {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 2px;
  padding-top: 4px;
}

.hm-tip-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.hm-tip-count {
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Topic × Branch matrix ──────────────────────────────────────── */

.topic-matrix {
  display: grid;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
}

.tm-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-label {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tm-emoji {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.tm-cell {
  height: 26px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tm-count {
  font-size: 10px;
  line-height: 1;
  color: transparent; /* hidden on empty cells (tm-pos-0 / tm-neg-0) */
}

/* ── tm-pos colour scale (green) ───────── */
.tm-pos-0 { background: var(--bg-muted); }
.tm-pos-1 { background: rgba(0,186,124,0.18); }
.tm-pos-2 { background: rgba(0,186,124,0.42); }
.tm-pos-3 { background: rgba(0,186,124,0.70); }
.tm-pos-4 { background: #00BA7C; }

.tm-pos-1 .tm-count { color: var(--green-dark); }
.tm-pos-2 .tm-count { color: var(--green-dark); }
.tm-pos-3 .tm-count { color: #fff; font-weight: 700; }
.tm-pos-4 .tm-count { color: #fff; font-weight: 700; }

/* ── tm-neg colour scale (red) ─────────── */
.tm-neg-0 { background: var(--bg-muted); }
.tm-neg-1 { background: rgba(244,33,46,0.15); }
.tm-neg-2 { background: rgba(244,33,46,0.38); }
.tm-neg-3 { background: rgba(244,33,46,0.65); }
.tm-neg-4 { background: #F4212E; }

.tm-neg-1 .tm-count { color: var(--red-dark); }
.tm-neg-2 .tm-count { color: var(--red-dark); }
.tm-neg-3 .tm-count { color: #fff; font-weight: 700; }
.tm-neg-4 .tm-count { color: #fff; font-weight: 700; }

/* very_positive rows — more saturated green scale */
.tm-very-pos.tm-pos-1 { background: rgba(0,186,124,0.35); }
.tm-very-pos.tm-pos-2 { background: rgba(0,186,124,0.62); }
.tm-very-pos.tm-pos-3 { background: rgba(0,186,124,0.88); }
.tm-very-pos.tm-pos-4 { background: #00BA7C; }

/* very_negative rows — more saturated red scale */
.tm-very-neg.tm-neg-1 { background: rgba(244,33,46,0.32); }
.tm-very-neg.tm-neg-2 { background: rgba(244,33,46,0.58); }
.tm-very-neg.tm-neg-3 { background: rgba(244,33,46,0.82); }
.tm-very-neg.tm-neg-4 { background: #F4212E; }

/* ── Chat / conversation bubbles ────────────────────────────── */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.chat-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-assistant {
  align-self: flex-start;
  background: var(--bg-muted);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-contact a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #25D366;
  font-weight: 700;
}

/* ── Info box ────────────────────────────────────────────────── */

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.info-box svg { flex-shrink: 0; margin-top: 1px; color: var(--text-tertiary); }

/* ── Help tooltip (?-circle) ────────────────────────────────── */

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font);
  cursor: default;
  position: relative;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}

.help-tip-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--text-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.65;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  text-transform: none;
  letter-spacing: 0;
}

.help-tip:hover .help-tip-content,
.help-tip:focus .help-tip-content {
  display: block;
}

/* ── Footer ─────────────────────────────────────────────────── */

.main-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 36px 32px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.main-footer a {
  color: var(--text-tertiary);
  transition: color 0.15s;
}

.main-footer a:hover { color: var(--text-primary); }

.ob-footer-guide { position: relative; padding-left: 10px; }
.ob-footer-guide::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: ob-dot-pulse 2s ease-in-out infinite;
}
@keyframes ob-dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(29,155,240,0.4); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(29,155,240,0); }
}

.main-footer-sep { opacity: 0.4; }

/* ── Billing status banner ─────────────────────────────────────────────────── */

.status-banner {
  padding: 10px 36px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.status-banner a {
  font-weight: 700;
  text-decoration: underline;
}

.status-banner--expired {
  background: var(--red-tint);
  color: var(--red-dark);
}

.status-banner--expired a { color: var(--red-dark); }

.status-banner--grace {
  background: var(--amber-tint);
  color: var(--amber-dark);
}

.status-banner--grace a { color: var(--amber-dark); }

/* ── Onboarding banner ─────────────────────────────────────────────────────── */

.ob-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  background: rgba(29,155,240,0.08);
  border-bottom: 1px solid rgba(29,155,240,0.18);
  font-size: 13px;
}

.ob-banner-track {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ob-banner-label {
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

.ob-banner-bar {
  width: 80px;
  height: 4px;
  background: rgba(29,155,240,0.2);
  border-radius: 9999px;
  overflow: hidden;
}

.ob-banner-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.ob-banner-next {
  flex: 1;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ob-banner-cta {
  flex-shrink: 0;
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.ob-banner-cta:hover { text-decoration: underline; }

/* ── Onboarding field highlight (glow pulse) ───────────────────────────────── */

@keyframes ob-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(29,155,240,0.7); }
  60%  { box-shadow: 0 0 0 8px rgba(29,155,240,0); }
  100% { box-shadow: 0 0 0 0   rgba(29,155,240,0); }
}

.ob-hl {
  border-color: var(--blue) !important;
  animation: ob-pulse 2.4s ease-in-out 4;
}

/* card-level highlight (banner/logo block, branch row) */
@keyframes ob-pulse-card {
  0%   { box-shadow: 0 0 0 0    rgba(29,155,240,0.6), 0 1px 3px rgba(0,0,0,0.06); }
  60%  { box-shadow: 0 0 0 10px rgba(29,155,240,0),   0 1px 3px rgba(0,0,0,0.06); }
  100% { box-shadow: 0 0 0 0    rgba(29,155,240,0),   0 1px 3px rgba(0,0,0,0.06); }
}

.ob-hl-card {
  border-color: var(--blue) !important;
  animation: ob-pulse-card 2.4s ease-in-out 4;
}

/* Nav alert dot ─────────────────────────────────────────────────────────── */

.nav-alert-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Billing popup ─────────────────────────────────────────────────────────── */

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.popup {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  position: relative;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
}

.popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: flex;
}

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

.popup-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.popup-icon--amber {
  background: var(--amber-tint);
  color: var(--amber-dark);
}

.popup-icon--red {
  background: var(--red-tint);
  color: var(--red-dark);
}

.popup-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.popup-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.popup-cta {
  width: 100%;
  text-decoration: none;
  justify-content: center;
  padding: 12px 16px;
}

.popup-days {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  line-height: 1;
}

.popup-days--amber { background: var(--amber-tint); }
.popup-days--red   { background: var(--red-tint); }

.popup-days-number {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
}

.popup-days--amber .popup-days-number { color: var(--amber-dark); }
.popup-days--red   .popup-days-number { color: var(--red-dark); }

.popup-days-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 1px;
}

.popup-days--amber .popup-days-label { color: var(--amber-dark); }
.popup-days--red   .popup-days-label { color: var(--red-dark); }

/* ── Billing page ──────────────────────────────────────────────────────────── */

.billing-duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.billing-duration-option { cursor: pointer; }
.billing-duration-option input { display: none; }

.billing-duration-label {
  display: block;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.billing-duration-option input:checked + .billing-duration-label {
  border-color: var(--blue);
  background: var(--blue-tint);
  color: var(--blue);
}

.billing-summary {
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 12px 16px;
}

.billing-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

/* ── Order history table ───────────────────────────────────────────────────── */

.order-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.order-history-table th,
.order-history-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.order-history-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
}

.order-history-table tr:last-child td { border-bottom: none; }

.order-detail-layout {
  display: grid;
  grid-template-columns: 1fr auto 1.5fr;
  gap: 28px;
  align-items: stretch;
}

.order-detail-layout--no-qris { grid-template-columns: 1fr 1.5fr; }

.order-detail-main { min-width: 0; overflow-wrap: break-word; }

.order-detail-info {
  display: flex;
  flex-direction: column;
}

.order-detail-info #proof-upload-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.order-detail-info #proof-upload-section form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.order-detail-info .dropzone {
  flex: 1;
}

.order-detail-qris {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

.qris-image {
  width: 300px;
  height: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  display: block;
}

.order-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
}

.order-status--pending   { background: var(--amber-tint); color: var(--amber-dark); }
.order-status--paid      { background: var(--green-tint);  color: var(--green-dark); }
.order-status--expired   { background: var(--bg-muted);    color: var(--text-tertiary); }
.order-status--proof     { background: var(--blue-tint);   color: var(--blue); }
.order-status--cancelled { background: var(--red-tint);    color: var(--red-dark); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.sg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sg-modal {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 0;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  overflow: hidden;
}

.sg-modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sg-modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--red);
}

.sg-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.sg-modal-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  padding: 10px 24px 24px 72px;
  line-height: 1.6;
}

.sg-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 24px 24px;
}

/* ── Button loader ───────────────────────────────────────────────────────────── */
.btn--loading .btn-icon-default { display: none !important; }
.btn--loading .btn-spinner      { display: inline-block !important; }
.btn--loading .btn-label        { opacity: 0.7; }

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.sg-toast {
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.sg-toast--error { background: var(--red); white-space: normal; max-width: 320px; text-align: left; }
.sg-toast--hide { opacity: 0; }

/* ── Dropzone ────────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed #b0b8c1;
  border-radius: var(--r-lg);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  background: transparent;
}

.dropzone:hover, .dropzone--over {
  border-color: var(--blue);
  background: var(--blue-tint);
}

.dropzone--selected {
  border-color: var(--green);
  background: var(--green-tint);
}

.dropzone-icon {
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.dropzone--selected .dropzone-icon { color: var(--green); }

.dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.dropzone-btn {
  margin-top: 4px;
  pointer-events: none;
}

/* ── Stepper ────────────────────────────────────────────────────────────────── */

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  width: fit-content;
}

.stepper-btn {
  background: var(--bg-muted);
  border: none;
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.stepper-btn:hover { background: var(--border); color: var(--text-primary); }

.stepper-value {
  min-width: 28px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0 6px;
}

/* ── Billing page ───────────────────────────────────────────────────────────── */

.card--amber {
  border-color: var(--border);
  background: var(--bg-page);
}

.billing-plan-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.billing-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  letter-spacing: .5px;
  text-transform: uppercase;
}
.billing-badge--trial   { background: var(--bg-muted);   color: var(--text-secondary); }
.billing-badge--business { background: var(--blue-tint);  color: var(--blue); }
.billing-badge--grace   { background: var(--amber-tint); color: var(--amber-dark); }
.billing-badge--expired { background: var(--red-tint);   color: var(--red-dark); }

.billing-plan-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

.upgrade-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.duration-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.duration-pill {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.duration-pill:hover { border-color: var(--blue); color: var(--blue); }

.duration-pill--active {
  background: var(--blue-tint);
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 700;
}

.billing-plan-features {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.billing-plan-features span { display: flex; align-items: center; gap: 5px; }
.billing-plan-features svg  { flex-shrink: 0; opacity: 0.6; }

.promo-tag {
  background: var(--green-tint);
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-pill);
}

.proof-success { color: var(--green-dark); font-weight: 600; font-size: 13px; }

/* ── Plan cards ── */
.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 36px 12px;
  align-items: stretch;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.plan-card--business:hover,
.plan-card--enterprise:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.1);
}

.plan-card--business {
  background: linear-gradient(160deg, rgba(29,155,240,0.12) 0%, rgba(29,155,240,0.03) 50%, rgba(139,92,246,0.06) 100%);
  border-color: rgba(29,155,240,0.3);
}

.plan-card--enterprise {
  background: linear-gradient(145deg, #1a1a2e 0%, #2c2c2e 50%, #1e1a2e 100%);
  border-color: #3a3a3e;
}

.plan-card--enterprise .plan-card-price   { color: #fff; }
.plan-card--enterprise .plan-card-period,
.plan-card--enterprise .plan-card-features { color: rgba(255,255,255,0.85); }
.plan-card--enterprise .plan-card-features li::before { color: rgba(255,255,255,0.5); }
.plan-card--enterprise .btn              { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: #fff; }
.plan-card--enterprise .btn:hover        { background: rgba(255,255,255,0.18); }

.plan-badge--enterprise {
  background: linear-gradient(135deg, #b8860b, #d4af37);
  color: #fff;
}

.plan-card-header { margin-bottom: 24px; }

.plan-card-price {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 14px;
  letter-spacing: -0.5px;
}

.plan-card-period { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.plan-card-features {
  list-style: none;
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
}

.plan-card-features li { display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; }
.plan-card-features li::before { content: '✓'; color: var(--green); font-weight: 700; flex-shrink: 0; }

.plan-card-cta {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  padding: 13px 16px;
  box-sizing: border-box;
}

.plan-card-price-promo { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.plan-card-price-original { font-size: 16px; color: var(--red); text-decoration: line-through; }
.plan-card-price-promo-row { display: flex; align-items: center; gap: 8px; }
.plan-card-price-promo-row .promo-tag { transform: translateY(-4px); }
.plan-card-price-promo .plan-card-price { margin-top: 0; }

/* Upgrade form inside plan card */
.plan-card-form {
  margin-top: auto;
  padding-top: 28px;
  border-top: 1px solid rgba(29,155,240,0.2);
}

.plan-card-form-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

/* ── Order detail ── */
.billing-order-item label  { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 2px; }
.billing-order-item strong { font-size: 14px; }

.billing-bank-box {
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
}
.billing-bank-box strong { font-size: 15px; }

/* ── Plan stats ── */
.plan-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 8px;
}

.plan-stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 16px;
  border-right: 1px solid var(--border);
  margin-right: 16px;
}

.plan-stat-item:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.plan-stat-icon { flex-shrink: 0; }

.plan-stat-text { display: flex; flex-direction: column; gap: 2px; }
.plan-stat-label { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }
.plan-stat-value { font-size: 16px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.plan-stat-unit  { font-size: 13px; font-weight: 400; color: var(--text-secondary); }

.plan-dates-col { align-items: flex-start; }
.plan-dates-stack { display: flex; flex-direction: column; gap: 8px; }

/* ── Billing dates ── */
.billing-date-item  { display: flex; flex-direction: column; gap: 1px; }
.billing-date-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); }
.billing-date-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.billing-date-value--warn { color: var(--red); }

/* ── Manage options ── */
.manage-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.manage-option-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--bg-page);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.manage-option-card--renew { border-color: var(--blue); }
.manage-option-card--renew:hover { box-shadow: 0 2px 12px rgba(29,155,240,0.15); }
.manage-option-card--add:hover   { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }

.manage-option-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-muted);
  color: var(--text-tertiary);
}

.manage-option-text  { flex: 1; }
.manage-option-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.manage-option-desc  { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

.manage-option-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--text-primary);
  color: #fff;
}

.manage-title-back {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  font-weight: inherit;
  color: var(--text-primary);
  padding: 0;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.manage-title-back:hover { opacity: 1; }

/* ── Renew / Add-branch form ── */
.renew-layout {
  display: grid;
  grid-template-columns: 60fr 40fr;
  gap: 24px;
  align-items: start;
}

.renew-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }

.renew-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.renew-meta svg { color: var(--text-tertiary); flex-shrink: 0; }
.renew-meta-dot { color: var(--text-tertiary); }

.renew-section {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.renew-section-hd { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }

.renew-section-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.renew-section-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.renew-section-desc  { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.renew-stepper { border-radius: var(--r-md); margin-top: 14px; }
.renew-stepper .stepper-btn   { width: 40px; height: 40px; font-size: 18px; }
.renew-stepper .stepper-value { font-size: 18px; font-weight: 700; min-width: 40px; }

.renew-duration-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.renew-dur-pill {
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-page);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.renew-dur-pill:hover { border-color: var(--blue); color: var(--blue); }
.renew-dur-pill--active { border-color: var(--blue); color: var(--blue); background: var(--blue-tint); font-weight: 700; }

.renew-info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--blue-tint);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--blue-dark);
  line-height: 1.5;
}
.renew-info-box svg { flex-shrink: 0; margin-top: 1px; }

.renew-summary-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.renew-summary-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.renew-summary-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.renew-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.renew-summary-box { background: var(--bg-muted); border-radius: var(--r-md); padding: 14px; }

.renew-summary-price-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.renew-promo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--green-tint);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: var(--r-md);
  margin-top: 10px;
}

.renew-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2px;
  border-top: 1px solid var(--border);
}

.renew-total-label  { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.renew-total-amount { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }

/* ── Add-branch summary ── */
.ab-summary-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ab-summary-group--last { border-bottom: none; padding-bottom: 0; }

.ab-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-secondary);
}

.ab-summary-row--total { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.ab-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ab-tooltip-icon { color: var(--text-tertiary); cursor: default; flex-shrink: 0; }

.ab-tooltip-box {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}

.ab-tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}

.ab-tooltip-wrap:hover .ab-tooltip-box { visibility: visible; opacity: 1; }

/* ── Order history expand button ── */
.order-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  transition: color 0.15s;
}
.order-expand-btn:hover { color: var(--text-primary); }

/* ── Referral page ───────────────────────────────────────────────────────────── */

.flash-success {
  background: var(--green-tint);
  color: var(--green-dark);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.referral-wrap { max-width: 760px; }

.ref-hero {
  background: var(--blue-tint);
  border-radius: 12px;
  margin: 0 36px 20px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
}

.ref-hero-copy {
  grid-column: 1;
  grid-row: 1;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.ref-hero-actions {
  grid-column: 1;
  grid-row: 2;
  padding: 14px 24px 20px;
}
.ref-hero-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.ref-hero-desc  { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.ref-hero-icon {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  pointer-events: none;
  border-left: 1px solid var(--border);
}
.ref-hero-icon img {
  height: 180px;
  width: auto;
  display: block;
  object-fit: contain;
  object-position: top right;
}

.ref-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ref-link-box {
  flex: 1;
  min-width: 0;
  display: block;
  text-align: left;
  background: #fff;
  border: 2px solid var(--text-primary);
  border-radius: 0;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.ref-link-box:hover { background: #f5f5f5; }
.ref-link-display {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ref-share-circle {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: opacity 0.15s;
}
.ref-share-circle:hover { opacity: 0.8; }

.ref-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 36px 20px;
}

.ref-stat      { display: flex; align-items: flex-start; gap: 9px; }
.ref-stat-icon { flex-shrink: 0; margin-top: 3px; }
.ref-stat-title { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.ref-stat-sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.ref-stat-value  { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; }
.ref-stat-amount { font-size: 26px; font-weight: 700; color: var(--text-primary); }

.ref-credit-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--blue-tint);
  color: var(--blue);
  border-radius: 4px;
  padding: 2px 7px;
}

.ref-section-title { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.ref-section-sub   { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.referred-by { font-size: 12px; color: var(--text-secondary); margin: 0 36px 16px; }

/* ── Referral history table ── */
.referral-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.referral-table th,
.referral-table td  { padding: 8px 0; text-align: left; }
.referral-table th  { font-weight: 500; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.referral-table td  { padding: 12px 0; border-bottom: 1px solid var(--border); }
.referral-table tr:last-child td { border-bottom: none; }

.referral-table .col-right { text-align: right; }
.referral-table .col-credit { font-weight: 600; color: var(--text-secondary); }
.referral-table .col-credit.col-credit--done { color: var(--green-dark); }
.referral-table .col-date   { color: var(--text-secondary); }

.referral-status           { border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.referral-status--done     { background: var(--green-tint); color: var(--green-dark); }
.referral-status--pending  { background: var(--amber-tint); color: var(--amber-dark); }

.ref-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
}

.ref-client-cell { display: flex; align-items: center; gap: 10px; }
.ref-client-name { color: var(--text-primary); font-weight: 500; }

.ref-empty { padding: 32px 0; text-align: center; color: var(--text-secondary); }
.ref-empty svg  { display: block; margin: 0 auto 12px; opacity: 0.4; }
.ref-empty-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.ref-empty-desc  { font-size: 13px; }

/* ── Mobile responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {

  /* Prevent any child from blowing out the horizontal layout */
  .main-panel { overflow-x: hidden; }

  /* Right panel: fixed overlay — always off-screen until JS opens it */
  .right-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(360px, 90vw);
    z-index: 300;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  .right-panel.rp-open {
    transform: translateX(0);
  }
  /* Backdrop behind the panel */
  #rp-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 299;
  }
  #rp-backdrop.rp-open { display: block; }

  /* Reduce horizontal padding on headers and content */
  .page-header,
  .page-header-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Period controls: drop to its own row, spread the two groups apart */
  .period-controls {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
  .period-nav-label { min-width: auto; }

  .page-content { padding-left: 12px; padding-right: 12px; }

  /* Metrics: 3-col → 1-col, switch from right-border to bottom-border */
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card  { padding: 16px 20px; border-right: none; border-bottom: 1px solid var(--border); }
  .metric-card:last-child { border-bottom: none; }

  /* Cards and two-column grid: reduce side margins */
  .card {
    margin-left: 12px;
    margin-right: 12px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
    margin-left: 12px;
    margin-right: 12px;
  }

  /* AI */
  .ai-summary-grid { grid-template-columns: 1fr; }
  .ai-report-grid  { grid-template-columns: 1fr; }

  /* Billing duration options: 4-col → 2-col */
  .billing-duration-grid { grid-template-columns: repeat(2, 1fr); }

  /* Plan cards: 3-col → 1-col */
  .plan-cards {
    grid-template-columns: 1fr;
    margin-left: 12px;
    margin-right: 12px;
  }

  /* Plan stats row: 4-col → 2-col */
  .plan-stats-row { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .plan-stat-item { border-right: none; margin-right: 0; padding-right: 0; }

  /* Manage options: 2-col → 1-col */
  .manage-options { grid-template-columns: 1fr; }

  /* Renew / add-branch layout: split → stack */
  .renew-layout { grid-template-columns: 1fr; }

  /* Order detail: 3-col → 1-col */
  .order-detail-layout,
  .order-detail-layout--no-qris { grid-template-columns: 1fr; }

  /* Referral */
  .ref-hero         { margin: 0 12px 20px; display: block; overflow: hidden; }
  .ref-hero-copy    { padding: 16px 16px 12px; min-width: 0; }
  .ref-hero-actions { padding: 12px 16px 16px; min-width: 0; }
  .ref-hero-icon    { display: none; }
  .ref-link-row     { flex-wrap: wrap; gap: 8px; }
  .ref-stats-grid   { grid-template-columns: 1fr; margin-left: 12px; margin-right: 12px; }

  /* QR designer: stack ctrl above preview */
  .main-panel:has(.qr-designer) { overflow: auto !important; }
  .main-panel:has(.qr-designer) .main-content { overflow: visible; display: block; }
  .qr-designer { flex-direction: column; height: auto; }
  .qr-ctrl { width: 100%; }
  .qr-preview { min-height: 320px; }
  #qr-canvas { max-height: 280px; }

  /* Footer */
  .main-footer {
    flex-wrap: wrap;
    padding: 16px 16px 24px;
    gap: 6px 8px;
  }
  .main-footer-sep { display: none; }
}
