* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; color: #333; line-height: 1.5; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid #e5e7eb; margin: 20px 0; }
.hidden { display: none !important; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0066cc 0%, #004999 100%); padding: 20px; }
.login-card { background: white; border-radius: 16px; padding: 48px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-card h1 { font-size: 28px; margin-bottom: 8px; color: #111827; }
.login-card > p { color: #6b7280; margin-bottom: 32px; }
.btn-microsoft { display: inline-flex; align-items: center; gap: 12px; padding: 14px 28px; background: #2f2f2f; color: white; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: all 0.15s; }
.btn-microsoft:hover { background: #1a1a1a; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.login-note { margin-top: 24px; font-size: 13px; color: #9ca3af; }

/* Loading */
.loading-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.95); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.spinner { width: 48px; height: 48px; border: 4px solid #e5e7eb; border-top-color: #0066cc; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen p { margin-top: 16px; color: #6b7280; }

/* Header */
.header { background: linear-gradient(135deg, #0066cc 0%, #004999 100%); color: white; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.logo { font-size: 22px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 14px; opacity: 0.9; }
.btn-header { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.btn-header:hover { background: rgba(255,255,255,0.25); }

/* Layout */
.app-container { display: flex; height: calc(100vh - 56px); }
.sidebar { width: 260px; background: white; border-right: 1px solid #e5e7eb; padding: 16px 0; overflow-y: auto; flex-shrink: 0; }
.sidebar-section { padding: 0 12px; margin-bottom: 20px; }
.sidebar-title { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; margin-bottom: 8px; padding: 0 12px; letter-spacing: 0.5px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: #374151; transition: all 0.15s; }
.sidebar-item:hover { background: #f3f4f6; }
.sidebar-item.active { background: #e6f0ff; color: #0066cc; font-weight: 500; }
.sidebar-item .count { margin-left: auto; font-size: 12px; background: #e5e7eb; padding: 2px 8px; border-radius: 10px; color: #6b7280; }
.sidebar-item.active .count { background: #cce0ff; color: #0066cc; }
.main-content { flex: 1; padding: 24px; overflow-y: auto; }

/* Buttons */
.btn { padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 8px; transition: all 0.15s; }
.btn-primary { background: #0066cc; color: white; }
.btn-primary:hover { background: #0055aa; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,102,204,0.3); }
.btn-secondary { background: white; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: #059669; color: white; }
.btn-success:hover { background: #047857; }
.btn-warning { background: #d97706; color: white; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 18px; }

/* Page Header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.page-header h1 { font-size: 26px; font-weight: 600; color: #111827; }
.page-header h2 { font-size: 20px; font-weight: 600; color: #111827; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; border: 1px solid #e5e7eb; }
.stat-card.stat-danger { border-color: #fecaca; background: #fef2f2; }
.stat-card.stat-success { border-color: #bbf7d0; background: #f0fdf4; }
.stat-card.stat-warning { border-color: #fde68a; background: #fffbeb; }
.stat-label { font-size: 13px; color: #6b7280; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; color: #111827; }
.stat-sub { font-size: 13px; color: #9ca3af; margin-top: 2px; }

/* Cards */
.card { background: white; border-radius: 12px; padding: 20px; border: 1px solid #e5e7eb; margin-bottom: 16px; }
.card h3 { font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 12px; }

/* Data Table */
.data-table { background: white; border-radius: 12px; border: 1px solid #e5e7eb; overflow: hidden; margin-top: 16px; }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f9fafb; padding: 14px 16px; text-align: left; font-size: 12px; text-transform: uppercase; color: #6b7280; font-weight: 600; letter-spacing: 0.5px; border-bottom: 1px solid #e5e7eb; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table td.empty-cell { text-align: center; color: #6b7280; padding: 40px; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { padding: 6px 10px; font-size: 12px; border-radius: 6px; cursor: pointer; background: white; border: 1px solid #e5e7eb; color: #6b7280; transition: all 0.15s; }
.row-actions button:hover { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.row-actions button.danger:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* Info Table */
.info-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.info-table th, .info-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
.info-table th { background: #f9fafb; font-weight: 600; }

/* Badges */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #f3f4f6; color: #6b7280; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-danger { background: #fef2f2; color: #dc2626; }
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-info { background: #dbeafe; color: #1d4ed8; }
.status-warning { background: #fff7ed; color: #c2410c; }

/* Document type badges */
.doc-type-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.doc-type-badge.invoice { background: #dbeafe; color: #1d4ed8; }
.doc-type-badge.estimate { background: #fef3c7; color: #92400e; }
.doc-type-badge.work_order { background: #ede9fe; color: #6d28d9; }

/* Locked indicator */
.locked-banner { background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 16px; margin-bottom: 16px; font-size: 13px; color: #92400e; display: flex; align-items: center; gap: 8px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: white; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal.wide { max-width: 720px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: #9ca3af; line-height: 1; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: #374151; }
.modal-body { padding: 24px; }
.modal-body h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #374151; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 12px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: #374151; }
.req { color: #dc2626; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; transition: all 0.15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #0066cc; box-shadow: 0 0 0 3px rgba(0,102,204,0.1); }
.form-group textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.form-row .form-group { margin-bottom: 0; }
.helper { font-size: 13px; color: #6b7280; margin-top: 6px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: #374151; }
.checkbox-label input { width: 18px; height: 18px; cursor: pointer; }

/* Filter Bar */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .search-input { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
.search-input { min-width: 240px; flex: 1; }

/* Document Form */
.doc-form-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.doc-form-left { }
.doc-form-right { }
.totals-card { position: sticky; top: 24px; }
.totals-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.totals-row.total-final { border-top: 2px solid #111827; padding-top: 12px; margin-top: 8px; font-size: 18px; font-weight: 700; }
.discount-input { display: flex; gap: 4px; align-items: center; }
.discount-input select { width: 50px; padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.discount-input input { width: 90px; padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; text-align: right; }

/* Line Items */
.line-item-row { display: flex; gap: 8px; padding: 6px 0; align-items: center; border-bottom: 1px solid #f3f4f6; }
.line-item-row .li-desc { flex: 3; padding: 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; }
.line-item-row .li-qty { width: 70px; padding: 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; text-align: center; }
.line-item-row .li-price { width: 100px; padding: 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; text-align: right; }
.line-item-row .li-amount { width: 90px; text-align: right; font-size: 13px; font-weight: 500; }
.line-item-row .li-tax-label { width: 52px; text-align: center; font-size: 12px; color: #6b7280; display: flex; align-items: center; gap: 3px; }
.line-item-row .li-tax-label input { width: 15px; height: 15px; }
.btn-remove-line { width: 34px; height: 34px; border: 1px solid #e5e7eb; border-radius: 6px; background: white; cursor: pointer; font-size: 18px; color: #9ca3af; display: flex; align-items: center; justify-content: center; }
.btn-remove-line:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* Document View */
.doc-view-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.doc-view-main { }
.doc-view-sidebar { }
.doc-header-info { display: flex; justify-content: space-between; margin-bottom: 16px; font-size: 14px; line-height: 1.6; }
.doc-actions-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

/* Activity Log */
.activity-log { }
.activity-item { padding: 8px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-time { display: block; color: #9ca3af; font-size: 11px; }
.activity-action { font-weight: 500; color: #374151; }
.activity-detail { color: #6b7280; margin-left: 4px; }

/* Report Tabs */
.report-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: #6b7280; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: #374151; margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* Pie Chart (CSS only) */
.pie-chart-container { display: flex; gap: 32px; align-items: center; justify-content: center; padding: 24px 0; flex-wrap: wrap; }
.pie-chart { width: 200px; height: 200px; border-radius: 50%; position: relative; }
.pie-legend { display: flex; flex-direction: column; gap: 10px; }
.pie-legend-item { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.pie-legend-color { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.pie-legend-value { font-weight: 600; margin-left: auto; padding-left: 12px; }

/* Profit bar */
.profit-bar-container { margin: 16px 0; }
.profit-bar { height: 32px; border-radius: 8px; background: #e5e7eb; position: relative; overflow: hidden; }
.profit-bar-fill { height: 100%; border-radius: 8px; display: flex; align-items: center; padding: 0 12px; font-size: 13px; font-weight: 600; color: white; }
.profit-bar-fill.positive { background: linear-gradient(90deg, #059669, #34d399); }
.profit-bar-fill.negative { background: linear-gradient(90deg, #dc2626, #f87171); }

/* CSV Import */
.import-dropzone { border: 2px dashed #d1d5db; border-radius: 12px; padding: 40px; text-align: center; cursor: pointer; transition: all 0.2s; color: #6b7280; }
.import-dropzone:hover { border-color: #0066cc; background: #f0f7ff; color: #0066cc; }
.import-dropzone input[type="file"] { display: none; }
.import-preview { max-height: 300px; overflow: auto; margin-top: 16px; font-size: 13px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: white; padding: 14px 20px; border-radius: 10px; font-size: 14px; display: none; z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.toast.show { display: flex; align-items: center; gap: 10px; animation: slideIn 0.2s ease; }
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 1024px) {
    .doc-form-grid { grid-template-columns: 1fr; }
    .doc-view-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .controls { flex-direction: column; align-items: stretch; }
}
@media (max-width: 600px) {
    .sidebar { display: none; }
    .app-container { flex-direction: column; }
}

/* Missing styles - added for new features */
.status-overdue { background: #fef2f2; color: #dc2626; font-weight: 600; }
.status-ready { background: #dcfce7; color: #166534; }

/* Report layout */
.report-layout { display: flex; gap: 24px; }
.report-nav { width: 220px; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.report-nav-section { font-size: 11px; text-transform: uppercase; color: #6b7280; font-weight: 600; padding: 8px 12px 4px; letter-spacing: 0.5px; }
.report-btn { display: flex; flex-direction: column; align-items: flex-start; padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 8px; background: white; cursor: pointer; font-size: 13px; font-weight: 500; color: #374151; transition: all 0.15s; text-align: left; }
.report-btn:hover { border-color: #0066cc; background: #f0f7ff; }
.report-btn.active { border-color: #0066cc; background: #e6f0ff; color: #0066cc; }
.report-btn span { font-size: 11px; color: #9ca3af; font-weight: 400; margin-top: 1px; }
.report-btn.active span { color: #60a5fa; }
.report-content { flex: 1; min-width: 0; }

/* Report Date Bar */
.report-date-bar { background: white; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.date-presets { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.date-preset-btn { padding: 6px 14px; border: 1px solid #d1d5db; border-radius: 6px; background: white; cursor: pointer; font-size: 13px; color: #374151; transition: all 0.15s; font-weight: 500; }
.date-preset-btn:hover { border-color: #0066cc; background: #f0f7ff; color: #0066cc; }
.date-preset-btn.active { background: #0066cc; color: white; border-color: #0066cc; }
.date-separator { color: #d1d5db; padding: 0 4px; font-size: 18px; }
#customDateRange input[type="date"] { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }

/* Report Action Bar */
.report-action-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.report-action-bar h2 { font-size: 18px; font-weight: 600; color: #111827; }
.report-actions { display: flex; gap: 8px; }

/* Report Section */
.report-section { margin-top: 20px; }
.report-section h3 { font-size: 15px; font-weight: 600; color: #111827; margin-bottom: 8px; }

/* Aging Styles */
.aging-section { margin-bottom: 20px; }
.aging-days { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.aging-mild { background: #fef3c7; color: #92400e; }
.aging-warning { background: #ffedd5; color: #c2410c; }
.aging-severe { background: #fef2f2; color: #dc2626; }

/* P&L Rows */
.pl-row-revenue td { background: #f0fdf4; }
.pl-row-cost td { background: #fef2f2; }
.pl-row-profit td { background: #f0f7ff; font-weight: 600; }
.pl-row-collected td { background: #f0fdf4; }
.pl-row-separator td { height: 4px; padding: 0; border: none; }

/* Matrix Grand Total */
.matrix-grand-total td { background: #f9fafb; font-weight: 700; border-top: 2px solid #111827; }

/* YoY Change */
.yoy-change td { border-top: 1px solid #e5e7eb; }

/* Mini Progress Bar */
.mini-bar { display: inline-block; width: 80px; height: 6px; background: #e5e7eb; border-radius: 3px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: #0066cc; border-radius: 3px; }

/* Settings grid */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; }

/* Card base */
.card { background: white; border-radius: 12px; border: 1px solid #e5e7eb; padding: 20px; }
.card h3 { font-size: 16px; font-weight: 600; color: #111827; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f3f4f6; }

/* Logo Upload */
.logo-upload-area { border: 2px dashed #d1d5db; border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.15s; background: #f9fafb; position: relative; }
.logo-upload-area:hover { border-color: #0066cc; background: #f0f7ff; }
.logo-upload-area.has-logo { border-style: solid; border-color: #e5e7eb; background: white; cursor: default; }
.logo-upload-area input[type="file"] { display: none; }
.logo-preview { max-width: 350px; max-height: 150px; display: block; margin: 0 auto; }
.logo-placeholder { color: #6b7280; }
.logo-placeholder .icon { font-size: 32px; margin-bottom: 8px; }
.logo-placeholder p { font-size: 13px; }
.logo-placeholder .specs { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.logo-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* Logo in views */
.doc-logo { max-width: 200px; max-height: 60px; display: block; margin-bottom: 4px; }
.paper-logo { max-width: 120px; max-height: 36px; display: block; margin-bottom: 2px; }
.print-logo { max-width: 350px; max-height: 150px; display: block; margin-bottom: 8px; }

/* Legend dot */
.legend-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }

/* View Toggle */
.view-toggle { display: flex; background: #e5e7eb; border-radius: 6px; padding: 2px; }
.view-toggle button { padding: 6px 14px; border: none; background: transparent; border-radius: 4px; cursor: pointer; font-size: 13px; color: #6b7280; transition: all 0.15s; }
.view-toggle button.active { background: white; color: #111827; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 500; }

/* Paper Invoice Cards */
.paper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 28px; padding: 8px 0; }
.paper-invoice { background: white; border-radius: 2px; padding: 28px 32px 24px; cursor: pointer; position: relative; min-height: 320px; display: flex; flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.06), -1px 0 0 #d8d8d8, 1px 0 0 #d8d8d8, 0 -1px 0 #e0e0e0;
    transition: transform 0.2s, box-shadow 0.2s; }
.paper-invoice::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: #0066cc; }
.paper-invoice:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 4px 8px rgba(0,0,0,0.08), 0 12px 32px rgba(0,0,0,0.12); }
.paper-invoice.type-estimate::before { background: #7c3aed; }
.paper-invoice.type-work_order::before { background: #d97706; }

/* Paper - Header */
.paper-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e5e7eb; }
.paper-company { font-size: 15px; font-weight: 700; color: #0066cc; letter-spacing: -0.3px; }
.paper-docinfo { text-align: right; }
.paper-doctype { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; color: #6b7280; }
.paper-docnum { font-size: 18px; font-weight: 700; color: #111827; margin-top: 1px; line-height: 1.2; }
.paper-date { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* Paper - Bill To */
.paper-billto { margin-bottom: 14px; }
.paper-billto-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #9ca3af; font-weight: 600; }
.paper-customer { font-size: 14px; font-weight: 600; color: #111827; margin-top: 2px; }
.paper-custaddr { font-size: 11px; color: #6b7280; line-height: 1.4; }

/* Paper - Line Items */
.paper-items { flex: 1; margin-bottom: 12px; }
.paper-item-header { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #e5e7eb; margin-bottom: 4px; }
.paper-item-header span { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: #9ca3af; font-weight: 600; }
.paper-item-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; font-size: 12px; }
.paper-item-desc { flex: 1; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 12px; }
.paper-item-amt { color: #111827; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paper-item-more { font-size: 11px; color: #9ca3af; padding: 2px 0; font-style: italic; }

/* Paper - Totals */
.paper-totals { border-top: 2px solid #111827; padding-top: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.paper-total-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #6b7280; font-weight: 600; }
.paper-total-amount { font-size: 20px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; }
.paper-balance { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.paper-balance-label { font-size: 10px; text-transform: uppercase; color: #dc2626; font-weight: 600; }
.paper-balance-amount { font-size: 14px; font-weight: 700; color: #dc2626; }

/* Paper - Status Stamp */
.paper-stamp { position: absolute; top: 50%; right: 24px; transform: translateY(-50%) rotate(-14deg); font-size: 28px; font-weight: 900; text-transform: uppercase; letter-spacing: 3px; padding: 6px 18px; border: 4px solid; border-radius: 8px; opacity: 0.12; pointer-events: none; white-space: nowrap; }
.paper-stamp.stamp-paid { color: #059669; border-color: #059669; }
.paper-stamp.stamp-void { color: #dc2626; border-color: #dc2626; }
.paper-stamp.stamp-draft { color: #6b7280; border-color: #6b7280; }
.paper-stamp.stamp-overdue { color: #dc2626; border-color: #dc2626; }
.paper-stamp.stamp-sent { color: #0066cc; border-color: #0066cc; }
.paper-stamp.stamp-partial { color: #d97706; border-color: #d97706; }
.paper-stamp.stamp-completed { color: #059669; border-color: #059669; }

/* Paper - PO / Terms footer */
.paper-footer { display: flex; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e5e7eb; }
.paper-footer-item { font-size: 10px; color: #9ca3af; }
.paper-footer-item strong { color: #6b7280; }

/* P&L Intro Box */
.pl-intro-box { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; font-size: 13px; color: #374151; line-height: 1.6; }
.pl-intro-box h3 { font-size: 15px; margin-bottom: 6px; color: #111827; border: none; padding: 0; }
.pl-intro-box p { margin-bottom: 6px; }
.pl-intro-box p:last-child { margin-bottom: 0; }
.pl-intro-box a { color: #0066cc; text-decoration: underline; }

/* P&L Waterfall Table */
.pl-waterfall-table { width: 100%; border-collapse: collapse; }
.pl-waterfall-table td { padding: 10px 16px; font-size: 14px; border-bottom: 1px solid #f3f4f6; }
.pl-waterfall-header td { font-weight: 600; font-size: 15px; color: #111827; background: #f9fafb; }
.pl-waterfall-minus td { color: #6b7280; }
.pl-waterfall-sub td { font-size: 13px; }
.pl-waterfall-subtotal td { font-weight: 600; color: #111827; background: #f0f7ff; border-top: 1px solid #bfdbfe; }
.pl-waterfall-total td { font-weight: 700; font-size: 16px; border-top: 2px solid #111827; }
.pl-waterfall-total.positive td { color: #059669; background: #f0fdf4; }
.pl-waterfall-total.negative td { color: #dc2626; background: #fef2f2; }
.pl-waterfall-spacer td { height: 8px; padding: 0; border: none; }
.pl-waterfall-note td { color: #6b7280; font-size: 13px; font-style: italic; text-align: center; padding: 16px; }
.pl-waterfall-note a { color: #0066cc; }

/* Health Gauges */
.gauge-grid { display: flex; flex-direction: column; gap: 20px; }
.gauge-item { }
.gauge-label { font-size: 14px; font-weight: 600; color: #111827; margin-bottom: 6px; }
.gauge-bar { height: 32px; background: #e5e7eb; border-radius: 8px; overflow: hidden; position: relative; }
.gauge-fill { height: 100%; border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px; min-width: 48px; transition: width 0.6s ease; }
.gauge-fill span { font-size: 13px; font-weight: 700; color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.gauge-green { background: linear-gradient(90deg, #059669, #34d399); }
.gauge-red { background: linear-gradient(90deg, #dc2626, #f87171); }
.gauge-neutral { background: linear-gradient(90deg, #6366f1, #a78bfa); }
.gauge-desc { font-size: 12px; color: #6b7280; margin-top: 4px; line-height: 1.4; }
.gauge-desc a { color: #0066cc; }

/* Expense Settings */
.expense-intro-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; font-size: 13px; color: #374151; line-height: 1.6; }
.expense-intro-box p { margin-bottom: 6px; }
.expense-intro-box p:last-child { margin-bottom: 0; }
.expense-field { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #f3f4f6; }
.expense-field:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.expense-field label { display: block; font-size: 14px; font-weight: 600; color: #111827; margin-bottom: 2px; }
.expense-field .expense-help { font-size: 12px; color: #6b7280; margin-bottom: 6px; line-height: 1.4; }
.expense-field input { width: 180px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.expense-field input:focus { outline: none; border-color: #0066cc; box-shadow: 0 0 0 3px rgba(0,102,204,0.1); }
.expense-total { margin-top: 16px; padding: 12px 16px; background: #f0f7ff; border-radius: 8px; font-size: 15px; }

/* Flip View */
.flip-container { display: flex; align-items: stretch; gap: 0; min-height: 500px; }
.flip-nav { flex-shrink: 0; width: 56px; background: none; border: none; font-size: 36px; color: #9ca3af; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; border-radius: 8px; }
.flip-nav:hover:not(:disabled) { background: #f3f4f6; color: #374151; }
.flip-nav:disabled { opacity: 0.25; cursor: default; }
.flip-stage { flex: 1; display: flex; justify-content: center; padding: 8px 0; }
.flip-doc { background: white; border: 1px solid #e5e7eb; border-radius: 4px; padding: 32px; width: 100%; max-width: 650px; box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04); cursor: pointer; position: relative; overflow: hidden; transition: box-shadow 0.2s; }
.flip-doc:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1), 0 12px 32px rgba(0,0,0,0.06); }
.flip-doc .paper-stamp { font-size: 36px; top: 50%; right: 16px; transform: translateY(-50%) rotate(-18deg); }
.flip-counter { text-align: center; padding: 12px 0 4px; font-size: 14px; color: #6b7280; font-weight: 500; }
.flip-hint { display: block; font-size: 11px; color: #9ca3af; font-weight: 400; margin-top: 2px; }

/* Responsive paper */
@media (max-width: 768px) {
    .paper-grid { grid-template-columns: 1fr; }
    .paper-invoice { min-height: 280px; }
    .flip-nav { width: 36px; font-size: 28px; }
    .flip-doc { padding: 20px; }
}

/* Responsive report */
@media (max-width: 768px) {
    .report-layout { flex-direction: column; }
    .report-nav { width: 100%; flex-direction: row; flex-wrap: wrap; }
    .report-nav-section { width: 100%; }
    .report-btn { flex: 1; min-width: 130px; }
    .settings-grid { grid-template-columns: 1fr; }
    .date-presets { gap: 4px; }
    .date-preset-btn { padding: 5px 10px; font-size: 12px; }
    .report-action-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
}
