:root {
    --dlk-bg: #f3f4f7;
    --dlk-surface: #ffffff;
    --dlk-sidebar: #171b2b;
    --dlk-sidebar-hover: #232840;
    --dlk-accent: #2f6bff;
    --dlk-text: #171b2b;
    --dlk-muted: #7a8296;
    --dlk-border: #e6e8ef;
    --dlk-radius: 14px;
    --dlk-shadow: 0 1px 2px rgba(23, 27, 43, .05),
                  0 8px 24px rgba(23, 27, 43, .05);
    --dlk-sidebar-w: 236px;
}

* { box-sizing: border-box; }

body.dlk {
    margin: 0;
    display: flex;
    min-height: 100vh;
    background: var(--dlk-bg);
    color: var(--dlk-text);
    font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Сайдбар ---------- */

.dlk-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--dlk-sidebar-w);
    padding: 22px 14px;
    background: var(--dlk-sidebar);
    color: #fff;
    overflow-y: auto;
}

.dlk-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 22px;
}

.dlk-brand__mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--dlk-accent);
    font-weight: 700;
    font-size: 17px;
}

.dlk-brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.dlk-brand__text b { font-size: 13px; letter-spacing: .06em; }
.dlk-brand__text i {
    font-style: normal;
    font-size: 10px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #8d95ad;
}

.dlk-nav { display: flex; flex-direction: column; gap: 2px; }

.dlk-nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    color: #c7ccda;
    font-size: 13.5px;
    text-decoration: none;
}

.dlk-nav__item svg { width: 18px; height: 18px; flex: none; fill: currentColor; }
.dlk-nav__item--muted { color: #8d95ad; cursor: default; }
.dlk-nav__item--parent { color: #fff; background: var(--dlk-sidebar-hover); }
.dlk-nav__chevron { margin-left: auto; fill: none; }

.dlk-nav__group { display: flex; flex-direction: column; gap: 2px; }

.dlk-nav__sub {
    padding: 8px 10px 8px 38px;
    border-radius: 9px;
    color: #8d95ad;
    font-size: 13px;
    text-decoration: none;
}

.dlk-nav__sub--muted { cursor: default; }
.dlk-nav__sub--active { background: var(--dlk-accent); color: #fff; font-weight: 500; }
a.dlk-nav__sub:not(.dlk-nav__sub--active):hover {
    background: var(--dlk-sidebar-hover);
    color: #fff;
}

/* ---------- Каркас ---------- */

.dlk-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--dlk-sidebar-w);
    display: flex;
    flex-direction: column;
}

.dlk-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: var(--dlk-surface);
    border-bottom: 1px solid var(--dlk-border);
}

.dlk-header__title { margin: 0; font-size: 21px; font-weight: 650; }
.dlk-header__side { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.dlk-bell {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--dlk-border);
    border-radius: 50%;
    background: #fff;
    color: var(--dlk-muted);
}

.dlk-user { display: flex; align-items: center; gap: 10px; }

.dlk-user__avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #dbe4ff;
    color: #2b4fb8;
    font-weight: 600;
    text-transform: uppercase;
}

.dlk-user__text { display: flex; flex-direction: column; line-height: 1.25; }
.dlk-user__text b { font-size: 13.5px; font-weight: 600; }
.dlk-user__text i { font-style: normal; font-size: 11.5px; color: var(--dlk-muted); }

.dlk-content { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 16px; }

.dlk-card {
    background: var(--dlk-surface);
    border: 1px solid var(--dlk-border);
    border-radius: var(--dlk-radius);
    box-shadow: var(--dlk-shadow);
}

.dlk-demo-note {
    padding: 9px 14px;
    border: 1px dashed #c9b784;
    border-radius: 10px;
    background: #fdf7e6;
    color: #7a6521;
    font-size: 12.5px;
}

/* ---------- Вкладки ---------- */

.dlk-tabs { display: flex; gap: 8px; }

.dlk-tab {
    padding: 8px 18px;
    border-radius: 9px;
    background: #e8eaf0;
    color: var(--dlk-muted);
    font-size: 13.5px;
    font-weight: 500;
}

