:root {
  --bg: #090b0e;
  --sidebar: #101319;
  --panel: #141820;
  --panel-2: #191e27;
  --line: #262c37;
  --text: #e8ebf1;
  --muted: #8c94a4;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, .14);
  --blue: #5b8def;
  --green: #34c98b;
  --red: #ff6b6b;
  --warn: #f5c451;
  --radius: 14px;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --sidebar: #0f172a;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --line: #e1e6ef;
  --text: #172033;
  --muted: #697386;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
code, .mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 238px; flex: 0 0 238px; background: var(--sidebar);
  border-right: 1px solid #1c212a; padding: 18px 14px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #f59e0b, #b77905); color: #111; font-weight: 800;
}
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-right: 2px; }
.nav a {
  color: #b9c0cd; padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.nav a:hover { background: #1a1f28; color: #fff; }
.nav a.active { background: #202630; color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav-label {
  color: #667080; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  margin: 17px 10px 5px;
}
.sidebar-foot {
  margin-top: auto; padding: 14px 10px 4px; color: var(--muted); font-size: 11px;
  display: flex; align-items: center; gap: 7px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

.main { flex: 1; min-width: 0; padding: 26px 32px 50px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: #717b8d; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
h1 { font-size: 28px; margin: 4px 0 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 4px 0 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.ghost, .button, button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 13px; border-radius: 9px; cursor: pointer;
}
.ghost { background: transparent; color: var(--muted); }
.button:hover, button:hover, .ghost:hover { border-color: #465064; }
.primary {
  background: var(--accent); border-color: var(--accent); color: #1a1300; font-weight: 700;
}
.primary:hover { filter: brightness(1.05); }
.small { padding: 6px 10px; font-size: 12px; }
.wide { width: 100%; }
.link-btn { border: 0; background: transparent; color: var(--blue); padding: 2px 5px; }
.link-btn.danger { color: var(--red); }
.icon-btn { font-size: 22px; line-height: 1; padding: 2px 8px; border: 0; background: transparent; }
.compact { padding: 7px 9px; min-width: 150px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { font-size: 26px; letter-spacing: -.03em; }
.stat small { color: #626c7d; font-size: 11px; }
.stat strong.ok { color: var(--green); font-size: 20px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
.block { display: block; }
.ok { color: var(--green); }
.hidden { display: none !important; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; color: var(--muted); font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; padding: 11px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { display: inline; }

label { display: flex; flex-direction: column; gap: 6px; color: #aeb6c5; font-size: 12px; }
input, select, textarea {
  background: #0f1319; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; width: 100%; outline: none;
}
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea {
  background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; }
select[multiple] { min-height: 78px; }
input[type="color"] { padding: 3px; height: 37px; }
.checkline { flex-direction: row; align-items: center; gap: 8px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form input, .inline-form select { width: auto; min-width: 180px; }
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar select { width: auto; min-width: 180px; }
.table-wrap { overflow-x: auto; }
.bulk-table { min-width: 2050px; }
.bulk-table th, .bulk-table td { white-space: nowrap; padding: 7px 5px; }
.bulk-table input, .bulk-table select { min-width: 120px; padding: 6px 7px; font-size: 12px; }
.funnel-table { min-width: 1180px; }
.funnel-table th, .funnel-table td { white-space: nowrap; padding: 8px 7px; font-size: 12px; }
.funnel-table td small { display: block; }
.funnel-table tfoot th { border-top: 1px solid var(--line); color: var(--text); }
.flash.warn { background: rgba(245,196,81,.09); border-color: rgba(245,196,81,.35); }
.status-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.status-tabs a {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font-size: 12px; background: var(--panel-2);
}
.status-tabs a.active { color: var(--text); border-color: var(--blue); background: rgba(91,141,239,.12); }
.status-tabs b { margin-left: 6px; color: var(--text); }
.thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.asset-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-preview { width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; background: #0f1319; }
.preview-frame { width: 100%; max-width: 520px; height: 760px; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; }

.radio-row { display: flex; gap: 12px; margin-top: 16px; }
.radio-card {
  flex: 1; flex-direction: row; align-items: center; gap: 10px; padding: 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.radio-card input { width: auto; }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--muted); }
.ad-form .card { scroll-margin-top: 20px; }
.wizard-steps { display: flex; gap: 8px; margin-bottom: 16px; color: var(--muted); font-size: 12px; }
.wizard-steps span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; }
.wizard-steps .active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.wizard-steps .done { color: var(--green); border-color: rgba(52,201,139,.4); }
.objective-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.objective-card { flex-direction: row; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.objective-card input { width: auto; margin-top: 3px; }
.objective-card b { display: block; color: var(--text); }
.objective-card small { color: var(--muted); }
.preset-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.preset-card { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.preset-card small { color: var(--muted); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 18px; }
.check-row { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 8px; color: var(--muted); }
.sticky-submit {
  position: sticky; bottom: 14px; z-index: 5; display: flex; justify-content: space-between;
  align-items: center; gap: 16px; padding: 14px 18px; background: rgba(20,24,32,.94);
  border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(12px);
}

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border-radius: 999px; background: #222936; color: #b9c1cf; font-size: 11px;
}
.pill.green { background: rgba(52,201,139,.14); color: var(--green); }
.pill.warn { background: rgba(245,196,81,.14); color: var(--warn); }
.pill.failed, .pill.error { background: rgba(255,107,107,.14); color: var(--red); }
.pill.completed, .pill.completed_paused { background: rgba(52,201,139,.14); color: var(--green); }
.pill.running, .pill.pending { background: rgba(91,141,239,.14); color: #8fb3ff; }
.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 12px; border: 1px solid var(--line); }
.flash.success { background: rgba(52,201,139,.09); border-color: rgba(52,201,139,.35); }
.flash.error { background: rgba(255,107,107,.09); border-color: rgba(255,107,107,.35); }
.flash.warning { background: rgba(245,196,81,.09); border-color: rgba(245,196,81,.35); }
.notice {
  background: rgba(91,141,239,.08); border: 1px solid rgba(91,141,239,.25);
  color: #b9cdf8; padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 12px;
}
.panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.empty { color: var(--muted); text-align: center; padding: 38px 16px; border: 1px dashed var(--line); border-radius: 10px; }
.empty a { color: var(--blue); }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row small { display: block; color: var(--muted); margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px;
  border-left: 3px solid var(--chip, var(--blue)); background: var(--panel-2); border-radius: 7px;
}
.mini-x { border: 0; background: transparent; color: var(--muted); padding: 0 2px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.quick {
  display: flex; flex-direction: column; gap: 3px; padding: 16px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.quick b { font-size: 22px; color: var(--accent); }
.quick span { font-weight: 600; }
.quick small { color: var(--muted); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.folder-card, .asset-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column; min-height: 150px;
}
.folder-card { padding: 18px; justify-content: center; gap: 6px; }
.folder-card:hover, .asset-card:hover { border-color: #465064; }
.folder-icon { font-size: 42px; color: var(--accent); line-height: 1; }
.folder-card small, .asset-card small { color: var(--muted); font-size: 11px; }
.asset-thumb { height: 105px; background: #0d1015; display: grid; place-items: center; overflow: hidden; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-placeholder { color: var(--muted); font-size: 12px; }
.asset-card > strong, .asset-card > small { padding: 0 10px; }
.asset-card > strong { margin-top: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-card > small { margin: 2px 0 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.code-box {
  display: block; white-space: pre-wrap; word-break: break-all; background: #0d1015;
  border: 1px solid var(--line); border-radius: 9px; padding: 12px; color: #b8c5dc;
  max-height: 460px; overflow: auto;
}
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-row { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-row > span {
  width: 9px; height: 9px; border-radius: 50%; background: var(--blue);
  margin-top: 5px; flex: 0 0 9px; box-shadow: 0 0 0 4px rgba(91,141,239,.1);
}
.timeline-row.error > span { background: var(--red); box-shadow: 0 0 0 4px rgba(255,107,107,.1); }
.timeline-row b { font-size: 11px; color: var(--muted); }
.timeline-row p { margin: 2px 0 0; }

.modal-card {
  max-width: 760px; margin: 5vh auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at 50% 0%, #1a2130, #090b0e 55%); }
.login-card { width: min(420px, calc(100vw - 30px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px; }
.login-brand { padding: 0 0 20px; }
.login-card h2 { font-size: 24px; margin: 4px 0; }
.login-card form { margin-top: 18px; }

.table-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px;
}
.check-col { width: 34px; text-align: center; }
.check-col input { width: 16px; height: 16px; accent-color: var(--blue); }
.bad { color: var(--red); }
.warn-text { color: var(--warn); font-size: 10px; }
.pill.red { background: rgba(255,107,107,.14); color: var(--red); }
.stat strong.stat-text { font-size: 15px; line-height: 1.35; }
.span-2 { grid-column: span 2; }
.profile-fields { border: 0; padding: 0; margin: 0; opacity: .55; }
.profile-fields:not([disabled]) { opacity: 1; }
.group-table td { vertical-align: top; }
.group-table td small { color: var(--muted); margin-top: 3px; }
.row-critical td { background: rgba(255,107,107,.055); }
.row-warning td { background: rgba(245,196,81,.045); }
.health {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); color: var(--muted);
}
.health.critical { color: var(--red); border-color: rgba(255,107,107,.35); background: rgba(255,107,107,.08); }
.health.warning { color: var(--warn); border-color: rgba(245,196,81,.35); background: rgba(245,196,81,.07); }
.health.info { color: var(--blue); border-color: rgba(91,141,239,.35); background: rgba(91,141,239,.07); }
.trend-bars {
  display: flex; align-items: stretch; gap: 7px; min-height: 180px;
  padding: 10px 2px 0; overflow-x: auto;
}
.trend-item {
  flex: 1 0 30px; min-width: 30px; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.trend-item em { font-style: normal; font-size: 10px; color: var(--muted); }
.trend-track {
  flex: 1; width: 100%; max-width: 30px; min-height: 120px;
  display: flex; align-items: flex-end; background: rgba(255,255,255,.035);
  border-radius: 5px; overflow: hidden;
}
.trend-track span {
  display: block; width: 100%; min-height: 2px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #6fa7ff, #2f63c8);
}
.trend-item small { font-size: 9px; color: var(--muted); white-space: nowrap; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .preset-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; max-height: 150px; }
  .nav-label, .sidebar-foot { display: none; }
  .main { padding: 18px; }
  .grid-2, .grid-3, .grid-4, .stat-grid { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .table-wrap { overflow-x: auto; }
}
