/* ============================================================
   InvoiceBase — Main Stylesheet
   Stack: Bootstrap 5 + Custom Design System
   ============================================================ */

:root {
  --brand-blue: #1a6ef5;
  --brand-blue-dark: #1458c8;
  --brand-yellow: #f5c518;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: rgba(26, 110, 245, 0.15);
  --sidebar-active-text: #60a5fa;
  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;
  --body-bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --status-paid: #16a34a;
  --status-unpaid: #d97706;
  --status-overdue: #dc2626;
  --status-partial: #7c3aed;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius: 0.75rem;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

.brand-icon { color: var(--brand-blue); font-size: 1.4rem; }
.brand-text { color: #fff; font-size: 1.1rem; letter-spacing: -0.02em; }

.brand-name {
  color: #ffa040;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.brand-sub {
  color: rgba(255,255,255,0.35);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.sidebar-link {
  color: var(--sidebar-text);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

.sidebar-link i { font-size: 1rem; flex-shrink: 0; }

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.disabled-pro {
  opacity: 0.55;
  pointer-events: none;
}

.badge-pro {
  font-size: 0.6rem;
  background: var(--brand-yellow);
  color: #000;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
}

.btn-upgrade {
  background: linear-gradient(135deg, var(--brand-blue), #6366f1);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  transition: opacity 0.2s;
}
.btn-upgrade:hover { opacity: 0.9; color: #fff; }

/* ── Main Content ─────────────────────────────────────────── */
#app-wrapper { padding-left: var(--sidebar-width); transition: padding 0.25s ease; }
#app-wrapper.sidebar-collapsed { padding-left: 0; }

.main-content { min-height: 100vh; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  background: transparent;
  border-radius: 0.5rem;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-blue), #6366f1);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-menu-btn {
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-primary);
  border-radius: 2rem;
  padding: 0.25rem 0.75rem;
}

.page-content { padding-top: 1.5rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Status Badges ────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 2rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-paid    { background: #dcfce7; color: var(--status-paid); }
.status-unpaid  { background: #fef3c7; color: var(--status-unpaid); }
.status-overdue { background: #fee2e2; color: var(--status-overdue); }
.status-partial { background: #ede9fe; color: var(--status-partial); }

/* ── Payment Risk ─────────────────────────────────────────── */
.risk-high   { color: var(--status-paid); }
.risk-medium { color: var(--status-unpaid); }
.risk-low    { color: var(--status-overdue); }

/* ── Tables ───────────────────────────────────────────────── */
.table {
  font-size: 0.875rem;
  --bs-table-bg: transparent;
}

.table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--card-border);
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover { background: #f8fafc; }

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  padding: 0.55rem 0.85rem;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(26,110,245,0.12);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.25rem;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--brand-blue-dark); border-color: var(--brand-blue-dark); }

.btn-outline-primary {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-outline-primary:hover {
  background: var(--brand-blue);
  color: #fff;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Pricing Cards ────────────────────────────────────────── */
.pricing-card {
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
  position: relative;
}

.pricing-card.selected,
.pricing-card:hover {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(26,110,245,0.1);
}

.pricing-card.best-offer {
  border-color: var(--brand-yellow);
}

.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-yellow);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 14px;
  border-radius: 2rem;
  white-space: nowrap;
}

.pricing-price {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--brand-blue);
}

.pricing-period {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pricing-original {
  text-decoration: line-through;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── AI Panel ─────────────────────────────────────────────── */
.ai-panel {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  border-radius: var(--radius);
  color: #fff;
  padding: 1.5rem;
  border: 1px solid rgba(26,110,245,0.3);
}

.ai-panel .form-control {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}

.ai-panel .form-control::placeholder { color: rgba(255,255,255,0.5); }
.ai-panel .form-control:focus {
  background: rgba(255,255,255,0.15);
  border-color: var(--brand-blue);
  color: #fff;
}

.ai-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-yellow);
  margin-bottom: 0.5rem;
}

/* ── Invoice Template Preview ─────────────────────────────── */
.template-option {
  border: 2px solid var(--card-border);
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.template-option:hover,
.template-option.selected {
  border-color: var(--brand-blue);
}

.template-option img { width: 100%; display: block; }

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1a6ef5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-logo {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand-blue);
  letter-spacing: -0.03em;
}

/* ── Invoice Document ─────────────────────────────────────── */
.invoice-document {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 3rem;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  font-size: 0.875rem;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  gap: 2rem;
}

.inv-logo { max-height: 56px; max-width: 160px; margin-bottom: 0.5rem; }
.inv-business-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.inv-address, .inv-meta-line { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }

.inv-title-block { text-align: right; }
.inv-title-word {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--inv-primary, var(--brand-blue));
  margin-bottom: 0.75rem;
}

.inv-meta-table { margin-left: auto; font-size: 0.8rem; }
.inv-meta-table td { padding: 2px 0 2px 1rem; }
.inv-meta-table td:first-child { color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.inv-meta-table td:last-child { font-weight: 600; text-align: right; }

.inv-bill-to { margin-bottom: 2rem; }
.inv-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.inv-client-name { font-size: 1rem; font-weight: 700; margin-bottom: 0.2rem; }

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
.inv-table thead tr {
  background: var(--inv-primary, var(--brand-blue));
  color: #fff;
}
.inv-table thead th {
  padding: 0.6rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inv-th-desc { width: 40%; }
.inv-th-num { text-align: right; }
.inv-table tbody td { padding: 0.65rem 0.85rem; border-bottom: 1px solid #f1f5f9; }
.inv-td-num { text-align: right; }
.inv-table tbody tr:last-child td { border-bottom: none; }

.inv-totals-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 2rem;
}
.inv-notes-block { flex: 1; }
.inv-notes-text { font-size: 0.82rem; color: var(--text-muted); line-height: 1.6; }

.inv-totals { min-width: 260px; }
.inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid #f1f5f9;
}
.inv-total-final {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  margin-top: 0.5rem;
  background: var(--inv-primary, var(--brand-blue));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 0.4rem;
}

.inv-terms { border-top: 1px solid var(--card-border); padding-top: 1rem; }
.inv-terms-text { font-size: 0.8rem; color: var(--text-muted); }

.inv-signature {
  border-top: 1px solid var(--card-border);
  padding-top: 1rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.inv-signature-img { max-height: 60px; max-width: 220px; display: block; }
.inv-signature-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Invoice Defaults active preset button */
.due-day-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.inv-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-20deg);
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  opacity: 0.12;
  pointer-events: none;
  border: 8px solid;
  padding: 0.25rem 1.5rem;
  border-radius: 0.5rem;
  white-space: nowrap;
}
.inv-stamp-paid { color: var(--status-paid); border-color: var(--status-paid); }
.inv-stamp-overdue { color: var(--status-overdue); border-color: var(--status-overdue); }

/* ── Reports ──────────────────────────────────────────────── */
.rpt-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

.rpt-avatar {
  width: 40px; height: 40px;
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--text-primary);
}

/* ── Print / PDF ──────────────────────────────────────────── */
@media print {
  .no-print,
  .sidebar,
  .topbar,
  #sidebarToggle,
  .btn,
  .alert {
    display: none !important;
  }

  #app-wrapper { padding-left: 0 !important; }
  .main-content { min-height: unset; }
  .page-content { padding: 0 !important; }

  .invoice-document {
    border: none !important;
    border-radius: 0 !important;
    padding: 1.5rem !important;
    max-width: 100% !important;
    box-shadow: none !important;
  }

  body { background: #fff !important; }
  .inv-stamp { opacity: 0.08 !important; }

  @page {
    margin: 1.5cm;
    size: A4;
  }
}

/* ── Logo Upload ──────────────────────────────────────────── */
.upload-drop-zone {
  border: 2px dashed var(--card-border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--body-bg);
}
.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--brand-blue);
  background: rgba(26, 110, 245, 0.05);
}
.logo-preview-wrap {
  display: inline-block;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--body-bg);
}
.logo-preview-img {
  max-height: 90px;
  max-width: 260px;
  object-fit: contain;
  display: block;
}
.logo-placeholder {
  padding: 1.5rem;
  border: 1px dashed var(--card-border);
  border-radius: 12px;
  background: var(--body-bg);
  display: inline-block;
  min-width: 160px;
}

/* ── Share ────────────────────────────────────────────────── */
.share-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  background: var(--body-bg);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  width: 100%;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.share-option-btn:hover {
  background: #eff6ff;
  border-color: var(--brand-blue);
  color: var(--text-primary);
}

/* ── Mobile Bottom Nav ────────────────────────────────────── */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.58rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 0.4rem;
  transition: color 0.15s;
  flex: 1;
}
.mobile-nav-item i { font-size: 1.15rem; display: block; }
.mobile-nav-item.active { color: var(--sidebar-active-text); }

.mobile-nav-fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(26,110,245,0.4);
  flex-shrink: 0;
  margin-bottom: 4px;
}
.mobile-nav-fab:hover { background: var(--brand-blue-dark); color: #fff; }

/* ── Sidebar Backdrop ─────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-backdrop.active { display: block; }

/* ── Brand Color Picker ───────────────────────────────────── */
.brand-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.brand-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  padding: 0;
}
.brand-swatch:hover { transform: scale(1.18); }
.brand-swatch.active {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor;
}
.brand-color-input {
  width: 52px;
  height: 52px;
  padding: 3px;
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.brand-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.brand-color-input::-webkit-color-swatch { border: none; border-radius: 0.35rem; }
.color-preview-bar {
  height: 52px;
  border-radius: 0.5rem;
  border: 1px solid var(--card-border);
  transition: background 0.2s;
}
.color-hex-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 5ch;
}

