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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f1f5;
  --border: #e2e4ea;
  --accent: #5b54e6;
  --accent2: #00b894;
  --danger: #e74c3c;
  --warn: #f39c12;
  --text: #1a1d27;
  --text2: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --danger: #ff5370;
  --warn: #ffcb6b;
  --text: #e8eaf6;
  --text2: #8b90b0;
}

.disclaimer-banner {
  background: #ffcb6b;
  color: #1a1d27;
  text-align: center;
  padding: 8px 32px;
  font-size: 12px;
  font-weight: 500;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
}
.disclaimer-banner ~ .layout .sidebar { top: 32px; height: calc(100vh - 32px); }
.disclaimer-banner ~ .layout .main { padding-top: 32px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-icon { font-size: 24px; color: var(--accent); }
.sidebar-collapse-btn {
  margin-left: auto;
  background: none; border: none; cursor: pointer; color: var(--text2);
  padding: 4px; border-radius: 4px; display: flex; align-items: center;
  opacity: 0; transition: opacity 0.15s;
}
.sidebar:hover .sidebar-collapse-btn { opacity: 1; }
.sidebar-collapse-btn:hover { background: var(--surface2); color: var(--text); }

/* Collapsed sidebar bubble */
.sidebar-bubble {
  display: none;
  position: fixed; top: 24px; left: 20px; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px;
  cursor: pointer; align-items: center; gap: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  transition: all 0.15s;
}
.sidebar-bubble .logo-icon { font-size: 18px; }
.sidebar-bubble:hover { border-color: var(--accent); box-shadow: 0 2px 16px rgba(108,99,255,0.2); }

/* Collapsed state */
.layout.sidebar-hidden .sidebar { display: none; }
.layout.sidebar-hidden .sidebar-bubble { display: flex; }
.layout.sidebar-hidden .main { margin-left: 0; max-width: 100vw; }
.layout.sidebar-hidden .topbar { padding-left: 100px; }
.layout.sidebar-hidden .btn-primary,
.layout.sidebar-hidden .btn-log,
.layout.sidebar-hidden .btn-icon,
.layout.sidebar-hidden .ob-widget { display: none !important; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
}

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

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108, 99, 255, 0.15); color: var(--accent); }

/* Nav groups (collapsible categories) */
.nav-group { margin: 0; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.nav-group-header svg:first-child { width: 18px; height: 18px; flex-shrink: 0; }
.nav-group-header span { flex: 1; }
.nav-group-header:hover { background: var(--surface2); color: var(--text); }
.nav-group.open > .nav-group-header { color: var(--text); }
.nav-chevron { width: 14px !important; height: 14px !important; opacity: 0.4; transition: transform 0.2s ease; }
.nav-group.open > .nav-group-header .nav-chevron { transform: rotate(180deg); opacity: 0.7; }
.nav-group-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding-left: 18px;
}
.nav-group.open > .nav-group-items { display: flex; }
.nav-sub { padding: 7px 12px 7px 20px; font-size: 13px; }

/* Main */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: calc(100vw - 220px);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 22px; font-weight: 700; }
.subtitle { color: var(--text2); margin-top: 3px; font-size: 13px; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); }

/* Views */
.view { display: none; padding: 28px 32px; }
.view.active { display: block; }

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.kpi-card:hover { border-color: var(--accent); }

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.kpi-card-name { font-size: 13px; color: var(--text2); font-weight: 500; }

.kpi-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.badge-revenue  { background: rgba(108, 99, 255, 0.15); color: var(--accent); }
.badge-growth   { background: rgba(0, 212, 170, 0.15);  color: var(--accent2); }
.badge-retention{ background: rgba(255, 203, 107, 0.15); color: var(--warn); }
.badge-acquisition { background: rgba(255, 83, 112, 0.15); color: var(--danger); }
.badge-engagement  { background: rgba(129, 212, 250, 0.15); color: #81d4fa; }
.badge-other    { background: var(--surface2); color: var(--text2); }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-target {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 12px;
}

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s;
}

.status-good  { background: var(--accent2); }
.status-warn  { background: var(--warn); }
.status-bad   { background: var(--danger); }

.kpi-status-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 8px;
  font-weight: 500;
}
.kpi-status-label .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-tall { min-height: 360px; }

/* Table */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.kpi-table { width: 100%; border-collapse: collapse; }

