:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #4f46e5;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 "Microsoft YaHei UI", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
}
button, input, select, textarea { font: inherit; }
code { background: #eef2ff; color: #3730a3; padding: 2px 6px; border-radius: 5px; font-size: 12px; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 20%, #312e81 0%, #0f172a 55%, #020617 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.brand-lg { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-lg h1 { margin: 0; font-size: 22px; }
.brand-lg p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.brand-badge {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 800; display: grid; place-items: center; flex-shrink: 0;
  letter-spacing: 0.5px;
}
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand strong { display: block; font-size: 16px; color: #fff; }
.brand small { color: #94a3b8; font-size: 11px; }

.nav { flex: 1; padding: 12px 0; display: flex; flex-direction: column; gap: 3px; }
.nav-group { font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 10px 4px; }
.nav-item {
  border: 0; background: transparent; color: #cbd5e1;
  text-align: left; padding: 9px 12px; border-radius: 9px;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: rgba(139, 92, 246, 0.25); color: #c4b5fd; letter-spacing: 0.04em; }
.nav-item.active .nav-tag { background: rgba(255,255,255,0.22); color: #fff; }
.badge-pill { background: #f59e0b; color: #111827; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }

.inline-pick { display: flex; gap: 8px; align-items: center; }
.inline-pick select { flex: 1; min-width: 0; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip-btn { border: 1px solid #cbd5e1; background: #f8fafc; color: #334155; font-size: 12px; padding: 4px 10px; border-radius: 99px; cursor: pointer; transition: all .15s; }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.mini-preview { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); margin-top: 6px; }
.mini-preview img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; background: #0f172a; flex-shrink: 0; }
.cost-box { padding: 10px 12px; border-radius: 9px; background: #eef2ff; border: 1px solid #c7d2fe; font-size: 12px; color: #1e1b4b; display: flex; flex-direction: column; gap: 4px; }
.cost-box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cost-amt { font-weight: 700; color: #4338ca; font-size: 14px; }
.cost-desc { color: #475569; font-size: 11px; line-height: 1.45; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #334155; color: #fff; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.user-meta strong { display: block; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: #94a3b8; font-size: 11px; }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { margin: 0; font-size: 18px; }
.page-sub { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 99px;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
.status-chip.warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }

.content { padding: 22px 26px 48px; max-width: 1380px; width: 100%; }

/* Cards & Grids */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .split { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .val { font-size: 28px; font-weight: 700; margin-top: 4px; color: var(--ink); }

/* Forms & Buttons */
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: #334155; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
textarea { resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.secondary { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn.secondary:hover:not(:disabled) { background: #f8fafc; }
.btn.danger { background: #fef2f2; color: var(--bad); border-color: #fecaca; }
.btn.danger:hover:not(:disabled) { background: #fee2e2; }
.btn.ghost { background: transparent; color: #cbd5e1; }
.btn.ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.active { background: #eef2ff; color: var(--primary); }

/* Pills & Tables */
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef2ff; color: #3730a3; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.run { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.muted { background: #f1f5f9; color: #475569; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); }

/* Media Cards */
.media-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.media-thumb {
  aspect-ratio: 16 / 10;
  background: #0f172a;
  position: relative;
  display: grid; place-items: center;
  color: #94a3b8;
  cursor: pointer;
  overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,0.72); color: #fff; font-size: 11px;
  padding: 2px 6px; border-radius: 5px;
}
.media-thumb .kind-tag {
  position: absolute; left: 8px; top: 8px;
  background: rgba(15,23,42,0.78); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 5px;
}
.media-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.media-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info small { font-size: 11px; color: var(--muted); }
.media-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

/* Checklist selector */
.pick-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.pick-row { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.pick-row:hover { background: #eef2ff; }
.pick-row input { width: auto; }

/* Progress bar */
.prog-bar { height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 5px; }
.prog-fill { height: 100%; background: linear-gradient(90deg, #4f46e5, #06b6d4); transition: width .3s; }

/* Scene editor list */
.scene-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.scene-head { display: flex; justify-content: space-between; align-items: center; }

/* Modal & Toast */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(760px, 92vw); max-height: 88vh; box-shadow: 0 24px 64px rgba(15,23,42,0.3); }
.modal::backdrop { background: rgba(15, 23, 42, 0.55); }
.modal-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; max-height: calc(88vh - 60px); }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 100;
  background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); font-size: 13px; max-width: 420px;
}
.err-text { color: var(--bad); font-size: 12px; min-height: 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.video-player { width: 100%; max-height: 460px; background: #000; border-radius: 10px; }
.pre-box { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; font-size: 13px; line-height: 1.65; }
