:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #f1eee7; --line: #e3ded3; --text: #1d2433; --muted: #6b7280;
  --ink: #1f2a3d; --ink-2: #2b3a55; --accent: #f2b544; --accent-ink: #3b2a00; --primary: #2b3a55; --primary-text: #fff;
  --c-falta: #c62828; --c-busqueda: #b26a00; --c-comprado: #2563eb; --c-prestado: #7c3aed; --c-listo: #15803d; --c-na: #8a8f98;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 4px 14px rgba(20, 24, 33, .05);
  --tabh: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --surface: #1a202c; --surface-2: #222a38; --line: #2e3748; --text: #e7eaf0; --muted: #9aa3b2;
    --ink: #0d1118; --ink-2: #1a2333; --primary: #f2b544; --primary-text: #1d1600;
    --c-falta: #f05252; --c-busqueda: #f59e0b; --c-comprado: #60a5fa; --c-prestado: #a78bfa; --c-listo: #34d399; --c-na: #8a8f98;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f; --surface: #1a202c; --surface-2: #222a38; --line: #2e3748; --text: #e7eaf0; --muted: #9aa3b2;
  --ink: #0d1118; --ink-2: #1a2333; --primary: #f2b544; --primary-text: #1d1600;
  --c-falta: #f05252; --c-busqueda: #f59e0b; --c-comprado: #60a5fa; --c-prestado: #a78bfa; --c-listo: #34d399; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; -webkit-tap-highlight-color: transparent; }
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
p { margin: 0 0 .8em; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ic.big { width: 44px; height: 44px; opacity: .55; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.center { justify-content: center; } .row.end { justify-content: flex-end; }
.hint { color: var(--muted); font-size: .86rem; margin: 6px 0 10px; }
.error { color: var(--c-falta); min-height: 1.2em; margin: 6px 0; font-size: .9rem; }

/* ---------- Botones e inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .92rem; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn.danger { background: var(--c-falta); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.on { background: var(--ink-2); color: #fff; border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: .85rem; border-radius: 9px; }
.btn.block { width: 100%; margin-top: 8px; }
.danger-t { color: var(--c-falta) !important; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.input.sm { min-height: 34px; padding: 4px 8px; font-size: .88rem; }
textarea.input { resize: vertical; min-height: 80px; }
.sel { width: auto; max-width: 260px; }
.lbl { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.lbl > .input, .lbl > select, .lbl > div { margin-top: 5px; color: var(--text); font-weight: 400; font-size: .95rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2.tight { gap: 0 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
@media (max-width: 560px) { .grid2:not(.tight), .grid3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.narrow { max-width: 420px; width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 6px; }
.pill .ic { width: 13px; height: 13px; }
.pill.red { background: color-mix(in srgb, var(--c-falta) 14%, transparent); color: var(--c-falta); }
.pill.amber { background: color-mix(in srgb, var(--c-busqueda) 16%, transparent); color: var(--c-busqueda); }

/* ---------- Pantallas de inicio ---------- */
.center-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; gap: 12px; }
.center-screen .card { text-align: left; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome { max-width: 980px; margin: 0 auto; padding: 32px 16px 48px; }
.welcome-hero { text-align: center; margin-bottom: 26px; }
.welcome-hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.02em; margin: 10px 0 6px; }
.welcome-hero p { color: var(--muted); max-width: 560px; margin: 0 auto 14px; }
.logo-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--ink); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(31, 42, 61, .25); }
.logo-mark .ic { width: 34px; height: 34px; }
.logo-mark.small { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 10px; }
.logo-mark.small .ic { width: 24px; height: 24px; }
.mode-badge { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.mode-badge.cloud { color: var(--c-listo); }
.welcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .welcome-grid { grid-template-columns: 1fr; } }
.proj-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.proj-item { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.proj-item span { font-size: .8rem; color: var(--muted); grid-column: 1; }
.proj-item .ic { grid-row: 1 / 3; grid-column: 2; color: var(--muted); }
.pin-card { text-align: center !important; }
.pin-input { text-align: center; font-size: 1.5rem; letter-spacing: .4em; }

/* ---------- Barra superior y progreso ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px; background: var(--ink); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; cursor: pointer; padding: 4px 0; min-width: 0; text-align: left; }
.brand > .ic { color: var(--accent); width: 26px; height: 26px; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.brand-txt small { color: #aab4c5; font-size: .75rem; }
.top-right { display: flex; align-items: center; gap: 8px; }
.top-right .btn.ghost { color: #fff; }
.top-right .btn.ghost:hover { background: rgba(255, 255, 255, .1); }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 600; padding: 5px 10px; border-radius: 99px; background: rgba(255, 255, 255, .08); white-space: nowrap; cursor: help; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.sync.ok i { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.sync.busy i { background: var(--accent); animation: pulse 1s infinite; }
.sync.off i { background: #f59e0b; }
.sync.err i { background: #f05252; }
.sync.local i { background: #94a3b8; }
@keyframes pulse { 50% { opacity: .3; } }
@media (max-width: 420px) { .sync span { display: none; } .sync { padding: 8px; } }
#progress { background: var(--ink-2); color: #fff; padding: 4px 16px 12px; }
.prog-main { cursor: pointer; max-width: 1200px; margin: 0 auto; }
.prog-label { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: .9rem; margin-bottom: 6px; }
.prog-label b { font-size: 1.15rem; color: var(--accent); }
.prog-label .muted { color: #aab4c5; }
.chev-t { margin-left: auto; transition: transform .2s; color: #aab4c5; transform: rotate(90deg); }
#progress.collapsed .chev-t { transform: rotate(0); }
.bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, currentColor 14%, transparent); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--c-listo); border-radius: inherit; transition: width .4s ease; }
#progress .bar > span { background: var(--accent); }
.bar.big { height: 9px; }
.prog-depts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 10px auto 0; max-width: 1200px; }
#progress.collapsed .prog-depts { display: none; }
.prog-dept { display: grid; grid-template-columns: 1fr auto; gap: 3px 6px; background: none; border: 0; color: inherit; padding: 4px 0; cursor: pointer; text-align: left; font-size: .78rem; }
.prog-dept .bar { grid-column: 1 / 3; height: 4px; }
.prog-dept .bar > span { background: var(--c) !important; }
.pd-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d5dceb; }
.pd-num { color: #aab4c5; }

/* ---------- Pestañas ---------- */
.tabs { position: sticky; top: 56px; z-index: 25; display: flex; justify-content: center; gap: 4px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 6px 12px; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab:hover { background: var(--surface-2); }
.tab.on { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.tab .dot { position: absolute; top: 2px; right: 4px; font-style: normal; font-size: .65rem; font-weight: 800; min-width: 17px; height: 17px; line-height: 17px; text-align: center; border-radius: 99px; background: var(--c-falta); color: #fff; padding: 0 4px; }
main { max-width: 1200px; margin: 0 auto; padding: 16px 16px 40px; }
@media (max-width: 760px) {
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; justify-content: space-around; padding: 4px 4px calc(4px + var(--safe-b)); border-top: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, .06); }
  .tab { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; }
  .tab .ic { width: 22px; height: 22px; }
  .tab.on { box-shadow: none; background: none; color: var(--ink-2); }
  :root:not([data-theme="light"]) .tab.on { color: var(--accent); }
  main { padding-bottom: calc(var(--tabh) + var(--safe-b) + 24px); }
  .hide-sm { display: none; }
}
@media (max-width: 760px) and (prefers-color-scheme: light) { .tab.on { color: var(--ink-2); } }

/* ---------- Toolbar, chips ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar.t2 { justify-content: flex-end; }
.toolbar.t2 .sel { margin-right: auto; }
.search { position: relative; flex: 1; min-width: 200px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .86rem; white-space: nowrap; }
.chip b { background: var(--surface-2); border-radius: 99px; padding: 0 7px; font-size: .78rem; }
.chip.on { background: var(--ink-2); color: #fff; border-color: transparent; }
.chip.on b { background: rgba(255, 255, 255, .18); }
.chip.f-prestado { border-color: color-mix(in srgb, var(--c-prestado) 45%, var(--line)); }
.chip.f-prestado.on { background: var(--c-prestado); }
.chip .warn { display: inline-flex; align-items: center; gap: 2px; font-style: normal; color: var(--c-falta); font-size: .78rem; }
.chip.on .warn { color: #ffd2d2; }
.chip .warn .ic { width: 13px; height: 13px; }
.bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; margin-bottom: 10px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 12px; position: sticky; top: 110px; z-index: 5; }
.bulk > span { margin-right: auto; font-size: .9rem; }

/* ---------- Tarjetas de ítem ---------- */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
@media (max-width: 420px) { .item-grid { grid-template-columns: 1fr; } }
.item-card { position: relative; display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; border-left: 4px solid var(--stc, var(--line)); }
.item-card.selected { outline: 2px solid var(--accent); }
.st-falta { --stc: var(--c-falta); } .st-busqueda { --stc: var(--c-busqueda); } .st-comprado { --stc: var(--c-comprado); }
.st-prestado { --stc: var(--c-prestado); } .st-listo { --stc: var(--c-listo); } .st-na { --stc: var(--c-na); }
.ic-main { flex: 1; min-width: 0; display: flex; gap: 10px; padding: 10px 6px 10px 12px; background: none; border: 0; text-align: left; cursor: pointer; }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.ic-body { min-width: 0; flex: 1; }
.ic-title { font-weight: 700; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.qty { font-size: .75rem; font-weight: 700; padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--c-busqueda) 15%, transparent); color: var(--c-busqueda); }
.qty.ok { background: color-mix(in srgb, var(--c-listo) 15%, transparent); color: var(--c-listo); }
.aliases { font-size: .75rem; color: var(--muted); }
.ic-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: .78rem; margin-top: 4px; color: var(--muted); }
.ic-meta .ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px; }
.dept-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text); }
.dept-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.dept-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }
.shared { color: var(--c-comprado); font-weight: 600; }
.loan { font-size: .8rem; margin-top: 5px; color: var(--c-prestado); }
.loan.overdue { color: var(--c-falta); } .loan.soon { color: var(--c-busqueda); }
.alert-tag { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.alert-tag .ic { width: 13px; height: 13px; }
.crew-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.crew-tags span { background: var(--surface-2); color: var(--text); border-radius: 6px; padding: 1px 7px; font-size: .76rem; }
.crew-tags small { color: var(--muted); }
.notes { font-size: .78rem; color: var(--muted); margin-top: 4px; font-style: italic; }
.ic-side { display: flex; align-items: center; padding: 8px 10px 8px 4px; }
.sel-box { display: flex; align-items: center; padding-left: 10px; }
.sel-box input { width: 20px; height: 20px; accent-color: var(--ink-2); }
.status-sel { appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; padding: 6px 26px 6px 11px; font-weight: 700; font-size: .78rem; cursor: pointer; color: #fff; background: var(--stc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='white' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center; max-width: 128px; }
.status-sel:disabled { opacity: .75; cursor: default; background-image: none; padding-right: 11px; }
.status-sel option { color: #111; background: #fff; }

/* ---------- Escenas ---------- */
.scene-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; box-shadow: var(--shadow); overflow: hidden; }
.scene-card > header { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.scene-card.open > header { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.scene-num { flex: none; min-width: 38px; height: 32px; padding: 0 6px; border-radius: 9px; background: var(--ink); color: var(--accent); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; }
.scene-h { flex: 1; min-width: 0; }
.scene-h b { display: block; font-size: .92rem; text-transform: uppercase; letter-spacing: .01em; }
.chars { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chars span { font-size: .72rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.scene-prog { flex: none; width: 76px; text-align: right; font-size: .78rem; color: var(--muted); }
.scene-prog > span { font-weight: 800; font-size: 1rem; color: var(--text); }
.scene-prog > span.ok { color: var(--c-listo); }
.scene-prog small { margin-left: 3px; }
.scene-prog .bar { margin-top: 4px; }
.scene-body { padding: 12px 14px 14px; }
.synopsis { color: var(--muted); font-size: .88rem; font-style: italic; }
.mini-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.mini-name { flex: 1; text-align: left; background: none; border: 0; padding: 4px 0; cursor: pointer; font-weight: 600; }
.mini-item .status-sel { background-color: var(--stc); }
.scene-group { margin-bottom: 20px; }
.scene-group > header { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; margin-bottom: 8px; position: sticky; top: 108px; z-index: 4; background: var(--bg); padding: 6px 0; }
.scene-group > header b { text-transform: uppercase; font-size: .88rem; }
.scene-group > header .bar { grid-column: 2 / 4; height: 4px; }
.sg-prog { font-size: .8rem; font-weight: 700; color: var(--muted); }
.sg-prog.ok { color: var(--c-listo); }
@media (max-width: 760px) { .scene-group > header { top: 56px; } .bulk { top: 60px; } }
.script-text { white-space: pre-wrap; font-family: "Courier Prime", "Courier New", monospace; font-size: .88rem; background: var(--surface-2); padding: 14px; border-radius: 10px; max-height: 60vh; overflow: auto; }

/* ---------- Ocultos ---------- */
.hidden-sec { margin-top: 22px; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; }
.hidden-sec summary { padding: 12px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); list-style: none; }
.hidden-sec summary::-webkit-details-marker { display: none; }
.hidden-sec summary small { font-weight: 400; margin-left: auto; }
.hidden-list { padding: 0 14px 10px; }
.hidden-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); color: var(--muted); }

/* ---------- Vacíos ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { justify-content: center; color: var(--text); margin-top: 12px; }
.empty p { max-width: 460px; margin: 0 auto 16px; }
.empty-sm { text-align: center; color: var(--muted); padding: 24px; }

/* ---------- Modal ---------- */
#modal-root { position: relative; z-index: 100; }
.modal-wrap { position: fixed; inset: 0; background: rgba(10, 14, 22, .5); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .15s; }
.modal-wrap.open { opacity: 1; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); transform: translateY(10px); transition: transform .18s; }
.modal-wrap.open .modal { transform: none; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.modal-body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-body fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 94dvh; }
}
.confirm-msg { font-size: 1rem; margin: 6px 0; }
.status-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.sp { position: relative; cursor: pointer; }
.sp input { position: absolute; opacity: 0; }
.sp span { display: inline-block; padding: 7px 12px; border-radius: 99px; border: 1.5px solid color-mix(in srgb, var(--stc) 50%, var(--line)); color: var(--stc); font-weight: 700; font-size: .82rem; }
.sp input:checked + span { background: var(--stc); color: #fff; border-color: var(--stc); }
.sp input:focus-visible + span { outline: 2px solid var(--accent); }
.loan-box { border: 1px solid color-mix(in srgb, var(--c-prestado) 35%, var(--line)); background: color-mix(in srgb, var(--c-prestado) 6%, var(--surface)); border-radius: 12px; padding: 10px 12px 0; margin-bottom: 12px; transition: opacity .2s; }
.loan-box h4 { font-size: .85rem; color: var(--c-prestado); margin-bottom: 6px; }
.loan-box.dim { opacity: .55; }
.crew-ed-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.crew-ed-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; background: var(--surface-2); border-radius: 10px; }
.crew-ed-row b { flex: 1; }
.crew-ed-row .input { width: auto; }
.scene-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 190px; overflow-y: auto; }
.scene-pick { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: .8rem; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-pick span { color: var(--muted); }
.scene-pick.on { background: var(--ink-2); color: #fff; border-color: transparent; }
.scene-pick.on span { color: #cbd5e1; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photo { aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); padding: 0; cursor: pointer; background: var(--surface-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: .78rem; border-style: dashed; }
.photo-big { width: 100%; max-height: 65vh; object-fit: contain; border-radius: 10px; background: #000; }
.radio-row, .check-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; font-size: .92rem; }
.radio-row input, .check-row input { margin-top: 3px; accent-color: var(--ink-2); width: 17px; height: 17px; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick { display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; }
.pick:hover { background: var(--surface-2); }
.st-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--stc); }
.color-in { width: 48px; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); }

/* ---------- Importación ---------- */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.drop b { color: var(--text); }
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.paste { margin: 12px 0; }
.paste summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: 4px 0; }
.paste textarea { margin: 8px 0; font-family: "Courier New", monospace; font-size: .85rem; }
.notice { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin: 12px 0; font-size: .9rem; }
.notice.ok { background: color-mix(in srgb, var(--c-listo) 12%, transparent); color: var(--c-listo); }
.notice.ok b { color: var(--text); }
.notice.warn { background: color-mix(in srgb, var(--c-busqueda) 14%, transparent); color: var(--c-busqueda); }
.imp-opts { margin: 4px 0 8px; }
.imp-detail summary { cursor: pointer; font-weight: 600; font-size: .9rem; padding: 6px 0; }
.imp-scenes { max-height: 280px; overflow-y: auto; font-size: .85rem; display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.tag { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 1px 7px; margin: 2px 0; font-size: .78rem; }
.tag.fixed { text-decoration: line-through; opacity: .6; }

/* ---------- Crew ---------- */
.add-member .input { min-width: 140px; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.member-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.mc-head { display: flex; align-items: center; gap: 10px; }
.mc-head small { display: block; color: var(--muted); font-size: .8rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--ink-2); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; font-size: .9rem; }
.avatar.big { width: 60px; height: 60px; font-size: 1.3rem; }
.mc-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem; color: var(--muted); }
.mc-stats b { color: var(--text); }
.member-items { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.mi-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--stc); border-radius: 10px; }
.mi-row .overdue { color: var(--c-falta); } .mi-row .soon { color: var(--c-busqueda); }
.sc-tag { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 1px 7px; margin: 3px 3px 0 0; }
.st-badge { flex: none; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--stc); color: #fff; }
.member-view { max-width: 720px; }
.mv-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 14px; }
.mv-head h2 { margin: 0; }
.mv-head p { margin: 0; }