.kpi-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.kpi-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.kpi-table tr:last-child td { border-bottom: none; }
.kpi-table tbody tr:hover { background: var(--surface2); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.pill-good { background: rgba(0, 212, 170, 0.15); color: var(--accent2); }
.pill-warn { background: rgba(255, 203, 107, 0.15); color: var(--warn); }
.pill-bad  { background: rgba(255, 83, 112, 0.15); color: var(--danger); }

/* Trends */
.trends-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-weight: 500;
}

.trends-filter select,
.kpi-table select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 98%;
  max-width: 98%;
  padding: 20px;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text2);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text2); }

.form-group input, .form-group select, .form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 20px; }

/* Wide modal variant */
.modal-wide { max-width: 600px; max-height: 92vh; display: flex; flex-direction: column; }

/* Modal tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}
.modal-tab {
  flex: 1;
  padding: 7px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-tab.active { background: var(--surface); color: var(--text); }
.modal-tab-panel  { display: none; }
.modal-tab-panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

/* Paste import */
.paste-hint {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
}
.paste-hint code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent);
}
#bulk-paste {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  resize: vertical;
  line-height: 1.6;
  transition: border-color 0.15s;
}
#bulk-paste:focus { outline: none; border-color: var(--accent); }

/* Bulk preview */
#bulk-preview { margin: 12px 0; max-height: 260px; overflow-y: auto; border-radius: var(--radius-sm); }
.bulk-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.bulk-preview-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text2);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.bulk-preview-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.bulk-preview-table tr:last-child td { border-bottom: none; }
.bulk-row-err td { color: var(--danger); }
.bulk-ok-icon  { color: var(--accent2); font-weight: 700; }
.bulk-err-icon { color: var(--danger);  font-weight: 700; }
.bulk-summary  { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.bulk-summary strong { color: var(--text); }

/* Modal subtitle */
.modal-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Entry log header */
.entry-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

/* Change indicator */
.change-up   { color: var(--accent2); font-weight: 600; }
.change-down { color: var(--danger);  font-weight: 600; }
.change-flat { color: var(--text2); }

/* Accounts data table */
.acc-toolbar { display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px }
.acc-search { flex:1;min-width:200px;padding:8px 12px;background:var(--surface);border:1px solid var(--border);border-radius:8px;color:var(--text);font-size:13px;font-family:inherit }
.acc-filter { padding:6px 10px;background:var(--surface);border:1px solid var(--border);border-radius:8px;color:var(--text);font-size:12px;font-family:inherit }
.acc-table { width:100%;border-collapse:collapse;font-size:13px }
.acc-table th { padding:8px 10px;text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--text2);background:var(--surface2);border-bottom:1px solid var(--border);cursor:pointer;white-space:nowrap;user-select:none;position:sticky;top:0;z-index:2 }
.acc-table th:hover { color:var(--text) }
.acc-table th .sort-icon { margin-left:4px;font-size:10px }
.acc-table td { padding:6px 10px;border-bottom:1px solid var(--border);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap }
.acc-table tr:hover td { background:var(--surface2) }
.acc-status { display:inline-block;padding:2px 8px;border-radius:4px;font-size:11px;font-weight:600 }
.acc-status.live { background:rgba(0,212,170,.12);color:#00d4aa }
.acc-status.trial { background:rgba(108,99,255,.12);color:#6c63ff }
.acc-status.demo { background:rgba(255,203,107,.12);color:#ffcb6b }
.acc-status.disabled { background:rgba(139,144,176,.1);color:#8b90b0 }
.acc-status.staging { background:rgba(255,152,0,.12);color:#ff9800 }
.acc-online { display:inline-block;width:8px;height:8px;border-radius:50% }
.acc-online.on { background:#00d4aa }
.acc-online.off { background:#555 }
.col-toggle { display:flex;flex-wrap:wrap;gap:4px;padding:8px;background:var(--surface);border:1px solid var(--border);border-radius:8px;margin-bottom:8px }
.col-toggle label { font-size:11px;display:flex;align-items:center;gap:4px;padding:2px 6px;border-radius:4px;cursor:pointer }
.col-toggle label:hover { background:var(--surface2) }

/* Animations */
@keyframes popIn { 0%{transform:scale(0);opacity:0} 50%{transform:scale(1.2)} 100%{transform:scale(1);opacity:1} }

/* Spinner */
.ebk-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Settings tabs */
.settings-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Settings card */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
}
.settings-card h3 { font-size: 15px; font-weight: 600; }

/* Template picker */
.template-picker {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 24px 12px;
  background: var(--bg);
}
.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.template-item:last-child { border-bottom: none; }
.template-item:hover { background: var(--surface2); }
.template-name { font-weight: 500; }

/* Log button */
.btn-log {
  background: rgba(108,99,255,.12);
  color: var(--accent);
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-log:hover { background: rgba(108,99,255,.25); }

/* Last updated label on KPI card */
.kpi-last-update { font-size: 11px; color: var(--text2); margin-top: 4px; }

/* Tour */
.tour-overlay { position:fixed;inset:0;z-index:9990;pointer-events:none }
.tour-highlight { position:fixed;z-index:9991;box-shadow:0 0 0 4px var(--accent),0 0 0 9999px rgba(0,0,0,0.55);border-radius:8px;transition:all 0.3s;pointer-events:none }
.tour-tooltip { position:fixed;z-index:9992;background:var(--surface);border:1px solid var(--accent);border-radius:12px;padding:20px;max-width:320px;box-shadow:0 12px 40px rgba(0,0,0,0.3) }
.tour-tooltip h4 { font-size:15px;font-weight:600;margin-bottom:8px }
.tour-tooltip p { font-size:13px;color:var(--text2);line-height:1.6;margin-bottom:16px }
.tour-actions { display:flex;gap:8px;justify-content:space-between;align-items:center }
.tour-step { font-size:12px;color:var(--text2) }
.tour-skip { background:none;border:none;color:var(--text2);cursor:pointer;font-size:13px;font-family:inherit }
.tour-next { background:var(--accent);color:#fff;border:none;padding:8px 20px;border-radius:8px;cursor:pointer;font-size:13px;font-weight:600;font-family:inherit }

/* Notifications */
.notif-bell { position:relative;background:none;border:1px solid var(--border);border-radius:8px;padding:6px 10px;cursor:pointer;color:var(--text2);font-size:16px;display:flex;align-items:center }
.notif-badge { position:absolute;top:-4px;right:-4px;background:var(--danger);color:#fff;font-size:9px;font-weight:700;padding:1px 5px;border-radius:8px;min-width:16px;text-align:center }
.notif-dropdown { display:none;position:absolute;top:100%;right:0;width:320px;max-height:400px;overflow-y:auto;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,0.3);margin-top:8px;z-index:100 }
.notif-dropdown.open { display:block }
.notif-item { padding:12px 16px;border-bottom:1px solid var(--border);font-size:13px;cursor:pointer;transition:background 0.15s }
.notif-item:hover { background:var(--surface2) }
.notif-item.unread { border-left:3px solid var(--accent) }
.notif-item h5 { font-size:13px;font-weight:600;margin-bottom:2px }
.notif-item p { color:var(--text2);font-size:12px }
.notif-item .notif-time { font-size:11px;color:var(--text2);margin-top:4px }

/* Onboarding widget */
.ob-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 250;
  font-family: inherit;
}

.ob-toggle {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108,99,255,0.3);
  transition: transform 0.2s;
  position: relative;
  color: #fff;
  margin-left: auto;
}
.ob-toggle:hover { transform: scale(1.08); }

.ob-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent2);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.ob-panel {
  display: none;
  width: 340px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  margin-bottom: 12px;
  overflow: hidden;
  flex-direction: column;
}
.ob-panel.open { display: flex; }

.ob-header {
  padding: 16px 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
}
.ob-header h3 { font-size: 15px; margin-bottom: 8px; }
.ob-close {
  background: none; border: none; color: var(--text2);
  font-size: 20px; cursor: pointer; padding: 0 4px;
}

.ob-progress-wrap { display: flex; align-items: center; gap: 8px; }
.ob-progress-bar {
  width: 120px; height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%;
  background: var(--accent2);
  border-radius: 3px;
  transition: width 0.3s;
}

.ob-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.ob-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.ob-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.ob-body {
  padding: 12px 16px;
  overflow-y: auto;
  max-height: 340px;
}

.ob-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.ob-item:last-child { border-bottom: none; }
.ob-item:hover { opacity: 0.8; }

.ob-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 12px;
  color: transparent;
  transition: all 0.2s;
}
.ob-item.done .ob-check {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}
.ob-item.done .ob-text { text-decoration: line-through; color: var(--text2); }

.ob-text h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ob-text p { font-size: 12px; color: var(--text2); line-height: 1.4; }

.ob-action {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.ob-search-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ob-search-item:hover { opacity: 0.8; }
.ob-search-item h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ob-search-item p { font-size: 12px; color: var(--text2); line-height: 1.4; }

/* View editor */
.view-editor-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}

.view-editor-panel .settings-card {
  padding: 16px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); }

/* Quill overrides for dark mode */
.ql-toolbar.ql-snow { border-color: var(--border) !important; border-radius: 8px 8px 0 0; }
.ql-container.ql-snow { border-color: var(--border) !important; border-radius: 0 0 8px 8px; }
.ql-editor { min-height: 250px; color: var(--text); font-size: 14px; line-height: 1.7; }
.ql-editor.ql-blank::before { color: var(--text2); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text2) !important; }
.ql-snow .ql-fill { fill: var(--text2) !important; }
.ql-snow .ql-picker-label { color: var(--text2) !important; }
.ql-snow .ql-picker-options { background: var(--surface) !important; border-color: var(--border) !important; }
.ql-snow .ql-picker-item { color: var(--text) !important; }
.ql-snow .ql-active .ql-stroke { stroke: var(--accent) !important; }
.ql-snow .ql-active .ql-fill { fill: var(--accent) !important; }
.ql-snow .ql-active { color: var(--accent) !important; }

@media (max-width: 900px) {
  .view-editor-layout { grid-template-columns: 1fr; }
}

/* Help page */
.help-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

.help-sidebar {
  position: sticky;
  top: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 0;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.help-sidebar-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
}

.help-sidebar a {
  display: block;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.help-sidebar a:hover { color: var(--text); background: var(--surface2); }
.help-sidebar a.active { color: var(--accent); border-left-color: var(--accent); background: rgba(108,99,255,0.06); }

.help-content {
  min-height: 400px;
}

.help-content section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}

.help-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.help-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--accent);
}

