
:root {
    --primary: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --bg: #f9fafb;
    --bg-primary: #f3f4f6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app {
    min-height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.layout {
    display: flex;
    min-height: calc(100vh - 72px);
}

.sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.collapse-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.collapse-btn:hover {
    color: var(--primary);
}

.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link .icon {
    font-size: 1.25rem;
}

.nav-menu {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link.nav-logout {
    color: var(--text);
}

.nav-link.nav-logout:hover {
    background: var(--text);
    color: #fff;
}

.main {
    flex: 1;
    padding: 2rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.95);
}


.nav-link {
    min-height: 44px;
    touch-action: manipulation;
}

.collapse-btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}


.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 0.75rem;
    max-width: 400px;
    width: 90%;
    overflow: hidden;
}

.modal-title {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.captcha-row {
    display: flex;
    gap: 0.75rem;
}

.captcha-row input {
    flex: 1;
}

.captcha-row img {
    height: 2.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid var(--border);
}

.modal-buttons {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}


@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .user-info {
        gap: 0.5rem;
    }
    
    .user-info span {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 0;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0 0.5rem;
    }
    
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    
    .nav-link {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        margin-right: 0.5rem;
    }
    
    .sidebar-header {
        display: none;
    }
    
    .nav-link[style*="margin-top: auto"] {
        margin-top: 0 !important;
        border-top: none !important;
    }
    
    .nav-link[style*="margin-top: 0"] {
        margin-top: 0 !important;
    }
    
    .nav-link.active {
        background: var(--primary);
        color: #fff;
    }
    
    
    .nav-tab {
        flex-shrink: 0;
        border-radius: 0.5rem;
        transition: all 0.2s;
    }
    
    .nav-tab.active {
        background: var(--primary);
        color: #fff;
    }
    
    .main {
        padding: 1rem;
    }
    
    
    .dashboard-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .data-card {
        padding: 1.25rem;
    }
    
    .data-card h3 {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    .data-card div {
        font-size: 1.5rem;
    }
    
    
    .form-group input {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 1rem;
    }
    
    .modal-title {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    
    .modal-buttons {
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .modal-buttons .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    
    .modal-qr-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .modal-qr-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    
    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        min-width: 4rem;
    }
    
    
    .table-container {
        margin-bottom: 1rem;
        overflow-x: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--border) var(--bg);
    }
    
    .table-container::-webkit-scrollbar {
        height: 6px;
    }
    
    .table-container::-webkit-scrollbar-track {
        background: var(--bg);
        border-radius: 3px;
    }
    
    .table-container::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }
    
    .table-container::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }
    
    
    table {
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    th {
        font-size: 0.625rem;
        padding: 0.5rem 0.25rem;
    }
    
    td {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }
    
    
    .status-tag {
        font-size: 0.625rem;
        padding: 0.125rem 0.5rem;
    }
}


@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .main {
        padding: 0.75rem;
    }
    
    .nav-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

.status-on {
    background: #d1fae5;
    color: #065f46;
}

.status-off {
    background: #fee2e2;
    color: #991b1b;
}

.status-warn {
    background: #fef3c7;
    color: #92400e;
}

.nav-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}


.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--success);
}

input:checked + .slider:before {
    transform: translateX(20px);
}


.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.notification.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.notification.warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}


.modal-qr-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}


.scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.scanner-container {
    background: #fff;
    border-radius: 1rem;
    width: 90%;
    max-width: 450px;
    overflow: hidden;
}

.scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.scanner-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.scanner-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.scanner-close:hover {
    color: var(--danger);
}

.scanner-body {
    padding: 1.5rem;
}

.scanner-viewfinder {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 1rem;
    overflow: hidden;
    background-color: #000;
    border-radius: 0.5rem;
}

.scanner-viewfinder video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.scanner-video {
    border-radius: 0.5rem;
    z-index: 1;
}

.scanner-frame {
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    bottom: 10%;
    border: 2px solid #4f46e5;
    border-radius: 0.5rem;
    z-index: 2;
    pointer-events: none;
}

.scanner-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #4f46e5;
}

.scanner-corner-tl {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scanner-corner-tr {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
}

.scanner-corner-bl {
    bottom: -3px;
    left: -3px;
    border-right: none;
    border-top: none;
}

.scanner-corner-br {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4f46e5, transparent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

.scanner-tips {
    text-align: center;
}

.scanner-tip-main {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.scanner-tip-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
