:root {
  --bg: #07090d;
  --bg-2: #0c1016;
  --panel: #10151d;
  --panel-2: #151b25;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f6;
  --muted: #8b95a5;
  --dim: #5d6676;
  --gold: #d4af37;
  --gold-2: #e9c96b;
  --ok: #3ecf8e;
  --warn: #f5b84a;
  --err: #ff6b6b;
  --run: #5aa9ff;
  --stale: #a78bfa;
  --r: 14px;
  --font: "Inter", system-ui, sans-serif;
  --display: "Sora", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(212, 175, 55, 0.07), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
code, .mono { font-family: var(--mono); font-size: 12px; }

/* sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg-2);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 4px 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font: 700 15px var(--display); color: #0a0a0a;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--display); font-size: 14px; }
.brand-text small { color: var(--muted); font-size: 11px; }
.side-label { color: var(--dim); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 8px; }
.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); border: 1px solid transparent;
}
.project-link:hover { background: var(--panel); color: var(--text); }
.project-link.active { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.dot { width: 9px; height: 9px; border-radius: 9px; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.project-link .meta { margin-left: auto; font-size: 11px; color: var(--dim); }
.side-foot { margin-top: auto; color: var(--dim); font-size: 11px; }

/* main */
.main { padding: 28px 36px 80px; min-width: 0; }
.header { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.header .sub { color: var(--muted); }
.header .actions { margin-left: auto; display: flex; gap: 8px; }

/* pipeline */
.pipeline { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; margin: 8px 0 22px; }
.stage { padding: 10px 10px 9px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.stage .n { font: 600 11px var(--mono); color: var(--dim); }
.stage .t { font-size: 11.5px; line-height: 1.25; margin-top: 2px; color: var(--muted); }
.stage .bar { height: 3px; border-radius: 3px; margin-top: 8px; background: var(--line); }
.stage.done .bar { background: var(--ok); } .stage.done .t { color: var(--text); }
.stage.running .bar { background: var(--run); animation: pulse 1.2s infinite; }
.stage.failed .bar { background: var(--err); } .stage.failed { border-color: rgba(255,107,107,0.4); }
.stage.stale .bar { background: var(--stale); }
@keyframes pulse { 50% { opacity: 0.4; } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }

/* cards */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent), var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card h3 { margin-bottom: 12px; }
.card .row + .row { margin-top: 10px; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r); }

/* project cards (dashboard) */
.pcard { cursor: pointer; transition: transform .15s, border-color .15s; }
.pcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.pcard .top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.pcard img { width: 44px; height: 44px; border-radius: 12px; background: #fff; object-fit: contain; padding: 4px; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s; }

/* buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: 600 13px var(--font); cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: #1b2230; border-color: rgba(255,255,255,0.22); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #0b0b0b; border-color: transparent; }
.btn-gold:hover { background: linear-gradient(135deg, #f1d784, #dcb84a); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 11px; font: 14px var(--font); width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(212,175,55,0.5); outline-offset: 0; border-color: transparent; }
input[type="color"] { padding: 2px; height: 38px; cursor: pointer; }
input[type="checkbox"] { width: auto; }
textarea.code { font: 12.5px/1.55 var(--mono); min-height: 520px; resize: vertical; tab-size: 2; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.hint { color: var(--dim); font-size: 12px; margin: 4px 0 0; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line-2); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: rgba(62,207,142,0.35); background: rgba(62,207,142,0.08); }
.badge.warn { color: var(--warn); border-color: rgba(245,184,74,0.35); background: rgba(245,184,74,0.08); }
.badge.err { color: var(--err); border-color: rgba(255,107,107,0.35); background: rgba(255,107,107,0.08); }
.badge.run { color: var(--run); border-color: rgba(90,169,255,0.35); background: rgba(90,169,255,0.08); }
.badge.gold { color: var(--gold-2); border-color: rgba(212,175,55,0.35); background: rgba(212,175,55,0.08); }

/* storyboard */
.timeline { display: flex; height: 34px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 18px; }
.timeline > div { display: grid; place-items: center; font-size: 11px; color: rgba(255,255,255,0.85); border-right: 1px solid rgba(0,0,0,0.35); overflow: hidden; white-space: nowrap; padding: 0 6px; min-width: 0; }
.t-intro, .t-outro { background: linear-gradient(135deg, #3b2f0d, #6d5718); }
.t-title { background: linear-gradient(135deg, #24203a, #3e3567); }
.t-screen { background: linear-gradient(135deg, #0f2a3d, #17486a); }
.scene { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; }
.scene .kv { grid-template-columns: 110px minmax(0, 1fr); }
details.card summary { list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary h3::before { content: "▸ "; color: var(--gold); }
details.card[open] summary h3::before { content: "▾ "; }
.scene .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); display: grid; place-items: center; color: var(--dim); font-size: 12px; text-align: center; padding: 8px; }
.scene .thumb.brandish { background: radial-gradient(circle at 30% 20%, rgba(212,175,55,0.25), transparent 60%), #0b0d12; }
.scene h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.scene .ov { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.issues { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.issues li { padding: 8px 10px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--line); }
.issues li.err { border-color: rgba(255,107,107,0.35); }
.issues li.warn { border-color: rgba(245,184,74,0.35); }

/* media */
.filmstrip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.frame { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); }
.frame img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.frame .cap { padding: 6px 8px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.stable { position: relative; height: 12px; border-radius: 6px; background: rgba(255,107,107,0.25); overflow: hidden; margin: 6px 0 2px; }
.stable > i { position: absolute; top: 0; bottom: 0; background: rgba(62,207,142,0.75); }
video { width: 100%; border-radius: 12px; background: #000; border: 1px solid var(--line); display: block; }
.preview-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--gold); background: rgba(212,175,55,0.06); }
.logo-prev { width: 84px; height: 84px; border-radius: 18px; background: #fff; object-fit: contain; padding: 8px; border: 1px solid var(--line); }
.swatches { display: flex; gap: 6px; }
.swatches i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-2); }

.job { display: flex; flex-direction: column; gap: 6px; }
.job .progress { height: 8px; }
.qa-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.qa-list li { display: grid; grid-template-columns: 18px 210px minmax(0, 1fr); gap: 8px; }
.qa-list .pass { color: var(--ok); } .qa-list .fail { color: var(--err); } .qa-list .manual { color: var(--warn); }

/* dialog & toasts */
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 18px; padding: 24px; width: min(460px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.dialog form { display: flex; flex-direction: column; gap: 14px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(440px, calc(100vw - 40px)); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--ok); border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); white-space: pre-wrap; font-size: 13px; }
.toast.err { border-left-color: var(--err); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px 16px 60px; }
  .pipeline { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .scene { grid-template-columns: 1fr; }
  .qa-list li { grid-template-columns: 18px minmax(0, 1fr); }
  .qa-list li span:last-child { grid-column: 2; }
}

.filmstrip.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
a.frame { display: block; }

/* ---------------------------- editor visual ---------------------------- */
.ed-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.ed-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.ed-scenes h3, .ed-props h3 { margin-bottom: 10px; }
.ed-scene-list { display: flex; flex-direction: column; gap: 4px; }
.ed-scene { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px 6px; align-items: start; padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.ed-scene:hover { background: var(--panel-2); }
.ed-scene.active { background: var(--panel-2); border-color: rgba(212,175,55,0.45); }
.ed-scene-name { display: flex; flex-direction: column; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.ed-scene-name small { color: var(--dim); font-size: 11px; }
.ed-scene-actions { grid-column: 2; display: none; gap: 4px; margin-top: 4px; }
.ed-scene.active .ed-scene-actions { display: flex; }
.ed-scene-actions button { background: none; border: 1px solid var(--line-2); color: var(--muted); border-radius: 6px; width: 22px; height: 22px; font-size: 11px; cursor: pointer; padding: 0; }
.ed-scene-actions button:hover:not(:disabled) { color: var(--text); border-color: var(--gold); }
.ed-scene-actions button:disabled { opacity: 0.3; cursor: default; }
.ed-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ed-add .btn { padding: 7px 10px; font-size: 12px; }

.ed-stage { position: relative; width: 100%; margin-top: 12px; border-radius: 10px; overflow: hidden; background: #000; user-select: none; touch-action: none; }
.ed-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.ed-crop { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); outline: 1px dashed rgba(255,255,255,0.35); pointer-events: none; }
.ed-region { position: absolute; border: 1px dashed rgba(255,255,255,0.35); border-radius: 3px; cursor: copy; }
.ed-region:hover { border-color: #fff; background: rgba(255,255,255,0.08); }
.ed-box { position: absolute; border: 2px solid; border-radius: 6px; cursor: move; }
.ed-box.cam { border-color: var(--gold); border-style: dashed; background: rgba(212,175,55,0.06); }
.ed-box.spot { border-color: #5aa9ff; background: rgba(90,169,255,0.08); }
.ed-box.sel { box-shadow: 0 0 0 3px rgba(255,255,255,0.55); }
.ed-box.live { background: rgba(90,169,255,0.18); }
.ed-handle { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 4px; background: #fff; border: 2px solid #111; cursor: nwse-resize; }
.ed-tag { position: absolute; left: 0; top: -22px; white-space: nowrap; font: 600 11px var(--font); padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,0.75); color: #fff; pointer-events: none; }
.ed-anchor { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid #fff; cursor: grab; box-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.ed-anchor.bubble { background: var(--gold); }
.ed-anchor.callout { background: #ff7a59; }
.ed-anchor.sel { box-shadow: 0 0 0 4px rgba(255,255,255,0.5); }
.ed-anchor .ed-tag { left: 14px; top: -6px; }
.ed-anchor:not(.live) { opacity: 0.55; }

.ed-time { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.ed-time input { flex: 1; }
.ed-tracks { position: relative; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.ed-track { position: relative; height: 24px; background: var(--bg-2); border-radius: 6px; }
.ed-bar-item { position: absolute; top: 2px; bottom: 2px; border-radius: 5px; background: rgba(212,175,55,0.35); border: 1px solid rgba(212,175,55,0.6); color: #fff; font-size: 11px; padding: 0 6px; overflow: hidden; white-space: nowrap; cursor: pointer; display: flex; align-items: center; }
.ed-bar-item.sel { background: rgba(212,175,55,0.75); color: #0b0b0b; }
.ed-playhead { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #fff; z-index: 2; pointer-events: none; }
.ed-props .grid { gap: 10px; }
.ed-brand-preview { margin-top: 12px; aspect-ratio: 16/9; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: radial-gradient(circle at 30% 20%, rgba(212,175,55,0.25), transparent 60%), #0b0d12; text-align: center; padding: 20px; }
.ed-brand-title { font: 700 28px var(--display); }

@media (max-width: 1200px) {
  .ed-grid { grid-template-columns: 1fr; }
}
/* Cajas no seleccionadas: dejan pasar el clic a las regiones; se toman por su etiqueta. */
.ed-box:not(.sel) { pointer-events: none; }
.ed-box:not(.sel) .ed-tag { pointer-events: auto; cursor: pointer; }
.ed-box:not(.sel) .ed-handle { display: none; }

.approval { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.approval summary { list-style: none; cursor: pointer; }
.approval summary::-webkit-details-marker { display: none; }
.approval-check { align-items: flex-start; line-height: 1.4; }
.approval-check input { margin-top: 3px; }

.btn-danger { background: rgba(255,107,107,0.12); border-color: rgba(255,107,107,0.5); color: #ffb4b4; }
.btn-danger:hover:not(:disabled) { background: rgba(255,107,107,0.22); }
.trash-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }

.capture-card { border-color: rgba(212,175,55,0.35); }
.sub-details summary { list-style: none; }
.sub-details summary::-webkit-details-marker { display: none; }

.dialog-wide { width: min(760px, calc(100vw - 32px)); }
