:root {
    --navy: #0b1c3f;
    --navy-2: #142a55;
    --accent: #e63946;
    --accent-2: #ff5a67;
    --muted: #6b7688;
    --line: #e6eaf2;
    --bg: #f5f7fb;
    --sidebar-w: 240px;
    --radius: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    color: var(--navy);
    background: var(--bg);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; }

[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 14px;
    transition: background .2s, color .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn--ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn--ghost:hover { border-color: var(--navy); }
.btn--ghost[disabled] { opacity: .5; cursor: not-allowed; }
.btn--full { width: 100%; }
.btn--danger {
    background: #fff0f1;
    color: var(--accent);
    border: 1px solid #f8d7db;
}
.btn--danger:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}
.btn--sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
}
.btn.is-disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ================= AUTH ================= */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    background-color: #050c1f;
    background-image:
        linear-gradient(rgba(5, 12, 31, .55), rgba(5, 12, 31, .75)),
        url('/assets/img/login-bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: #fff; border-radius: 20px;
    padding: 40px 34px;
    box-shadow: 0 30px 60px -30px rgba(0,0,0,.6);
    position: relative;
    z-index: 1;
}
.auth-card__logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 22px; color: var(--navy);
    margin-bottom: 22px;
}
.auth-card__logo .accent { color: var(--accent); }
.auth-card h1 { font-size: 22px; margin: 0 0 22px; letter-spacing: -.01em; }
.auth-card label { display: block; margin-bottom: 14px; }
.auth-card label span {
    display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.auth-card input {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    border: 1px solid var(--line); background: #fbfcfe; color: var(--navy);
    transition: border-color .2s, box-shadow .2s;
}
.auth-card input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(230,57,70,.1);
}
.auth-card__error {
    background: #fff0f1; color: var(--accent);
    border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.auth-card__back { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }

/* ================= LAYOUT ================= */
.admin {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    background: #050c1f;
    color: #fff;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar__head {
    padding: 22px 20px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__logo {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 17px; color: #fff;
}
.sidebar__close {
    display: none; margin-left: auto; color: rgba(255,255,255,.7);
    font-size: 26px; line-height: 1;
}
.sidebar__nav {
    flex: 1; padding: 14px 10px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
}
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 10px;
    color: rgba(255,255,255,.75);
    font-weight: 600; font-size: 14px;
    transition: background .2s, color .2s;
}
.sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar__link.is-active { background: rgba(230,57,70,.16); color: #fff; }
.sidebar__link svg { flex-shrink: 0; }

.sidebar__foot {
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sidebar__avatar {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    line-height: 38px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    text-align: center;
    user-select: none;
    aspect-ratio: 1 / 1;
}
.sidebar__avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    margin: 0;
    padding: 0;
}
.sidebar__avatar-letter {
    display: block;
    font-style: normal;
    line-height: 1;
    transform: translateY(-1px);
}
.sidebar__user > div {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    line-height: 1.7;
}
.sidebar__user strong {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.sidebar__user span {
    display: block;
    font-size: 12px;
    color: rgba(255,255,255,.55);
    text-transform: capitalize;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    place-content: center;
}

.sidebar__balance {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, .7);
    text-transform: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    transition: color .2s;
    cursor: pointer;
}
.sidebar__balance:hover { color: #fff; }
.sidebar__balance b { color: var(--accent-2); font-weight: 700; }

.sidebar__legal {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar__legal a {
    font-size: 11px;
    color: rgba(255,255,255,.45);
    text-decoration: none;
    transition: color .2s;
}
.sidebar__legal a:hover { color: rgba(255,255,255,.85); }

.sidebar__logout {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 10px;
    background: var(--accent); color: #fff;
    font-weight: 700; font-size: 14px;
    transition: background .2s;
}
.sidebar__logout:hover { background: var(--accent-2); }

.sidebar-backdrop { display: none; }

/* ---------- MAIN ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 26px;
    position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: 18px; margin: 0; font-weight: 700; }
.topbar__spacer { flex: 1; }

.topbar__logo {
    display: none;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 16px;
    color: var(--navy);
    letter-spacing: -.01em;
    text-decoration: none;
    flex-shrink: 0;
}
.topbar__logo img { display: block; }

.topbar__burger {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.topbar__burger span {
    width: 20px; height: 2px; background: var(--navy); border-radius: 2px;
}

.content { padding: 28px 26px 60px; }

/* ================= DASHBOARD ================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
}
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 26px 22px;
    position: relative; overflow: hidden;
}
.stat::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--accent);
}
.stat--photo::before  { background: #e63946; }
.stat--topic::before  { background: #2a9d8f; }
.stat--author::before { background: #f4a261; }
.stat--video::before  { background: #4361ee; }
.stat__value { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.stat__label { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ================= TOOLBAR ================= */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 20px;
}
.toolbar__spacer { flex: 1; }
.toolbar input, .toolbar select {
    padding: 10px 14px; border-radius: 10px;
    border: 1px solid var(--line); background: #fff;
    min-width: 180px;
    transition: border-color .2s;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); }

/* ================= MEDIA GRID ================= */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.tile {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; position: relative;
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 16px 30px -20px rgba(11,28,63,.35); }
.tile__img {
    aspect-ratio: 4 / 3;
    background: #eef1f8;
    overflow: hidden;
    position: relative;
}
.tile__img img {
    width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .35s ease;
}
.tile__img img.is-loaded { opacity: 1; }

/* Водяной знак на плитке */
.tile__watermark {
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    text-shadow: 0 1px 3px rgba(0,0,0,.55);
    letter-spacing: .02em;
    pointer-events: none;
    user-select: none;
}

.tile__body { padding: 12px 14px; flex: 1; }
.tile__title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.tile__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
}
.tile__meta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.tile__views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}
.tile__views svg {
    display: block;
    opacity: .75;
}
.tile:hover .tile__views { color: var(--navy); }

