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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --danger: #ff5370;
  --warn: #ffcb6b;
  --text: #e8eaf6;
  --text2: #8b90b0;
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f1f5;
  --border: #e2e4ea;
  --accent: #5b54e6;
  --accent2: #00b894;
  --danger: #e74c3c;
  --warn: #f39c12;
  --text: #1a1d27;
  --text2: #6b7280;
}

.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 { 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); }

.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); }

/* Main */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 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 { /* same style */
  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: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  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 {
  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;
}
.form-group input:focus, .form-group select: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-ok  { }
.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); }

/* 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; }

/* Auth overlay */
.auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.auth-overlay.open { display: flex; }

.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; }
.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;
}
.auth-tab.active { background: var(--surface); color: var(--text); }

.auth-form { display: none; }
.auth-form.active { 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; }
