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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #181824;
  --border: #1e1e2e;
  --border-hover: #2a2a3e;
  --text: #e4e4ef;
  --muted: #8888a4;
  --accent: #f97316;
  --accent-dim: rgba(249, 115, 22, 0.12);
  --accent-hover: #ea6c0e;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
}

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

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  letter-spacing: -0.5px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  text-decoration: none;
  display: block;
}
.sidebar-logo span { color: var(--accent); }

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  cursor: pointer;
}
.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-section {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 20px 12px 8px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 1200px;
  min-height: 100vh;
}

/* ---- AUTH PAGES ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: -0.5px;
  text-align: center;
  margin-bottom: 8px;
  text-decoration: none;
  display: block;
}
.auth-logo span { color: var(--accent); }

.auth-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-trial-badge {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: var(--green);
  background: var(--green-dim);
  padding: 6px 16px;
  border-radius: 20px;
  margin: 0 auto 24px;
  width: fit-content;
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--accent);
}
.form-input::placeholder {
  color: #555570;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
  font-family: 'DM Sans', monospace;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238888a4' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-hover); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid transparent;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-hover); }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.stat-card-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-card-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---- PAGE HEADERS ---- */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---- ALERT ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.alert-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.alert-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.alert-warning {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid rgba(234, 179, 8, 0.2);
}
.alert-info {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

/* ---- REPORT BUILDER ---- */
.builder-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.builder-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.builder-full {
  grid-column: 1 / -1;
}

.field-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.field-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  font-family: 'DM Sans', monospace;
}

.field-chip-off {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.field-chip-off:hover {
  border-color: var(--border-hover);
  color: var(--text);
}
.field-chip-on {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.filter-row .form-input {
  flex: 1;
}

.filter-row select.form-input {
  max-width: 160px;
}

.query-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'DM Sans', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.builder-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- DATA TABLE ---- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: var(--surface);
  padding: 12px 16px;
  text-align: left;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tr:hover td {
  background: var(--surface-hover);
}

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

.table-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- SUITEQL EDITOR ---- */
.suiteql-editor {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'DM Sans', monospace;
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}
.suiteql-editor:focus {
  border-color: var(--accent);
}
.suiteql-editor::placeholder {
  color: #555570;
}

/* ---- SETUP GUIDE ---- */
.setup-steps {
  counter-reset: steps;
}

.setup-step {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.setup-step:last-child { border-bottom: none; }

.setup-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.setup-step-content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.setup-step-content p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.setup-step-content code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
}

/* ---- SAVED REPORT LIST ---- */
.report-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: border-color 0.15s;
}
.report-card:hover {
  border-color: var(--border-hover);
}

.report-card-info h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.report-card-info p {
  font-size: 0.82rem;
  color: var(--muted);
}

.report-card-actions {
  display: flex;
  gap: 8px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* ---- LOADING ---- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 480px;
  width: 100%;
}

.modal h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ---- SUBSCRIPTION BANNER ---- */
.sub-banner {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(249, 115, 22, 0.05) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.sub-banner-text h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.sub-banner-text p {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
  width: fit-content;
}

.tab {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: 'DM Sans', sans-serif;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar {
    width: 60px;
    padding: 16px 8px;
  }
  .sidebar-logo { font-size: 0; padding-bottom: 16px; }
  .sidebar-logo::first-letter { font-size: 1.2rem; }
  .sidebar-link { justify-content: center; padding: 10px; }
  .sidebar-link span { display: none; }
  .sidebar-section { display: none; }
  .sidebar-user span { display: none; }
  .main-content { margin-left: 60px; padding: 24px 20px; }
  .builder-config { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .builder-config { grid-template-columns: 1fr; }
  .sub-banner { flex-direction: column; gap: 16px; text-align: center; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- LINK ---- */
.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--muted);
}
.auth-link a {
  color: var(--accent);
  text-decoration: none;
}
.auth-link a:hover {
  text-decoration: underline;
}

/* ---- CONNECTION STATUS ---- */
.connection-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.connection-status.connected {
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.connection-status.disconnected {
  background: var(--surface);
  border: 1px solid var(--border);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green { background: var(--green); }
.status-dot.gray { background: var(--muted); }
