:root {
    --app-bg: #f4f6f8;
    --app-surface: #ffffff;
    --app-border: #dce2e8;
    --app-ink: #202733;
    --app-muted: #657284;
    --app-primary: #1f6feb;
    --app-green: #138a4b;
    --app-red: #c93434;
    --app-amber: #a16207;
}

body {
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-ink);
    font-size: 0.95rem;
}

.app-shell {
    width: 100%;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
}

.app-main {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

.app-nav-shell {
    min-height: 58px;
}

.app-navbar {
    background: #243447;
    box-shadow: 0 8px 24px rgba(32, 39, 51, 0.12);
}

.navbar .nav-link {
    border-radius: 6px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.navbar .nav-link.active,
.navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.user-menu-link .badge {
    font-weight: 700;
}

.dropdown-menu {
    border-color: var(--app-border);
    box-shadow: 0 14px 30px rgba(32, 39, 51, 0.12);
}

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

.page-heading h1 {
    font-size: clamp(1.35rem, 1.55vw, 1.85rem);
    font-weight: 750;
    letter-spacing: 0;
}

.month-filter {
    min-width: 300px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card,
.summary-panel,
.form-panel,
.table-panel,
.chart-panel,
.empty-state,
.filter-bar {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(32, 39, 51, 0.06);
}

.stat-card {
    padding: 0.9rem;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card span,
.summary-panel span,
.live-calculations span {
    color: var(--app-muted);
    font-size: 0.82rem;
}

.stat-card strong {
    display: block;
    font-size: clamp(1.15rem, 1.1vw, 1.45rem);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

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

.chart-panel {
    padding: 0.9rem;
    height: 260px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-panel canvas {
    display: block;
    width: 100% !important;
    height: 220px !important;
    max-height: 220px;
    min-height: 0;
    flex: 0 0 220px;
}

.chart-panel h2 {
    margin-bottom: 0.5rem;
    flex: 0 0 auto;
}

.target-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.target-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 0.85rem;
    background: #fbfcfd;
}

.target-card .progress {
    height: 0.65rem;
}

.channel-share-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    color: var(--app-muted);
    font-size: 0.8rem;
}

.form-panel,
.table-panel,
.empty-state {
    padding: 1rem;
}

.form-panel .row {
    --bs-gutter-x: 0.9rem;
    --bs-gutter-y: 0.9rem;
}

.form-label {
    font-weight: 650;
    color: #3a4656;
}

.form-label-icon {
    color: var(--app-muted);
    font-size: 0.92em;
    margin-right: 0.38rem;
    vertical-align: -0.08em;
}

.form-control,
.form-select,
.input-group-text,
.btn {
    min-height: 38px;
    font-size: 0.94rem;
}

.filter-bar {
    display: grid;
    grid-template-columns: auto minmax(220px, 300px) auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
    padding: 0.8rem;
}

.filter-bar-range {
    grid-template-columns: repeat(6, minmax(140px, 1fr)) auto;
}

.records-filter .custom-months-box {
    grid-column: 1 / -1;
    border-top: 1px solid var(--app-border);
    padding-top: 0.7rem;
}

.all-months-check {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    white-space: nowrap;
}

.list-summary-grid {
    margin-bottom: 0.9rem;
}

.compare-filter {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(32, 39, 51, 0.05);
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
    padding: 0.8rem;
}

.entry-type-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.entry-type-toggle .btn {
    border-radius: 6px;
}

.live-calculations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
}

.operating-expenses-panel {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 0.9rem;
}

.live-calculations div {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.live-calculations strong {
    font-size: 1.05rem;
}

.table th {
    color: var(--app-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    white-space: nowrap;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

.table td {
    vertical-align: middle;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.notes-cell {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.actions-cell {
    min-width: 180px;
    white-space: nowrap;
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.9rem !important;
}

.warehouse-actions-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1.15fr) repeat(2, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.warehouse-table .warehouse-thumb,
.warehouse-thumb-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    border: 1px solid var(--app-border);
    background: #f7f9fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
}

.warehouse-thumb-placeholder {
    color: var(--app-muted);
    font-size: 1.15rem;
}

.warehouse-actions-cell {
    min-width: 260px;
}

.warehouse-adjust-form {
    display: inline-grid;
    grid-template-columns: 78px auto;
    gap: 0.25rem;
    vertical-align: middle;
}

.warehouse-adjust-form .form-control {
    min-height: 31px;
}

.warehouse-barcode-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.02em;
}

.summary-changes {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(32, 39, 51, 0.05);
    padding: 0.9rem;
    margin-bottom: 0.9rem !important;
}

.summary-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.65rem;
}

.summary-copy span,
.summary-change-grid span {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.summary-copy strong {
    font-size: 0.98rem;
}

.summary-change-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}

.summary-change-grid article {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 0.7rem;
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.summary-change-grid strong {
    font-size: 1rem;
}

.summary-change-grid small {
    color: var(--app-muted);
}

.summary-panel {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-panel strong {
    font-size: 1.15rem;
}

.summary-panel small,
.empty-state p {
    color: var(--app-muted);
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.app-footer {
    color: var(--app-muted);
    padding: 1rem 0 1.25rem;
}

.login-page {
    background:
        linear-gradient(135deg, rgba(31, 111, 235, 0.08), rgba(19, 138, 75, 0.06)),
        var(--app-bg);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 460px);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(32, 39, 51, 0.12);
    padding: 1.5rem;
}

.account-form {
    max-width: 1100px;
}

.user-row-form {
    margin: 0;
}

.text-success {
    color: var(--app-green) !important;
}

.text-danger {
    color: var(--app-red) !important;
}

.text-warning-emphasis {
    color: var(--app-amber) !important;
}

@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .summary-change-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (min-width: 1500px) {
    .stats-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .charts-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

}

@media (max-width: 991.98px) {
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .month-filter {
        min-width: 0;
    }

    .stats-grid,
    .charts-grid,
    .compare-filter,
    .warehouse-actions-grid,
    .filter-bar-range,
    .summary-change-grid,
    .live-calculations {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .stats-grid,
    .charts-grid,
    .live-calculations,
    .compare-grid,
    .warehouse-actions-grid,
    .filter-bar,
    .compare-filter,
    .filter-bar-range,
    .summary-change-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        align-items: stretch;
    }

    .form-panel,
    .table-panel,
    .chart-panel {
        padding: 1rem;
    }

    .app-shell {
        padding-left: 14px;
        padding-right: 14px;
    }

    .app-main {
        padding-top: 0.9rem;
    }
}
