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

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --danger: #DC2626;
    --danger-hover: #B91C1C;
    --success: #059669;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ---------- Login ---------- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: #fff;
    padding: 48px 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logo { color: var(--primary); margin-bottom: 16px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-subtitle { color: var(--gray-500); margin-bottom: 32px; font-size: 14px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* ---------- Top Bar ---------- */

.top-bar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.top-bar-right { display: flex; gap: 8px; align-items: center; }

/* ---------- Container / Toolbar ---------- */

.container { max-width: 1400px; margin: 0 auto; padding: 32px; }
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.toolbar h2 { font-size: 20px; font-weight: 600; }

/* ---------- Table ---------- */

.table-wrap {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}
tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

.col-name   { width: 180px; }
.col-creds  { width: 130px; }
.col-image  { width: 120px; }
.col-bio    { width: 300px; }
.col-slugs  { min-width: 250px; }
.col-actions { width: 150px; }

/* ---------- Editable Cells ---------- */

.cell-name,
.cell-creds,
.cell-image,
.cell-bio {
    cursor: pointer;
}
.cell-name:hover,
.cell-creds:hover,
.cell-bio:hover {
    background: var(--gray-100);
    border-radius: 4px;
}
.edit-hint {
    font-size: 11px;
    color: var(--gray-400);
    opacity: 0;
    transition: opacity .15s;
    margin-left: 4px;
}
.cell-name:hover .edit-hint,
.cell-creds:hover .edit-hint,
.cell-bio:hover .edit-hint {
    opacity: 1;
}
.name-display { font-weight: 500; }
.creds-display { color: var(--gray-600); font-size: 13px; }
.cell-name input,
.cell-creds input {
    font-size: 14px;
    padding: 4px 8px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    outline: none;
    width: 100%;
    font-family: inherit;
}

/* ---------- Image Cell ---------- */

.cell-image { text-align: center; }
.cell-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.no-image {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 2px dashed var(--gray-300);
    color: var(--gray-400);
    font-size: 11px;
    margin: 0 auto;
    transition: border-color .15s, color .15s;
}
.cell-image:hover .no-image {
    border-color: var(--primary);
    color: var(--primary);
}

/* ---------- Bio Cell ---------- */

.bio-preview {
    font-size: 13px;
    color: var(--gray-600);
    max-height: 80px;
    overflow: hidden;
    position: relative;
}
.bio-preview::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 30px;
    background: linear-gradient(transparent, #fff);
    pointer-events: none;
}
tr:hover .bio-preview::after {
    background: linear-gradient(transparent, var(--gray-50));
}
.bio-empty {
    font-size: 13px;
    color: var(--gray-400);
    font-style: italic;
}

/* ---------- Slug Tags ---------- */

.slug-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.slug-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--gray-700);
}
.slug-remove {
    cursor: pointer;
    color: var(--gray-400);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    transition: color .15s;
}
.slug-remove:hover { color: var(--danger); }
.slug-add-form { display: flex; gap: 4px; }
.slug-add-form input {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    width: 170px;
    font-family: inherit;
}
.slug-add-form input:focus { outline: none; border-color: var(--primary); }
.slug-add-form button {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.slug-add-form button:hover { background: var(--primary-hover); }
.slug-error { color: var(--danger); font-size: 11px; margin-top: 4px; }

/* ---------- Status / Actions ---------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    margin-bottom: 8px;
}
.status-active  { color: var(--success); background: #D1FAE5; }
.status-inactive { color: var(--gray-500); background: var(--gray-100); }

.btn-decommission {
    font-size: 12px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 4px;
    cursor: pointer;
    transition: all .15s;
}
.btn-decommission:hover { background: var(--danger); color: #fff; }

.btn-reenable {
    font-size: 12px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
    border-radius: 4px;
    cursor: pointer;
    transition: all .15s;
}
.btn-reenable:hover { background: var(--success); color: #fff; }

.row-inactive { opacity: .45; }

/* ---------- Footer ---------- */

.admin-footer {
    text-align: center;
    padding: 32px 0 8px;
}
.btn-link-muted {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color .15s;
}
.btn-link-muted:hover { color: var(--gray-600); }

/* ---------- Empty State ---------- */

.empty-state { padding: 60px 20px; text-align: center; color: var(--gray-500); }

/* ---------- Modals ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-lg { max-width: 800px; }
.modal-sm { max-width: 420px; }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Bio editor inside modal */
#bio-editor { min-height: 300px; }
#bio-editor .ql-editor { min-height: 260px; font-size: 14px; }

/* Decommission modal */
.decom-warning { color: var(--gray-600); margin-bottom: 20px; font-size: 14px; }
.decom-slug-list { display: flex; flex-direction: column; gap: 12px; }
.decom-slug-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}
.decom-slug-row .slug-label { font-weight: 500; font-size: 14px; flex-shrink: 0; }
.decom-slug-row select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.decom-note { color: var(--gray-500); font-size: 14px; font-style: italic; }

/* Snippet modal */
.snippet-description { font-size: 13px; color: var(--gray-600); margin-bottom: 16px; line-height: 1.5; }
.snippet-description code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}
.snippet-wrap {
    position: relative;
}
.snippet-code {
    width: 100%;
    padding: 10px 14px;
    padding-right: 70px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    color: var(--gray-800);
    resize: vertical;
    cursor: text;
    min-height: 90px;
}
.btn-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    background: #fff;
    color: var(--gray-600);
    cursor: pointer;
    transition: all .15s;
}
.btn-copy:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}
.btn-copy.copied {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    z-index: 2000;
    animation: toastIn .3s ease, toastOut .3s ease 2.7s forwards;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .container { padding: 16px; }
    .top-bar { padding: 0 16px; }
    .top-bar-right { gap: 4px; }
    .table-wrap { overflow-x: auto; }
    table { min-width: 900px; }
}
