/* ============================================================
   MasterInvoice - Professional Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- Variables ---- */
:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e40af;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --success-light: #d1fae5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0284c7;
  --info-light: #e0f2fe;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ============================================================
   AUTH SCREENS
   ============================================================ */
#auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
  padding: 24px;
}
.auth-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}
.auth-logo span { color: var(--accent); }
.auth-logo p { color: var(--text-muted); font-size: .875rem; margin-top: 4px; }
.auth-tab {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}
.auth-tab button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form h3 { font-size: 1.25rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .8125rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border-left: 3px solid var(--danger);
  display: none;
}
.auth-success {
  background: var(--success-light);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border-left: 3px solid var(--success);
  display: none;
}

/* Company Setup Screen */
#company-setup-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
  padding: 24px;
}
.setup-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
}
.setup-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.setup-box > p { color: var(--text-muted); font-size: .9375rem; margin-bottom: 28px; }
.setup-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: var(--transition);
}
.step-dot.active { background: var(--primary); width: 24px; border-radius: 4px; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app-container {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo h1 {
  font-size: 1.375rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
}
.sidebar-logo h1 span { color: var(--accent); }
.sidebar-logo p { font-size: .75rem; color: var(--sidebar-text); margin-top: 2px; }
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-section-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 12px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .875rem;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-info strong {
  display: block;
  font-size: .8125rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-info span { font-size: .75rem; color: var(--sidebar-text); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
}
.main-header h2 {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.content-area { padding: 24px; flex: 1; }

/* ============================================================
   COMPONENTS - Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(30,64,175,.3); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: .8125rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   COMPONENTS - Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   COMPONENTS - Stats Cards
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-info { min-width: 0; }
.stat-value { font-size: 1.625rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-label { font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }
.stat-trend { font-size: .75rem; margin-top: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================================
   COMPONENTS - Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-sent { background: var(--info-light); color: var(--info); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }
.badge-accepted { background: var(--success-light); color: var(--success); }
.badge-rejected { background: var(--danger-light); color: var(--danger); }
.badge-pending { background: var(--warning-light); color: var(--warning); }

/* ============================================================
   COMPONENTS - Data Table
   ============================================================ */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #f8fafc;
}
.data-table th:first-child { border-radius: 8px 0 0 0; }
.data-table th:last-child { border-radius: 0 8px 0 0; }
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-actions { text-align: right; white-space: nowrap; }
.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.table-empty svg { margin: 0 auto 12px; opacity: .3; }
.table-empty p { font-size: .9375rem; }

/* ============================================================
   COMPONENTS - Search & Filters
   ============================================================ */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: #fff;
  outline: none;
  transition: var(--transition);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.filter-select {
  padding: 9px 32px 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat calc(100% - 10px) center;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ============================================================
   COMPONENTS - Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(.97);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.125rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   COMPONENTS - Toast Notifications
   ============================================================ */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .2s ease;
  border-left: 4px solid rgba(255,255,255,.2);
}
.toast.success { border-left-color: #34d399; }
.toast.error { border-left-color: #f87171; }
.toast.info { border-left-color: #60a5fa; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ============================================================
   INVOICE EDITOR
   ============================================================ */
.invoice-editor { display: flex; gap: 24px; align-items: flex-start; }
.editor-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.editor-sidebar { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }

/* Line Items */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  text-align: left;
}
.items-table td { padding: 8px 6px; vertical-align: middle; }
.items-table input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: transparent;
  outline: none;
  transition: var(--transition);
}
.items-table input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.items-table .col-desc { width: 45%; }
.items-table .col-qty { width: 12%; }
.items-table .col-price { width: 18%; }
.items-table .col-total { width: 18%; text-align: right; font-weight: 600; }
.items-table .col-del { width: 40px; text-align: center; }
.item-row:hover td input { background: #f8fafc; }
.btn-remove-item {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.btn-remove-item:hover { color: var(--danger); background: var(--danger-light); }
.items-subtotals {
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}
.subtotal-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding: 4px 8px;
  font-size: .9rem;
}
.subtotal-row span:first-child { color: var(--text-muted); }
.subtotal-row span:last-child { font-weight: 600; min-width: 100px; text-align: right; }
.subtotal-row.total-row {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 4px;
}
.subtotal-row.total-row span:first-child { color: rgba(255,255,255,.8); }
.subtotal-row.total-row span:last-child { font-size: 1.125rem; }

/* Totals inputs */
.totals-inputs { display: flex; flex-direction: column; gap: 10px; }
.totals-inputs .form-group label { font-size: .75rem; }

/* ============================================================
   INVOICE PREVIEW / PRINT TEMPLATE
   ============================================================ */
#invoice-preview {
  background: #fff;
  max-width: 860px;
  margin: 0 auto;
  padding: 0;
}
.invoice-doc {
  padding: 48px;
  font-size: .9rem;
  color: #1a1a1a;
}
.invoice-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 3px solid var(--primary);
}
.company-info h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}
.company-info p { font-size: .85rem; color: #555; line-height: 1.7; }
.invoice-meta { text-align: right; }
.invoice-meta h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  text-transform: uppercase;
}
.invoice-meta .inv-number { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.invoice-meta p { font-size: .85rem; color: #555; line-height: 1.7; }
.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.party-block h4 {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--primary-light);
  padding-bottom: 4px;
}
.party-block strong { display: block; font-size: 1rem; margin-bottom: 4px; }
.party-block p { font-size: .85rem; color: #555; line-height: 1.7; }
.invoice-items-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-items-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  font-size: .8125rem;
  font-weight: 600;
  text-align: left;
}
.invoice-items-table th:last-child { text-align: right; }
.invoice-items-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #e8ecf0;
  font-size: .875rem;
}
.invoice-items-table td:last-child { text-align: right; font-weight: 600; }
.invoice-items-table tbody tr:nth-child(even) { background: #f8fafc; }
.invoice-totals-block {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 32px;
}
.invoice-totals-inner { min-width: 280px; }
.totals-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: .875rem;
  border-bottom: 1px solid #e8ecf0;
}
.totals-line.grand {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 1.0625rem;
  font-weight: 700;
  border-bottom: none;
  margin-top: 6px;
}
.invoice-notes-block { margin-bottom: 24px; }
.invoice-notes-block h4 { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); margin-bottom: 6px; }
.invoice-notes-block p { font-size: .8125rem; color: #555; line-height: 1.7; white-space: pre-wrap; }
.invoice-policies-block {
  border: 1.5px solid #e0e0e0;
  border-radius: var(--radius-sm);
  padding: 16px;
  background: #fafafa;
  margin-top: 16px;
}
.invoice-policies-block h4 { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--danger); margin-bottom: 8px; }
.invoice-policies-block p { font-size: .75rem; color: #666; line-height: 1.8; white-space: pre-wrap; }
.invoice-doc-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #e8ecf0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
  color: #999;
}
.status-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%) rotate(-30deg);
  font-size: 5rem;
  font-weight: 900;
  opacity: .04;
  text-transform: uppercase;
  pointer-events: none;
  letter-spacing: -2px;
}

