:root {
  --bg: #000000;
  --bg-elevated: #050505;
  --panel: #0c0c0c;
  --panel-2: #111111;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f5;
  --muted: rgba(255, 255, 255, 0.6);
  --muted-2: rgba(255, 255, 255, 0.4);
  --accent: #c8f02a;
  --accent-bright: #e8ff5a;
  --accent-deep: #1fa84a;
  --accent-2: #9fe82e;
  --danger: #ff6b6b;
  --ok: #c8f02a;
  --warn: #e8c36a;
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Syne", "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --radius: 12px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 70vmin 50vmin at 0% 0%, rgba(212, 255, 58, 0.12), transparent 60%),
    radial-gradient(ellipse 65vmin 50vmin at 100% 100%, rgba(31, 168, 74, 0.14), transparent 62%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 64px 64px, 64px 64px, auto;
  mask-image: radial-gradient(ellipse at 40% 30%, black 15%, transparent 75%);
}
::selection {
  background: rgba(200, 240, 42, 0.35);
  color: #fff;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(212, 255, 58, 0.16), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(31, 168, 74, 0.18), transparent 50%);
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  background: rgba(12, 12, 12, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.6rem 1.45rem 1.35rem;
  display: grid;
  gap: 0.75rem;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.login-logo {
  display: block;
  width: min(220px, 70%);
  height: auto;
  margin: 0 auto 0.35rem;
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: center;
}
.login-card > p {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  line-height: 1.45;
}
.login-error {
  color: #ffb4b4;
  font-size: 0.85rem;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-top-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.app-top-brand img {
  height: 1.85rem;
  width: auto;
  display: block;
}
.app-top-meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.app-top-meta strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.app-product {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home-view {
  padding: 1.25rem 1.25rem 2.5rem;
  display: grid;
  gap: 1rem;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
.home-upload .drop { margin-top: 0.75rem; }
.jobs-table-wrap { overflow-x: auto; }
.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.jobs-table th,
.jobs-table td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.jobs-table th {
  color: var(--muted-2);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 600;
}
.jobs-table .job-title {
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font-size: 1rem;
}
.jobs-table .job-title:hover { color: var(--accent); }
.jobs-table select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 0.35rem 0.45rem;
  font: inherit;
  max-width: 11rem;
}
.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.job-actions button {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
}
.wf-iniciado { color: #9ec9ff; }
.wf-en_revision { color: var(--warn); }
.wf-enviado_qc { color: #d2a8ff; }
.wf-finalizado { color: var(--accent); }

.editor-view { flex: 1; }
.hidden { display: none !important; }

.panel {
  background: rgba(12, 12, 12, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--accent);
}

input[type="text"], textarea, .cue input, .cue textarea, select {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}
input[type="text"]:focus, textarea:focus, select:focus, .cue input:focus, .cue textarea:focus {
  outline: none;
  border-color: rgba(200, 240, 42, 0.45);
  box-shadow: 0 0 0 3px rgba(200, 240, 42, 0.12);
}
.drop {
  display: grid;
  place-items: center;
  gap: 0.25rem;
  margin: 0.6rem 0;
  padding: 1.25rem 0.9rem;
  border: 1px dashed rgba(200, 240, 42, 0.28);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  background: rgba(200, 240, 42, 0.03);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.drop:hover, .drop.drag {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(200, 240, 42, 0.07);
}
.drop small { font-size: 0.75rem; color: var(--muted-2); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.55rem 1rem;
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  background: var(--accent);
  color: #000;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover:not(:disabled), .button:hover { background: var(--accent-bright); }
button:disabled { opacity: 0.45; cursor: wait; }
button.secondary, .button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}
button.secondary:hover:not(:disabled), .button.secondary:hover {
  border-color: rgba(200, 240, 42, 0.55);
  color: var(--accent);
  background: transparent;
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
button.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line-strong);
}
button.danger {
  background: transparent;
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb4b4;
}
button.danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.55);
}

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.jobs { display: grid; gap: 0.45rem; max-height: 48vh; overflow: auto; }
.job {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  font-weight: 500;
}
.job.active { border-color: var(--accent); }
.job .t { font-weight: 650; margin-bottom: 0.15rem; }
.job .s { color: var(--muted); font-size: 0.78rem; }

.main { padding: 1.15rem 1.25rem 2.25rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.95rem;
}
.topbar h2 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.muted { color: var(--muted); font-size: 0.85rem; }
.hint { color: var(--muted-2); font-size: 0.8rem; margin: 0.45rem 0 0; line-height: 1.45; }

.options-panel { margin-bottom: 0.9rem; }
.review-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  align-items: baseline;
  margin-bottom: 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: rgba(200, 240, 42, 0.06);
  border: 1px solid rgba(200, 240, 42, 0.22);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
}
.review-banner strong { color: var(--accent); }
.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.field select, .field textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 1100px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
}
.field input[type="number"] {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.toast {
  display: none;
  position: fixed;
  top: 4.4rem;
  right: 1.25rem;
  z-index: 50;
  max-width: min(420px, calc(100vw - 2rem));
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(12, 12, 12, 0.95);
  border: 1px solid rgba(200, 240, 42, 0.28);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  color: var(--text);
}
.toast.show { display: block; }
.toast.err {
  background: rgba(40, 12, 12, 0.95);
  border-color: rgba(255, 107, 107, 0.4);
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
}
.progress > div:first-child {
  height: 8px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-bright), var(--accent), var(--accent-deep));
  width: 0%;
  min-width: 8px;
  transition: width 0.3s ease;
}
.progress span { color: var(--muted); font-size: 0.82rem; }

.stage {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
}
@media (max-width: 1100px) {
  .stage { grid-template-columns: 1fr; }
}

video {
  width: 100%;
  max-height: 420px;
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.transport {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}
.wave-stack {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.35rem;
}
.wave-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.wave-scrub-tc {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  min-width: 9.5rem;
  text-align: center;
}
.wave-zoom {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.wave-zoom button {
  min-width: 2.2rem;
  padding: 0.35rem 0.55rem;
}
.wave-label {
  color: var(--muted-2);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}
.wave {
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.4rem;
  min-height: 80px;
  overflow-x: auto;
}
.wave .wavesurfer-region { border-radius: 2px; }
.wave [part="hover-label"],
.wave .wavesurfer-hover-label {
  font-family: var(--font-mono) !important;
  font-size: 11px !important;
}

.script-head, .cue {
  display: grid;
  grid-template-columns: 118px 118px 1fr 64px 32px 32px 32px;
  gap: 0.4rem;
  align-items: start;
}
.script-head {
  color: var(--muted-2);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  padding: 0 0.1rem;
}
.cues { display: grid; gap: 0.45rem; max-height: 70vh; overflow: auto; }
.cue {
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem;
  cursor: pointer;
}
.cue.active {
  border-color: rgba(200, 240, 42, 0.55);
  box-shadow: inset 3px 0 0 var(--accent);
}
.cue.overlap {
  border-color: #c45050;
  box-shadow: inset 3px 0 0 #c45050;
  background: #140c0c;
}
.cue.overflow {
  border-color: var(--warn);
  box-shadow: inset 3px 0 0 var(--warn);
  background: #14110a;
}
.cue.overflow.overlap {
  box-shadow: inset 3px 0 0 #c45050, inset 6px 0 0 var(--warn);
}
.cue-text-wrap {
  position: relative;
  display: grid;
}
.cue-text-wrap .overlap-flag {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 1;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #c45050;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.cue-text-wrap .overflow-flag {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 1;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.2rem;
  border-radius: 4px;
  background: var(--warn);
  color: #1a1208;
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.cue-text-wrap .overlap-flag ~ .overflow-flag {
  right: 1.55rem;
}
.cue textarea { min-height: 64px; resize: vertical; width: 100%; }
.cue input[data-k="start"],
.cue input[data-k="end"] {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  padding: 0.5rem 0.4rem;
  text-align: center;
}
.cue .preview-cue,
.cue .patch-cue,
.cue .del {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  margin-top: 0.15rem;
  border-radius: 0;
}
.cue .preview-cue { color: var(--accent); }
.cue .patch-cue { color: var(--accent-2); font-size: 0.95rem; }
.cue .del { color: #d09090; font-size: 1.1rem; }
.cue select[data-k="rate"] {
  font-size: 0.78rem;
  padding: 0.4rem 0.2rem;
  text-align: center;
}
.cue.dirty {
  border-color: var(--warn);
  box-shadow: inset 3px 0 0 var(--warn);
}
input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}
.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: #0c0c0c;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.modal-foot { border-bottom: 0; border-top: 1px solid var(--line); }
.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.modal-body { padding: 1rem; display: grid; gap: 0.85rem; }
.check-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.check-field input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}
.export-preview { display: grid; gap: 0.45rem; }
.export-wave { min-height: 88px; }
.modal-card .mix-only.hidden,
.modal-card .sap-only.hidden { display: none !important; }