.dlk-tab--active { background: var(--dlk-accent); color: #fff; }
.dlk-tab--disabled { opacity: .55; }

/* ---------- Фильтры ---------- */

.dlk-filters { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.dlk-collapsible > summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    padding: 8px 15px;
    border: 1px solid #cfd7ff;
    border-radius: 9px;
    background: #f4f7ff;
    color: #2b4fb8;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    list-style: none;
}
.dlk-collapsible > summary::-webkit-details-marker { display: none; }
.dlk-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--dlk-accent);
    color: #fff;
    font-size: 11px;
    line-height: 1;
}
.dlk-filters__form { display: flex; flex-direction: column; gap: 12px; }
.dlk-filters__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dlk-filters__spacer { flex: 1; }
.dlk-filters__row--chips { gap: 8px; }
.dlk-filters__hint { color: var(--dlk-muted); font-size: 12px; }
.dlk-filters__groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.dlk-filters__errors {
    margin: 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff2f2;
    color: #9b1c1c;
    font-size: 12.5px;
}

.dlk-field { display: flex; align-items: center; gap: 8px; }
.dlk-field__label { color: var(--dlk-muted); font-size: 12.5px; white-space: nowrap; }

.dlk-input {
    padding: 6px 10px;
    border: 1px solid var(--dlk-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--dlk-text);
}
.dlk-input--num { width: 110px; }

.dlk-filter-group {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--dlk-border);
    border-radius: 10px;
    background: #fafbfe;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dlk-filter-group legend {
    padding: 0 4px;
    color: var(--dlk-text);
    font-size: 12.5px;
    font-weight: 600;
}

.dlk-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--dlk-text);
}
.dlk-check input { accent-color: var(--dlk-accent); }

.dlk-chip-filter {
    padding: 6px 12px;
    border: 1px solid #d3ddff;
    border-radius: 999px;
    background: #f0f4ff;
    color: #2b4fb8;
    font-size: 12.5px;
    font-weight: 500;
}

