:root {
    --bg: #07111f;
    --bg2: #0b1627;
    --panel: #0f1d31;
    --panel2: #12233a;
    --line: rgba(255,255,255,.08);
    --line-strong: rgba(255,255,255,.14);
    --text: #f6f8fc;
    --muted: #8ea0b9;
    --blue: #3972ff;
    --blue2: #2356d9;
    --green: #58e8a5;
    --yellow: #ffd35a;
    --red: #ff6f76;
    --shadow: 0 30px 80px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
form { margin: 0; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; border-right: 1px solid var(--line); background: linear-gradient(180deg,#091526,#07111f 72%); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 13px; padding: 2px 10px 24px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.22); border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(150deg,rgba(68,111,255,.35),rgba(255,255,255,.05)); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: var(--muted); text-transform: uppercase; letter-spacing: .22em; font-size: 10px; }
.sidebar nav { display: grid; gap: 6px; margin-top: 14px; }
.nav-link { padding: 12px 14px; border-radius: 11px; color: #aebbd0; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.04); color: white; }
.nav-link.active { background: rgba(57,114,255,.14); color: white; border: 1px solid rgba(57,114,255,.28); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 2px; color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 8px; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 18px rgba(88,232,165,.45); }

.main { min-width: 0; }
.topbar { height: 74px; padding: 0 34px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: rgba(7,17,31,.82); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.tenant-name { color: var(--muted); font-size: 13px; }
.userbox { display: flex; align-items: center; gap: 14px; color: #cbd5e3; font-size: 13px; }
.link-button { border: 0; background: transparent; color: var(--muted); padding: 5px 0; }
.link-button:hover { color: white; }
.content { padding: 34px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { margin: 0; font-size: 34px; letter-spacing: -.025em; }
.page-head p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.stats-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: linear-gradient(180deg,var(--panel2),var(--panel)); border: 1px solid var(--line); border-radius: 18px; padding: 21px; box-shadow: 0 14px 30px rgba(0,0,0,.12); }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin: 10px 0 6px; font-size: 34px; }
.stat-card small { font-size: 11px; }
.stat-card.good strong { color: var(--green); }
.stat-card.bad strong { color: var(--red); }

.panel { background: linear-gradient(180deg,rgba(18,35,58,.94),rgba(13,27,46,.96)); border: 1px solid var(--line); border-radius: 18px; margin: 0 0 20px; box-shadow: 0 18px 42px rgba(0,0,0,.12); overflow: hidden; }
.accent-panel { border-color: rgba(57,114,255,.26); box-shadow: 0 20px 50px rgba(29,69,169,.12); }
.panel-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 18px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: white; font-weight: 650; font-size: 13px; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { background: linear-gradient(180deg,var(--blue),var(--blue2)); border-color: rgba(105,147,255,.7); box-shadow: 0 9px 22px rgba(44,92,220,.24); }
.button.ghost { color: #c8d3e4; }
.button.danger { color: #ffd7d9; border-color: rgba(255,111,118,.35); background: rgba(255,111,118,.08); }
.button.danger:hover { background: rgba(255,111,118,.14); }
.button.warning { color: #ffe6a4; border-color: rgba(255,211,90,.3); background: rgba(255,211,90,.08); }
.button.disabled, .button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.wide { width: 100%; }
.button.center { text-align: center; }
.compact-button { min-height: 32px; padding: 0 10px; font-size: 11px; border-radius: 8px; }
.button-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 20px; text-align: left; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
thead th { border-top: 0; color: #71849f; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
tbody tr:hover { background: rgba(255,255,255,.018); }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); font-size: 10px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td a { color: #dce6ff; font-weight: 650; }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; }
.danger-text { color: #ff9da2 !important; white-space: normal !important; max-width: 280px !important; }
.hint-inline { color: var(--muted); font-size: 10px; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.online { color: var(--green); }
.status.online i { background: var(--green); }
.status.stale { color: var(--yellow); }
.status.stale i { background: var(--yellow); }
.status.offline { color: #9cacbf; }
.status.offline i { background: #5b6d84; }
.status-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.status-pill.published { color: var(--green); border-color: rgba(88,232,165,.25); background: rgba(88,232,165,.06); }
.status-pill.draft { color: var(--yellow); }

.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; padding: 22px; }
.form-grid.compact { max-width: 900px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 7px; color: #aebdd0; font-size: 12px; font-weight: 600; }
input, select { width: 100%; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(2,9,18,.45); color: white; padding: 11px 12px; outline: none; }
input:focus, select:focus { border-color: rgba(73,124,255,.8); box-shadow: 0 0 0 3px rgba(57,114,255,.11); }
select option { background: #0e1a2b; color: white; }

.pair-form { display: grid; grid-template-columns: 1.05fr 1.4fr 1fr auto; gap: 14px; align-items: end; padding: 22px; }
.pair-input { text-transform: uppercase; letter-spacing: .18em; font-size: 16px; font-weight: 800; }
.pair-submit { padding-bottom: 1px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.small { font-size: 10px; }

.action-menu { position: relative; min-width: 120px; }
.action-menu > summary { cursor: pointer; list-style: none; color: #cfd9e8; font-size: 11px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; width: fit-content; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > summary { border-color: rgba(57,114,255,.45); }
.action-menu-body { margin-top: 9px; width: min(310px,70vw); padding: 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: #0b1728; box-shadow: var(--shadow); display: grid; gap: 10px; position: absolute; right: 0; z-index: 15; }
.mini-form { display: grid; gap: 9px; }
.mini-form input, .mini-form select { padding: 8px 9px; font-size: 11px; }

.upload-form { padding: 22px; display: flex; gap: 12px; align-items: center; }
.upload-form input[type=file] { flex: 1; padding: 9px; }
.media-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; padding: 20px; }
.media-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.018); display: flex; gap: 13px; align-items: center; }
.media-card.rich { display: block; padding: 0; overflow: hidden; }
.preview-wrap { aspect-ratio: 16/9; background: #030812; overflow: hidden; border-bottom: 1px solid var(--line); }
.media-preview { width: 100%; height: 100%; display: block; object-fit: cover; background: #030812; }
.media-meta { min-width: 0; padding: 14px; }
.media-card:not(.rich) .media-meta { padding: 0; }
.media-meta strong, .media-meta span, .media-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta strong { font-size: 12px; }
.media-meta span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.media-meta small { margin-top: 4px; color: #667a95; font-size: 9px; }
.usage-badge { display: inline-flex !important; width: fit-content; margin-top: 9px !important; padding: 4px 7px; border-radius: 999px; color: #ffe3a0 !important; border: 1px solid rgba(255,211,90,.2); background: rgba(255,211,90,.06); }
.usage-badge.free { color: #bdf8db !important; border-color: rgba(88,232,165,.2); background: rgba(88,232,165,.05); }
.media-actions { margin-top: 12px; }
.empty-card { grid-column: 1/-1; padding: 36px; color: var(--muted); text-align: center; }

.campaign-form { padding: 22px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.form-row-4 { grid-template-columns: minmax(220px,2fr) repeat(3,minmax(150px,1fr)); }
.toggle-box { align-content: end; }
.split-select { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 24px; }
.split-select h3 { margin: 0 0 11px; font-size: 13px; color: #dbe5f5; }
.choice-list { max-height: 290px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: rgba(3,9,17,.24); }
.choice { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--line); cursor: pointer; }
.choice:first-child { border-top: 0; }
.choice:hover { background: rgba(255,255,255,.022); }
.choice input { width: auto; }
.choice span { min-width: 0; }
.choice strong, .choice small { display: block; }
.choice strong { font-size: 11px; color: #dfe8f6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.choice small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.publish-row { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.checkline { display: flex; align-items: center; gap: 9px; }
.checkline input { width: auto; }
.hint { color: var(--muted); font-size: 11px; padding: 14px; }

.flash { padding: 12px 14px; margin: 0 0 18px; border-radius: 10px; border: 1px solid var(--line); font-size: 12px; }
.flash.ok { color: #bdf8db; background: rgba(88,232,165,.07); border-color: rgba(88,232,165,.2); }
.flash.error { color: #ffc2c6; background: rgba(255,111,118,.08); border-color: rgba(255,111,118,.22); }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 78% 18%,rgba(57,114,255,.25),transparent 32%),radial-gradient(circle at 18% 82%,rgba(88,232,165,.09),transparent 30%),linear-gradient(135deg,#07111f,#050b14); }
.login-card { width: min(100%,460px); border: 1px solid rgba(255,255,255,.11); border-radius: 22px; background: rgba(10,22,38,.92); box-shadow: var(--shadow); padding: 30px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { color: var(--muted); margin-top: 3px; font-size: 10px; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.login-card > p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 9px 0 22px; }
.stack { display: grid; gap: 15px; }
.login-foot { margin-top: 22px; text-align: center; color: #657890; font-size: 10px; }

@media (max-width: 1250px) {
    .form-row-4 { grid-template-columns: 1fr 1fr; }
    .media-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 1050px) {
    .shell { grid-template-columns: 82px 1fr; }
    .brand > span:last-child { display: none; }
    .sidebar-foot span:last-child { display: none; }
    .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .pair-form { grid-template-columns: 1fr 1fr; }
    .nav-link { font-size: 11px; padding: 10px 8px; text-align: center; }
}

@media (max-width: 720px) {
    .shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 12px; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand, .sidebar-foot { display: none; }
    .sidebar nav { display: flex; margin: 0; }
    .nav-link { white-space: nowrap; font-size: 12px; }
    .topbar { height: 60px; padding: 0 16px; }
    .content { padding: 20px 14px; }
    .page-head h1 { font-size: 28px; }
    .stats-grid, .form-grid, .pair-form, .split-select, .form-row, .form-row-4, .media-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .upload-form, .publish-row { align-items: stretch; flex-direction: column; }
    .media-grid { padding: 14px; }
    th, td { padding: 12px 14px; }
    .action-menu-body { position: static; width: 100%; }
}