/* ---------- Exportar / Ajustes ---------- */
.radio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 14px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); }
.radio-card:has(input:checked) { border-color: var(--ink-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.radio-card input { margin-top: 3px; accent-color: var(--ink-2); }
.radio-card span { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.radio-card small { color: var(--muted); }
.ex-actions { margin-top: 14px; }
.code-box { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.3rem; font-weight: 800; letter-spacing: .15em; padding: 6px 12px; background: var(--surface-2); border-radius: 10px; display: inline-block; }
.dept-table { display: flex; flex-direction: column; margin-bottom: 12px; }
.dept-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dept-row input[type=color] { width: 32px; height: 32px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.dept-row small { display: block; color: var(--muted); font-size: .8rem; }
.dept-row small .ic { width: 12px; height: 12px; }
.link-txt { display: block; margin-top: 3px; font-size: .72rem; color: var(--muted); background: none; padding: 0; word-break: break-all; }
@media (max-width: 560px) { .dept-row > .row { width: 100%; justify-content: flex-start; padding-left: 44px; } }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: .9rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) { #toast { bottom: calc(var(--tabh) + var(--safe-b) + 14px); } }

/* Contraste de etiquetas de estado en modo oscuro */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status-sel, :root:not([data-theme="light"]) .st-badge,
  :root:not([data-theme="light"]) .sp input:checked + span { color: #0b0f17; }
  :root:not([data-theme="light"]) .status-sel { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%230b0f17' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); }
}
