:root {
    color-scheme: light;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --text: #18212f;
    --muted: #64748b;
    --line: #d8dee8;
    --primary: #155eef;
    --primary-dark: #1049bd;
    --danger: #c62828;
    --success: #157347;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
.topbar { min-height: 64px; padding: 0 5vw; background: #111827; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: #fff; font-size: 1.2rem; font-weight: 700; text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 18px; }
.topbar nav a { color: #dbe5f5; text-decoration: none; }
.container { width: min(1400px, 92vw); margin: 32px auto 64px; }
.page-heading h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.3rem); }
.page-heading p { margin-top: 6px; color: var(--muted); }
.panel, .card, .stat, .auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 18px rgba(15, 23, 42, .05); }
.panel { padding: 24px; margin: 22px 0; }
.panel h2, .panel h3, .card h2, .card h3 { margin-top: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.card { padding: 22px; }
.stats { display: flex; flex-wrap: wrap; gap: 18px; margin: 24px 0; }
.stat { padding: 18px 24px; min-width: 210px; display: flex; flex-direction: column; }
.stat strong { font-size: 2rem; color: var(--primary); }
.stat span, .hint { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full, .form-actions { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 7px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #b9c2d0; border-radius: 7px; padding: 10px 12px; font: inherit; background: #fff; color: inherit; }
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(21, 94, 239, .18); border-color: var(--primary); }
.checkbox { flex-direction: row; align-items: center; font-weight: 500; }
.checkbox input { width: auto; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border: 1px solid #aeb8c7; border-radius: 7px; background: #fff; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; white-space: nowrap; }
.button:hover { background: #eef2f7; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.danger { border-color: #efb1b1; color: var(--danger); }
.button.small { min-height: 32px; padding: 5px 9px; font-size: .88rem; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.actions, .form-actions, .copy-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { display: inline-flex; margin: 0; }
.alert { padding: 12px 15px; border-radius: 7px; margin: 14px 0; }
.alert.error { background: #fdecec; color: #8b1f1f; border: 1px solid #f2b7b7; }
.alert.success { background: #e8f6ee; color: #0e603a; border: 1px solid #a9ddc0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #475569; font-size: .86rem; text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #e8ebef; font-size: .82rem; }
.badge.active { background: #dff4e8; color: var(--success); }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 24px; color: var(--muted); text-align: center; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #111827; }
.auth-card { width: min(440px, 100%); padding: 32px; }
.auth-card form { display: grid; gap: 18px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 15px 0 20px; }
.card-check, .select-item { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.select-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.copy-row input { min-width: 280px; }
.preview-button { min-height: 32px; padding: 5px 9px; border: 1px solid #aeb8c7; border-radius: 7px; background: #fff; color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; }
.preview-button:hover { background: #eef2f7; }
.preview-dialog { width: min(1100px, 94vw); padding: 0; border: 0; border-radius: 12px; background: #111827; color: #fff; box-shadow: 0 25px 80px rgba(0, 0, 0, .45); }
.preview-dialog::backdrop { background: rgba(15, 23, 42, .78); }
.preview-dialog-header, .preview-dialog-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; }
.preview-dialog-header h2 { margin: 0; font-size: 1.1rem; }
.preview-dialog-footer .hint { color: #cbd5e1; }
.preview-stage { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.preview-media, .preview-frame { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.preview-media.contain { object-fit: contain; }
.preview-media.cover { object-fit: cover; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
    .topbar { align-items: flex-start; flex-direction: column; padding-block: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > * { grid-column: 1 !important; }
}
