/* ── Design Tokens ─────────────────────────────────── */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-card: #1c1f2e;
    --bg-input: #1a1d2e;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b4;
    --text-muted: #6b7280;
    --text-white: #fff;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-bg: rgba(99,102,241,0.12);
    --success: #10b981;
    --success-bg: rgba(16,185,129,0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.12);
    --warning: #f59e0b;
    --border: rgba(255,255,255,0.06);
    --border-active: rgba(99,102,241,0.4);
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ── Top Navbar ──────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-white);
    flex-shrink: 0;
}
.navbar-brand span { font-size: 1.3rem; }
.navbar-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}
.navbar-nav a {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.navbar-nav a:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.navbar-nav a.active { color: var(--text-white); background: var(--accent-bg); }
.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.navbar-right a { color: var(--text-muted); font-size: 0.85rem; }
.navbar-right a:hover { color: var(--danger); }

/* ── Container ───────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 24px; }

/* ── Page Header ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; color: var(--text-white); }
.page-header .sub { font-size: 0.85rem; color: var(--text-muted); margin-left: 10px; font-weight: 400; }

/* ── Stats Row ───────────────────────────────────────── */
.stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.stat-item {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.2s;
}
.stat-item:hover { border-color: var(--border-active); }
.stat-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.purple { background: var(--accent-bg); }
.stat-icon.green { background: var(--success-bg); }
.stat-icon.blue { background: rgba(59,130,246,0.12); }
.stat-icon.orange { background: rgba(245,158,11,0.12); }
.stat-val { font-size: 1.5rem; font-weight: 800; color: var(--text-white); line-height: 1; }
.stat-lbl { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Search Bar (inline) ─────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.search-bar input {
    flex: 1;
    max-width: 360px;
    padding: 7px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-muted); }

/* ── Table ────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table.dt {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 0.95rem;
}
table.dt th {
    text-align: left;
    padding: 9px 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.015);
    white-space: nowrap;
}
table.dt td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
    white-space: nowrap;
}
table.dt tbody tr { transition: background 0.1s; }
table.dt tbody tr:hover { background: rgba(99,102,241,0.03); }
table.dt tbody tr:last-child td { border-bottom: none; }

.name-link { font-weight: 600; color: var(--text-primary); }
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-on { background: var(--success-bg); color: var(--success); }
.badge-off { background: var(--danger-bg); color: var(--danger); }
.badge-dev { background: var(--accent-bg); color: var(--accent-hover); }
.cell-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    vertical-align: middle;
    cursor: pointer;
    transition: opacity 0.2s;
}
.cell-avatar:hover { opacity: 0.8; }
.cell-avatar-placeholder {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    vertical-align: middle;
    cursor: pointer;
    transition: all 0.2s;
}
.cell-avatar-placeholder:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(99,102,241,0.05);
}
.muted { color: var(--text-muted); }
.small { font-size: 0.78rem; }
.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger { color: var(--danger) !important; }
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}
.copyable {
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.copyable:hover { background: rgba(99,102,241,0.1); }
.copy-icon {
    font-size: 0.7rem;
    opacity: 0.3;
    transition: opacity 0.15s;
}
.copyable:hover .copy-icon { opacity: 1; }
.captcha-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245,158,11,0.12);
    color: #f59e0b;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    margin-top: 2px;
    animation: captchaGlow 2s ease-in-out infinite;
}
@keyframes captchaGlow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 6px rgba(245,158,11,0.3); }
}
.captcha-badge strong { color: #fbbf24; font-size: 0.9rem; }
.copy-icon-inline {
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.copy-icon-inline:hover { opacity: 1; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px;
    border: none; border-radius: var(--radius);
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    font-family: inherit; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-p { background: var(--accent); color: #fff; }
.btn-p:hover { background: var(--accent-hover); color: #fff; }
.btn-s { background: rgba(255,255,255,0.06); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-s:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-d { background: var(--danger-bg); color: var(--danger); }
.btn-d:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 10px 22px; font-size: 0.95rem; }

.actions { display: flex; gap: 4px; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%239aa0b4' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
textarea.form-control { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }

/* ── Photo Upload ─────────────────────────────────────── */
.photo-box {
    width: 140px; height: 170px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    background: var(--bg-input);
    flex-shrink: 0;
}
.photo-box:hover { border-color: var(--accent); }
.photo-box.has-photo { border-style: solid; border-color: var(--accent); }
.photo-box img {
    width: 100%; height: 100%;
    object-fit: cover;
    position: absolute; inset: 0;
}
.photo-box .ph {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.photo-box .ph .icon { font-size: 2rem; display: block; margin-bottom: 4px; }
.photo-box .overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
    color: #fff; font-size: 0.8rem; font-weight: 600;
}
.photo-box:hover .overlay { opacity: 1; }

/* Detail photo */
.detail-photo {
    width: 120px; height: 150px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo-empty {
    width: 120px; height: 150px;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 2px dashed var(--border);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 0.8rem;
    cursor: pointer; flex-shrink: 0;
}
.detail-photo-empty .icon { font-size: 2rem; margin-bottom: 4px; }

/* ── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 3px; margin-top: 14px;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 8px;
    border-radius: var(--radius);
    font-size: 0.82rem; font-weight: 500;
    color: var(--text-secondary); transition: all 0.15s;
}
.pagination a:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.pagination .active { background: var(--accent); color: #fff; }
.pagination .disabled { opacity: 0.3; pointer-events: none; }

/* ── Flash Messages ───────────────────────────────────── */
.flash-bar {
    position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
    z-index: 9999;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500;
    color: #fff; box-shadow: var(--shadow);
    animation: slideDown 0.3s ease;
    white-space: nowrap;
}
@keyframes slideDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.flash-bar.success { background: linear-gradient(135deg, #059669, #10b981); }
.flash-bar.error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.flash-bar.info { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.flash-bar.warning { background: linear-gradient(135deg, #d97706, #f59e0b); }

/* ── Detail Page ──────────────────────────────────────── */
.detail-top {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}
.detail-name { font-size: 1.4rem; font-weight: 800; color: var(--text-white); }
.detail-tags { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.detail-tags span { font-size: 0.82rem; color: var(--text-muted); }

.info-section { margin-bottom: 18px; }
.info-section h3 {
    font-size: 0.9rem; font-weight: 700; color: var(--text-white);
    margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px 16px;
}
.info-field { min-width: 0; }
.info-lbl { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 2px; }
.info-val { font-size: 0.9rem; color: var(--text-primary); word-break: break-all; }
.info-val.empty { color: var(--text-muted); font-style: italic; font-size: 0.82rem; }

/* ── Login Page ───────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary);
}
.login-card {
    width: 380px; padding: 40px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px; margin-bottom: 12px;
}
.login-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-white); }
.login-logo p { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ── Modal ────────────────────────────────────────────── */
.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none; align-items: center; justify-content: center;
}
.modal-bg.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    min-width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-box h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-white); margin-bottom: 10px; }
.modal-box p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Import / Settings ────────────────────────────────── */
.simple-card {
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}
.simple-card .center { text-align: center; }
.simple-card .icon-big { font-size: 3rem; margin-bottom: 12px; }
.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    cursor: pointer;
    transition: all 0.2s;
}
.file-upload-area:hover { border-color: var(--accent); background: rgba(99,102,241,0.04); }
.file-upload-area.selected { border-color: var(--success); border-style: solid; }
.file-upload-area .icon { font-size: 2rem; }

/* ── Empty ────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty .icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.5; }
.empty .title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
    .stats-row { flex-wrap: wrap; }
    .stat-item { min-width: calc(50% - 6px); }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .container { padding: 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .stat-item { min-width: 100%; }
    .detail-top { flex-direction: column; }
}
