:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --brand: #cc2030;
    --brand-dark: #9d1824;
    --blue: #2563eb;
    --green: #15803d;
    --orange: #c56a09;
    --red: #b42318;
    --shadow: 0 14px 40px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; margin-bottom: 6px; letter-spacing: 0; }
h2 { font-size: 17px; margin-bottom: 14px; letter-spacing: 0; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    padding: 18px;
    background: #111827;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
}

.brand:hover, .nav a:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: var(--brand);
}

.nav { display: grid; gap: 4px; }
.nav a {
    color: #dbe4f0;
    padding: 10px 12px;
    border-radius: 6px;
}
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.userbox { display: grid; gap: 2px; color: #e5e7eb; }
.userbox span { color: #aab4c3; font-size: 12px; }

.main {
    margin-left: 250px;
    padding: 28px;
    min-height: 100vh;
}

.auth-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.global-search {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 18px;
}
.global-search input {
    max-width: 360px;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.muted { color: var(--muted); margin-bottom: 0; }
.compact { margin: 0; }

.button {
    appearance: none;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 6px;
    padding: 9px 13px;
    font: inherit;
    font-weight: 650;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    cursor: pointer;
}
.button:hover { text-decoration: none; border-color: #b9c4d2; }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); }
.button.ghost { background: transparent; }
.button.logout { background: #334155; border-color: #334155; color: #fff; }
.button.logout:hover { background: #1f2937; border-color: #1f2937; color: #fff; }
.button.danger { background: #fff2f1; border-color: #f3b5b0; color: var(--red); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button.full { width: 100%; }

.flash {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: #fff;
}
.flash.success { border-color: #b8dfc5; background: #eefaf2; color: #0d6b2e; }
.flash.error { border-color: #f3b5b0; background: #fff2f1; color: var(--red); }

.stats-grid, .dashboard-grid, .detail-grid {
    display: grid;
    gap: 16px;
}
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }

.stat, .panel, .table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(23, 32, 51, 0.04);
}
.stat { padding: 18px; display: grid; gap: 8px; }
.stat span { color: var(--muted); }
.stat strong { font-size: 30px; }
.panel { padding: 18px; min-width: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-title h2 { margin-bottom: 0; }

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}
th {
    color: #475467;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 750;
    background: #f8fafc;
}
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.compact-table th, .compact-table td { padding: 8px 9px; }
.num { text-align: right; white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.strong-link { font-weight: 750; color: var(--text); }
.subline {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
    overflow-wrap: anywhere;
}
.empty-cell, .empty { text-align: center; color: var(--muted); padding: 28px; }

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, 180px)) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.form-grid { display: grid; gap: 14px; }
.form-grid.wide { max-width: 980px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label { display: grid; gap: 6px; font-weight: 650; color: #344054; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
    color: var(--text);
    background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: var(--blue);
}
.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
}
.checkline input { width: auto; }
.form-actions { display: flex; gap: 10px; }
.danger-zone { margin-top: 16px; }
.inline-form {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 140px minmax(180px, 1fr) 190px minmax(180px, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.mini-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.mini-form select {
    min-width: 150px;
    padding: 5px 8px;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
    background: var(--muted);
}
.status-dot.active { background: var(--green); }
.status-dot.inactive, .status-dot.removed { background: var(--red); }
.status-dot.redirected, .status-dot.video_unavailable { background: var(--orange); }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #475467;
    font-size: 12px;
    font-weight: 750;
}
.badge.new { background: #e8f5ee; color: var(--green); margin-left: 6px; }

.meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 14px;
}
.meta div { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.meta dt { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.meta dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }

.media-list { display: grid; gap: 12px; }
.media-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.media-item img {
    width: 120px;
    height: 78px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
}
.media-item span, .media-item p { display: block; color: var(--muted); margin: 3px 0 0; }
.file-tile {
    width: 120px;
    height: 78px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: #eef2f7;
    color: #344054;
    font-weight: 750;
}

.traffic-chart {
    width: 100%;
    background: #fbfdff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
}

@media (max-width: 1120px) {
    .dashboard-grid, .detail-grid, .stats-grid { grid-template-columns: 1fr; }
    .filters, .inline-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: auto; }
    .main { margin-left: 0; padding: 18px; }
    .page-header { display: grid; }
    .actions { justify-content: flex-start; }
    .filters, .inline-form, .grid.two, .grid.three, .meta, .media-item { grid-template-columns: 1fr; }
    .media-item img, .file-tile { width: 100%; height: 160px; }
}
