:root {
    --dm-primary: #d97706;
    --dm-primary-dark: #92400e;
    --dm-primary-soft: #fff7ed;
    --dm-accent: #7c2d12;
    --dm-gold: #f59e0b;
    --dm-ink: #24160d;
    --dm-muted: #756457;
    --dm-bg: #fff8ed;
    --dm-line: #f0d8b8;
    --dm-card: #ffffff;
    --dm-radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--dm-ink);
    background: var(--dm-bg);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.app-shell.sidebar-collapsed .app-main {
    padding-left: 0;
}

.app-shell.sidebar-collapsed .sidebar-show-btn {
    display: inline-flex !important;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 224px;
    background: linear-gradient(180deg, #7c2d12 0%, #9a3412 100%);
    color: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .2s ease;
}

.sidebar-brand {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .7rem .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-collapse-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    margin-left: auto;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .32);
    background: rgba(255, 255, 255, .08);
}

.sidebar-collapse-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .18);
}

.sidebar-show-btn {
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, .4);
    background: rgba(255, 255, 255, .12);
}

.sidebar-show-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .22);
}

.sidebar-brand strong,
.brand-inline strong {
    display: block;
    line-height: 1.2;
    font-weight: 700;
    font-size: .92rem;
}

.sidebar-brand small,
.brand-inline small {
    display: block;
    color: rgba(255, 255, 255, .76);
    line-height: 1.25;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #ffffff;
    background: #f59e0b;
    font-weight: 800;
    border: 2px solid rgba(255, 255, 255, .42);
}

.sidebar-nav {
    padding: .55rem;
    display: grid;
    gap: .18rem;
}

.sidebar .nav-link {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: .55rem;
    color: rgba(255, 255, 255, .82);
    border-radius: 8px;
    padding: .5rem .6rem;
    font-size: .82rem;
    font-weight: 500;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 247, 237, .16);
}

.sidebar .nav-link svg,
.btn svg,
.alert svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.sidebar-footer {
    margin-top: auto;
    padding: .75rem;
    color: rgba(255, 255, 255, .7);
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .52);
    z-index: 1030;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.app-main {
    width: 100%;
    min-width: 0;
    padding-left: 224px;
}

.topbar {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .9rem;
    background: linear-gradient(90deg, #b45309 0%, #d97706 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

.brand-inline {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
    color: #fff;
}

.brand-inline:hover {
    color: #fff;
}

.brand-logo {
    width: 156px;
    max-width: 32vw;
    height: 34px;
    object-fit: contain;
    object-position: left center;
    background: #fff;
    border-radius: 6px;
    padding: .15rem .35rem;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

.btn {
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 600;
}

.btn-primary {
    --bs-btn-bg: var(--dm-primary);
    --bs-btn-border-color: var(--dm-primary);
    --bs-btn-hover-bg: var(--dm-primary-dark);
    --bs-btn-hover-border-color: var(--dm-primary-dark);
    --bs-btn-active-bg: var(--dm-primary-dark);
    --bs-btn-active-border-color: var(--dm-primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--dm-primary);
    --bs-btn-border-color: var(--dm-primary);
    --bs-btn-hover-bg: var(--dm-primary);
    --bs-btn-hover-border-color: var(--dm-primary);
}

.btn-outline-secondary {
    --bs-btn-color: #7c2d12;
    --bs-btn-border-color: #d6a35d;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #b45309;
    --bs-btn-hover-border-color: #b45309;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
}

.content-wrap {
    padding: .75rem;
}

.app-footer {
    margin-top: 1rem;
    padding: .55rem .25rem .15rem;
    color: var(--dm-muted);
    font-size: .74rem;
    text-align: center;
}

.app-footer strong {
    color: #7c2d12;
    font-weight: 700;
}

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

.page-head h1 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
}

.page-head p {
    margin: .2rem 0 0;
    color: var(--dm-muted);
    font-size: .8rem;
}

.smart-card,
.table-card,
.form-panel {
    background: var(--dm-card);
    border: 1px solid var(--dm-line);
    border-radius: var(--dm-radius);
    box-shadow: 0 8px 20px rgba(146, 64, 14, .055);
}

.smart-card {
    padding: .7rem;
    min-height: 82px;
    display: flex;
    align-items: center;
    gap: .85rem;
}

.smart-card .icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--dm-primary);
}

