/* ============================================================================
   Контент-завод · новый UX — дизайн-основа (Batch 3).
   Изолированный слой: ничего из боевого v2.css не переопределяет.
   Бренд АрендОК: мятный акцент, глубокий графит, Days One + Manrope.
   ============================================================================ */

:root {
  /* --- Цвет ------------------------------------------------------------- */
  --mint: #2FB89A;          /* основной интерактив (бренд, затемнён до AA) */
  --mint-soft: #E4F6F1;
  --mint-line: #A8DED1;
  --ink: #0F1A17;
  --ink-2: #3C4A46;
  --ink-3: #6B7A75;
  --ink-4: #9AA7A2;
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --surface-2: #FBFCFC;
  --line: #E4E9E7;
  --line-2: #D3DBD8;

  --ok: #1E9E6A;   --ok-bg: #E6F6EE;
  --info: #3B7BD8; --info-bg: #E9F1FC;
  --warn: #B87514; --warn-bg: #FCF2E2;
  --bad: #C3392F;  --bad-bg: #FBEAE8;
  --plan: #6D5BD0; --plan-bg: #EFECFB;
  --muted-bg: #EEF1F0;

  /* --- Ритм -------------------------------------------------------------- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r1: 6px; --r2: 10px; --r3: 14px; --r4: 20px; --r5: 28px;
  --sh1: 0 1px 2px rgba(15,26,23,.06);
  --sh2: 0 2px 8px rgba(15,26,23,.07), 0 1px 2px rgba(15,26,23,.05);
  --sh3: 0 12px 32px rgba(15,26,23,.13), 0 2px 8px rgba(15,26,23,.07);
  --rail: 272px;
  --topbar: 68px;
  --maxw: 1600px;

  --font: "Manrope", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Days One", var(--font);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --mint: #53D9BA; --mint-soft: #14302A; --mint-line: #2A5F53;
    --ink: #EEF3F1; --ink-2: #C3CFCB; --ink-3: #93A29D; --ink-4: #6F7F7A;
    --bg: #0C1311; --surface: #141C1A; --surface-2: #101715;
    --line: #222E2B; --line-2: #2E3C38;
    --ok-bg: #12291F; --info-bg: #141F30; --warn-bg: #2A2013; --bad-bg: #2C1816; --plan-bg: #1D1932; --muted-bg: #1A2220;
    --ok: #4CC58C; --info: #7BA9EE; --warn: #E0A64A; --bad: #EE7A70; --plan: #A899EE;
    --sh1: 0 1px 2px rgba(0,0,0,.4); --sh2: 0 2px 10px rgba(0,0,0,.45); --sh3: 0 16px 40px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --mint: #53D9BA; --mint-soft: #14302A; --mint-line: #2A5F53;
  --ink: #EEF3F1; --ink-2: #C3CFCB; --ink-3: #93A29D; --ink-4: #6F7F7A;
  --bg: #0C1311; --surface: #141C1A; --surface-2: #101715;
  --line: #222E2B; --line-2: #2E3C38;
  --ok-bg: #12291F; --info-bg: #141F30; --warn-bg: #2A2013; --bad-bg: #2C1816; --plan-bg: #1D1932; --muted-bg: #1A2220;
  --ok: #4CC58C; --info: #7BA9EE; --warn: #E0A64A; --bad: #EE7A70; --plan: #A899EE;
  --sh1: 0 1px 2px rgba(0,0,0,.4); --sh2: 0 2px 10px rgba(0,0,0,.45); --sh3: 0 16px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; font-synthesis: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: 32px; } h2 { font-size: 23px; } h3 { font-size: 19px; } h4 { font-size: 16.5px; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0; }
p { margin: 0 0 var(--s3); }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: var(--r1); }

/* --- Текстовые уровни ----------------------------------------------------- */
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.tiny { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.tt { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; color: var(--ink-3); }

/* --- Оболочка ------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.app.norail { grid-template-columns: 1fr; }
.rail {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.rail-head { padding: var(--s4) var(--s4) var(--s3); display: flex; align-items: center; gap: var(--s3); }
.logo {
  width: 32px; height: 32px; border-radius: 9px; background: var(--mint); color: #05231D;
  display: grid; place-items: center; font-family: var(--display); font-size: 15px; flex: none;
}
.rail nav { padding: var(--s3); display: flex; flex-direction: column; gap: 3px; }
.nav-group { margin-top: var(--s4); }
.nav-group > .tt { padding: 0 var(--s3) var(--s2); }
.nav-item {
  display: flex; align-items: center; gap: var(--s3); padding: 11px var(--s3);
  border-radius: var(--r2); cursor: pointer; border: 0; background: none; width: 100%;
  text-align: left; font-size: 15.5px; color: var(--ink-2); transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--muted-bg); color: var(--ink); }
.nav-item.on { background: var(--mint-soft); color: var(--ink); font-weight: 700; }
.nav-item .ico { width: 22px; display: grid; place-items: center; opacity: .8; flex: none; }
.nav-item .cnt {
  margin-left: auto; font-size: 12px; font-weight: 700; background: var(--muted-bg);
  border-radius: 999px; padding: 1px 7px; color: var(--ink-3);
}
.nav-item.on .cnt, .nav-item .cnt.hot { background: var(--bad); color: #fff; }
.rail-foot { margin-top: auto; padding: var(--s4); border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar); border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5);
  position: sticky; top: 0; z-index: 30;
}
.topbar .grow { flex: 1; min-width: 0; }
.page { padding: var(--s6) var(--s6) var(--s7); max-width: var(--maxw); width: 100%; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 240px; }

/* --- Поверхности ---------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3);
  box-shadow: var(--sh1);
}
.card.pad { padding: 18px; }
.card h3, .card h4 { overflow-wrap: anywhere; }
.card.hov { cursor: pointer; transition: box-shadow .14s, transform .14s, border-color .14s; }
.card.hov:hover { box-shadow: var(--sh2); border-color: var(--line-2); transform: translateY(-1px); }
.grid { display: grid; gap: var(--s4); }
.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)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }
.sp { flex: 1; }
.sep { height: 1px; background: var(--line); margin: var(--s4) 0; }

/* --- Кнопки --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 10px 18px; border-radius: var(--r2); border: 1px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-size: 15px; font-weight: 600;
  transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn.pri { background: var(--mint); border-color: var(--mint); color: #05231D; }
.btn.pri:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--muted-bg); }
.btn.sm { padding: 7px 13px; font-size: 13.5px; border-radius: var(--r1); }
.btn.lg { padding: 15px 28px; font-size: 17px; border-radius: var(--r3); }
.btn.bad { color: var(--bad); border-color: var(--line-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* --- Значки статусов (цвет + форма + текст, §69/§100) --------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; line-height: 1.2;
}
.badge .dot { font-size: 11px; line-height: 1; }
.b-muted { background: var(--muted-bg); color: var(--ink-3); }
.b-work  { background: var(--mint-soft); color: #14685A; border-color: var(--mint-line); }
.b-info  { background: var(--info-bg); color: var(--info); }
.b-warn  { background: var(--warn-bg); color: var(--warn); }
.b-ok    { background: var(--ok-bg); color: var(--ok); }
.b-plan  { background: var(--plan-bg); color: var(--plan); }
.b-done  { background: var(--ok-bg); color: var(--ok); }
.b-bad   { background: var(--bad-bg); color: var(--bad); }
:root[data-theme="dark"] .b-work { color: var(--mint); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--mint-soft); border-color: var(--mint-line); font-weight: 700; }

/* --- Канал ---------------------------------------------------------------- */
.ch {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
}
.ch .av {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  color: #fff; font-size: 10px; font-weight: 800; flex: none;
}
.ch.big .av { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }

/* --- Прогресс -------------------------------------------------------------- */
.bar { height: 6px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--mint); border-radius: 999px; transition: width .4s; }
.rail-steps { display: flex; gap: 3px; }
.rail-steps i { flex: 1; height: 5px; border-radius: 999px; background: var(--muted-bg); }
.rail-steps i.on { background: var(--mint); }

/* --- KPI ------------------------------------------------------------------- */
.kpi { padding: 20px; }
.kpi .v { font-size: 36px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi .t { font-size: 14px; color: var(--ink-3); margin-bottom: 2px; }
.kpi .h { font-size: 12px; color: var(--ink-4); margin-top: 4px; }

/* --- Таблица --------------------------------------------------------------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 700; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
.tbl td { padding: 13px var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.hov:hover td { background: var(--surface-2); cursor: pointer; }

/* --- Ввод ------------------------------------------------------------------ */
.inp, textarea.inp {
  width: 100%; padding: 10px var(--s3); border: 1px solid var(--line-2); border-radius: var(--r2);
  background: var(--surface); outline: none;
}
.inp:focus { border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
textarea.inp { resize: vertical; min-height: 96px; line-height: 1.55; }

/* --- Командное поле (§11) --------------------------------------------------- */
.cmd { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r5);
  box-shadow: var(--sh2); padding: var(--s4) var(--s5) var(--s3); }
.cmd textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  font-size: 19px; line-height: 1.55; min-height: 92px;
}
.cmd textarea::placeholder { color: var(--ink-4); }
.cmd-foot { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding-top: var(--s2); border-top: 1px solid var(--line); }
.scen { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); justify-content: center; }

