/* ===== Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--gray-900); background: var(--gray-50); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== Navbar ===== */
.navbar { display: flex; align-items: center; background: var(--gray-900); color: #fff; padding: 0 1rem; height: 56px; position: sticky; top: 0; z-index: 100; }
.nav-brand a { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.nav-links { list-style: none; display: flex; gap: .25rem; margin-left: 1.5rem; flex: 1; }
.nav-links a { color: var(--gray-300); padding: .4rem .75rem; border-radius: var(--radius); font-size: .9rem; text-decoration: none; }
.nav-links a:hover, .nav-links a.active { color: #fff; background: rgba(255,255,255,0.1); }
.nav-right { display: flex; align-items: center; gap: .5rem; }
.nav-user { color: var(--gray-300); font-size: .85rem; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }

/* ===== Nav Dropdowns ===== */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { color: var(--gray-300); padding: .4rem .75rem; border-radius: var(--radius); font-size: .9rem; text-decoration: none; cursor: pointer; display: inline-block; }
.nav-dropdown-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-dropdown.active-parent > .nav-dropdown-toggle { color: #fff; background: rgba(255,255,255,0.1); }
.nav-dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--gray-900); border-radius: var(--radius); min-width: 180px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 200; padding: .25rem 0; list-style: none; }
.nav-dropdown:hover > .nav-dropdown-menu { display: block; }
.nav-dropdown-menu li a { display: block; padding: .5rem 1rem; color: var(--gray-300); font-size: .85rem; white-space: nowrap; }
.nav-dropdown-menu li a:hover, .nav-dropdown-menu li a.active { color: #fff; background: rgba(255,255,255,0.1); }

@media (max-width: 768px) {
    .navbar { flex-wrap: wrap; }
    .nav-toggle { display: block; }
    .nav-links, .nav-right { display: none; width: 100%; flex-direction: column; padding: .5rem 0; }
    .navbar.open .nav-links, .navbar.open .nav-right { display: flex; }
    .nav-links { margin-left: 0; }
    .nav-dropdown-menu { position: static; box-shadow: none; background: rgba(255,255,255,0.05); display: none; }
    .nav-dropdown.open > .nav-dropdown-menu { display: block; }
}

/* ===== Container ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ===== Page Header ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .5rem; }
.page-header h1 { font-size: 1.5rem; }

/* ===== Cards ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.5rem; }
.card h2 { font-size: 1.15rem; margin-bottom: 1rem; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; text-align: center; display: flex; flex-direction: column; }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--gray-500); margin-top: .25rem; }
.stat-badge { display: inline-block; margin-top: .4rem; font-size: .75rem; background: #fef2f2; color: var(--danger); padding: .15rem .5rem; border-radius: 999px; }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
.table thead th { background: var(--gray-100); font-weight: 600; font-size: .8rem; text-transform: uppercase; color: var(--gray-500); }
.table tbody tr:hover { background: var(--gray-50); }
.table td.num, .table th.num { text-align: right; }

/* ===== Status Badges ===== */
.status-badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.status-draft { background: var(--gray-200); color: var(--gray-700); }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-paid { background: #dcfce7; color: #166534; }
.status-partial { background: #fef9c3; color: #854d0e; }
.status-overdue { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: var(--gray-200); color: var(--gray-500); text-decoration: line-through; }

/* ===== Buttons ===== */
.btn { display: inline-block; padding: .45rem .9rem; border-radius: var(--radius); font-size: .875rem; border: none; cursor: pointer; text-decoration: none; line-height: 1.4; }
.btn:hover { text-decoration: none; opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ===== Forms ===== */
.form-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; max-width: 900px; }
.form-card h2 { margin-top: 1.25rem; margin-bottom: .75rem; font-size: 1.05rem; border-bottom: 1px solid var(--gray-200); padding-bottom: .5rem; }
.form-card h2:first-child { margin-top: 0; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; font-size: .85rem; margin-bottom: .25rem; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .45rem .6rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .9rem; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* ===== Alerts ===== */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== Login Page ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.login-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 380px; }
.login-box h1 { text-align: center; font-size: 1.2rem; color: var(--primary); margin-bottom: .25rem; }
.login-box h2 { text-align: center; font-size: 1rem; color: var(--gray-500); margin-bottom: 1.25rem; font-weight: 400; }
.login-footer { text-align: center; margin-top: 1rem; font-size: .85rem; }

/* ===== Text ===== */
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }

/* ===== Footer ===== */
.footer { text-align: center; padding: 1.5rem; margin-top: auto; border-top: 1px solid var(--gray-200); color: var(--gray-500); font-size: .85rem; }

/* ===== Print Styles ===== */
@media print {
    .navbar, .footer, .btn, .nav-toggle, .no-print, .alert, .form-card { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .container { max-width: 100%; padding: 0; margin: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .table th, .table td { border: 1px solid #ccc; padding: 4px 8px; }
    .invoice-print { display: block !important; }
    .invoice-print-header { margin-bottom: 1rem; }
    .invoice-print-header h1 { font-size: 1.4rem; }
    .invoice-print-footer { margin-top: 2rem; font-size: .85rem; }
    .status-badge { border: 1px solid #999; }
}

.invoice-print { display: none; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--gray-200); }
.tab-link { padding: .6rem 1rem; font-size: .9rem; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; text-decoration: none; font-weight: 500; }
.tab-link:hover { color: var(--gray-700); text-decoration: none; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Filters ===== */
.filters { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters .form-group { margin-bottom: 0; min-width: 140px; }
.filters .form-group input, .filters .form-group select { max-width: 200px; }

/* ===== Help Page ===== */
.help-nav h2 { margin-bottom: .75rem; }
.help-toc { list-style: none; columns: 2; column-gap: 2rem; }
.help-toc li { padding: .3rem 0; border-bottom: 1px solid var(--gray-100); }
.help-toc a { font-size: .9rem; color: var(--primary); text-decoration: none; }
.help-toc a:hover { text-decoration: underline; }
.help-section { scroll-margin-top: 70px; }
.help-section h2 { font-size: 1.3rem; border-bottom: 2px solid var(--primary); padding-bottom: .5rem; margin-bottom: 1rem; }
.help-section h3 { font-size: 1.05rem; margin-top: 1.25rem; margin-bottom: .5rem; color: var(--gray-700); }
.help-section h4 { font-size: .95rem; margin-top: .75rem; margin-bottom: .25rem; }
.help-section ol, .help-section ul { padding-left: 1.5rem; margin: .5rem 0; }
.help-section li { margin-bottom: .3rem; font-size: .9rem; }
.help-section p { font-size: .9rem; margin: .5rem 0; }
.help-note { background: #fffbeb; border: 1px solid #fde68a; padding: .6rem .8rem; border-radius: var(--radius); font-size: .85rem; color: #92400e; margin: .75rem 0; }
.faq-item { margin-bottom: 1rem; }
.faq-item h4 { color: var(--primary-dark); }
.faq-item p { margin-top: .25rem; }
@media (max-width: 600px) { .help-toc { columns: 1; } }