/* ============================================================
   REPORTS
   ============================================================ */
.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.chart-container { position: relative; height: 280px; }
.report-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.quick-action-card {
  flex: 1;
  min-width: 200px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  text-align: left;
}
.quick-action-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(30,64,175,.3); }
.quick-action-card.accent { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.quick-action-card strong { display: block; font-size: 1rem; font-weight: 700; }
.quick-action-card span { font-size: .8125rem; opacity: .85; }
.quick-action-icon { width: 44px; height: 44px; background: rgba(255,255,255,.15); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
/* ============================================================
   GLOBAL SEARCH
   ============================================================ */
.global-search-wrap {
  position: relative;
  flex: 1;
  max-width: 380px;
  margin: 0 12px;
}
.global-search-wrap .search-box input {
  background: var(--bg);
  width: 100%;
}
.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-height: 400px;
  overflow-y: auto;
}
.search-result-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.search-result-section:last-child { border-bottom: none; }
.search-result-label {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 6px 14px 4px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.search-result-item:hover { background: var(--bg); }
.search-result-item .sri-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .75rem;
  font-weight: 700;
}
.sri-icon.inv { background: var(--primary-light); color: var(--primary); }
.sri-icon.qt { background: var(--warning-light); color: var(--warning); }
.sri-icon.cl { background: var(--success-light); color: var(--success); }
.search-result-item .sri-main { flex: 1; min-width: 0; }
.search-result-item .sri-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item .sri-sub {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item .sri-amount { font-size: .8125rem; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.search-no-results { padding: 20px 14px; text-align: center; color: var(--text-muted); font-size: .875rem; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 99;
}

/* ============================================================
   LOADING
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.9);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-sm { font-size: .875rem; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h3 { font-size: 1rem; font-weight: 700; }
.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.page-subtitle { font-size: .9rem; color: var(--text-muted); margin-bottom: 24px; }

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: .9rem;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 20px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  left: 3px; top: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================================
   PRINT STYLES — Black & White
   ============================================================ */
@page {
  margin: 12mm;       /* quita la fecha/URL/pagina del navegador */
  size: letter portrait;
}
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff !important; color: #000 !important; }
  #app-container, .sidebar, .main-header, .no-print, #toast-container { display: none !important; }
  #print-area { display: block !important; }
  .invoice-doc { padding: 32px !important; box-shadow: none !important; }
  /* Header: black border instead of blue background */
  .invoice-doc-header { border-bottom: 3px solid #000 !important; }
  .company-info h2 { color: #000 !important; }
  .invoice-meta h1 { color: #000 !important; }
  .invoice-meta .inv-number { color: #333 !important; }
  /* Party block headers */
  .party-block h4 { color: #000 !important; border-bottom-color: #ccc !important; }
  /* Table header: black instead of blue */
  .invoice-items-table th { background: #1a1a1a !important; color: #fff !important; }
  .invoice-items-table tbody tr:nth-child(even) { background: #f5f5f5 !important; }
  /* Totals */
  .totals-line.grand { background: #1a1a1a !important; color: #fff !important; }
  /* Badges: remove color, just text */
  .badge { background: #eee !important; color: #000 !important; border: 1px solid #999 !important; }
  /* Notes/policies */
  .invoice-notes-block h4 { color: #000 !important; }
  .invoice-policies-block { border-color: #999 !important; background: #f9f9f9 !important; }
  .invoice-policies-block h4 { color: #000 !important; }
  /* Footer */
  .invoice-doc-footer { color: #555 !important; border-top-color: #ccc !important; }
}

/* ============================================================
   RESPONSIVE - Tablet
   ============================================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .reports-grid { grid-template-columns: 1fr; }
  .invoice-editor { flex-direction: column; }
  .editor-sidebar { width: 100%; }
}

/* ============================================================
   RESPONSIVE - Mobile
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .global-search-wrap { max-width: none; margin: 0 8px; }
  .global-search-wrap .search-box input { font-size: .8125rem; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 1.25rem; }
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .table-toolbar { padding: 12px 16px; }
  .auth-box { padding: 32px 24px; }
  .setup-box { padding: 32px 24px; }
  .quick-actions { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .invoice-parties { grid-template-columns: 1fr; gap: 16px; }
  .invoice-doc { padding: 24px; }
  .invoice-doc-header { flex-direction: column; gap: 16px; }
  .invoice-meta { text-align: left; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