/* Юридическая строка под каждой плиткой */
.tile__legal {
    padding: 8px 14px 12px;
    font-size: 10px;
    line-height: 1.35;
    color: var(--muted);
    border-top: 1px solid var(--line);
    background: #fafbfe;
}
.tile__legal a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
}
.tile__legal a:hover { border-bottom-style: solid; }

/* ================= TABLE ================= */
.table-wrap {
    background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); overflow: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.table th {
    background: #fafbfe; font-weight: 700; font-size: 12px;
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfe; }
.table td b { color: var(--navy); font-weight: 700; }
.cell--muted { color: var(--muted); }
.cell--actions { white-space: nowrap; text-align: right; }
.cell--actions button {
    padding: 6px 10px; border-radius: 8px;
    font-size: 13px; color: var(--navy);
    transition: background .15s, color .15s;
}
.cell--actions button:hover { background: var(--bg); }
.cell--actions .danger { color: var(--accent); }
.cell--actions .danger:hover { background: #fff0f1; }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; text-transform: capitalize;
}
.badge--admin     { background: #ffe0e2; color: #b31f2a; }
.badge--moderator { background: #fff0d6; color: #8a5b00; }
.badge--user      { background: #e2ecff; color: #24408a; }
.badge--ok        { background: #e6f6ee; color: #1e7a4d; }
.badge--block     { background: #ffe0e2; color: #b31f2a; }

/* ================= TABS ================= */
.tabs {
    display: flex; gap: 6px; margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.tab {
    padding: 10px 18px; border-radius: 10px 10px 0 0;
    color: var(--muted); font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s;
}
.tab:hover { color: var(--navy); }
.tab.is-active { color: var(--navy); border-bottom-color: var(--accent); }

/* ================= FORM ================= */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.form--wide { max-width: 820px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form label > span {
    display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.form input, .form select, .form textarea {
    width: 100%; padding: 11px 14px;
    border-radius: 10px; border: 1px solid var(--line);
    background: #fff; color: var(--navy);
    transition: border-color .2s, box-shadow .2s;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(230,57,70,.1);
}
.form input.is-readonly,
.form textarea.is-readonly,
.form select.is-readonly {
    background: #f4f6fb;
    color: var(--muted);
    cursor: not-allowed;
}
.form input.is-readonly:focus,
.form textarea.is-readonly:focus,
.form select.is-readonly:focus {
    box-shadow: none;
    border-color: var(--line);
}
.sep { border: none; border-top: 1px solid var(--line); margin: 32px 0 24px; }

/* Drop-zone */
.drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 30px 20px; gap: 8px;
    border: 2px dashed var(--line); border-radius: 12px;
    cursor: pointer; text-align: center;
    transition: border-color .2s, background .2s;
    position: relative;
}
.drop:hover, .drop.is-over {
    border-color: var(--accent);
    background: #fff5f6;
}
.drop__icon {
    font-size: 28px; color: var(--accent);
    line-height: 1;
}
.drop__text { color: var(--muted); font-size: 14px; }

.drop__preview {
    display: block;
    width: 96px; height: 96px;
    border-radius: 12px;
    background: #eef1f8 center/cover no-repeat;
    margin-top: 10px;
    box-shadow: 0 6px 16px -8px rgba(11,28,63,.4);
}
.drop__preview[hidden] { display: none; }

/* ================= MODAL ================= */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: grid; place-items: center;
    padding: 20px;
}
.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(8,17,38,.65);
    backdrop-filter: blur(4px);
    animation: fadeIn .2s ease;
}
.modal__dialog {
    position: relative; z-index: 1;
    background: #fff; border-radius: 16px;
    width: 100%; max-width: 560px; max-height: 90vh;
    display: flex; flex-direction: column;
    animation: popIn .25s cubic-bezier(.2,.7,.2,1);
}
.modal__dialog:has(.media-view) { max-width: 720px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }

.modal__head {
    padding: 20px 24px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
}
.modal__head h3 { margin: 0; font-size: 18px; }
.modal__close { font-size: 24px; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.modal__close:hover { background: var(--bg); color: var(--navy); }
.modal__body { padding: 24px; overflow-y: auto; }
.modal__foot {
    padding: 16px 24px; border-top: 1px solid var(--line);
    display: flex; justify-content: flex-end; align-items: center; gap: 10px;
}

/* ================= MEDIA VIEW ================= */
.media-view__preview {
    margin: -24px -24px 20px;
    background: #eef1f8;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.media-view__preview img {
    display: block;
    width: 100%;
    max-height: 55vh;
    object-fit: contain;
    background: #f4f6fb;
}
.media-view__watermark {
    position: absolute;
    right: 12px;
    bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
    letter-spacing: .02em;
    pointer-events: none;
    user-select: none;
}

/* ================= USAGE BLOCK ================= */
.usage-block {
    margin: -8px 0 20px;
    padding: 14px 16px;
    background: #fafbfe;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.usage-block__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.usage-block__inner .usage-info { margin-left: 0; }

.usage-download {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
}
.usage-download__label {
    font-size: 13px;
    color: var(--muted);
    margin-right: 4px;
}

.usage-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--navy);
    user-select: none;
}
.usage-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.usage-checkbox--off {
    cursor: not-allowed;
    color: var(--muted);
}
.usage-checkbox--off input { cursor: not-allowed; }
.usage-checkbox--on { color: var(--accent); }

.usage-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--muted);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-style: italic;
    cursor: help;
    flex: 0 0 18px;
}

/* ================= LICENSE ACCEPT ================= */
.license-accept__lead {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--navy);
    line-height: 1.6;
}
.license-accept__lead a { color: var(--accent); text-decoration: underline; }
.license-accept__box {
    background: #fafbfe;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 13px;
    color: #303a4d;
    line-height: 1.6;
}
.license-accept__box p { margin: 0 0 8px; }
.license-accept__box p:last-child { margin-bottom: 0; }
.license-accept__check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: var(--navy);
}
.license-accept__check input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.license-accept__check a { color: var(--accent); text-decoration: underline; }

#licenseAcceptBtn[disabled] {
    opacity: .5;
    cursor: not-allowed;
}

