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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  height: 100vh;
  overflow: hidden;
}

#root { display: flex; flex-direction: column; height: 100vh; }

/* ── Layout ──────────────────────────────────────────────────── */
.app { display: flex; flex: 1; overflow: hidden; }

.main-content { flex: 1; overflow-y: auto; padding: 32px; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #818cf8;
  letter-spacing: -0.3px;
  border-bottom: 1px solid #1e293b;
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.sidebar-logo span { color: #f1f5f9; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: #1e293b; color: #cbd5e1; }
.nav-item.active { background: #1e3a5f; color: #93c5fd; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid #1e293b; }

.sidebar-disclaimer {
  margin-top: 10px;
  padding: 8px 6px;
  font-size: 9px;
  line-height: 1.5;
  color: #475569;
  text-align: center;
  opacity: 0.7;
}

.import-btn {
  width: 100%;
  padding: 10px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.2px;
}
.import-btn:hover { background: #4f46e5; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: #0f172a; }
.page-header p { color: #64748b; font-size: 13px; margin-top: 3px; }

/* ── Summary cards ───────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.card-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.card-value.positive { color: #10b981; }
.card-value.negative { color: #ef4444; }

.card-sublabel {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
  font-weight: 400;
}
.card-sublabel.sublabel-positive { color: #10b981; }
.card-sublabel.sublabel-negative { color: #ef4444; }

.card-info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  margin-left: 5px;
  cursor: help;
  vertical-align: 1px;
  font-style: normal;
}

/* ── Data freshness bar ─────────────────────────────────────── */
.data-freshness {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  padding: 6px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.freshness-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.freshness-sep { color: #cbd5e1; }

/* ── Disclaimer banner ──────────────────────────────────────── */
.data-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 20px;
  line-height: 1.5;
}
.data-disclaimer svg { flex-shrink: 0; margin-top: 1px; }

/* ── Chart grid ──────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: white;
  border-radius: 12px;
  padding: 20px 20px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 16px;
}
.chart-date-range {
  font-weight: 400;
  font-size: 12px;
  color: #94a3b8;
  margin-left: 6px;
}

/* ── Table card ──────────────────────────────────────────────── */
.table-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  margin-bottom: 20px;
}

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  color: #1e293b;
}
.search-input:focus { border-color: #6366f1; }

.filter-select {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: white;
  color: #1e293b;
  cursor: pointer;
}

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

thead tr { background: #f8fafc; }

th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  font-size: 13px;
  border-top: 1px solid #f1f5f9;
  color: #334155;
}

tr:hover td { background: #fafafa; }
tr.row-selected td { background: #f5f3ff; }

.amount-positive { color: #10b981; font-weight: 600; font-variant-numeric: tabular-nums; }
.amount-negative { color: #ef4444; font-weight: 600; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  transition: background 0.1s;
}
.badge:hover { background: #e2e8f0; }

.category-select-inline {
  padding: 3px 8px;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 12px;
  background: white;
  outline: none;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: #6366f1; color: white; }
.btn-primary:hover { background: #4f46e5; }
.btn-primary:disabled { background: #c7d2fe; cursor: not-allowed; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #ef4444; }
.btn-danger:hover { background: #fee2e2; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}

.modal-title { font-size: 19px; font-weight: 700; color: #0f172a; }
.modal-subtitle { color: #64748b; font-size: 13px; margin-top: 6px; margin-bottom: 24px; line-height: 1.5; }

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #64748b;
  user-select: none;
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: #6366f1;
  background: #f5f3ff;
  color: #6366f1;
}
.drop-zone-icon { font-size: 32px; margin-bottom: 10px; }
.drop-zone-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.drop-zone-sub { font-size: 12px; opacity: 0.75; }

.preview-box {
  margin-top: 16px;
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 11px;
  color: #475569;
  overflow-x: auto;
  max-height: 110px;
  overflow-y: auto;
  white-space: pre;
}

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-top: 14px; }
.alert-error { background: #fef2f2; color: #dc2626; }
.alert-success { background: #f0fdf4; color: #16a34a; font-weight: 600; text-align: center; }

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

/* ── Empty / loading states ──────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 24px;
  color: #64748b;
  text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h2 { font-size: 18px; font-weight: 600; color: #1e293b; margin-bottom: 6px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #94a3b8;
  font-size: 14px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

.tab-btn {
  padding: 7px 20px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  background: none;
  transition: all 0.15s;
}

.tab-btn:hover { color: #1e293b; background: #f8fafc; }
.tab-btn.active { background: #6366f1; color: #fff; }

/* ── Form elements ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.form-input {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.08); }

/* ── Better Deal Modal ───────────────────────────────────────── */
.deal-modal {
  max-width: 820px;
  max-height: 88vh;
  overflow-y: auto;
}

.deal-tip {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
}

.deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.deal-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.deal-card:hover { border-color: #6366f1; box-shadow: 0 2px 8px rgba(99,102,241,0.1); }
.deal-card-current { border-color: #10b981; background: #f0fdf4; }

.deal-current-tag {
  position: absolute;
  top: -1px;
  right: 10px;
  background: #10b981;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 0 0 6px 6px;
  letter-spacing: 0.3px;
}

.deal-card-name { font-weight: 700; font-size: 14px; color: #0f172a; }
.deal-card-price { font-size: 13px; font-weight: 600; color: #6366f1; }
.deal-card-note { font-size: 12px; color: #64748b; flex: 1; }
.deal-card-btn { font-size: 12px; padding: 5px 10px; text-align: center; text-decoration: none; margin-top: 4px; }

/* ── AI Chat ────────────────────────────────────────────────── */
.ai-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
}

.ai-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.ai-chat-header h1 { font-size: 22px; font-weight: 700; color: #0f172a; }
.ai-chat-header p { color: #64748b; font-size: 13px; margin-top: 3px; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: #64748b;
  padding: 40px 20px;
}
.ai-empty-icon { margin-bottom: 16px; }
.ai-empty-chat h3 { font-size: 18px; font-weight: 600; color: #1e293b; margin-bottom: 6px; }
.ai-empty-chat > p { font-size: 13px; margin-bottom: 24px; }

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
}

.ai-suggestion {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-suggestion:hover { border-color: #6366f1; color: #6366f1; background: #f5f3ff; }

/* Messages */
.ai-message {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
}
.ai-message-user { background: #f8fafc; }
.ai-message-assistant { background: white; }

.ai-message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-message-user .ai-message-avatar { background: #6366f1; color: white; }
.ai-message-assistant .ai-message-avatar { background: #f0fdf4; color: #10b981; }

.ai-message-body { flex: 1; min-width: 0; }
.ai-message-name { font-size: 12px; font-weight: 600; color: #94a3b8; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }

.ai-message-text {
  font-size: 14px;
  line-height: 1.65;
  color: #1e293b;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ai-message-error {
  font-size: 13px;
  color: #ef4444;
  background: #fef2f2;
  padding: 8px 12px;
  border-radius: 8px;
}

/* Typing indicator */
.ai-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ai-bounce 1.4s infinite ease-in-out;
}
.ai-typing span:nth-child(1) { animation-delay: 0s; }
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input bar */
.ai-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 16px 0 0;
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
}

.ai-chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  color: #1e293b;
  background: white;
  transition: border-color 0.15s;
}
.ai-chat-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.08); }
.ai-chat-input:disabled { background: #f8fafc; color: #94a3b8; }

.ai-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #6366f1;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ai-send-btn:hover { background: #4f46e5; }
.ai-send-btn:disabled { background: #c7d2fe; cursor: not-allowed; }
.ai-cancel-btn { background: #ef4444; }
.ai-cancel-btn:hover { background: #dc2626; }

/* Setup screen */
.ai-setup {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 32px;
}

.ai-setup-card {
  background: white;
  border-radius: 16px;
  padding: 36px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ai-setup-icon { text-align: center; margin-bottom: 12px; }
.ai-setup-card h2 { font-size: 20px; font-weight: 700; color: #0f172a; text-align: center; margin-bottom: 8px; }
.ai-setup-card > p { font-size: 13px; color: #64748b; text-align: center; line-height: 1.6; margin-bottom: 24px; }

.ai-setup-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.ai-setup-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #6366f1;
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-setup-step strong { font-size: 14px; color: #0f172a; }
.ai-setup-step p { font-size: 12px; color: #64748b; margin-top: 2px; }
.ai-setup-step a { color: #6366f1; text-decoration: underline; cursor: pointer; }

.ai-key-form { margin-bottom: 20px; }

.ai-privacy-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  background: #f0fdf4;
  border-radius: 8px;
  font-size: 12px;
  color: #16a34a;
  line-height: 1.5;
}
.ai-privacy-note svg { flex-shrink: 0; margin-top: 1px; color: #16a34a; }

/* Provider picker */
.provider-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.provider-card {
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}
.provider-card:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.provider-selected {
  border-color: #6366f1;
  background: #f5f3ff;
}
.provider-selected:hover {
  border-color: #6366f1;
  background: #f5f3ff;
}

.provider-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.provider-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.provider-selected .provider-radio {
  border-color: #6366f1;
}
.provider-radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s;
}
.provider-radio-dot.active {
  background: #6366f1;
}
.provider-name {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
}
.provider-vendor {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}
.provider-description {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  padding-left: 28px;
}
.provider-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.provider-badge-ready {
  background: #dcfce7;
  color: #16a34a;
}
.provider-badge-local {
  background: #fef3c7;
  color: #d97706;
}

.provider-setup-panel {
  border-top: 1px solid #e2e8f0;
  padding-top: 20px;
  margin-top: 8px;
}
.provider-setup-panel h3 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.provider-setup-warning {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.5;
}
.provider-setup-warning svg { flex-shrink: 0; margin-top: 1px; }
.provider-setup-warning code {
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.provider-setup-note {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  margin-top: 8px;
  line-height: 1.5;
}

.provider-cost {
  font-size: 11px;
  color: #94a3b8;
  padding-left: 28px;
  margin-top: 4px;
  font-style: italic;
}

.provider-api-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  background: #f0f0ff;
  border: 1px solid #e0e0ff;
  border-radius: 8px;
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 16px;
}
.provider-api-note svg { flex-shrink: 0; margin-top: 1px; }
.provider-api-note strong { color: #0f172a; }

.ai-response-disclaimer {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
  font-style: italic;
}

/* Model picker cards */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.model-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}
.model-card:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.model-selected {
  border-color: #6366f1;
  background: #faf5ff;
}
.model-selected:hover {
  border-color: #6366f1;
  background: #faf5ff;
}
.model-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.model-name {
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
}
.model-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}
.model-tier {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.model-pricing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 26px;
  margin-top: 6px;
  font-size: 11px;
  color: #64748b;
}
.model-pricing strong {
  color: #0f172a;
  font-weight: 600;
}
.model-pricing-sep {
  color: #cbd5e1;
  margin: 0 2px;
}
.model-pricing-unit {
  color: #94a3b8;
  font-size: 10px;
  margin-left: 2px;
}
.model-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Key detected banner */
.ai-key-detected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #16a34a;
  margin-bottom: 12px;
  animation: ai-fade-in 0.3s ease;
}

.input-detected {
  border-color: #10b981 !important;
  background: #f0fdf4 !important;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Budget styles ────────────────────────────────────────────── */
.budget-item {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.budget-item:last-child { border-bottom: none; }

.budget-progress-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
}
.budget-progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}
.budget-good { background: #10b981; }
.budget-warning { background: #f59e0b; }
.budget-over { background: #ef4444; }

/* ── Alert styles ─────────────────────────────────────────────── */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid;
  font-size: 13px;
  position: relative;
  animation: alert-slide-in 0.3s ease;
}
.alert-info {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}
.alert-warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}
.alert-danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}
.alert-card-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.alert-card-message {
  font-size: 12px;
  opacity: 0.85;
}
.alert-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
}
.alert-dismiss:hover { opacity: 1; }

@keyframes alert-slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Upcoming bills styles ────────────────────────────────────── */
.upcoming-bills {
  margin-bottom: 20px;
}
.bill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.bill-item:last-child { border-bottom: none; }
.bill-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bill-name {
  font-weight: 500;
  font-size: 14px;
  color: #1e293b;
}
.bill-date {
  font-size: 11px;
  color: #94a3b8;
}
.bill-amount {
  font-weight: 600;
  font-size: 14px;
  color: #ef4444;
}
.bill-soon {
  background: #fef2f2;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: #ef4444;
  font-weight: 600;
  margin-left: 8px;
}

/* ── Upgrade / Subscription ──────────────────────────────────── */
.btn-upgrade {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-upgrade:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.btn-upgrade.btn-sm { padding: 6px 14px; font-size: 12px; }

.upgrade-banner {
  background: linear-gradient(135deg, #f0f0ff 0%, #faf5ff 100%);
  border: 1.5px solid #e0e0ff;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
}
.upgrade-banner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.upgrade-banner-content h3 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.upgrade-banner-content p {
  font-size: 14px;
  color: #64748b;
  margin: 0;
  max-width: 440px;
  line-height: 1.6;
}
.upgrade-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  margin-top: 8px;
}
.upgrade-features span {
  font-size: 13px;
  color: #6366f1;
  font-weight: 500;
}

.pro-required-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #fef3cd;
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #92400e;
}
.pro-required-banner svg { flex-shrink: 0; color: #d97706; }
.pro-required-banner strong { display: block; font-size: 14px; color: #78350f; margin-bottom: 2px; }
.pro-required-banner p { margin: 0; font-size: 12px; color: #92400e; }
.pro-required-banner div { flex: 1; }
.pro-required-banner .btn-upgrade { flex-shrink: 0; }

.pro-required-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fef3cd;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
  font-weight: 500;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* ── License / Subscription page ─────────────────────────────── */
.sub-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
}
.sub-card-active {
  border-color: #a5b4fc;
  background: linear-gradient(135deg, #fafafe 0%, #f5f3ff 100%);
}
.sub-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.sub-card-header h3 { font-size: 18px; font-weight: 700; color: #0f172a; margin: 0; }
.sub-card-header p { font-size: 13px; color: #64748b; margin: 2px 0 0; }

.sub-badge-pro {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.sub-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
}
.sub-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #475569;
}
.sub-detail-row span:first-child { font-weight: 500; color: #64748b; }

.sub-status { font-weight: 600; }
.sub-status-active { color: #10b981; }
.sub-status-past_due { color: #f59e0b; }

.sub-features {
  margin-top: 16px;
}
.sub-features h4 {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sub-feature-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 13px;
  color: #10b981;
}

/* Comparison columns */
.sub-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.sub-comp-col {
  padding: 16px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #fafafa;
}
.sub-comp-pro {
  border-color: #a5b4fc;
  background: linear-gradient(135deg, #f5f3ff, #eef2ff);
}
.sub-comp-col h4 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px;
}
.sub-price {
  font-size: 13px;
  font-weight: 500;
  color: #6366f1;
  margin-left: 6px;
}
.sub-comp-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sub-comp-col li {
  font-size: 13px;
  padding: 4px 0;
}
.sub-comp-col li.included { color: #0f172a; }
.sub-comp-col li.included::before { content: '✓ '; color: #10b981; font-weight: 700; }
.sub-comp-col li.not-included { color: #94a3b8; text-decoration: line-through; }
.sub-comp-col li.not-included::before { content: '✗ '; color: #cbd5e1; }

.license-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  font-size: 12px;
  color: #94a3b8;
}
.license-divider::before,
.license-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.checkout-pending {
  text-align: center;
  padding: 16px;
}
.checkout-pending-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0fdf4;
  color: #10b981;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.checkout-pending p { margin: 4px 0; font-size: 14px; color: #0f172a; }

.sub-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  margin-top: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 12px;
  color: #16a34a;
  line-height: 1.5;
}
.sub-privacy-note svg { flex-shrink: 0; margin-top: 1px; color: #16a34a; }

/* ── Web app banner ──────────────────────────────────────────── */
.web-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  flex-shrink: 0;
}
.web-banner a { color: #e0e7ff; text-decoration: underline; }

/* ── Mobile nav toggle ───────────────────────────────────────── */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #6366f1;
  color: white;
  border: none;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ── AI Chat Panel (sidebar mode) ───────────────────────────── */
.chat-panel {
  width: 0;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  transition: width 0.25s ease;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.chat-panel-open {
  width: 420px;
}

.ai-chat-panel {
  height: 100vh;
  max-height: 100vh;
  padding: 16px;
}
.ai-chat-panel .ai-chat-header {
  margin-bottom: 12px;
}
.ai-chat-panel .ai-chat-messages {
  padding-bottom: 8px;
}
.ai-chat-panel .ai-empty-chat {
  padding: 20px 12px;
}
.ai-chat-panel .ai-empty-icon svg {
  width: 40px;
  height: 40px;
}
.ai-chat-panel .ai-empty-chat h3 {
  font-size: 15px;
}
.ai-chat-panel .ai-suggestions {
  gap: 6px;
}
.ai-chat-panel .ai-suggestion {
  font-size: 12px;
  padding: 6px 12px;
}
.ai-chat-panel .ai-chat-input {
  padding: 10px 12px;
  font-size: 13px;
}
.ai-chat-panel .ai-message {
  padding: 10px 12px;
}
.ai-chat-panel .ai-message-text {
  font-size: 13px;
}

.ai-panel-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ai-panel-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.ai-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: none;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ai-panel-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Sidebar chat button */
.nav-item-chat {
  margin-bottom: 10px;
  background: #1e293b;
  border-radius: 8px;
}
.nav-item-chat:hover {
  background: #334155;
}
.nav-item-chat.active {
  background: #312e81;
  color: #a5b4fc;
}

/* ── Responsive: tablet ──────────────────────────────────────── */
@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .sub-comparison { grid-template-columns: 1fr; }
  .sub-feature-list { grid-template-columns: 1fr; }
}

/* ── Responsive: mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 90;
    transition: left 0.25s ease;
  }
  .sidebar.sidebar-open { left: 0; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 85;
  }
  .sidebar-backdrop.active { display: block; }
  .mobile-nav-toggle { display: flex; }
  .main-content { padding: 20px 16px; }
  .cards-grid { grid-template-columns: 1fr; }
  .modal { width: calc(100vw - 32px); padding: 24px; }
  .deal-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 18px; }
  .table-toolbar { flex-direction: column; }
  .search-input { min-width: auto; }
  .ai-chat-container { height: calc(100vh - 40px); }
  .web-banner { flex-wrap: wrap; }
  .chat-panel-open {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100vw;
    z-index: 95;
  }
}

.alert-success {
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
  color: #16a34a;
}
