:root {
  --navy: #0F2A33;
  --coral: #E8613C;
  --coral-dark: #B8461F;
  --teal: #2E8C8A;
  --teal-dark: #1F6E6C;
  --cream: #FBF8F2;
  --sand: #F4EEE4;
  --line: #ECE8E1;
  --muted: #5B6E76;
  --card: #FFFFFF;
  --bg: var(--cream);
  --text: var(--navy);
  --ok: #2E8C8A;
  --warn: #D99A1E;
  --bad: #C8442A;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1E25; --card: #12303A; --text: #EEF3F2; --line: #1F4350; --muted: #9DB3B9; --sand: #173843; --cream: #0B1E25;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1E25; --card: #12303A; --text: #EEF3F2; --line: #1F4350; --muted: #9DB3B9; --sand: #173843; --cream: #0B1E25;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: 'Oswald', sans-serif; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin: 0; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
a { color: var(--teal); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
.eyebrow { color: var(--coral); text-transform: uppercase; letter-spacing: 3px; font-weight: 700; font-size: 12px; margin: 0; }
.spacer { flex: 1; }

/* Botones */
.btn { font: inherit; border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; cursor: pointer; background: var(--sand); color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--coral); color: #fff; }
.btn.primary:hover { background: var(--coral-dark); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #0F2A33 0%, #1F6E6C 100%); }
.login-card { background: var(--card); border-radius: 22px; padding: 36px 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card h1 { font-size: 40px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
textarea { min-height: 90px; resize: vertical; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--navy); color: #FBF8F2; display: flex; align-items: center; gap: 18px; padding: 10px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: #BFD8D5; font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 50%; background: var(--coral); display: grid; place-items: center; font-family: 'Oswald'; font-size: 18px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { font: inherit; background: none; border: 0; color: #BFD8D5; padding: 8px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tabs button.active, .tabs button:hover { background: rgba(255,255,255,.12); color: #fff; }
.top-actions { display: flex; gap: 6px; }
.top-actions .btn { color: #FBF8F2; border-color: rgba(255,255,255,.25); }

/* Vista */
.view { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 22px; }
.section-head { min-width: 0; display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.kpi .value { font-family: 'Oswald'; font-size: 34px; font-weight: 600; margin-top: 4px; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.kpi .edit { float: right; }
.bar { height: 8px; border-radius: 99px; background: var(--sand); overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--teal); border-radius: 99px; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }
.two { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

.alert { border-left: 4px solid var(--warn); background: var(--card); padding: 12px 14px; border-radius: 10px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.alert.bad { border-left-color: var(--bad); }
.alerts { display: flex; flex-direction: column; gap: 8px; }

/* Listas */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--sand) 60%, transparent); }
.row .date { font-family: 'Oswald'; width: 64px; flex-shrink: 0; text-align: center; line-height: 1.1; }
.row .date b { display: block; font-size: 22px; }
.row .date small { text-transform: uppercase; font-size: 11px; color: var(--muted); }
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main small { color: var(--muted); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--sand); white-space: nowrap; }
.pill.Idea { background: #E9E4F7; color: #4B3A8C; }
.pill.Guion { background: #FFF1D6; color: #8A5A00; }
.pill.Producido { background: #DDEFF7; color: #1D5D7A; }
.pill.Aprobación { background: #FDE3D8; color: var(--coral-dark); }
.pill.Programado { background: #D8F0EE; color: var(--teal-dark); }
.pill.Publicado { background: var(--teal); color: #fff; }

/* Calendario */
.cal-head { display: flex; align-items: center; gap: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; text-align: center; }
.day { min-height: 92px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.day.out { opacity: .4; }
.day.today { border-color: var(--coral); box-shadow: inset 0 0 0 1px var(--coral); }
.day.empty-slot { background: repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in srgb, var(--coral) 8%, transparent) 6px 12px); }
.day .n { font-size: 12px; font-weight: 700; color: var(--muted); }
.day .ev { font-size: 11.5px; padding: 3px 6px; border-radius: 6px; background: var(--sand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .ev.Programado, .day .ev.Publicado { background: #D8F0EE; color: var(--teal-dark); }
.day .ev.Guion, .day .ev.Idea { background: #FFF1D6; color: #8A5A00; }
@media (max-width: 700px) { .day { min-height: 64px; } .day .ev { font-size: 0; height: 6px; padding: 0; } }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.col { background: var(--sand); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.col h3 { font-size: 13px; display: flex; justify-content: space-between; }
.deal { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.deal b { font-size: 14px; }
.deal small { color: var(--muted); }
.deal .due { color: var(--bad); font-weight: 700; font-size: 12px; }
.deal select { font-size: 12px; padding: 4px 6px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Tareas */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.task input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--teal); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .t { flex: 1; cursor: pointer; }

/* Modal */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100% - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(15,42,51,.55); }
#modal-form { padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 85vh; overflow-y: auto; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } }
.modal-actions { display: flex; gap: 8px; align-items: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(40px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { color: var(--muted); padding: 14px 0; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .view { padding: 18px 16px 50px; }
}

.modal-extra { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.ai { background: linear-gradient(90deg, #2E8C8A, #1F6E6C); color: #fff; }
.btn:disabled { opacity: .55; cursor: wait; }
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.idea { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.idea.Usada { opacity: .55; }
.idea .acts { display: flex; gap: 6px; margin-top: auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.status::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
.status.on::before { background: var(--ok); }
.thumb { width: 44px; height: 55px; object-fit: cover; border-radius: 6px; background: var(--sand); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.modal-actions { flex-wrap: wrap; }
.modal-extra { flex-basis: 100%; order: -1; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.modal-extra:empty { display: none; }