/* ================= BALANCE ================= */
.balance-hero {
    background: linear-gradient(135deg, #0b1c3f 0%, #142a55 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 32px 28px;
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}
.balance-hero__label {
    font-size: 13px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255,255,255,.65);
}
.balance-hero__value {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.05;
    margin-top: 8px;
}
.balance-hero__hint {
    color: rgba(255,255,255,.55);
    font-size: 13px;
    margin-top: 4px;
}
.balance-hero__btn {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
}
.balance-hero__btn:hover,
.balance-hero__btn:focus {
    background: var(--accent);
    transform: translateY(-50%);
    box-shadow: none;
    transition: none;
}
.balance-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.balance-stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
}
.balance-stat__num {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.02em;
}
.balance-stat__label {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}
.is-cancelled td { opacity: .55; text-decoration: line-through; }
.media-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-style: dotted;
}
.media-link:hover { text-decoration-style: solid; }

/* Миниатюры в таблице просмотров */
.media-thumb-link { display: block; }
.media-thumb {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #eef1f8;
}

/* ================= EMPTY / LOADER ================= */
.loader, .empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
}
.empty {
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    font-size: 15px;
}
.empty::before {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    background-color: var(--muted);
    opacity: .55;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-4.3-4.3'/></svg>") center / contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M20 20l-4.3-4.3'/></svg>") center / contain no-repeat;
}

