/* ==================== Reset & Variables ==================== */
:root {
    --navy: #FFFEE8;
    --navy-light: #FFFFF5;
    --navy-dark: #F5F0D8;
    --gold: #4A9EBF;
    --gold-light: #7BC0DE;
    --gold-dark: #2E7A9A;
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --gray: #9ca3af;
    --gray-bg: rgba(156, 163, 175, 0.1);
    --white: #3D2F1F;
    --white-90: rgba(61,47,31,0.92);
    --white-70: rgba(61,47,31,0.7);
    --white-50: rgba(61,47,31,0.5);
    --white-20: rgba(61,47,31,0.15);
    --white-10: rgba(61,47,31,0.08);
    --white-05: rgba(255,255,255,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--navy-dark);
    color: var(--white-90);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius); font-size: 14px;
    font-weight: 500; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-dark)); color: var(--navy); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(212,175,55,0.4); transform: translateY(-1px); }
.btn-secondary { background: var(--white-10); color: var(--white-90); border: 1px solid var(--white-20); }
.btn-secondary:hover:not(:disabled) { background: var(--white-20); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ==================== Form ==================== */
.form-input, .form-select {
    padding: 10px 14px; background: var(--white-05); border: 1px solid var(--white-20);
    border-radius: var(--radius); color: var(--white-90); font-size: 14px;
    outline: none; transition: border-color 0.3s; width: 100%;
}
.form-input:focus, .form-select:focus { border-color: var(--gold); }
.form-input::placeholder { color: var(--white-50); }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-select option { background: var(--navy); color: var(--white-90); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--white-70); margin-bottom: 6px; }

/* ==================== Table ==================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--white-05); }
th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--white-70); font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--white-10); cursor: pointer; -webkit-user-select: none;
    user-select: none; }
th:hover { color: var(--gold); }
td { padding: 12px 16px; border-bottom: 1px solid var(--white-05); vertical-align: middle; }
tr:hover td { background: var(--white-05); }

/* ==================== Status Badge ==================== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-valid { background: var(--green-bg); color: var(--green); }
.badge-invalid { background: var(--gray-bg); color: var(--gray); }
.badge-role { background: rgba(212,175,55,0.15); color: var(--gold); }

/* ==================== Pagination ==================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination button { padding: 6px 12px; background: var(--white-05); border: 1px solid var(--white-10); border-radius: var(--radius); color: var(--white-70); cursor: pointer; font-size: 13px; transition: var(--transition); }
.pagination button:hover:not(:disabled) { background: var(--white-10); color: var(--white-90); }
.pagination button.active { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 600; }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .info { color: var(--white-50); font-size: 13px; margin: 0 8px; }

/* ==================== Modal ==================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--navy-light); border: 1px solid var(--white-10); border-radius: var(--radius-xl); padding: 0; width: 100%; max-width: 520px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--white-10); }
.modal-header h3 { font-size: 18px; color: var(--white-90); }
.modal-close { background: none; border: none; color: var(--white-50); font-size: 24px; cursor: pointer; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--white-90); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--white-10); }

/* ==================== Toast ==================== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); font-size: 14px; animation: slideIn 0.3s ease; min-width: 200px; max-width: 400px; }
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--red); color: #fff; }
.toast-info { background: #3b82f6; color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ==================== Confirm Dialog ==================== */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1100; padding: 20px; }
.confirm-overlay.active { display: flex; }
.confirm-dialog { background: var(--navy-light); border: 1px solid var(--white-10); border-radius: var(--radius-xl); padding: 32px; max-width: 380px; text-align: center; }
.confirm-dialog .icon { font-size: 48px; margin-bottom: 16px; }
.confirm-dialog h4 { font-size: 18px; margin-bottom: 8px; }
.confirm-dialog p { color: var(--white-70); font-size: 14px; margin-bottom: 24px; }
.confirm-dialog .actions { display: flex; gap: 12px; justify-content: center; }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .btn { padding: 6px 12px; font-size: 13px; }
    .modal { max-width: 100%; }
    table { font-size: 13px; }
    th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .btn-sm { padding: 4px 8px; font-size: 11px; }
}
