:root {
    --primary: #4361ee;
    --primary-light: #eef0ff;
    --success: #2ec4b6;
    --success-light: #e8faf8;
    --warning: #ff9f1c;
    --warning-light: #fff5e6;
    --danger: #e71d36;
    --danger-light: #fde8eb;
    --purple: #7b2ff7;
    --purple-light: #f0e8ff;
    --gray: #6c757d;
    --gray-light: #f8f9fa;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --radius: 10px;
    --top-bar-height: 52px;
    --bottom-nav-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-light);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #4361ee 0%, #7b2ff7 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-icon { font-size: 48px; margin-bottom: 16px; }
.login-card h1 { font-size: 22px; margin-bottom: 8px; color: var(--text); }
.login-subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus { border-color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #3a56d4; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #27b0a3; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d01930; }

.btn-warning { background: var(--warning); color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--gray-light); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.top-bar-title { font-size: 17px; font-weight: 700; }

.main-content {
    padding: calc(var(--top-bar-height) + 12px) 12px calc(var(--bottom-nav-height) + 12px) 12px;
    max-width: 800px;
    margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.stat-blue { border-left: 3px solid var(--primary); }
.stat-blue .stat-value { color: var(--primary); }
.stat-green { border-left: 3px solid var(--success); }
.stat-green .stat-value { color: var(--success); }
.stat-red { border-left: 3px solid var(--danger); }
.stat-red .stat-value { color: var(--danger); }
.stat-purple { border-left: 3px solid var(--purple); }
.stat-purple .stat-value { color: var(--purple); }
.stat-orange { border-left: 3px solid var(--warning); }
.stat-orange .stat-value { color: var(--warning); }
.stat-gray { border-left: 3px solid var(--gray); }
.stat-gray .stat-value { color: var(--gray); }

.section-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--card-shadow);
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.recent-list { max-height: 400px; overflow-y: auto; }

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.recent-item:last-child { border-bottom: none; }
.recent-name { font-weight: 600; font-size: 14px; }
.recent-date { font-size: 12px; color: var(--text-secondary); }

.recent-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: var(--success-light); color: var(--success); }
.badge-expired { background: var(--danger-light); color: var(--danger); }

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

.search-box { flex: 1; }

.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus { border-color: var(--primary); }

.toolbar-actions { display: flex; gap: 6px; }

.data-list { display: flex; flex-direction: column; gap: 8px; }

.data-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--card-shadow);
}

.data-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.data-item-title { font-weight: 700; font-size: 15px; }
.data-item-subtitle { font-size: 12px; color: var(--text-secondary); }

.data-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 8px 0;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.generate-form { display: flex; flex-direction: column; gap: 12px; }

.form-row { display: flex; gap: 12px; }

.form-group { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--primary); }

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.filter-bar select {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}

.card-id-text {
    font-family: "Courier New", monospace;
    font-size: 12px;
    word-break: break-all;
    color: var(--text-secondary);
    background: var(--gray-light);
    padding: 6px 8px;
    border-radius: 6px;
    margin-top: 4px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 4px;
}

.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 20px; }
.nav-label { font-size: 11px; font-weight: 600; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-card {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 4px;
}

.modal-body { padding: 20px; }

.modal-body .form-group { margin-bottom: 14px; }

.modal-body .btn-block { margin-top: 8px; }

#toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease;
    max-width: 300px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.generated-cards-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--gray-light);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
}

.generated-card-item {
    font-family: "Courier New", monospace;
    font-size: 11px;
    padding: 4px 0;
    border-bottom: 1px solid #e0e0e0;
    word-break: break-all;
}

.generated-card-item:last-child { border-bottom: none; }

.user-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.user-detail-label { color: var(--text-secondary); }
.user-detail-value { font-weight: 600; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon { font-size: 40px; margin-bottom: 8px; }

@media (min-width: 600px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
    .stat-value { font-size: 28px; }
    .main-content { padding-top: calc(var(--top-bar-height) + 20px); padding-left: 20px; padding-right: 20px; }
}

@media (min-width: 768px) {
    .bottom-nav {
        top: var(--top-bar-height);
        bottom: auto;
        left: 0;
        right: auto;
        width: 140px;
        height: auto;
        flex-direction: column;
        border-top: none;
        border-right: 1px solid var(--border);
        background: #fff;
        padding: 12px 0;
    }

    .nav-item {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 20px;
        gap: 10px;
    }

    .nav-icon { font-size: 18px; }
    .nav-label { font-size: 14px; }

    .main-content {
        margin-left: 140px;
        padding-bottom: 20px;
    }

    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
