:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #f0eeea;
  --ink: #17181b;
  --muted: #6b6a66;
  --line: #e2dfd8;
  --accent: #e8452c;
  --accent-ink: #ffffff;
  --accent-soft: #fde7e2;
  --ok: #1f8a4c;
  --ok-soft: #e1f3e8;
  --warn: #a35d00;
  --warn-soft: #fdf0d9;
  --bad: #b42318;
  --bad-soft: #fde4e1;
  --info: #2459c6;
  --info-soft: #e3ebfb;
  --side: #17181b;
  --side-ink: #d9d7d2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 2px 8px rgba(20, 20, 20, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315; --surface: #1b1c1f; --surface-2: #232428; --ink: #ecebe7; --muted: #9c9a95; --line: #2e2f33;
    --accent: #ff6a50; --accent-soft: #3a1f1a; --ok: #4cc27f; --ok-soft: #173023; --warn: #f0b252; --warn-soft: #362812;
    --bad: #ff7b6e; --bad-soft: #3b1b18; --info: #7aa5ff; --info-soft: #1a2540; --side: #0c0d0e; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: .25rem 0 .75rem; }
small, .muted { color: var(--muted); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .88em; word-break: break-all; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; background: conic-gradient(#00b7eb, #e8452c, #ffd400, #00b7eb); }
.brand small { display: block; color: #8d8b86; font-weight: 400; font-size: .75rem; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-size: .93rem; }
.nav a:hover { background: #26272b; }
.nav a.active { background: #2c2d32; color: #fff; }
.nav .group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7b7974; margin: 14px 10px 4px; }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 7px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.menu-btn { display: none; }
.modes { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .main { padding: 14px 16px 60px; }
  .menu-btn { display: inline-flex; }
}

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card.narrow { max-width: 440px; margin: 0 auto; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.spacer { flex: 1; }

.kpi { padding: 14px 16px; }
.kpi .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi .s { font-size: .78rem; color: var(--muted); }
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 13px; border-radius: 9px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: .82rem; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: .83rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: .92rem; margin-bottom: 8px; }
.check input { margin-top: 3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-weight: 500; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.alert { border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Calendario ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.cal .day { background: var(--surface); min-height: 108px; padding: 6px; cursor: pointer; }
.cal .day.out { background: var(--surface-2); opacity: .6; }
.cal .day.today .n { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; }
.cal .n { font-size: .8rem; font-weight: 600; display: inline-block; margin-bottom: 4px; }
.cal .ev { display: block; font-size: .74rem; padding: 2px 6px; border-radius: 6px; margin-bottom: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: var(--surface-2); color: var(--ink); border-left: 3px solid var(--muted); }
.ev.scheduled { border-left-color: var(--info); }
.ev.published { border-left-color: var(--ok); }
.ev.failed { border-left-color: var(--bad); }
.ev.pending_approval { border-left-color: var(--warn); }
.ev.draft { border-left-color: var(--line); }
@media (max-width: 640px) { .cal .day { min-height: 64px; } .cal .ev { font-size: 0; height: 6px; padding: 0; } }

/* ---------- Creatividades ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.media { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); position: relative; }
.media img, .media video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.media .meta { padding: 6px 8px; font-size: .74rem; color: var(--muted); }
.media.pick { cursor: pointer; }
.media.sel { outline: 3px solid var(--accent); }
.media .order { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; border-radius: 99px; width: 22px; height: 22px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { display: flex; justify-content: space-between; font-size: .82rem; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; font-size: .86rem; }
.mini:hover { border-color: var(--muted); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 99px; background: var(--surface); border: 2px solid var(--muted); }

/* ---------- Modal y avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 10, 12, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(860px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.sm { width: min(480px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 200; font-size: .9rem; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

.center-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-logo .dot { width: 36px; height: 36px; border-radius: 10px; background: conic-gradient(#00b7eb, #e8452c, #ffd400, #00b7eb); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.pre { white-space: pre-wrap; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none; } }
