:root {
    --sidebar-width: 220px;
    --topbar-height: 60px;
    --mobile-sidebar-width: 280px;
    --transition-duration: 0.3s;
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    position: relative;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all var(--transition-duration) ease;
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-duration) ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media screen and (max-width: 767px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }

    .topbar {
        padding: 0 16px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .hamburger {
        display: flex;
        margin-right: 16px;
    }

    .brand {
        font-size: 20px;
        flex: 1;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: var(--mobile-sidebar-width);
        height: 100vh;
        z-index: 1000;
        transition: left var(--transition-duration) ease;
        padding-top: calc(var(--topbar-height) + 20px);
        overflow-y: auto;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        left: 0;
    }

    .nav-item {
        padding: 14px 24px;
        font-size: 15px;
    }

    .content {
        padding: 16px 12px 32px;
    }

    .page-header h2 {
        font-size: 16px;
    }

    .filter-row {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .filter {
        min-width: 100%;
    }

    .filter span {
        min-width: 70px;
    }

    .filter select {
        width: 100%;
        flex: 1;
    }

    .search-box {
        margin-left: 0;
        margin-top: 8px;
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .search-box input {
        width: 100%;
    }

    .btn-search,
    .btn-action {
        width: 100%;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    table {
        min-width: 600px;
        font-size: 13px;
    }

    th,
    td {
        padding: 10px 12px;
        white-space: nowrap;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .pager {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .toast {
        right: 16px;
        left: 16px;
        bottom: 16px;
        min-width: auto;
        max-width: none;
    }

    .chart-card,
    .table-card,
    .card {
        padding: 16px 12px;
        border-radius: 8px;
    }

    .chart-container {
        height: 250px !important;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-group {
        width: 100%;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
    }

    .btn-primary,
    .btn-outline,
    .btn {
        width: 100%;
        padding: 12px 16px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px auto;
        padding: 20px 16px;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-item {
        min-width: 100px;
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
    .layout {
        grid-template-columns: 180px auto;
    }

    .sidebar {
        width: 180px;
    }

    .nav-item {
        padding: 12px 20px;
        font-size: 15px;
    }

    .content {
        padding: 18px 16px 36px;
    }

    .filter-row {
        gap: 16px;
    }

    .filter select {
        width: 110px;
    }

    .search-box input {
        width: 180px;
    }

    table {
        min-width: 800px;
        font-size: 13px;
    }

    th,
    td {
        padding: 10px 14px;
    }

    .chart-container {
        height: 300px !important;
    }

    .modal-content {
        width: 80%;
    }
}

@media screen and (max-width: 1024px) {
    .grid-2-cols,
    .grid-3-cols,
    .grid-4-cols {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

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

    .dual-panel {
        flex-direction: column;
    }

    .dual-panel > * {
        width: 100%;
    }
}

@media screen and (max-width: 767px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .action-buttons button,
    .action-buttons .btn {
        width: 100%;
    }

    .info-list {
        font-size: 13px;
    }

    .info-list dt {
        min-width: 80px;
    }
}

body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.touch-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.touch-scroll::-webkit-scrollbar {
    height: 6px;
}

.touch-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.touch-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.touch-scroll::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