.help-content p, .help-content li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text2);
  margin-bottom: 8px;
}

.help-content ul, .help-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.help-content code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent);
}

.help-content .tip {
  background: rgba(108,99,255,0.08);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text2);
}

.help-content .warn {
  background: rgba(255,203,107,0.08);
  border-left: 3px solid var(--warn);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text2);
}

.help-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.help-content table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.help-content table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}

.help-shortcut {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-sidebar { position: static; max-height: none; }
}

/* Auth overlay */
.auth-overlay {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-box {
  width: 100%;
  max-width: 440px;
  padding: 40px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 92vh;
  overflow-y: auto;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.auth-footer a { color: var(--text2); transition: color 0.15s; text-decoration: none; }
.auth-footer a:hover { color: var(--accent); }
.auth-footer-sep { color: var(--border); }

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-tagline {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
  text-align: center;
  display: block;
}
.auth-tab.active { background: var(--surface); color: var(--text); }

.auth-form { display: block; }

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 12px;
}

.btn-full { width: 100%; justify-content: center; padding: 11px; }

/* cname field */
.cname-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}
.cname-wrap:focus-within { border-color: var(--accent); }
.cname-wrap input {
  background: none;
  border: none;
  flex: 1;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}
.cname-wrap input:focus { outline: none; }
.cname-suffix {
  padding: 0 12px;
  color: var(--text2);
  font-size: 13px;
  white-space: nowrap;
  border-left: 1px solid var(--border);
  line-height: 40px;
}
.cname-status {
  font-size: 12px;
  margin-top: 5px;
  min-height: 16px;
}
.cname-ok   { color: var(--accent2); }
.cname-err  { color: var(--danger); }
.cname-info { color: var(--text2); }