/* --- Ящик (side panel) ------------------------------------------------------ */
.scrim { position: fixed; inset: 0; background: rgba(9,17,15,.42); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg);
  border-left: 1px solid var(--line); box-shadow: var(--sh3); z-index: 61;
  transform: translateX(100%); transition: transform .22s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-body { flex: 1; overflow: auto; padding: var(--s5); }
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); overflow: auto; }
.tabs button {
  border: 0; background: none; padding: 10px var(--s3); cursor: pointer; font-size: 14px;
  color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--mint); }

/* --- Модалка ---------------------------------------------------------------- */
.modal {
  position: fixed; z-index: 62; top: 50%; left: 50%; transform: translate(-50%, -48%) scale(.98);
  width: min(720px, calc(100% - 32px)); max-height: 86vh; overflow: auto; background: var(--surface);
  border-radius: var(--r4); box-shadow: var(--sh3); padding: var(--s5); opacity: 0; pointer-events: none;
  transition: opacity .16s, transform .16s;
}
.modal.on { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

/* --- Календарь --------------------------------------------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r3); overflow: hidden; }
.cal .dow { background: var(--surface-2); padding: var(--s2); font-size: 12px; font-weight: 700; color: var(--ink-3); text-align: center; }
.cell { background: var(--surface); min-height: 134px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cell.dim { background: var(--surface-2); }
.cell.drop { outline: 2px dashed var(--mint); outline-offset: -3px; }
.cell .d { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.cell .d.today { color: var(--mint); }
.pub {
  border: 1px solid var(--line); border-left: 3px solid var(--mint); border-radius: var(--r1);
  padding: 4px 6px; font-size: 11.5px; background: var(--surface); cursor: grab; line-height: 1.3;
}
.pub:hover { background: var(--surface-2); }
.pub.dragging { opacity: .4; }
.pub .tm { color: var(--ink-3); font-weight: 700; }

/* --- Матрица каналов --------------------------------------------------------- */
.matrix { overflow: auto; }
.matrix table { border-collapse: collapse; width: 100%; min-width: 720px; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: var(--s2); font-size: 13px; vertical-align: top; }
.matrix th { background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.matrix td.day { background: var(--surface-2); font-weight: 700; text-align: center; width: 56px; }

/* --- Конвейер (вариант B) ----------------------------------------------------- */
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s3); }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s4);
  cursor: pointer; position: relative; transition: border-color .14s, box-shadow .14s; }
