/* «Дела по датам» — тема Битрикс24 Air: акцент #0075ff, текст #424956, линии #dfe0e3, фон #eef2f5. */
:root {
    --ink: #424956; --muted: #828b95; --line: #dfe0e3; --bg: #eef2f5; --card: #fff; --soft: #f6fafb;
    --accent: #0075ff; --accent-d: #0068e0; --accent-l: #e5f0ff; --ok: #1bce7b; --off: #c3c8cd; --warn: #e5464c; --amber: #f5a623;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.dd { max-width: 920px; margin: 0 auto; padding: 24px 20px 72px; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.dd-lead { color: var(--muted); margin: 0 0 18px; max-width: 700px; }
.dd-muted { color: var(--muted); }
.dd-warn { color: var(--warn); }
.dd-small { font-size: 12px; }
.dd-card { background: var(--card); border-radius: 12px; padding: 18px 20px; margin: 0 0 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.dd-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dd-gap { height: 10px; }

/* Состояние */
.dd-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.dd-status__head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.dd-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.is-on > .dd-dot, .dd-dot.is-on { background: var(--ok); }
.dd-settings { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); align-items: center; }
.dd-settings label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dd-settings select { width: auto; max-width: 240px; }

/* Список сценариев */
.dd-list__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dd-sc { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.dd-sc:first-of-type { border-top: 0; }
.dd-sc__name { font-weight: 600; margin-bottom: 2px; }
.dd-sc__text { color: var(--muted); }
.dd-sc.is-off .dd-sc__name, .dd-sc.is-off .dd-sc__text { opacity: .55; }
.dd-sc__btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dd-empty { text-align: center; padding: 26px 10px; color: var(--muted); }

/* Шаблоны */
.dd-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.dd-tpl { text-align: left; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; font: inherit; color: inherit; }
.dd-tpl:hover { border-color: var(--accent); background: var(--accent-l); }
.dd-tpl b { display: block; margin-bottom: 4px; }
.dd-tpl span { color: var(--muted); font-size: 12px; }

/* Переключатель */
.dd-switch { position: relative; width: 36px; height: 20px; flex: none; margin-top: 2px; }
.dd-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.dd-switch span { position: absolute; inset: 0; background: var(--off); border-radius: 10px; cursor: pointer; transition: .2s; }
.dd-switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.dd-switch input:checked + span { background: var(--ok); }
.dd-switch input:checked + span::after { transform: translateX(16px); }
.dd-switch input:disabled + span { cursor: default; opacity: .6; }

/* Конструктор */
.dd-step { display: flex; gap: 12px; }
.dd-step__num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-l); color: var(--accent); font-weight: 600; display: flex; align-items: center; justify-content: center; }
.dd-step__body { flex: 1; min-width: 0; }
.dd-field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; }
.dd-field > span { font-size: 12px; color: var(--muted); }
.dd-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dd-sentence select, .dd-sentence input { width: auto; }
select, input[type=text], input[type=number], input[type=time], textarea {
    width: 100%; max-width: 460px; height: 34px; padding: 0 10px; border: 1px solid #c6cdd3; border-radius: 6px;
    background: #fff; font: inherit; color: inherit;
}
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; max-width: 100%; }
input[type=number] { width: 80px; }
input[type=time] { width: 100px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,117,255,.15); }
.dd-name { font-size: 16px; font-weight: 600; max-width: 100%; height: 40px; }

.dd-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.dd-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dd-funnel { margin: 6px 0 10px; }
.dd-funnel__name { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dd-stage-done { color: var(--muted); }

.dd-cond { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.dd-cond select, .dd-cond input { max-width: 220px; }

.dd-radio { display: flex; flex-direction: column; gap: 8px; }
.dd-sub { margin: 10px 0 0 26px; padding: 12px 14px; background: var(--soft); border-radius: 10px; }

.dd-action { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.dd-action__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.dd-action__type { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.dd-ico { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; }
.dd-ico--todo { background: #0075ff; } .dd-ico--task { background: #9b59f6; } .dd-ico--stage { background: #1bce7b; } .dd-ico--notify { background: #f5a623; }
.dd-add { display: flex; flex-wrap: wrap; gap: 8px; }
.dd-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dd-chip { border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 1px 8px; font-size: 12px; cursor: pointer; color: var(--ink); font-family: inherit; }
.dd-chip:hover { border-color: var(--accent); color: var(--accent); }
.dd-users { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dd-user { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-l); color: var(--accent-d); border-radius: 12px; padding: 2px 4px 2px 10px; font-size: 13px; }
.dd-user button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }

details { margin-top: 6px; }
summary { cursor: pointer; color: var(--accent); font-size: 13px; }
details[open] summary { margin-bottom: 8px; }

/* Кнопки */
.dd-btn { height: 34px; padding: 0 16px; border: 0; border-radius: 17px; background: var(--accent); color: #fff; font: 600 13px/34px inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.dd-btn:hover { background: var(--accent-d); }
.dd-btn:disabled { opacity: .5; cursor: default; }
.dd-btn--ghost { background: #fff; color: var(--ink); border: 1px solid #c6cdd3; }
.dd-btn--ghost:hover { background: #f1f4f6; }
.dd-btn--sm { height: 28px; line-height: 28px; padding: 0 12px; font-size: 12px; border-radius: 14px; }
.dd-btn--link { background: none; color: var(--accent); padding: 0 6px; }
.dd-btn--link:hover { background: none; text-decoration: underline; }
.dd-btn--danger { color: var(--warn); }
.dd-bar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
          background: var(--card); border-radius: 12px; padding: 12px 20px; box-shadow: 0 -2px 10px rgba(0,0,0,.08); z-index: 5; }

/* Проверка и журнал */
.dd-plan { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.dd-plan th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dd-plan td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dd-plan tr.is-err td { color: var(--warn); }
.dd-problems { margin: 8px 0 0; padding-left: 18px; color: var(--warn); }

/* Окно */
.dd-modal { position: fixed; inset: 0; background: rgba(40,46,56,.45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 20; }
.dd-modal__box { background: #fff; border-radius: 12px; padding: 20px 22px; max-width: 620px; width: 100%; max-height: calc(100vh - 120px); overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.dd-modal__btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.dd-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s;
            background: #333; color: #fff; padding: 10px 16px; border-radius: 8px; max-width: 90vw; z-index: 30; }
.dd-toast.show { opacity: 1; transform: translate(-50%, 0); }
.dd-toast--err { background: var(--warn); }

@media (max-width: 640px) {
    .dd { padding: 16px 12px 72px; }
    .dd-sc { grid-template-columns: auto 1fr; }
    .dd-sc__btns { grid-column: 1 / -1; justify-content: flex-start; }
    .dd-sub { margin-left: 0; }
    .dd-plan { display: block; overflow-x: auto; }
}
