:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #222632;
    --border: #2a2e3b;
    --text: #e4e6ed;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --green: #00cec9;
    --green-bg: rgba(0,206,201,0.12);
    --orange: #fdcb6e;
    --orange-bg: rgba(253,203,110,0.12);
    --red: #ff7675;
    --red-bg: rgba(255,118,117,0.12);
    --blue: #74b9ff;
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.header h1 { font-size: 18px; font-weight: 600; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    font-size: 13px;
    color: var(--text-dim);
}

.user-info .role {
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
}

/* Navigation */
nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    gap: 4px;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

nav a:hover { color: var(--text); }
nav a.active { color: var(--accent-light); border-bottom-color: var(--accent); }

/* Buttons */
.btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.85; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: 0.85; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: none; border: none; color: var(--text-dim); padding: 5px 10px; }
.btn-ghost:hover { color: var(--text); }

/* Main content */
.main { max-width: 1200px; margin: 0 auto; padding: 24px 28px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Client Cards Grid */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.client-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.client-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.client-card h3 { font-size: 16px; margin-bottom: 12px; }

.client-stats {
    display: flex;
    gap: 16px;
}

.client-stat {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.client-stat.required { background: var(--orange-bg); }
.client-stat.filled { background: var(--green-bg); }
.client-stat.missing { background: var(--red-bg); }

.client-stat .num {
    font-size: 24px;
    font-weight: 700;
}

.client-stat.required .num { color: var(--orange); }
.client-stat.filled .num { color: var(--green); }
.client-stat.missing .num { color: var(--red); }

.client-stat .label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Credential Table */
.cred-table {
    width: 100%;
    border-collapse: collapse;
}

.cred-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.cred-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.cred-table tr:last-child td { border-bottom: none; }
.cred-table tr:hover td { background: var(--surface-hover); }

/* Status badges */
.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 500;
}

.status-filled { background: var(--green-bg); color: var(--green); }
.status-missing { background: var(--red-bg); color: var(--red); }
.status-inactive { background: rgba(139,143,163,0.15); color: var(--text-dim); }

/* Category headers */
.category-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    padding: 14px 12px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Password reveal */
.password-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-value {
    font-family: 'Courier New', monospace;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    user-select: all;
}

.password-dots {
    color: var(--text-dim);
    letter-spacing: 2px;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 22px;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 28px;
}

.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* Audit log */
.audit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.audit-row:last-child { border-bottom: none; }

.audit-action {
    font-weight: 500;
    min-width: 80px;
}

.audit-action.login { color: var(--blue); }
.audit-action.create { color: var(--green); }
.audit-action.update { color: var(--orange); }
.audit-action.reveal { color: var(--accent-light); }
.audit-action.delete { color: var(--red); }
.audit-action.login_failed { color: var(--red); }

.audit-details { color: var(--text-dim); flex: 1; }
.audit-time { color: var(--text-dim); font-size: 12px; }

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-dim);
}

.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 13px;
    z-index: 200;
    animation: slideUp 0.3s ease;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .main { padding: 16px; }
    .clients-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .modal { margin: 16px; }
    nav { overflow-x: auto; }
}