/* ── Font Option Cards ────────────────────────────────────── */
.font-option-card {
  display: block;
  border: 2px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 0.75rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card-bg);
}
.font-option-card:hover { border-color: var(--brand-blue); }
.font-option-card.selected {
  border-color: var(--brand-blue);
  background: rgba(26,110,245,0.05);
}
.foc-sample {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}
.foc-name { font-size: 0.72rem; font-weight: 600; color: var(--text-primary); }
.foc-desc { font-size: 0.62rem; color: var(--text-muted); }

/* ── Template Option Cards ────────────────────────────────── */
.tmpl-option-card {
  display: block;
  border: 2px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 0.75rem 0.6rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card-bg);
}
.tmpl-option-card:hover { border-color: var(--brand-blue); }
.tmpl-option-card.selected {
  border-color: var(--brand-blue);
  background: rgba(26,110,245,0.05);
}
.toc-name { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); margin-bottom: 1px; }
.toc-desc { font-size: 0.62rem; color: var(--text-muted); }

.toc-prev {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 7px 6px;
  height: 68px;
  margin-bottom: 8px;
  overflow: hidden;
}
.toc-hdr  { height: 11px; border-radius: 2px; margin-bottom: 5px; }
.toc-line { height: 3px; background: #e2e8f0; border-radius: 2px; margin-bottom: 3px; }
.toc-line-s { width: 58%; }
.toc-tot  { height: 9px; border-radius: 2px; margin-top: 5px; }

.toc-prev-classic .toc-hdr { background: var(--preview-color, #1a6ef5); }
.toc-prev-classic .toc-tot { background: var(--preview-color, #1a6ef5); }

.toc-prev-modern { border-left: 3px solid var(--preview-color, #1a6ef5); }
.toc-prev-modern .toc-hdr {
  background: #f1f5f9;
  height: 9px;
  border-bottom: 1.5px solid var(--preview-color, #1a6ef5);
}
.toc-prev-modern .toc-tot { background: var(--preview-color, #1a6ef5); }

.toc-prev-minimal .toc-hdr { background: #1e293b; }
.toc-prev-minimal .toc-tot { background: #1e293b; }

/* ── Invoice Template Styles ──────────────────────────────── */
.tmpl-modern {
  border-left: 5px solid var(--inv-primary, var(--brand-blue));
}
.tmpl-modern .inv-table thead tr { background: #f8fafc !important; }
.tmpl-modern .inv-table thead th {
  color: var(--text-primary) !important;
  border-bottom: 2px solid var(--inv-primary, var(--brand-blue));
}

.tmpl-minimal .inv-table thead tr { background: #1e293b !important; color: #fff !important; }
.tmpl-minimal .inv-total-final { background: #1e293b !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Sidebar: hidden by default, opens as overlay */
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  #app-wrapper { padding-left: 0; }

  /* Bottom nav spacing */
  main.page-content { padding-bottom: 5rem !important; }
  main.page-content { padding-left: 1rem !important; padding-right: 1rem !important; }

  /* Page header stacks on mobile */
  .page-header { flex-wrap: wrap; gap: 0.75rem; }
  .page-header .d-flex { flex-wrap: wrap; }
  .page-title { font-size: 1.15rem; }

  /* Stat cards */
  .stat-value { font-size: 1.3rem; }
  .stat-card { padding: 1rem; }

  /* Tables scroll horizontally */
  .card .table-responsive,
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* Invoice document */
  .invoice-document { padding: 1.25rem; border-radius: 0.5rem; }
  .inv-header { flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
  .inv-title-block { text-align: left; }
  .inv-title-word { font-size: 1.6rem; }
  .inv-meta-table { margin-left: 0; }
  .inv-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inv-table { min-width: 500px; }
  .inv-totals-wrapper { flex-direction: column; gap: 1rem; }
  .inv-totals { min-width: unset; width: 100%; }
  .inv-stamp { font-size: 2.5rem; }

  /* Auth cards */
  .auth-card { padding: 1.75rem 1.25rem; }

  /* Pricing cards stack */
  .pricing-card { padding: 1.25rem; }
}

/* ── Auth Split Layout (carousel + form) ─────────────────── */
.auth-outer {
  display: flex;
  min-height: 100vh;
}

/* Left feature panel — desktop only */
.auth-feature-panel {
  flex: 0 0 55%;
  background: linear-gradient(160deg, #0f172a 0%, #1a3a6a 55%, #1a6ef5 100%);
  flex-direction: column;
  padding: 2.5rem 3rem;
  position: relative;
  overflow: hidden;
}

/* Decorative blobs */
.auth-feature-panel::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(26,110,245,0.15);
  bottom: -100px;
  right: -80px;
  pointer-events: none;
}
.auth-feature-panel::after {
  content: '';
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: rgba(249,115,22,0.1);
  top: -60px;
  left: -40px;
  pointer-events: none;
}

.auth-panel-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  position: relative;
  z-index: 1;
}
.auth-panel-brand-name {
  color: #ffa040;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.auth-panel-brand-sub {
  color: rgba(255,255,255,0.45);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* Feature carousel */
.auth-carousel { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; }

.feat-slide { display: flex; flex-direction: column; height: 100%; }

.feat-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin-bottom: 1.75rem;
}

.feat-slide h2 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #fff;
  margin-bottom: 0.85rem;
}

.feat-slide p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  max-width: 360px;
}

.feat-points { list-style: none; padding: 0; margin: 0 0 2rem; }
.feat-points li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.875rem;
  margin-bottom: 0.55rem;
  font-weight: 500;
}
.feat-points li i { color: #34d399; font-size: 1rem; flex-shrink: 0; }

/* Carousel dot indicators */
.feat-dots {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-bottom: 0.5rem;
}
.feat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s;
}
.feat-dot.active {
  background: #fff;
  width: 26px;
  border-radius: 4px;
}

/* Panel footer */
.auth-panel-footer {
  position: relative;
  z-index: 1;
  margin-top: 2rem;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
}
.auth-panel-footer strong { color: rgba(255,255,255,0.6); }

/* Right form panel */
.auth-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  /* mobile: dark gradient (existing feel) */
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1a6ef5 100%);
}

@media (min-width: 992px) {
  .auth-form-panel { background: #f0f4fa; }
}

.auth-form-footer {
  margin-top: 1.5rem;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  text-align: center;
}
.auth-form-footer a { color: #f97316; text-decoration: none; }

@media (min-width: 992px) {
  .auth-form-footer { color: #94a3b8; }
}

/* ── Intro.js tour overrides ─────────────────────────────── */
.introjs-tooltip {
  border-radius: 0.875rem !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.875rem !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18) !important;
  padding: 1.25rem !important;
  min-width: 280px !important;
  max-width: 340px !important;
}

.introjs-tooltipTitle {
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  color: #0f172a !important;
  margin-bottom: 0.4rem !important;
}

.introjs-tooltiptext { color: #475569 !important; line-height: 1.55 !important; }

.introjs-button {
  border-radius: 0.5rem !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  padding: 0.45rem 1rem !important;
  text-shadow: none !important;
}

.introjs-nextbutton, .introjs-donebutton {
  background: #1a6ef5 !important;
  border-color: #1458c8 !important;
  color: #fff !important;
}
.introjs-nextbutton:hover, .introjs-donebutton:hover {
  background: #1458c8 !important;
  color: #fff !important;
}

.introjs-prevbutton {
  background: #fff !important;
  border-color: #d1d5db !important;
  color: #374151 !important;
}

.introjs-progressbar { background-color: #1a6ef5 !important; }

.introjs-helperLayer { border-radius: 0.75rem !important; }

.introjs-overlay { opacity: 0.6 !important; }

/* ── Coming Soon badge ───────────────────────────────────── */
.soon-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 4px;
  white-space: nowrap;
}

/* Tour trigger link */
.tour-link {
  font-size: 0.78rem;
  color: #94a3b8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}
.tour-link:hover { color: var(--brand-blue); }
