:root {
    --green: #11845b;
    --green-dark: #0b5f43;
    --green-soft: #e7f6ef;
    --teal: #0f9f9a;
    --ink: #17231f;
    --muted: #71807a;
    --line: #e5ece8;
    --page: #f5f8f7;
    --white: #ffffff;
    --shadow: 0 18px 45px rgba(16, 72, 51, .10);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { text-decoration: none; }
.btn {
    border-radius: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}
.btn-primary {
    background: linear-gradient(135deg, var(--green), var(--teal));
    border: 0;
    box-shadow: 0 10px 24px rgba(17, 132, 91, .24);
}
.btn-outline-primary { color: var(--green); border-color: rgba(17, 132, 91, .35); }
.btn-outline-primary:hover { background: var(--green); border-color: var(--green); }
.form-control, .form-select {
    border: 1px solid var(--line);
    border-radius: 10px;
    min-height: 46px;
}
.form-control:focus, .form-select:focus {
    border-color: rgba(17, 132, 91, .55);
    box-shadow: 0 0 0 .22rem rgba(17, 132, 91, .12);
}
.form-label { font-weight: 700; color: #38534b; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 280px;
    background: #0f241d;
    color: #fff;
    padding: 24px;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.brand-block { display: flex; align-items: center; gap: 14px; padding-bottom: 26px; border-bottom: 1px solid rgba(255,255,255,.10); }
.brand-logo, .login-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #23b67e, #71d8c9);
    color: #fff;
    font-size: 22px;
}
.brand-title { font-weight: 900; letter-spacing: 0; }
.brand-subtitle { color: rgba(255,255,255,.62); font-size: .78rem; font-weight: 700; }
.nav-menu { display: grid; gap: 8px; margin-top: 28px; }
.nav-menu a {
    color: rgba(255,255,255,.72);
    padding: 13px 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    transition: .2s ease;
}
.nav-menu a:hover, .nav-menu a.active { color: #fff; background: rgba(255,255,255,.10); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.user-chip { background: rgba(255,255,255,.08); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.logout-link { color: rgba(255,255,255,.72); font-weight: 700; }

.main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    padding: 28px;
}
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.1rem); font-weight: 900; letter-spacing: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.stat-card, .action-card, .content-card {
    background: var(--white);
    border: 1px solid rgba(229,236,232,.86);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.stat-card, .action-card {
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.stat-card span, .action-card span { color: var(--muted); font-weight: 700; }
.stat-card strong, .action-card strong { display: block; font-size: 1.55rem; margin-top: 4px; }
.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 22px;
}
.stat-icon.green { background: var(--green); }
.stat-icon.teal { background: var(--teal); }
.content-card { padding: 24px; }
.section-heading, .invoice-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.section-heading h2, .invoice-view-header h2 { font-size: 1.24rem; margin: 0; font-weight: 900; }
.section-heading p, .invoice-view-header p { color: var(--muted); margin: 4px 0 0; }
.invoice-number, .soft-badge, .status-badge {
    background: var(--green-soft);
    color: var(--green-dark);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.professional-table thead th, .invoice-items-table thead th {
    background: #f7faf8;
    color: #51635c;
    border-bottom: 1px solid var(--line);
    font-size: .82rem;
    text-transform: uppercase;
}
.professional-table td, .professional-table th, .invoice-items-table td, .invoice-items-table th {
    padding: 14px;
    border-color: var(--line);
}
.btn-light-action {
    width: 36px;
    height: 36px;
    background: #f2f7f5;
    color: var(--green-dark);
    border: 1px solid var(--line);
}
.btn-danger-soft {
    background: #fff0f0;
    color: #b32626;
    border: 1px solid #ffd2d2;
}
.action-buttons { white-space: nowrap; }
.search-bar { position: relative; max-width: 480px; }
.search-bar i { position: absolute; left: 16px; top: 15px; color: var(--muted); }
.search-bar .form-control { padding-left: 44px; }
.pagination-modern .page-link { color: var(--green); border-color: var(--line); }
.pagination-modern .active .page-link { background: var(--green); border-color: var(--green); }

.invoice-items-table { min-width: 980px; }
.w-qty { width: 110px; }
.totals-box {
    background: #f7fbf9;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.total-row, .view-totals div, .print-totals div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.total-row.grand, .view-totals .grand, .print-totals .grand {
    border-bottom: 0;
    color: var(--green-dark);
    font-size: 1.2rem;
    font-weight: 900;
}
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.action-toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.view-totals { max-width: 360px; margin-left: auto; margin-top: 20px; }
.note-box { background: #f7fbf9; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 12%, rgba(23, 184, 125, .15), transparent 28%),
        linear-gradient(135deg, #f5faf8, #edf6f3);
}
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
    width: min(1060px, 100%);
    display: grid;
    grid-template-columns: 1fr 440px;
    gap: 34px;
    align-items: center;
}
.login-brand h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); font-weight: 950; margin: 20px 0 6px; color: var(--green-dark); }
.login-brand p { color: var(--muted); font-weight: 800; }
.login-card { background: #fff; border-radius: 8px; padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card-header h2 { font-weight: 900; margin: 18px 0 6px; }
.login-card-header p { color: var(--muted); }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 14px; top: 15px; color: var(--muted); }
.input-icon .form-control { padding-left: 42px; }

.print-body { background: #e9eeec; padding: 24px; }
.print-actions { max-width: 210mm; margin: 0 auto 16px; display: flex; gap: 10px; justify-content: flex-end; }
.invoice-a4 {
    width: 210mm;
    min-height: 297mm;
    margin: auto;
    background: #fff;
    padding: 18mm;
    box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.print-header { display: grid; grid-template-columns: 76px 1fr 160px; gap: 18px; align-items: start; border-bottom: 3px solid var(--green); padding-bottom: 18px; }
.print-logo { width: 70px; height: 70px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.print-header h1 { font-size: 24px; margin: 0 0 8px; font-weight: 950; color: var(--green-dark); }
.print-header p { margin: 0 0 4px; color: #4a5f57; }
.print-meta { text-align: right; display: grid; gap: 5px; }
.print-meta strong { font-size: 22px; color: var(--green-dark); text-transform: uppercase; }
.print-client { margin: 22px 0; background: #f7fbf9; border: 1px solid var(--line); padding: 14px; border-radius: 8px; display: grid; gap: 4px; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th { background: #eef7f2; color: var(--green-dark); }
.print-table th, .print-table td { border: 1px solid var(--line); padding: 9px; font-size: 13px; }
.print-bottom { display: grid; grid-template-columns: 1fr 290px; gap: 26px; margin-top: 24px; }
.signature-box { margin-top: 44px; border: 1px dashed #b7c7c0; border-radius: 8px; height: 86px; display: grid; place-items: center; color: var(--muted); font-weight: 800; }

@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; padding: 18px; }
    .sidebar-toggle { display: grid; place-items: center; }
    .dashboard-grid, .login-panel { grid-template-columns: 1fr; }
    .section-heading, .invoice-view-header { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 576px) {
    .content-card, .login-card { padding: 18px; }
    .stat-card, .action-card { align-items: flex-start; flex-direction: column; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
}
@media print {
    .no-print { display: none !important; }
    .print-body { background: #fff; padding: 0; }
    .invoice-a4 { width: auto; min-height: auto; margin: 0; padding: 12mm; box-shadow: none; }
    @page { size: A4; margin: 0; }
}