.smart-card .icon-box svg {
    width: 22px;
    height: 22px;
}

.smart-card .metric {
    font-size: 1.38rem;
    line-height: 1;
    font-weight: 800;
}

.smart-card .label {
    margin-top: .2rem;
    color: var(--dm-muted);
    font-size: .76rem;
}

.table-card,
.form-panel {
    padding: .7rem;
}

.form-label {
    font-weight: 600;
    font-size: .76rem;
    margin-bottom: .22rem;
}

.form-section {
    padding: .7rem;
    border: 1px solid var(--dm-line);
    border-radius: 8px;
    background: #fffdf8;
    margin-bottom: .65rem;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: #7c2d12;
    font-weight: 700;
    font-size: .82rem;
    margin-bottom: .55rem;
}

.form-section-title svg {
    width: 17px;
    height: 17px;
}

.form-control,
.form-select,
.select2-container--bootstrap-5 .select2-selection {
    border-radius: 8px;
    border-color: #e7c99b;
    color: var(--dm-ink);
    font-size: .8rem;
    min-height: 32px;
}

.form-control::placeholder {
    color: #a58b74;
    opacity: 1;
}

.form-control:focus,
.form-select:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--dm-primary);
    box-shadow: 0 0 0 .18rem rgba(217, 119, 6, .18);
}

.required::after {
    content: " *";
    color: #dc2626;
}

.action-group {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    white-space: nowrap;
}

.dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .55rem;
    opacity: 1 !important;
    visibility: visible !important;
}

.dt-buttons .btn,
.dt-button.btn,
.dt-export-btn {
    opacity: 1 !important;
    visibility: visible !important;
    color: #7c2d12 !important;
    background: #fff7ed !important;
    border: 1px solid #d6a35d !important;
    box-shadow: none !important;
}

.dt-buttons .btn:hover,
.dt-button.btn:hover,
.dt-export-btn:hover {
    color: #ffffff !important;
    background: #b45309 !important;
    border-color: #b45309 !important;
}

table.dataTable td,
table.dataTable th {
    vertical-align: middle;
    font-size: .76rem;
    padding: .34rem .42rem;
}

table.dataTable thead th {
    font-weight: 700;
    color: #5f260d;
    background: #fff7ed;
}

.dt-search input {
    border-color: #e7c99b;
    border-radius: 8px;
    font-size: .8rem;
}

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

.profile-item {
    padding: .5rem;
    border: 1px solid var(--dm-line);
    border-radius: 8px;
    background: #fff;
}

.profile-item small {
    display: block;
    color: var(--dm-muted);
    margin-bottom: .2rem;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        linear-gradient(135deg, rgba(124, 45, 18, .96), rgba(217, 119, 6, .88)),
        #b45309;
}

.login-card {
    width: min(100%, 430px);
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, .24);
}

.login-logo {
    max-width: 100%;
    height: 56px;
    object-fit: contain;
    object-position: left center;
}

.login-title {
    margin: 1rem 0 .25rem;
    font-size: 1.24rem;
    font-weight: 800;
}

.text-muted-compact {
    color: var(--dm-muted);
    font-size: .86rem;
}

.filter-panel {
    background: #fff;
    border: 1px solid var(--dm-line);
    border-radius: 8px;
    padding: .7rem;
    margin-bottom: .75rem;
}

.select2-container--bootstrap-5 .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-results__option {
    font-size: .8rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    border-color: #d6a35d;
    background: #fff7ed;
    color: #7c2d12;
    font-size: .78rem;
}

.chart-box {
    display: flex;
    flex-direction: column;
    height: 310px;
    min-height: 310px;
    overflow: hidden;
}

.chart-canvas {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

.chart-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 238px;
}

.modal-content {
    border-radius: 8px;
    border: 1px solid var(--dm-line);
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    .app-main {
        padding-left: 0;
    }

    .topbar {
        padding-inline: .8rem;
    }

    .topbar-actions span {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .content-wrap {
        padding: .75rem;
    }

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

    .brand-logo {
        width: 128px;
        max-width: 40vw;
    }

    .brand-inline small {
        display: none;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .chart-box {
        height: 285px;
        min-height: 285px;
    }
}
