:root {
    color-scheme: dark;
    --bg: #101114;
    --panel: #181b20;
    --panel-2: #20242b;
    --text: #f3f5f7;
    --muted: #aab1bd;
    --line: #303640;
    --accent: #eb3042;
    --accent-2: #2f9e89;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
.wrap { width: min(1220px, calc(100% - 28px)); margin: 0 auto; }
.topbar {
    border-bottom: 1px solid var(--line);
    background: #15171c;
}
.topbar .wrap {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand { font-weight: 900; letter-spacing: .2px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav a, .btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 6px;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 700;
}
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.green, button.green { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.btn.danger, button.danger { background: #7f1d2a; border-color: #a52a3a; color: white; }
.btn.danger:disabled, button.danger:disabled {
    opacity: .45;
    cursor: not-allowed;
}
main.wrap { padding: 26px 0 44px; }
h1, h2 { margin: 0 0 16px; line-height: 1.15; }
p { color: var(--muted); margin: 0 0 18px; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.poster { width: 54px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; background: #050506; }
.muted { color: var(--muted); }
.flash { padding: 12px; border-radius: 6px; margin-bottom: 16px; background: #14231f; border: 1px solid #29584d; }
.flash.error { background: #32181b; border-color: #6c2731; color: #ffd7dc; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: block; margin: 0 0 6px; color: var(--muted); font-weight: 800; font-size: 12px; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 6px;
    padding: 10px;
}
textarea { min-height: 130px; resize: vertical; font-family: inherit; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-row { display: grid; grid-template-columns: 1fr 160px 160px auto; gap: 10px; align-items: end; }
.code {
    display: block;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    background: #0c0d10;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    color: #dbe1ea;
}
.import-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(5, 6, 8, .76);
    backdrop-filter: blur(7px);
}
.import-overlay.active { display: flex; }
.import-modal {
    width: min(560px, 100%);
    background: #171a20;
    border: 1px solid #333b47;
    border-radius: 8px;
    box-shadow: 0 22px 80px rgba(0, 0, 0, .45);
    padding: 22px;
}
.import-modal-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.import-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid #353c47;
    border-top-color: var(--accent);
    animation: import-spin .8s linear infinite;
    flex: 0 0 auto;
}
.import-overlay.done .import-spinner,
.import-overlay.error .import-spinner {
    animation: none;
    border-color: var(--accent-2);
}
.import-overlay.error .import-spinner { border-color: var(--accent); }
.import-title { font-size: 20px; font-weight: 900; margin: 0; }
.import-detail { color: var(--muted); margin: 3px 0 0; }
.import-bar {
    position: relative;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #0c0d10;
    border: 1px solid #2a3039;
    margin: 16px 0;
}
.import-bar span {
    position: absolute;
    inset: 0 auto 0 -35%;
    width: 35%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: import-bar 1.15s ease-in-out infinite;
}
.import-meta {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}
.import-steps {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
}
.import-steps li {
    padding: 7px 0 7px 22px;
    position: relative;
}
.import-steps li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 13px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #46505d;
}
.import-steps li.active { color: var(--text); }
.import-steps li.active::before { background: var(--accent); box-shadow: 0 0 0 4px rgba(235, 48, 66, .12); }
.import-steps li.done::before { background: var(--accent-2); }
.import-actions {
    display: none;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.import-overlay.done .import-actions,
.import-overlay.error .import-actions { display: flex; }
@keyframes import-spin {
    to { transform: rotate(360deg); }
}
@keyframes import-bar {
    0% { left: -35%; }
    100% { left: 100%; }
}
@media (max-width: 820px) {
    .grid, .form-grid, .search-row { grid-template-columns: 1fr; }
    .topbar .wrap { align-items: flex-start; flex-direction: column; padding: 12px 0; }
    table { display: block; overflow-x: auto; }
}
