:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #222;
  --border: #2a2a2a;
  --accent: #8B5CF6;
  --accent-dim: rgba(139,92,246,.15);
  --text: #e8e8e8;
  --muted: #888;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Outfit', sans-serif; font-size: 15px; }
a { color: inherit; text-decoration: none; }
img { display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; width: 100%; outline: none; transition: border-color .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 24px 0; }
.main { flex: 1; overflow-y: auto; padding: 32px; max-width: 900px; }

/* Sidebar */
.logo { padding: 0 20px 24px; font-size: 1rem; font-weight: 700; color: var(--accent); letter-spacing: .02em; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted); font-size: .9rem; font-weight: 500; border-radius: 0; transition: background .15s, color .15s; }
.nav-item:hover, .nav-item.active { background: var(--accent-dim); color: var(--text); }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid var(--border); }
.btn-logout { width: 100%; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); padding: 8px 14px; font-size: .85rem; transition: background .15s, color .15s; }
.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .8rem; color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-size: .9rem; font-weight: 600; border: none; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { opacity: .9; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon { background: none; border: none; color: var(--muted); padding: 6px; border-radius: 6px; display: inline-flex; align-items: center; transition: background .15s, color .15s; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* Stats bar */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-value.accent { color: var(--accent); }

/* Model grid */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.model-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s; }
.model-card:hover { border-color: var(--accent); }
.model-card-banner { height: 90px; background: linear-gradient(135deg, #1e1e1e, #2a2a2a); overflow: hidden; position: relative; }
.model-card-banner img { width: 100%; height: 100%; object-fit: cover; }
.model-card-body { padding: 16px; }
.model-card-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.model-card-slug { font-size: .75rem; color: var(--muted); margin-bottom: 12px; font-family: monospace; }
.model-card-meta { display: flex; align-items: center; justify-content: space-between; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-active { background: rgba(34,197,94,.15); color: var(--success); }
.badge-inactive { background: rgba(239,68,68,.12); color: var(--danger); }
.model-card-actions { display: flex; gap: 6px; margin-top: 12px; }

/* Form */
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.form-section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-hint { font-size: .72rem; color: var(--muted); }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 8px; }

/* Image upload */
.img-upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; position: relative; overflow: hidden; }
.img-upload-area:not(.has-img):hover { border-color: var(--accent); background: var(--accent-dim); }
.img-upload-area.has-img { border-style: solid; border-color: var(--border); padding: 0; }
.img-upload-area img { width: 100%; height: 140px; object-fit: cover; display: block; }
.img-upload-hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.img-overlay { display: none; position: absolute; inset: 0; background: rgba(0,0,0,.62); align-items: center; justify-content: center; gap: 8px; }
.img-upload-area.has-img:hover .img-overlay { display: flex; }

/* Links list */
.links-list { display: flex; flex-direction: column; gap: 8px; }
.link-item { display: flex; align-items: center; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: grab; }
.link-item:active { cursor: grabbing; }
.link-drag { color: var(--border); flex-shrink: 0; }
.link-type-badge { flex-shrink: 0; padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; background: var(--accent-dim); color: var(--accent); }
.link-info { flex: 1; min-width: 0; }
.link-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-url { font-size: .72rem; color: var(--muted); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-toggle { flex-shrink: 0; }
.link-actions { flex-shrink: 0; display: flex; gap: 4px; }

/* Toggle */
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .2s; cursor: pointer; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.show { display: flex; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 1.1rem; font-weight: 700; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; padding: 10px 14px; background: var(--surface); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* Alert */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .85rem; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: #86efac; }

/* Chip group (platforms) */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; cursor: pointer; transition: all .15s; user-select: none; }
.chip input { display: none; }
.chip:has(input:checked) { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty p { margin-bottom: 20px; font-size: .9rem; }

/* Spinner */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* Color swatch */
input[type=color] { width: 48px; height: 38px; padding: 2px 4px; cursor: pointer; flex-shrink: 0; }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type=text] { flex: 1; }

/* ── Editor 2-column layout ── */
.editor-wrap { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.editor-form { flex: 1; overflow-y: auto; padding: 32px; min-width: 0; max-width: 780px; }
.editor-preview { width: 310px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; padding: 24px 20px; position: sticky; top: 0; height: 100vh; border-left: 1px solid var(--border); background: var(--bg); overflow-y: auto; }
.preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; width: 100%; }
.preview-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
/* Phone shell — 390×844 viewport scaled to fit preview panel */
.phone-shell { width: 260px; height: 553px; background: #111; border-radius: 40px; border: 8px solid #1e1e1e; overflow: hidden; position: relative; box-shadow: 0 0 0 1px #333, inset 0 0 0 1px rgba(255,255,255,.04), 0 24px 64px rgba(0,0,0,.7); flex-shrink: 0; }
.phone-shell::before { content: ''; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 72px; height: 6px; background: #1e1e1e; border-radius: 999px; z-index: 10; }
.phone-shell iframe { width: 390px; height: 844px; border: none; display: block; padding-top: 24px; transform: scale(0.626); transform-origin: 0 0; background: #111; }
.preview-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: .82rem; text-align: center; gap: 8px; padding: 20px; }

/* ── Icon picker ── */
.icon-picker-wrap { position: relative; }
.icon-selected-preview { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; transition: border-color .15s; min-height: 40px; }
.icon-selected-preview:hover { border-color: var(--accent); }
.icon-selected-none { font-size: .82rem; color: var(--muted); }
.icon-picker-grid { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; z-index: 200; display: none; }
.icon-picker-grid.open { display: block; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.icon-opt { width: 100%; aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content:center; cursor: pointer; transition: background .15s; border: 2px solid transparent; background: var(--surface2); }
.icon-opt:hover { background: var(--accent-dim); border-color: var(--accent); }
.icon-opt.active { border-color: var(--accent); background: var(--accent-dim); }
.icon-opt svg { display: block; }
.icon-custom-row { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; }
.icon-custom-row input { flex: 1; font-size: .82rem; padding: 7px 10px; }
.icon-custom-row span { font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* ── Social dynamic list ── */
.social-list { display: flex; flex-direction: column; gap: 8px; }
.social-row { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.social-row-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.social-row-icon svg { display: block; }
.social-row select { flex: 0 0 130px; font-size: .82rem; padding: 6px 8px; }
.social-row input { flex: 1; font-size: .82rem; padding: 6px 10px; min-width: 0; }
.social-row .del-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; }
.social-row .del-btn:hover { background: rgba(239,68,68,.15); color: var(--danger); }

/* ── Popup config ── */
.popup-config { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.popup-config-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 10px; }

/* Responsive */
@media (max-width: 1100px) {
  .editor-preview { display: none; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo span, .nav-item span, .sidebar-footer .btn-logout span { display: none; }
  .logo { justify-content: center; }
  .nav-item { justify-content: center; padding: 12px; }
  .editor-form { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .model-grid { grid-template-columns: 1fr; }
}
