:root {
    --ink: #0a0f2c;
    --ink-2: #121a45;
    --brand: #3b5bfd;
    --brand-soft: #eef1ff;
    --violet: #7c5cff;
    --lilac: #b39dff;
    --lilac-soft: #f3efff;
    --mint: #17c8a3;
    --coral: #ff5d73;
    --amber: #ffb23f;
    --bg: #f5f6fc;
    --surface: #ffffff;
    --line: #e8eaf4;
    --text: #1a1f3d;
    --muted: #7a82a6;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 18px 40px -24px rgba(16, 24, 64, .35);
    --shadow-lg: 0 30px 70px -35px rgba(16, 24, 64, .55);
    --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: inherit; margin: 0; font-weight: 600; letter-spacing: -.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

/* Embebido en Bitrix24: el iframe se ajusta al contenido real,
   sin forzar 100vh (evita que el iframe crezca y nunca se encoja). */
.app.is-embedded { min-height: 0; }
.app.is-embedded .main { padding-bottom: 26px; }

.main {
    flex: 1;
    min-width: 0;
    padding: 22px 30px 60px;
    margin-left: var(--sidebar-w);
}

.page { display: grid; gap: 18px; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(170deg, var(--ink) 0%, #171f52 55%, #24205c 100%);
    color: #cfd4f2;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow-y: auto;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand__mark {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--violet));
    color: #fff; font-weight: 700; letter-spacing: -.03em;
    box-shadow: 0 10px 24px -10px var(--violet);
}

.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { color: #fff; font-size: 15px; font-weight: 600; }
.brand__text small { color: #8d95c9; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav__group {
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #6f78ad;
    margin: 16px 10px 6px;
    font-weight: 500;
}

.nav__link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 400;
    color: #c2c8ee;
    transition: background .18s, color .18s, transform .18s;
}

.nav__link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.nav__link.is-active {
    background: linear-gradient(120deg, var(--brand), var(--violet));
    color: #fff;
    font-weight: 500;
    box-shadow: 0 14px 28px -16px var(--violet);
}

.badge {
    margin-left: auto;
    background: var(--coral);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    border-radius: 20px;
    padding: 1px 7px;
}

.badge--soon {
    background: rgba(255, 255, 255, .1);
    color: #8d95c9;
    font-weight: 500;
    letter-spacing: .02em;
}

.nav__link.is-locked { color: #8189b8; }
.nav__link.is-locked .icon { opacity: .6; }

/* ---------- Próximamente ---------- */
.soon { display: grid; place-items: center; min-height: 62vh; }

.soon__card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 46px 40px;
    text-align: center;
    max-width: 520px;
    box-shadow: var(--shadow);
}

.soon__badge {
    display: inline-block;
    background: var(--lilac-soft);
    color: var(--violet);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.soon__title { font-size: 24px; margin: 16px 0 8px; }
.soon__text { color: var(--muted); font-size: 13.5px; }

.soon__bar {
    height: 6px;
    background: #eef0f8;
    border-radius: 10px;
    overflow: hidden;
    margin: 26px 0 12px;
}
.soon__bar span {
    display: block;
    height: 100%;
    width: 38%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--brand), var(--violet));
    animation: soon-slide 2.4s ease-in-out infinite;
}

@keyframes soon-slide {
    0%, 100% { transform: translateX(-12%); }
    50% { transform: translateX(180%); }
}

.soon__note { color: var(--muted); font-size: 12px; margin-bottom: 22px; }

.sidebar__card {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 16px;
    padding: 16px;
}

.sidebar__card-title { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar__card-text { color: #9aa2d2; font-size: 11.5px; margin: 4px 0 12px; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.topbar__eyebrow { font-size: 10.5px; letter-spacing: .16em; color: var(--muted); font-weight: 500; }
.topbar__title { font-size: 27px; font-weight: 600; margin-top: 2px; }
.topbar__title span { background: linear-gradient(120deg, var(--brand), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar__sub { color: var(--muted); font-size: 12.5px; }
.topbar__tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search {
    display: flex; align-items: center; gap: 9px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 9px 14px;
    color: var(--muted);
    min-width: 250px;
}
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 13px; }

.segmented {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 3px;
}
.segmented__item { padding: 6px 13px; border-radius: 11px; font-size: 12.5px; color: var(--muted); }
.segmented__item.is-active { background: var(--ink); color: #fff; font-weight: 500; }

.avatar {
    width: 40px; height: 40px;
    border-radius: 14px;
    display: grid; place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, var(--violet), var(--lilac));
    color: #fff; font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent;
    border-radius: 13px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: linear-gradient(120deg, var(--brand), var(--violet)); color: #fff; box-shadow: 0 16px 30px -18px var(--violet); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--soft { background: var(--brand-soft); color: var(--brand); }
.btn--lilac { background: var(--lilac-soft); color: var(--violet); }
.btn--outline { border-color: var(--line); color: var(--text); }
.btn--ghost { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .2); }
.btn--sm { padding: 7px 12px; font-size: 12px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn--danger { background: #fff1f3; color: var(--coral); }

/* ---------- Cards & grid ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card--flat { box-shadow: none; }
.card--ink { background: linear-gradient(150deg, var(--ink), #2b2a6b); color: #fff; border-color: transparent; }
.card--gradient { background: linear-gradient(140deg, var(--brand), var(--violet)); color: #fff; border-color: transparent; }

.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__title { font-size: 15px; font-weight: 600; }
.card__sub { font-size: 12px; color: var(--muted); }
.card--ink .card__sub, .card--gradient .card__sub { color: rgba(255, 255, 255, .75); }

.grid { display: grid; gap: 18px; }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); align-items: start; }
.grid--aside { grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr); align-items: start; }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 10px; }
.kpi__label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.kpi__value { font-size: 26px; font-weight: 600; letter-spacing: -.03em; }
.kpi__foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

.pill {
    display: inline-flex; align-items: center; gap: 4px;
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 11.5px;
    font-weight: 500;
    background: var(--brand-soft);
    color: var(--brand);
}
.pill.is-up { background: #e7faf4; color: #0f9b7e; }
.pill.is-down { background: #ffeef1; color: var(--coral); }
.pill--muted { background: #f2f3f9; color: var(--muted); }
.pill--lilac { background: var(--lilac-soft); color: var(--violet); }
.pill--amber { background: #fff6e6; color: #b97800; }

/* ---------- Charts ---------- */
.chart { position: relative; height: 260px; }
.chart--sm { height: 150px; }
.chart--xs { height: 90px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }

.list__item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px;
    border-radius: 14px;
    background: #fafbff;
    border: 1px solid var(--line);
}
.list__item:hover { background: #f6f7ff; }
.list__title { font-size: 13px; font-weight: 500; }
.list__meta { font-size: 11.5px; color: var(--muted); }
.list__value { margin-left: auto; text-align: right; font-weight: 600; font-size: 13px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: 10px;
    padding: 4px 9px;
    font-size: 11.5px;
    background: #f2f3fa;
    color: var(--muted);
}
.chip--on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.bar { height: 7px; border-radius: 10px; background: #eef0f8; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--brand), var(--violet)); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
    color: var(--muted); font-weight: 500; padding: 0 12px 10px;
}
.table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fafbff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; font-weight: 500; color: var(--muted); }
.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fafbff;
    border-radius: 13px;
    padding: 11px 13px;
    outline: none;
    transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(59, 91, 253, .12); background: #fff; }
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.form-grid { display: grid; gap: 14px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }
.toggle input { display: none; }
.toggle__track { width: 42px; height: 24px; border-radius: 20px; background: #dfe2f0; position: relative; transition: background .2s; }
.toggle__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.toggle input:checked + .toggle__track { background: linear-gradient(120deg, var(--brand), var(--violet)); }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); }

.platform-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.platform-picker label {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); border-radius: 12px;
    padding: 8px 12px; cursor: pointer; font-size: 12.5px;
    background: #fafbff; transition: .15s;
}
.platform-picker input { display: none; }
.platform-picker label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 500; }

/* ---------- Calendar ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar__dow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); text-align: center; padding-bottom: 4px; }
.calendar__cell {
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px;
    background: #fafbff;
    display: flex; flex-direction: column; gap: 5px;
}
.calendar__cell.is-out { opacity: .45; }
.calendar__cell.is-today { border-color: var(--brand); background: var(--brand-soft); }
.calendar__cell.is-over { border-style: dashed; border-color: var(--violet); }
.calendar__cell { cursor: pointer; }
.calendar__day { font-size: 11.5px; font-weight: 600; color: var(--muted); }

.event {
    border-radius: 10px;
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.35;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    cursor: grab;
}
.event--publicado { border-left-color: var(--mint); }
.event--borrador { border-left-color: var(--amber); }
.event--idea { border-left-color: var(--lilac); background: #f7f4ff; border-style: dashed; }
.event--fallido, .event--parcial { border-left-color: var(--coral); }
.event--gcal { border-left-color: var(--violet); background: var(--lilac-soft); cursor: default; }
.event strong { display: block; font-weight: 500; }
.event span { color: var(--muted); font-size: 10.5px; }
.event__more { font-size: 10.5px; color: var(--muted); padding: 2px 4px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__overlay { position: absolute; inset: 0; background: rgba(10, 15, 44, .55); backdrop-filter: blur(2px); }
.modal__panel {
    position: relative;
    background: var(--surface);
    border-radius: 22px;
    width: min(480px, 100%);
    max-height: 84vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    padding: 22px 24px 26px;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal__head h3 { font-size: 16px; }
.modal__close { background: none; border: 0; font-size: 15px; color: var(--muted); cursor: pointer; padding: 4px; }
.modal__body { display: grid; gap: 14px; }
.modal__section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; margin-bottom: 8px; }


/* ---------- Media library ---------- */
.drive-crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.drive-crumb {
    background: none; border: 0; cursor: pointer;
    font-size: 12px; color: var(--muted);
    padding: 3px 6px; border-radius: 8px;
    transition: .15s;
}
.drive-crumb:hover { background: #eef0f8; color: var(--text); }
.drive-crumb.is-current { color: var(--brand); font-weight: 500; }
.drive-folders { display: flex; flex-wrap: wrap; gap: 8px; }
.drive-folder {
    display: inline-flex; align-items: center; gap: 6px;
    background: #f4f5fb; border: 1px solid var(--line);
    border-radius: 12px; padding: 7px 12px;
    font-size: 12.5px; cursor: pointer;
    transition: .15s;
}
.drive-folder:hover { border-color: var(--brand); background: #eef1ff; transform: translateY(-1px); }

.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; }
.asset {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #fafbff;
    cursor: pointer;
    transition: .15s;
}
.asset:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.asset.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 91, 253, .15); }
.asset__thumb { height: 116px; background: linear-gradient(140deg, #e9ecfb, #efe9fb); display: grid; place-items: center; overflow: hidden; }
.asset__thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset__body { padding: 9px 11px; }
.asset__name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset__meta { font-size: 10.5px; color: var(--muted); }

/* ---------- Comments ---------- */
.comment { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fafbff; }
.comment__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.comment__author { font-weight: 500; }
.comment__msg { font-size: 13.5px; }
.comment__reply { border-left: 3px solid var(--violet); padding: 10px 12px; background: var(--lilac-soft); border-radius: 0 12px 12px 0; font-size: 13px; }
.comment__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.comment.is-done { opacity: .6; }
.comment.is-new { animation: slide-in .45s ease; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124, 92, 255, .12); }

.comment__body { display: flex; gap: 14px; align-items: flex-start; }
.comment__text { min-width: 0; flex: 1; }

.post-preview {
    width: 76px; height: 76px; flex: none;
    border-radius: 14px; overflow: hidden;
    background: linear-gradient(140deg, #e9ecfb, #efe9fb);
    display: grid; place-items: center;
    border: 1px solid var(--line);
    transition: transform .15s, box-shadow .15s;
}
.post-preview:hover { transform: scale(1.04); box-shadow: var(--shadow); }
.post-preview img { width: 100%; height: 100%; object-fit: cover; }
.post-preview__empty { font-size: 10px; color: var(--muted); text-align: center; padding: 4px; }

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: none; }
}

.live {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 11px; font-weight: 500; letter-spacing: .04em;
    white-space: nowrap;
    color: #9fe9d5;
    background: rgba(23, 200, 163, .15);
    border-radius: 20px; padding: 4px 10px;
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: pulse 1.6s infinite; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(23, 200, 163, .6); }
    70% { box-shadow: 0 0 0 7px rgba(23, 200, 163, 0); }
    100% { box-shadow: 0 0 0 0 rgba(23, 200, 163, 0); }
}

