:root {
    --primary: #6c9bcf;
    --primary-dark: #4a7fb5;
    --primary-light: #e8f1fa;
    --accent: #f2a365;
    --accent-dark: #e08a45;
    --success: #7ec8a0;
    --danger: #e87f7f;
    --warning: #f2c94c;
    --bg: #f7f9fc;
    --card: #ffffff;
    --text: #3d4f5f;
    --text-light: #8a9bae;
    --border: #e2e8f0;
    --shadow: 0 2px 12px rgba(108, 155, 207, 0.08);
    --radius: 12px;
}

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

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

/* ===== Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: linear-gradient(180deg, #6c9bcf 0%, #4a7fb5 100%);
    color: #fff;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar .logo {
    padding: 0 1.2rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 1rem;
}

.sidebar .logo small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

.sidebar nav {
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.2rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: #fff;
}

.sidebar nav a .icon {
    width: 18px;
    text-align: center;
    font-style: normal;
}

.sidebar .user-info {
    padding: 1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.85rem;
}

.sidebar .user-info .username {
    font-weight: 600;
}

.sidebar .user-info .logout-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.3rem;
    padding: 0;
}

.sidebar .user-info .logout-btn:hover {
    color: #fff;
}

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 2rem;
    max-width: 1200px;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.2rem;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-accent:hover {
    background: var(--accent-dark);
}

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

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

.btn-danger:hover {
    background: #d06060;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--text-light);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 155, 207, 0.15);
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.65rem 0.8rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

table th {
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.8rem;
    background: var(--bg);
}

table tr:hover td {
    background: var(--primary-light);
}

/* ===== Tags ===== */
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-pending {
    background: #fef3cd;
    color: #856404;
}

.tag-paid {
    background: #d4edda;
    color: #155724;
}

.tag-expired {
    background: #f8d7da;
    color: #721c24;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* ===== SK Group ===== */
.sk-group {
    margin-bottom: 1.5rem;
}

.sk-group-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    background: var(--primary-light);
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
}

.sk-group-header .sk-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.sk-group-header .sk-value {
    font-size: 0.78rem;
    color: var(--text-light);
    font-family: monospace;
}

.sk-group-header .sk-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-light);
}

.sk-group-body {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e8f1fa 0%, #f7f9fc 50%, #fef0e3 100%);
}

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 380px;
    box-shadow: 0 8px 32px rgba(108, 155, 207, 0.12);
}

.login-box h1 {
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 0.3rem;
    color: var(--primary-dark);
}

.login-box .subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.login-box .toggle {
    text-align: center;
    font-size: 0.85rem;
    margin-top: 1rem;
    color: var(--text-light);
}

.login-box .toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.login-box .toggle a:hover {
    text-decoration: underline;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 0.65rem;
    font-size: 0.95rem;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #fff;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

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

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.modal h3 {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.2rem;
}

/* ===== Empty State ===== */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ===== Mobile Cards Container ===== */
.mobile-cards {
    display: none;
}

.sk-card-mobile,
.stat-card-mobile {
    display: none;
}

/* ===== Done Section (collapsed) ===== */
.done-section {
    border-top: 1px dashed var(--border);
}

.done-toggle {
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: var(--text-light);
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.done-toggle::-webkit-details-marker {
    display: none;
}

.done-toggle::before {
    content: "▸ ";
}

details[open] > .done-toggle::before {
    content: "▾ ";
}

.done-section .table-wrap {
    opacity: 0.7;
}

.done-section .order-card {
    opacity: 0.7;
}

/* ===== Mobile Order Card ===== */
.order-card {
    display: none;
}

.order-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.8rem;
}

.order-card .order-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.order-card .order-card-row:last-child {
    margin-bottom: 0;
}

.order-card .order-card-label {
    color: var(--text-light);
    font-size: 0.78rem;
}

.order-card .order-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.order-card .order-card-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
}

/* ===== Mobile Bottom Tab ===== */
.bottom-tab {
    display: none;
}

/* ===== SK Picker (mobile top bar) ===== */
.sk-picker {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0.8rem;
        padding-bottom: 70px;
    }

    /* Bottom tab bar */
    .bottom-tab {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid var(--border);
        z-index: 100;
        height: 56px;
    }

    .bottom-tab a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-light);
        font-size: 0.7rem;
        gap: 2px;
        transition: color 0.2s;
    }

    .bottom-tab a .tab-icon {
        font-size: 1.2rem;
        font-style: normal;
    }

    .bottom-tab a.active {
        color: var(--primary);
    }

    .bottom-tab a .tab-logout {
        color: var(--danger);
    }

    /* SK picker bar */
    .sk-picker {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: var(--card);
        padding: 0.6rem 0.8rem;
        border-radius: var(--radius);
        margin-bottom: 0.8rem;
        border: 1px solid var(--border);
        box-shadow: var(--shadow);
    }

    .sk-picker label {
        font-size: 0.8rem;
        color: var(--text-light);
        white-space: nowrap;
    }

    .sk-picker select {
        flex: 1;
        padding: 0.4rem 0.5rem;
        border: 1.5px solid var(--border);
        border-radius: 8px;
        font-size: 0.85rem;
        color: var(--text);
        background: #fff;
    }

    /* Hide table, show cards on mobile */
    .table-wrap {
        display: none !important;
    }

    .mobile-cards {
        display: block;
    }

    .sk-card-mobile,
    .stat-card-mobile {
        display: block;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1rem;
        margin-bottom: 0.8rem;
    }

    .sk-group .table-wrap {
        display: none !important;
    }

    .order-card {
        display: block;
    }

    .sk-group-header {
        flex-wrap: wrap;
        gap: 0.3rem;
        border-radius: var(--radius);
        border-bottom: 1px solid var(--border);
    }

    .sk-group-header .sk-value {
        display: none;
    }

    .sk-group-body {
        border: none;
        border-radius: 0;
    }

    /* Filter bar */
    .filter-bar {
        display: none;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .stat-card {
        padding: 0.8rem;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    /* Login box */
    .login-box {
        width: calc(100vw - 2rem);
        padding: 1.5rem;
    }
}

/* ===== Copy button ===== */
.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
}

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

/* ===== Filter bar ===== */
.filter-bar {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-bar select {
    padding: 0.45rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text);
    background: #fff;
}

.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}