.stage:hover { border-color: var(--mint-line); box-shadow: var(--sh2); }
.stage.on { border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
.stage .n { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stage .arrow { position: absolute; right: -13px; top: 50%; transform: translateY(-50%); color: var(--ink-4); z-index: 2; }

/* --- Студия (вариант D) -------------------------------------------------------- */
.tile { border-radius: var(--r3); overflow: hidden; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.tile .thumb { height: 250px; background: linear-gradient(150deg, #20302C, #0F1A17);
  position: relative; display: grid; place-items: center; color: rgba(255,255,255,.5); font-size: 30px; }
.tile.post .thumb { height: 250px; background: linear-gradient(150deg, #1B2740, #0F1A17); }
.tile.carousel .thumb { height: 250px; background: linear-gradient(150deg, #3A2E16, #0F1A17); }
.tile .thumb .st { position: absolute; left: 8px; top: 8px; }
.tile .meta { padding: var(--s3); }

/* --- Прочее -------------------------------------------------------------------- */
.attn { border-left: 3px solid var(--warn); }
.attn.bad { border-left-color: var(--bad); }
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: var(--s3); opacity: .5; }
.log { font-size: 13.5px; }
.log .li { display: grid; grid-template-columns: 52px 1fr; gap: var(--s3); padding: 7px 0; border-bottom: 1px solid var(--line); }
.log .li:last-child { border-bottom: 0; }
.demo {
  background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 700; border: 1px solid rgba(184,117,20,.25);
}
.switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.switch button { border: 0; background: var(--surface); padding: 5px 12px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink-3); }
.switch button.on { background: var(--mint); color: #05231D; }
.vlist { display: flex; flex-direction: column; }
.vitem { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.vitem:last-child { border-bottom: 0; }
.wave { height: 26px; flex: 1; background:
  repeating-linear-gradient(90deg, var(--mint-line) 0 2px, transparent 2px 5px); opacity: .55; border-radius: 3px; }

/* --- Адаптив -------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage .arrow { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 70; width: var(--rail); transform: translateX(-100%);
    transition: transform .2s; }
  .rail.on { transform: none; box-shadow: var(--sh3); }
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .page { padding: var(--s4); }
  .topbar { padding: 0 var(--s4); }
  .cal { grid-template-columns: 1fr; }
  .cal .dow { display: none; }
  .cell { min-height: 0; }
  .cell.empty-day { display: none; }
  .pipeline { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
  h1 { font-size: 23px; }
  .cmd textarea { font-size: 16px; }
}
.burger { display: none; }
@media (max-width: 860px) { .burger { display: inline-flex; } }

/* --- Телефон: шапка не должна распирать страницу вширь ---------------------- */
@media (max-width: 860px) {
  /* Ни один блок не должен распирать страницу вширь: горизонтальная прокрутка
     разрешена только внутри таблиц, у которых для этого есть своя обёртка. */
  html, body { max-width: 100%; overflow-x: hidden; }
  .app, .main, .page { min-width: 0; max-width: 100%; }
  .topbar { gap: var(--s2); }
  .topbar #mode-switch { display: none; }          /* тот же переключатель есть в «Настройках» */
  .topbar .btn.pri { padding: 8px 12px; font-size: 13px; }
  .topbar .btn.ghost.sm { padding: 6px 8px; }
  h1.display, .display { font-size: 26px !important; }
  .cmd { padding: var(--s4); border-radius: var(--r4); }
  .kpi .v { font-size: 26px; }
  .drawer-body, .drawer-head { padding: var(--s4); }
  .tabs button { padding: 9px 10px; font-size: 13px; }
}


/* --- Иконки (Lucide): один стиль, наследуют цвет текста --------------------- */
.ic { flex: none; display: block; }
.badge .ic { opacity: .95; }
.empty .big { display: grid; place-items: center; color: var(--ink-4); }
.empty .big .ic { margin: 0 auto; }
.stage .arrow, .row > .muted > .ic { display: block; }
.btn .ic { margin: 0 -1px; }
.chip .ic { margin-right: 2px; }
.tile .thumb .ic { opacity: .5; }
.vitem .btn .ic { margin: 0; }

/* --- Крупные экраны: не сжимать содержимое в узкую колонку ------------------ */
@media (min-width: 1700px) {
  :root { --rail: 300px; --maxw: 1720px; }
  body { font-size: 16.5px; }
  .kpi .v { font-size: 40px; }
  h1 { font-size: 36px; }
  .cell { min-height: 150px; }
}
@media (min-width: 2100px) {
  :root { --maxw: 1920px; }
}
