:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1d2430;
    --muted: #6b7380;
    --line: #e6eaef;
    --brand: #2e5a27;
    --brand-2: #3d7a32;
    --ok: #1b7f4e;
    --danger: #c0392b;
    --warn: #c77800;
    --info: #2b6cb0;
    --radius: 16px;
    --shadow: 0 8px 24px rgba(23, 32, 46, 0.06);
}

* { box-sizing: border-box; }
html, body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: "Segoe UI", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}

.app-body { padding-bottom: 118px; }
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #eef6ee, #f4f6f8);
}
.auth-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 12px 12px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: #1a3320;
    color: #fff;
    flex-direction: column;
    z-index: 30;
}
.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 22px 18px 16px;
}
.brand-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    padding: 4px;
}
.brand-logo-sm {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 2px;
    flex-shrink: 0;
}
.login-logo {
    width: 140px;
    height: auto;
    max-width: 70%;
    display: block;
    margin: 0 auto 12px;
}
.invoice-logo {
    width: 120px;
    height: auto;
    display: block;
    margin: 0 auto 8px;
}
.sidebar-nav { display: flex; flex-direction: column; padding: 8px; gap: 4px; flex: 1; }
.sidebar-nav a, .logout-link {
    color: #d7e3ef;
    text-decoration: none;
    border-radius: 10px;
    padding: 11px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.sidebar-nav a.active, .sidebar-nav a:hover, .logout-link:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.dev-credit-sidebar {
    margin-top: 10px;
    font-size: .75rem;
    color: rgba(255,255,255,.55);
    text-align: center;
}

.mobile-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.mobile-top h1 { font-size: 1.15rem; margin: 0; }
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--bg);
    color: var(--ink);
    text-decoration: none;
}

.app-main {
    padding: 16px;
    max-width: 1100px;
}
@media (min-width: 992px) {
    .app-body { padding-bottom: 24px; }
    .app-main { margin-left: 250px; padding: 28px; }
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.page-head h2 { font-size: 1.35rem; margin: 0; }
.d-lg-flex.page-head { display: none; }
@media (min-width: 992px) {
    .d-lg-flex.page-head { display: flex !important; }
}

.card-soft {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.stat-grid, .mini-grid { display: grid; gap: 12px; }
.stat-grid { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.mini-grid { grid-template-columns: 1fr; }
@media (min-width: 768px) {
    .stat-grid { grid-template-columns: repeat(5, 1fr); }
    .mini-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat-card, .list-card, .form-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-card { padding: 14px; }
.stat-card .label { color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.stat-card .value { font-size: 1.15rem; font-weight: 700; }
.stat-card.ok .value { color: var(--ok); }
.stat-card.danger .value { color: var(--danger); }
.stat-card.info .value { color: var(--info); }
.stat-card.warn .value { color: var(--warn); }
.stock-dash-row {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}
.stock-dash-row:first-of-type { border-top: 0; padding-top: 0; }
.stock-dash-meta {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 8px;
    margin-top: 10px;
}
.stock-dash-meta .label { color: var(--muted); font-size: .75rem; margin-bottom: 2px; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-chips a, .filter-chips button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 14px;
    text-decoration: none;
    font-size: .92rem;
}
.filter-chips a.active, .filter-chips button.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.list-card {
    padding: 14px 16px;
    margin-bottom: 10px;
    text-decoration: none;
    color: inherit;
    display: block;
}
.list-card h3 { font-size: 1.02rem; margin: 0 0 4px; }
.meta { color: var(--muted); font-size: .86rem; }
.row-between { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.amount-in { color: var(--ok); font-weight: 700; }
.amount-out { color: var(--danger); font-weight: 700; }

.badge-success, .badge-warning, .badge-danger, .badge-info {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-success { background: #e7f6ee; color: var(--ok); }
.badge-warning { background: #fff4e0; color: var(--warn); }
.badge-danger { background: #fdecea; color: var(--danger); }
.badge-info { background: #e8f1fb; color: var(--info); }

.form-label { font-weight: 600; margin-bottom: 6px; }
.form-control, .form-select {
    min-height: 50px;
    border-radius: 12px;
    font-size: 1.05rem;
}
.btn { border-radius: 12px; min-height: 48px; font-weight: 600; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: #16324f; color: #fff; }
.btn-lg-touch { width: 100%; }

.search-box { margin-bottom: 14px; }
.pager-wrap { padding-bottom: 8px; }
.pager-info { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.pagination .page-link { min-width: 44px; min-height: 42px; display: flex; align-items: center; justify-content: center; }

.calc-box {
    background: #f7f9fb;
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
}
.calc-row { display: flex; justify-content: space-between; padding: 4px 0; }
.calc-row.total { font-weight: 700; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 25;
    padding: 6px 4px 10px;
}
.bottom-nav a {
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    font-size: .75rem;
    padding: 6px 0;
}
.bottom-nav a i { display: block; font-size: 1.2rem; margin-bottom: 2px; }
.bottom-nav a.active { color: var(--brand); font-weight: 700; }

.fab {
    position: fixed;
    right: 16px;
    bottom: 82px;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 10px 24px rgba(46,90,39,.35);
    z-index: 26;
}
.quick-sheet { height: auto !important; border-radius: 20px 20px 0 0; }
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
}

.auth-card {
    width: min(420px, 92vw);
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 28px 22px;
}
.auth-card h1 { font-size: 1.4rem; }

.invoice-wrap { background: #fff; padding: 8px; }
.invoice {
    max-width: 420px;
    margin: 0 auto;
    border: 1px solid #d9dee6;
    padding: 22px 18px;
    background: #fff;
}
.invoice-head { text-align: center; margin-bottom: 14px; }
.invoice-head h2 { font-size: 1.25rem; margin-bottom: 2px; }
.invoice-credit { margin-top: 10px; font-size: .75rem; color: #8a9099; }
.invoice-line { border-top: 1px dashed #c5ccd6; margin: 12px 0; }
.app-credit {
    text-align: center;
    color: var(--muted);
    font-size: .78rem;
    padding: 18px 8px 8px;
}
.auth-credit { padding-top: 18px; }
@media (min-width: 992px) {
    .app-credit:not(.auth-credit) { display: none; }
}
.invoice table { width: 100%; font-size: .95rem; }
.invoice td { padding: 4px 0; }

#appToast .toast-body { white-space: pre-line; }
.app-alert { margin-bottom: 14px; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 12px; }

.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.more-link {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 14px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow);
}
.more-link i { display: block; font-size: 1.4rem; margin-bottom: 8px; color: var(--brand); }

.form-screen .fab { display: none !important; }
@media (max-width: 991.98px) {
    .form-screen .app-main {
        padding: 0;
        min-height: calc(100dvh - 70px);
    }
    .form-screen .form-card {
        min-height: calc(100dvh - 70px);
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 16px 16px 160px !important;
        overflow: visible;
    }
    .form-screen .app-credit { display: none; }
}

@media print {
    .sidebar, .mobile-top, .bottom-nav, .fab, .no-print, .app-alert, .app-credit { display: none !important; }
    .app-main { margin: 0; padding: 0; }
    body { background: #fff; }
}
