:root {
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-primary-soft: rgba(37, 99, 235, 0.1);
  --brand-accent: #0ea5e9;
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-sidebar: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;

  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;

  --info: #3b82f6;
  --info-bg: #dbeafe;
  --info-text: #1e40af;

  --purple: #8b5cf6;
  --purple-bg: #ede9fe;
  --purple-text: #5b21b6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.14);
  --doc-accent: #2563eb;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #1e293b;
  --bg-elevated: #0f172a;
  --bg-sidebar: #090d16;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-strong: #475569;

  --success-bg: rgba(16, 185, 129, 0.18);
  --success-text: #34d399;
  --warning-bg: rgba(245, 158, 11, 0.18);
  --warning-text: #fbbf24;
  --danger-bg: rgba(239, 68, 68, 0.18);
  --danger-text: #f87171;
  --info-bg: rgba(59, 130, 246, 0.18);
  --info-text: #60a5fa;
  --purple-bg: rgba(139, 92, 246, 0.18);
  --purple-text: #c4b5fd;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Layout Shell */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 30;
  user-select: none;
}

.brand-header {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 19px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.5);
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title .orijen-brand-red {
  font-size: 16.5px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #ff1e1e;
  text-shadow: 0 2px 10px rgba(255, 30, 30, 0.4);
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-title h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
}

.brand-title span {
  font-size: 10.5px;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.topbar-orijen-badge {
  font-size: 18px;
  font-weight: 900;
  color: #dc2626;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(220, 38, 38, 0.15);
}

.sidebar-quick-cta {
  padding: 16px 14px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-quick-est,
.btn-quick-inv {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.18s ease;
}

.btn-quick-est {
  background: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-quick-est:hover {
  background: rgba(14, 165, 233, 0.28);
}

.btn-quick-inv {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-quick-inv:hover {
  background: var(--brand-primary-hover);
}

.nav-menu {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 10px 10px 4px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.9) 0%, rgba(29, 78, 216, 0.85) 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Main Content Area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.page-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.global-search-wrap {
  position: relative;
  max-width: 380px;
  width: 100%;
}

.global-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.global-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 13px;
  transition: all 0.15s ease;
}

.global-search-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
}

.btn-accent {
  background: #0ea5e9;
  color: #ffffff;
}

.btn-accent:hover {
  background: #0284c7;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 5px;
}

/* Content Container */
.content-body {
  padding: 24px 26px 48px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brand-primary);
}

.kpi-card.kpi-success::before { background: var(--success); }
.kpi-card.kpi-warning::before { background: var(--warning); }
.kpi-card.kpi-danger::before { background: var(--danger); }
.kpi-card.kpi-purple::before { background: var(--purple); }

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.75fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Filter Bar */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.filter-pill.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-elevated);
}

.doc-number-cell {
  font-weight: 700;
  color: var(--brand-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.doc-number-cell:hover {
  text-decoration: underline;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-purple { background: var(--purple-bg); color: var(--purple-text); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Convert 1-Click Highlight Button */
.btn-convert-oneclick {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  transition: all 0.15s ease;
}

.btn-convert-oneclick:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.45);
}

/* Action Group in Table */
.row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  padding: 8.5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
}

/* Document Editor Workspace (Split View or Full Editor) */
.editor-workspace {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: start;
}

/* Line Items Editor Table */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.line-items-table th {
  background: var(--bg-elevated);
  padding: 9px 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.line-items-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.line-items-table input,
.line-items-table select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
}

.line-items-table input:focus,
.line-items-table select:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.totals-summary-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.totals-row.grand-total {
  border-top: 2px solid var(--border-strong);
  padding-top: 10px;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

/* Live ORIJEN TOOLS Paper Preview */
.preview-sticky-pane {
  position: sticky;
  top: 84px;
}

.invoice-paper {
  background: #ffffff;
  color: #0f172a;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  border: 1px solid #cbd5e1;
  padding: 36px 38px;
  min-height: 760px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  font-size: 12.5px;
}

.invoice-paper.template-modern .paper-top-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: var(--doc-accent, #2563eb);
}

.invoice-paper.template-executive {
  border-top: 6px solid #0f172a;
}

.invoice-paper.template-minimal {
  box-shadow: var(--shadow-md);
}

/* Stamp Watermark */
.paper-stamp {
  position: absolute;
  top: 145px;
  right: 45px;
  border: 3px solid currentColor;
  padding: 4px 14px;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border-radius: 6px;
  transform: rotate(-10deg);
  opacity: 0.22;
  pointer-events: none;
}

.paper-stamp.stamp-paid { color: #059669; }
.paper-stamp.stamp-approved { color: #2563eb; }
.paper-stamp.stamp-overdue { color: #dc2626; }
.paper-stamp.stamp-converted { color: #7c3aed; }

.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 22px;
}

.paper-company-logo {
  max-height: 58px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 8px;
}

.paper-doc-badge {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--doc-accent, #2563eb);
  text-transform: uppercase;
  text-align: right;
}

.paper-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.paper-party-box h4 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 4px;
}

.paper-party-box .party-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.paper-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
}

.paper-meta-item span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}

.paper-meta-item strong {
  font-size: 12px;
  color: #0f172a;
}

.paper-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.paper-table th {
  background: var(--doc-accent, #2563eb);
  color: #ffffff;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
}

.invoice-paper.template-minimal .paper-table th {
  background: transparent;
  color: #0f172a;
  border-bottom: 2px solid #0f172a;
}

.paper-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: 12px;
}

.paper-totals-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-top: 10px;
}

.paper-notes-col {
  flex: 1;
  font-size: 11.5px;
  color: #475569;
}

.paper-totals-col {
  width: 250px;
}

.paper-total-line {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12px;
  color: #334155;
}

.paper-total-line.final {
  border-top: 2px solid #0f172a;
  margin-top: 6px;
  padding-top: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--doc-accent, #2563eb);
}

.paper-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
  color: #64748b;
}