/* Sidebar user */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

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

.user-info { flex: 1; min-width: 0; }
.user-name    { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-company { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Forecast tabs */
.forecast-tabs {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
  width: fit-content;
}

.forecast-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.forecast-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

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

/* Forecast summary cards */
.forecast-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.forecast-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.forecast-card-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  margin-bottom: 8px;
}

.forecast-card-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Template picker grid (inside Add KPI modal) */
.template-grid {
  display: flex;
  flex-direction: column;
}

/* Modal wider variant for Add KPI */
.modal-add-kpi {
  max-width: 560px;
  width: 96%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-add-kpi .modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 24px;
}
.modal-add-kpi .modal-header,
.modal-add-kpi .modal-footer {
  padding: 20px 24px;
}

/* Log modal */
.modal-log {
  max-width: 460px;
  width: 96%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-log .modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 24px;
}
.modal-log .modal-header,
.modal-log .modal-footer {
  padding: 20px 24px;
}

/* Inline error inside modals */
.modal-error {
  display: none;
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* Language toggle in sidebar */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  margin-top: 4px;
}
.lang-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.lang-btn:hover:not(.active) { background: var(--surface2); color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar-bubble { display: flex; }
  .main { margin-left: 0; max-width: 100vw; }
  .charts-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 20px 16px; }
  .view { padding: 20px 16px; }
}