/* ================= MOBILE ================= */
@media (max-width: 900px) {
    .admin { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 50;
        width: 260px;
        transform: translateX(-100%);
        transition: transform .3s ease;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar__close { display: block; }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(8,17,38,.5); z-index: 40;
    }
    .topbar {
        padding: 0 16px;
        gap: 10px;
    }
    .topbar__logo { display: inline-flex; }
    .topbar__burger { display: flex; }
    .topbar__title {
        flex: 1;
        text-align: center;
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .content { padding: 20px 16px 60px; }
    .form__row { grid-template-columns: 1fr; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 12px; }
    .cell--actions button { padding: 5px 8px; font-size: 12px; }

    .modal { padding: 12px; }
    .modal__dialog { max-width: 100%; }
    .media-view__preview img { max-height: 40vh; }
}

@media (max-width: 720px) {
    .balance-stats { grid-template-columns: 1fr; }
    .balance-hero__btn {
        position: static;
        transform: none;
        margin-top: 18px;
    }
    .balance-hero__btn:hover,
    .balance-hero__btn:focus {
        transform: none;
    }
    .auth-body {
        background-attachment: scroll;
        background-position: center 30%;
        padding: 16px;
    }
    .auth-card { padding: 32px 24px; }

    /* Миниатюры в таблице просмотров — скрываем */
    .media-thumb-link { display: none; }
    .table thead th:first-child,
    .table tbody td:first-child { display: none; }
}


/* ================= CERT DIALOG ================= */
.cert-dialog p {
    margin: 0 0 14px;
    line-height: 1.6;
    color: var(--navy);
}
.cert-dialog__loader { margin-top: 16px; }
.cert-dialog__url { margin: 18px 0; }
.cert-dialog__url label {
    display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.cert-dialog__field {
    display: flex; gap: 8px; align-items: stretch;
}
.cert-dialog__field input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    background: #fafbfe;
    color: var(--navy);
}
.cert-dialog__actions {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
}

/* ================= CERT DIALOG ================= */
.cert-dialog p {
    margin: 0 0 14px;
    line-height: 1.6;
    color: var(--navy);
}
.cert-dialog__loader { margin-top: 16px; }
.cert-dialog__url { margin: 18px 0; }
.cert-dialog__url label {
    display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.cert-dialog__field {
    display: flex; gap: 8px; align-items: stretch;
}
.cert-dialog__field input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    background: #fafbfe;
    color: var(--navy);
}
.cert-dialog__actions {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
}

/* ================= KIND SWITCH (Изображение / Видео) ================= */
.kind-switch {
    display: inline-flex;
    background: #eef1f8;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}
.kind-switch__item {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    transition: background .2s, color .2s;
    user-select: none;
}
.kind-switch__item input { display: none; }
.kind-switch__item.is-active {
    background: #fff;
    color: var(--navy);
    box-shadow: 0 2px 6px -2px rgba(11,28,63,.2);
}

/* ================= VIDEO TILE ================= */
.tile--video .tile__img { position: relative; }
.tile__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    transition: transform .25s ease;
}
.tile__play svg {
    filter: drop-shadow(0 4px 10px rgba(0,0,0,.35));
}
.tile:hover .tile__play { transform: scale(1.08); }

.tile__duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(8,17,38,.75);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: .02em;
}

.tile__badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    vertical-align: 1px;
}

/* ================= VIDEO IN MODAL ================= */
.media-view__preview--video {
    background: #000;
}
.media-view__preview video {
    display: block;
    width: 100%;
    max-height: 60vh;
    background: #000;
    border-radius: 0;
}

/* ================= SEARCH INPUT ================= */
.search-input {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 260px;
    flex: 1 1 260px;
    max-width: 420px;
}
.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search-input input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-size: 15px;
    color: var(--navy);
    transition: border-color .2s, box-shadow .2s;
}
.search-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(230,57,70,.1);
}
.search-input input::placeholder {
    color: var(--muted);
}
.search-input__clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--line);
    color: var(--navy);
    font-size: 16px;
    line-height: 1;
    display: grid;
    place-items: baseline;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.search-input__clear:hover {
    background: var(--accent);
    color: #fff;
}

/* В тулбаре — не растягивать выше разумного */
.toolbar .search-input { margin-right: 4px; }

/* На мобильных — на всю ширину */
@media (max-width: 720px) {
    .toolbar .search-input {
        max-width: 100%;
        flex: 1 1 100%;
    }
}