.signature-box {
  text-align: center;
  min-width: 160px;
}

.signature-line {
  border-top: 1px solid #94a3b8;
  padding-top: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

/* Modal System */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn 0.18s ease-out;
}

.modal-dialog.modal-xl {
  max-width: 1020px;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--brand-primary);
  animation: modalSlideIn 0.2s ease;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-danger { border-left-color: var(--danger); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 42px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  color: var(--text-main);
  font-size: 16px;
  margin-bottom: 6px;
}

/* Bar Chart styles */
.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 210px;
  padding: 20px 8px 6px;
  border-bottom: 1px solid var(--border-color);
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  width: 100%;
  justify-content: center;
}

.chart-bar {
  width: 16px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
  min-height: 4px;
}

.chart-bar.income { background: var(--brand-primary); }
.chart-bar.expense { background: #f43f5e; opacity: 0.8; }

.chart-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Mobile Bottom Navigation Bar & Device Mode Support (Celular y PC) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-sidebar);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
  padding: 4px 6px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
}

.mobile-nav-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  flex: 1;
}

.mobile-nav-btn span.m-icon {
  font-size: 18px;
  line-height: 1;
}

.mobile-nav-btn.active {
  color: #ffffff;
  background: rgba(220, 38, 38, 0.25);
}

.mobile-nav-btn.fab-create {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.45);
}

.mobile-menu-toggle {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
}

/* Forced Mobile View on PC (Simulador Modo Celular en PC) */
body.force-mobile-view {
  background: #090d16;
}

body.force-mobile-view .app-shell {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  grid-template-columns: 1fr;
  background: var(--bg-app);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 20px 60px rgba(0,0,0,0.6);
  position: relative;
}

body.force-mobile-view .sidebar {
  display: none;
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-220px);
  width: 280px;
  height: 100vh;
  z-index: 120;
}

body.force-mobile-view .sidebar.mobile-open {
  display: flex;
}

body.force-mobile-view .mobile-menu-toggle {
  display: inline-flex;
}

body.force-mobile-view .mobile-bottom-nav {
  display: flex;
  max-width: 440px;
  margin: 0 auto;
}

body.force-mobile-view .content-body {
  padding: 14px 12px 84px;
}

body.force-mobile-view .topbar {
  padding: 0 12px;
  height: 58px;
}

body.force-mobile-view .page-heading,
body.force-mobile-view .topbar-right .btn-accent,
body.force-mobile-view .topbar-right .btn-primary {
  display: none;
}

body.force-mobile-view .editor-workspace,
body.force-mobile-view .dashboard-grid,
body.force-mobile-view .kpi-grid {
  grid-template-columns: 1fr;
}

body.force-mobile-view .col-8,
body.force-mobile-view .col-6,
body.force-mobile-view .col-5,
body.force-mobile-view .col-4,
body.force-mobile-view .col-3 {
  grid-column: span 12;
}

body.force-mobile-view .paper-parties,
body.force-mobile-view .paper-totals-wrap {
  grid-template-columns: 1fr;
  flex-direction: column;
}

body.force-mobile-view .paper-totals-col {
  width: 100%;
}

body.force-mobile-view .invoice-paper {
  padding: 18px 14px;
  min-height: auto;
}

/* Responsive (Automático en Teléfonos / Tablets) */
@media (max-width: 1150px) {
  .editor-workspace,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .preview-sticky-pane {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 275px;
    height: 100vh;
    z-index: 120;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.45);
  }
  .sidebar.mobile-open {
    display: flex;
  }
  .mobile-menu-toggle {
    display: inline-flex;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .content-body {
    padding: 14px 12px 84px;
  }
  .topbar {
    padding: 0 12px;
    height: 58px;
  }
  .page-heading {
    display: none;
  }
  .topbar-orijen-badge {
    font-size: 19px;
  }
  .col-8, .col-6, .col-5, .col-4, .col-3 {
    grid-column: span 12;
  }
  .form-control {
    font-size: 16px; /* Evita auto-zoom en celulares iOS/Android */
    min-height: 42px;
  }
  .paper-parties,
  .paper-totals-wrap {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
  .paper-totals-col {
    width: 100%;
  }
  .invoice-paper {
    padding: 18px 14px;
    min-height: auto;
  }
  .modal-backdrop {
    padding: 8px;
  }
  .modal-body {
    padding: 14px;
  }
}

/* PRINT / PDF EXPORT MODE */
@media print {
  @page {
    size: letter;
    margin: 10mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sidebar,
  .topbar,
  .no-print,
  .editor-form-pane,
  .toast-container {
    display: none !important;
  }

  .app-shell,
  .main-area,
  .content-body,
  .editor-workspace {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .modal-backdrop {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .modal-dialog {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    max-height: none !important;
  }

  .modal-header,
  .modal-footer {
    display: none !important;
  }

  .modal-body {
    padding: 0 !important;
    overflow: visible !important;
  }

  .invoice-paper {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    min-height: auto !important;
    width: 100% !important;
  }
}
