/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f0f2f5;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f5f6f8;
    --border: rgba(0,0,0,0.08);
    --text: #1a1a2e;
    --text-sec: #4a5568;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99,102,241,0.2);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.25s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo { margin-bottom: 24px; }
.logo-icon { font-size: 28px; margin-right: 8px; }
.logo-text { font-size: 22px; font-weight: 800; }
.logo-accent {
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-card h2 { font-size: 16px; color: var(--text-sec); margin-bottom: 24px; font-weight: 500; }
.login-card input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 14px;
    outline: none;
    transition: var(--transition);
}
.login-card input:focus { border-color: var(--accent); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ===== LAYOUT ===== */
.main-panel {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.sidebar-nav { flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: var(--text-sec);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.nav-item.active {
    color: var(--accent);
    background: rgba(99,102,241,0.08);
    border-left-color: var(--accent);
}
.nav-icon { font-size: 16px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ===== CONTENT ===== */
.content {
    flex: 1;
    margin-left: 240px;
    padding: 32px 40px;
    max-width: 1100px;
}
.section { display: none; animation: fadeIn 0.3s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.content h1 { font-size: 24px; font-weight: 700; margin-bottom: 24px; }
.content h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.content h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: var(--transition);
}
.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.stat-icon { font-size: 24px; margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 20px;
    transition: var(--transition);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px var(--accent-glow); }
.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: rgba(0,0,0,0.06); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== FORMS ===== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-sec);
}
.hint { color: var(--text-muted); font-weight: 400; }
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}
.form-group input:focus { border-color: var(--accent); }
.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.form-input-sm {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    flex: 1;
    min-width: 80px;
}
.form-input-sm:focus { border-color: var(--accent); }

/* ===== COUNTRY CHECKBOXES ===== */
.country-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.country-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}
.country-checkbox:hover { border-color: var(--accent); }
.country-checkbox.checked {
    border-color: var(--accent);
    background: rgba(99,102,241,0.12);
}
.country-checkbox input { display: none; }

/* ===== CREATE RESULT ===== */
.create-result {
    margin-top: 20px;
    padding: 20px;
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: var(--radius);
}
.result-label { font-size: 14px; font-weight: 600; color: var(--success); margin-bottom: 10px; }
.result-url-wrap { display: flex; gap: 10px; }
.result-url-wrap input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: monospace;
}

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}
.table tr:hover td { background: rgba(0,0,0,0.02); }

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-active { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-used { background: rgba(99,102,241,0.12); color: var(--accent-hover); }
.badge-expired { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-on { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-off { background: rgba(239,68,68,0.12); color: var(--danger); }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}
.page-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ===== DETAIL INFO ===== */
.detail-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.detail-field {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.detail-field-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-field-value { font-size: 14px; font-weight: 600; word-break: break-all; }

/* ===== TOGGLE ===== */
.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.15);
    border-radius: 11px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transform: translateY(100px);
    transition: transform 0.3s ease;
}
.toast.show { transform: translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; padding: 12px 0; }
    .sidebar-logo { display: none; }
    .nav-item span:not(.nav-icon) { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .sidebar-footer { display: none; }
    .content { margin-left: 60px; padding: 20px 16px; }
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}
.modal-close-btn:hover { color: var(--text); }
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}