.dlk-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: none;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.dlk-btn:disabled { cursor: default; opacity: .75; }
.dlk-btn__plus { font-size: 16px; line-height: 1; }
.dlk-btn__chevron { width: 14px; height: 14px; fill: none; }
.dlk-btn--ghost { border-color: #cfd7ff; background: #f4f7ff; color: #2b4fb8; }
.dlk-btn--quiet { border-color: var(--dlk-border); background: #fff; color: var(--dlk-text); }
.dlk-btn--primary { background: var(--dlk-accent); color: #fff; font-weight: 500; }

.dlk-presets { position: relative; }
.dlk-presets > summary { list-style: none; }
.dlk-presets > summary::-webkit-details-marker { display: none; }
.dlk-presets__menu {
    position: absolute;
    z-index: 5;
    min-width: 280px;
    margin-top: 6px;
    padding: 8px;
    border: 1px solid var(--dlk-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--dlk-shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dlk-presets__item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dlk-presets__item form { margin: 0 0 0 auto; }
.dlk-presets__delete { padding: 4px 8px; }

.dlk-constructor { display: flex; flex-direction: column; gap: 10px; }
.dlk-constructor__row {
    margin: 0;
    padding: 10px 12px;
    border: 1px dashed #cfd7ff;
    border-radius: 10px;
    background: #f7f9ff;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dlk-constructor__row legend {
    padding: 0 4px;
    color: var(--dlk-text);
    font-size: 12.5px;
    font-weight: 600;
}
.dlk-constructor__values {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dlk-preset-save {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dlk-messages {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dlk-messages__item {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}
.dlk-messages__item--success { background: #e9f8ee; color: #146c2e; }
.dlk-messages__item--error { background: #fff2f2; color: #9b1c1c; }

/* ---------- Карточки метрик ---------- */

.dlk-metrics-block { display: flex; flex-direction: column; gap: 8px; }

.dlk-metrics__caption { color: var(--dlk-muted); font-size: 12.5px; padding-left: 2px; }

.dlk-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 12px;
}

.dlk-metric { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.dlk-metric__title { color: var(--dlk-muted); font-size: 12.5px; }

/* margin-top прижимает значения к низу: заголовок в две строки не должен
   ронять цифру ниже соседних карточек. */
.dlk-metric__value {
    margin-top: auto;
    font-size: 21px;
    font-weight: 650;
    letter-spacing: -.01em;
}

/* ---------- Таблица ---------- */

.dlk-table-card { overflow: hidden; }
.dlk-table-scroll { overflow-x: auto; }

.dlk-table { width: 100%; border-collapse: collapse; white-space: nowrap; }

.dlk-table th {
    padding: 12px 14px;
    border-bottom: 1px solid var(--dlk-border);
    background: #fafbfd;
    color: var(--dlk-muted);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
}

.dlk-table td { padding: 13px 14px; border-bottom: 1px solid #f1f2f6; font-size: 13.5px; }
.dlk-table tbody tr:last-child td { border-bottom: none; }
.dlk-table tbody tr:hover { background: #fafbfd; }

.dlk-th--num, .dlk-td--num { text-align: right; }
.dlk-th--center { text-align: center; }
.dlk-th--sortable a { color: inherit; text-decoration: none; }
.dlk-th--sortable a:hover { color: var(--dlk-text); }
.dlk-th--sortable::after { content: " ⇅"; color: #c3c8d4; font-size: 11px; }
.dlk-th--asc::after { content: " ↑"; color: var(--dlk-accent); }
.dlk-th--desc::after { content: " ↓"; color: var(--dlk-accent); }
.dlk-td--muted { color: var(--dlk-muted); }
.dlk-td--negative { color: #c0392b; }

.dlk-link { color: var(--dlk-accent); text-decoration: none; }
.dlk-link:hover { text-decoration: underline; }

.dlk-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.dlk-chip--green { background: #e6f6ec; color: #1b7f4b; }
.dlk-chip--amber { background: #fdf1e0; color: #a76b13; }
.dlk-chip--red { background: #fdeceb; color: #c0392b; }

.dlk-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 5px;
    background: #eef0f5;
    color: var(--dlk-muted);
    font-size: 11px;
}

.dlk-warn {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    background: #fdf1e0;
    color: #a76b13;
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    vertical-align: text-bottom;
}

.dlk-tick { color: #1b7f4b; font-weight: 700; }

/* ---------- Подвал таблицы ---------- */

.dlk-tablefoot {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid var(--dlk-border);
    flex-wrap: wrap;
}

.dlk-tablefoot__left,
.dlk-tablefoot__right { display: flex; align-items: center; gap: 10px; }
.dlk-tablefoot__right { margin-left: auto; }
.dlk-tablefoot__left { color: var(--dlk-muted); font-size: 12.5px; }
.dlk-tablefoot__counter { color: var(--dlk-muted); font-size: 12.5px; }

.dlk-select {
    padding: 6px 10px;
    border: 1px solid var(--dlk-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--dlk-text);
}

.dlk-pager { display: flex; align-items: center; gap: 4px; }

a.dlk-pager__btn { text-decoration: none; }
a.dlk-pager__btn:hover { border-color: var(--dlk-accent); }

.dlk-pager__btn {
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--dlk-border);
    border-radius: 8px;
    background: #fff;
    color: var(--dlk-text);
    font-size: 13px;
}

.dlk-pager__btn--active {
    border-color: var(--dlk-accent);
    background: var(--dlk-accent);
    color: #fff;
}

.dlk-pager__btn--off { color: #c3c8d4; }
.dlk-pager__dots { padding: 0 2px; color: var(--dlk-muted); }

.dlk-todo-overdue { color: #c0392b; font-weight: 700; }

.dlk-kanban {
    display: grid;
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    gap: 12px;
    align-items: start;
}

.dlk-kanban__column { padding: 12px; }
.dlk-kanban__head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: baseline;
    margin-bottom: 10px;
}
.dlk-kanban__head i {
    color: var(--dlk-muted);
    font-style: normal;
    font-size: 12px;
}
.dlk-todo-card {
    padding: 8px 0;
    border-top: 1px solid #f1f2f6;
    font-size: 13px;
}
.dlk-todo-card__type { color: var(--dlk-muted); font-size: 12px; }
.dlk-todo-card__text { margin: 2px 0 4px; }
.dlk-todo-card__meta { color: var(--dlk-muted); font-size: 12px; }

.dlk-modal {
    width: min(640px, calc(100vw - 32px));
    max-width: 640px;
    padding: 20px 22px;
    border: none;
    border-radius: var(--dlk-radius);
    box-shadow: var(--dlk-shadow);
    color: var(--dlk-text);
}
.dlk-modal::backdrop {
    background: rgba(23, 27, 43, .45);
}
.dlk-modal__close {
    display: inline-flex;
    margin: 0 0 12px auto;
    padding: 4px 10px;
    border: 1px solid var(--dlk-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}
.dlk-todo-history { margin: 0; }
.dlk-todo-history__title {
    margin: 0 0 12px;
    font-size: 16px;
}
.dlk-todo-history ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dlk-todo-history__row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 2px 12px;
}
.dlk-todo-history__date {
    grid-row: 1 / span 3;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--dlk-muted);
}
.dlk-todo-history__source {
    color: var(--dlk-muted);
    font-size: 12px;
}

@media (max-width: 900px) {
    .dlk-sidebar { display: none; }
    .dlk-main { margin-left: 0; }
    .dlk-content { padding: 16px; }
    .dlk-kanban { grid-template-columns: 1fr; }
}
