:root {
  --paper: #f2f4f1;
  --surface: #ffffff;
  --ink: #17251f;
  --ink-soft: #52625a;
  --line: #d5dcd6;
  --spruce: #1f3a30;
  --spruce-deep: #14271f;
  --brass: #c79a3b;
  --brass-dim: #3b4a39;
  --rosewood: #8a2f2a;
  --rosewood-bg: #f6e6e3;
  --moss: #2f6b4a;
  --moss-bg: #e3f0e8;
  --amber-bg: #f8eed6;
  --amber: #7a5a10;
  --focus: #1b6fd1;
  --radius: 6px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101a16;
    --surface: #17241e;
    --ink: #e8efe9;
    --ink-soft: #9fb0a6;
    --line: #2b3d34;
    --spruce: #0c1713;
    --spruce-deep: #08100d;
    --brass: #d9ab4a;
    --brass-dim: #34402f;
    --rosewood: #e58f88;
    --rosewood-bg: #3a1f1d;
    --moss: #7fc79b;
    --moss-bg: #1d3427;
    --amber-bg: #3a3014;
    --amber: #e3c36b;
    --focus: #6aa8f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--moss); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- barra superior ---------- */
.top { background: var(--spruce); color: #eef3ef; padding: 18px 0; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.shop { color: #b7c8be; font-size: 0.9rem; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.top .btn.quiet { color: #eef3ef; border-color: #3d5a4d; }
.top .btn.quiet:hover { background: #2a4a3d; }

/* ---------- distribución ---------- */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 28px; padding: 24px 0 64px; align-items: start; }
.actions { display: grid; gap: 20px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.hint { color: var(--ink-soft); }
.hint.small { font-size: 0.85rem; }
.opt { color: var(--ink-soft); font-weight: 400; }

/* ---------- formularios ---------- */
.field { display: grid; gap: 6px; }
label { font-weight: 560; }

select, input[type="text"] {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
}

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--spruce); flex: none; }

.opts { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.opts legend { font-weight: 560; padding: 0; margin-bottom: 8px; }

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  background: var(--paper);
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--spruce); background: var(--moss-bg); }
.drop.has-file { border-style: solid; border-color: var(--moss); }
.drop-main { font-weight: 560; overflow-wrap: anywhere; }

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--spruce); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--spruce); border-color: var(--spruce); color: #f4f7f4; }
.btn.primary:hover { background: var(--spruce-deep); }
@media (prefers-color-scheme: dark) {
  .btn.primary { background: var(--brass); border-color: var(--brass); color: #1b1608; }
  .btn.primary:hover { background: #e6bb62; }
}
.btn.quiet { background: transparent; }
.btn.danger { color: var(--rosewood); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }

/* ---------- avisos ---------- */
.banner { margin: 18px 0 0; padding: 12px 14px; border-radius: var(--radius); background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }
.banner.error { background: var(--rosewood-bg); color: var(--rosewood); border-color: var(--rosewood); }
.banner p + p { margin-top: 4px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 12px 14px; border-radius: var(--radius); background: var(--spruce-deep); color: #f4f7f4; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); z-index: 10; }
.toast.error { background: var(--rosewood); color: #fff; }

/* ---------- trabajos ---------- */
.jobs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
#jobs { display: grid; gap: 14px; }

.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; }
.job.focus { border-color: var(--spruce); box-shadow: 0 0 0 2px var(--moss-bg); }
.job-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.job-title { font-weight: 650; font-size: 1.02rem; }
.job-sub { color: var(--ink-soft); font-size: 0.88rem; overflow-wrap: anywhere; }

.chip { display: inline-block; font-size: 0.82rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); white-space: nowrap; }
.chip.running { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.chip.ok { background: var(--moss-bg); color: var(--moss); border-color: transparent; }
.chip.warn { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.chip.bad { background: var(--rosewood-bg); color: var(--rosewood); border-color: transparent; }

/* Medidor de nivel: el progreso se lee como el indicador de un equipo de audio */
.meter { display: grid; gap: 8px; }
.meter-bar {
  display: grid;
  grid-template-columns: repeat(40, 1fr);
  gap: 3px;
  height: 22px;
  padding: 4px;
  background: var(--spruce-deep);
  border-radius: 4px;
}
.seg { background: var(--brass-dim); border-radius: 1px; }
.seg.on { background: var(--brass); }
.seg.hot { background: #e8704f; }
.seg.lead { animation: lead 1.1s ease-in-out infinite; }
.meter.idle .seg.scan { animation: scan 1.6s linear infinite; }
@keyframes lead { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes scan { 0%, 100% { background: var(--brass-dim); } 50% { background: var(--brass); } }
@media (prefers-reduced-motion: reduce) {
  .seg.lead, .meter.idle .seg.scan { animation: none; }
}
.meter-info { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
.meter-info .pct { font-weight: 650; }
.meter-info .eta { color: var(--ink-soft); }
.meter-msg { color: var(--ink-soft); font-size: 0.9rem; overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin: 0; }
.stats div { border-left: 3px solid var(--line); padding-left: 10px; }
.stats dt { color: var(--ink-soft); font-size: 0.82rem; }
.stats dd { margin: 0; font-weight: 650; font-size: 1.1rem; }
.stats .bad { border-left-color: var(--rosewood); }
.stats .bad dd { color: var(--rosewood); }
.stats .good { border-left-color: var(--moss); }

.job-error { padding: 10px 12px; border-radius: var(--radius); background: var(--rosewood-bg); color: var(--rosewood); overflow-wrap: anywhere; }
.note { padding: 10px 12px; border-radius: var(--radius); background: var(--amber-bg); color: var(--amber); font-size: 0.9rem; }

.job-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.job-actions .spacer { flex: 1; }

details.log summary { cursor: pointer; font-weight: 560; color: var(--ink-soft); }
.logbox { margin-top: 8px; max-height: 260px; overflow: auto; background: var(--spruce-deep); color: #cfe0d5; border-radius: var(--radius); padding: 10px 12px; font: 0.8rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.logbox .l { white-space: pre-wrap; overflow-wrap: anywhere; }
.logbox .t { color: #7f968a; }
.logbox .warn { color: #e8c46a; }
.logbox .error { color: #f0907f; }

.empty { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px 20px; text-align: center; display: grid; gap: 6px; }
.empty-title { font-weight: 650; }
