:root {
    --brand: #2f6b43;
    --brand-dark: #1f4b31;
    --ink: #1f2933;
    --muted: #667085;
    --line: #e5e7eb;
    --surface: #ffffff;
    --page: #f5f7f6;
    --danger-soft: #fff4e5;
}

body {
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
}

.app-layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem;
    background: #14251b;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
}

.brand-mobile {
    color: var(--ink);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 42px;
    border-radius: .5rem;
    color: rgba(255, 255, 255, .78);
    font-weight: 600;
}

.offcanvas .nav-link {
    color: var(--ink);
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.offcanvas .nav-link:hover {
    color: var(--brand-dark);
    background: #eef6f0;
}

.nav-group-label {
    margin: 1rem .75rem .35rem;
    color: rgba(255, 255, 255, .52);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 0;
}

.app-main {
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 68px;
    padding: .85rem 1.25rem;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.app-content {
    padding: 1.25rem;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-heading h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 750;
}

.page-heading p {
    margin: .2rem 0 0;
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: flex-end;
}

.page-actions form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: flex-end;
}

.page-actions form .form-control {
    width: 240px;
}

.dashboard-actions {
    align-items: center;
}

.dashboard-financial-toggle {
    width: 42px;
    min-width: 42px;
}

.financial-value {
    display: inline-block;
    min-width: 8ch;
    white-space: nowrap;
}

.metric-card,
.panel,
.placeholder-panel,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .5rem;
    box-shadow: 0 12px 30px rgba(16, 24, 40, .06);
}

.metric-card {
    display: grid;
    gap: .35rem;
    min-height: 132px;
    padding: 1rem;
}

.metric-card i {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: .5rem;
    color: var(--brand-dark);
    background: #e8f3eb;
    font-size: 1.15rem;
}

.metric-card span {
    color: var(--muted);
    font-weight: 600;
}

.metric-card strong {
    font-size: 1.65rem;
}

.metric-card small {
    color: var(--muted);
    font-weight: 600;
}

.metric-alert i {
    color: #9a3412;
    background: var(--danger-soft);
}

.panel {
    padding: 1rem;
    min-height: 240px;
}

.compact-panel {
    min-height: auto;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .35rem;
    white-space: nowrap;
}

.table-actions form {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.col-span-2 {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    padding-top: .5rem;
}

.form-section-title {
    padding: .35rem 0 .1rem;
    color: var(--brand-dark);
    font-weight: 800;
    border-bottom: 1px solid var(--line);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.detail-grid-one {
    grid-template-columns: 1fr;
}

.detail-grid div {
    padding: .85rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: #fbfcfb;
}

.detail-grid span {
    display: block;
    margin-bottom: .3rem;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
}

.detail-grid strong {
    display: block;
    overflow-wrap: anywhere;
}

.section-title {
    margin: 0 0 .75rem;
    font-size: 1rem;
    font-weight: 700;
}

.store-logo-preview {
    display: grid;
    place-items: center;
    min-height: 190px;
    border: 1px dashed var(--line);
    border-radius: .5rem;
    background: #fbfcfb;
}

.store-logo-preview img {
    max-width: 180px;
    max-height: 180px;
    object-fit: contain;
}

.store-logo-preview i {
    color: var(--brand);
    font-size: 3rem;
}

.store-logo-inline,
.receipt-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.store-logo-inline img,
.receipt-brand img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: #fff;
}

.store-logo-inline span,
.receipt-brand span {
    display: block;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.sale-add-form {
    display: inline-flex;
    justify-content: flex-end;
    gap: .35rem;
}

.sale-qty-input {
    width: 82px;
}

.sale-cart-panel {
    position: sticky;
    top: 86px;
}

.sale-cart-list {
    display: grid;
    gap: .75rem;
}

.sale-cart-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .75rem;
    padding: .8rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: #fbfcfb;
}

.sale-cart-item span {
    display: block;
    color: var(--muted);
    font-size: .875rem;
}

.sale-cart-controls {
    display: grid;
    grid-template-columns: 76px 92px 34px;
    align-items: center;
    gap: .4rem;
    text-align: right;
}

.sale-remove-list {
    display: grid;
    gap: .4rem;
    margin-top: .75rem;
}

.sale-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: .5rem;
    background: #eef6f0;
}

.sale-total span {
    color: var(--muted);
    font-weight: 700;
}

.sale-total strong {
    color: var(--brand-dark);
    font-size: 1.5rem;
}

.payment-summary {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .75rem;
}

.quick-actions a {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 58px;
    padding: .85rem 1rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 12px 30px rgba(16, 24, 40, .06);
}

.quick-actions i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: .5rem;
    color: var(--brand-dark);
    background: #e8f3eb;
}

.ranking-list,
.stock-alert-list,
.payment-breakdown {
    display: grid;
    gap: .75rem;
}

.ranking-item,
.stock-alert-item,
.payment-breakdown div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: #fbfcfb;
}

.ranking-item span,
.stock-alert-item span,
.payment-breakdown small {
    display: block;
    color: var(--muted);
    font-size: .875rem;
}

.stock-alert-item {
    border-color: #fed7aa;
    background: #fff7ed;
}

.stock-empty-item {
    border-color: #fecaca;
    background: #fff1f2;
}

.payment-breakdown div {
    align-items: flex-start;
    flex-direction: column;
    gap: .2rem;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.report-card {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-height: 260px;
}

.report-card-wide {
    grid-column: span 2;
}

.report-card > i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: .5rem;
    color: var(--brand-dark);
    background: #e8f3eb;
    font-size: 1.25rem;
}

.report-card h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 750;
}

.report-card p {
    margin: 0;
    color: var(--muted);
}

.report-card .btn {
    margin-top: auto;
}

.report-filters {
    display: grid;
    gap: .6rem;
    margin-top: auto;
}

.report-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-filters-grid .btn {
    grid-column: span 2;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-heading h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.panel-heading a {
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: none;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 150px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: .5rem;
}

.placeholder-panel {
    display: grid;
    place-items: center;
    gap: .65rem;
    min-height: 320px;
    padding: 2rem;
    text-align: center;
}

.placeholder-panel i {
    color: var(--brand);
    font-size: 2.2rem;
}

.placeholder-panel h1,
.placeholder-panel h2 {
    margin: 0;
    font-size: 1.35rem;
}

.placeholder-panel p {
    margin: 0;
    color: var(--muted);
}

.flash-stack {
    margin-bottom: 1rem;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(245, 247, 246, .92)),
        #eef4ef;
}

.login-panel {
    width: min(100%, 440px);
    padding: 1.4rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: 1.25rem;
}

.login-brand img {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
}

.login-brand p {
    margin: .15rem 0 0;
    color: var(--muted);
}

.login-footer {
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: .875rem;
    text-align: center;
}

@media (max-width: 991.98px) {
    .app-layout {
        display: block;
    }

    .app-content {
        padding: 1rem;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading .btn {
        width: 100%;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1 1 160px;
    }

    .page-actions form,
    .page-actions form .form-control {
        width: 100%;
    }

    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: span 1;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .sale-cart-panel {
        position: static;
    }

    .sale-cart-item {
        grid-template-columns: 1fr;
    }

    .sale-cart-controls {
        grid-template-columns: 80px minmax(0, 1fr) 38px;
        text-align: left;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .ranking-item,
    .stock-alert-item {
        align-items: flex-start;
        flex-direction: column;
        gap: .35rem;
    }

    .reports-grid,
    .report-filters-grid {
        grid-template-columns: 1fr;
    }

    .report-card-wide,
    .report-filters-grid .btn {
        grid-column: span 1;
    }
}