/* ---------- Misc ---------- */
.flash { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.flash--success { background: #e7faf4; color: #0f7f68; }
.flash--error { background: #ffeef1; color: #c0344a; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 13px; }

.toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 60;
    background: var(--ink); color: #fff;
    padding: 12px 18px; border-radius: 14px; font-size: 13px;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
}
.toast.is-error { background: var(--coral); }

.section-title { font-size: 17px; font-weight: 600; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login {
    min-height: 100vh; display: grid; place-items: center;
    background: radial-gradient(1000px 600px at 20% 10%, #2a2d78, var(--ink));
    padding: 24px;
}
.login__card { background: var(--surface); border-radius: 26px; padding: 34px; width: min(410px, 100%); box-shadow: var(--shadow-lg); }
.login__title { font-size: 22px; margin: 14px 0 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--main, .grid--aside { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .sidebar { position: static; width: 100%; flex-direction: row; overflow-x: auto; align-items: center; gap: 14px; }
    .sidebar__card, .nav__group { display: none; }
    .nav { flex-direction: row; gap: 6px; }
    .main { margin-left: 0; padding: 18px; }
    .app { flex-direction: column; }
    .grid--3, .grid--2, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid--2 { grid-template-columns: minmax(0, 1fr); }
    .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calendar__dow { display: none; }
}
