/* TaskImporter — оформление под Bitrix24 UI kit.
   Токены (цвета/шрифт) взяты из taskmanager (css/style.css, air.css). */

:root {
    --ti-font: 'Open Sans', 'OpenSans-Regular', system-ui, -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --ti-text: #333;
    --ti-text-secondary: #535c69;
    --ti-text-subtle: #828b95;
    --ti-heading: #3a4255;
    --ti-line: #dfe0e3;
    --ti-line-strong: #c6cdd3;
    --ti-bg: #eef2f4;
    --ti-card: #fff;
    --ti-link: #2066b0;
    --ti-primary: #2fc6f6;
    --ti-primary-hover: #11a9d9;
    --ti-success: #9dcf00;
    --ti-success-hover: #8dbb00;
    --ti-radius: 6px;
    --ti-radius-lg: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: var(--ti-font);
    font-size: 14px;
    line-height: 1.4;
    color: var(--ti-text);
    background: var(--ti-bg);
}

a { color: var(--ti-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace;
    font-size: 12px;
    background: #f1f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    color: #525c69;
}

/* Каркас */
.ti-app { margin: 0 auto; padding: 0 16px 40px; }

.ti-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--ti-line);
}
.ti-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 18px; font-weight: 600; color: var(--ti-heading);
}
.ti-brand-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--ti-primary); color: #fff; font-size: 12px; font-weight: 700;
}
.ti-nav { display: flex; gap: 6px; }
.ti-nav a {
    padding: 8px 16px; border-radius: var(--ti-radius);
    color: var(--ti-text-secondary); font-weight: 600;
}
.ti-nav a:hover { background: #e5f2f8; text-decoration: none; }
.ti-nav a.active { background: var(--ti-primary); color: #fff; }

.ti-content { min-height: 50vh; }
.ti-footer {
    margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--ti-line);
    color: var(--ti-text-subtle); font-size: 12px; text-align: center;
}

/* Типографика */
.ti-h1 { font-size: 24px; font-weight: 600; color: var(--ti-heading); margin: 6px 0 8px; }
.ti-subtitle { color: var(--ti-text-secondary); margin: 0 0 20px; max-width: 720px; }
.ti-list { margin: 8px 0 0; padding-left: 20px; }
.ti-list li { margin: 2px 0; }

/* Карточка */
.ti-card {
    background: var(--ti-card);
    border: 1px solid var(--ti-line);
    border-radius: var(--ti-radius-lg);
    padding: 24px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

/* Форма */
.ti-form { display: flex; flex-direction: column; gap: 18px; }
.ti-row { display: flex; gap: 18px; flex-wrap: wrap; }
.ti-row > .ti-field { flex: 1 1 260px; }
.ti-field { display: flex; flex-direction: column; gap: 6px; }
.ti-field-narrow { max-width: 260px; }
.ti-label { font-size: 13px; font-weight: 600; color: var(--ti-text-secondary); }
.ti-label .req { color: #f0371b; }
.ti-hint { font-size: 12px; color: var(--ti-text-subtle); }
.ti-hint .ti-ok { color: #4caf3f; font-weight: 600; }
.ti-hint .ti-warn { color: #f0762d; font-weight: 600; }

.ui-ctl-element {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    font-family: var(--ti-font);
    font-size: 14px;
    color: var(--ti-text-secondary);
    background: #fff;
    border: 1px solid var(--ti-line-strong);
    border-radius: var(--ti-radius);
    outline: 0;
    transition: border-color .15s ease;
}
.ui-ctl-element:focus { border-color: var(--ti-primary); }
select.ui-ctl-element { cursor: pointer; }
.ti-multiselect { min-height: 140px; padding: 4px; }
.ti-textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input[type="file"].ui-ctl-element { padding: 7px 8px; cursor: pointer; }

/* Кнопки */
.ti-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ui-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 38px; padding: 0 20px;
    font-family: var(--ti-font); font-size: 14px; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--ti-radius);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease;
}
.ui-btn:hover { text-decoration: none; }
.ui-btn:disabled { opacity: .5; cursor: not-allowed; }
.ui-btn-success { background: var(--ti-success); color: #fff; }
.ui-btn-success:hover:not(:disabled) { background: var(--ti-success-hover); }
.ui-btn-primary { background: var(--ti-primary); color: #fff; }
.ui-btn-primary:hover:not(:disabled) { background: var(--ti-primary-hover); }
.ui-btn-light { background: #fff; color: var(--ti-text-secondary); border-color: var(--ti-line-strong); }
.ui-btn-light:hover:not(:disabled) { background: #f1f4f6; }

/* Спиннер */
.ti-spinner {
    width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid #d5d7db; border-top-color: var(--ti-primary);
    animation: ti-spin .8s linear infinite; display: inline-block;
}
@keyframes ti-spin { to { transform: rotate(360deg); } }

/* Уведомления */
.ui-alert {
    padding: 12px 16px; border-radius: var(--ti-radius);
    margin-bottom: 18px; font-size: 14px; border: 1px solid transparent;
}
.ui-alert code { background: rgba(0,0,0,.05); }
.ui-alert-warning { background: #fff1d6; color: #7a5100; border-color: #ffe1a6; }
.ui-alert-danger  { background: #ffe8e8; color: #9a0703; border-color: #ffcdcc; }
.ui-alert-success { background: #f1fbd0; color: #506900; border-color: #e2f1b3; }
.ui-alert-info    { background: #e5f9ff; color: #00789e; border-color: #c3f0ff; }

/* Результат / таблица предпросмотра */
.ti-result { margin-top: 22px; }
.ti-table-wrap { overflow-x: auto; border: 1px solid var(--ti-line); border-radius: var(--ti-radius-lg); }
.ti-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.ti-table th, .ti-table td {
    padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef2f4;
    color: var(--ti-text-secondary); vertical-align: top;
}
.ti-table th { background: #f5f7f8; font-weight: 600; color: var(--ti-text-secondary); white-space: nowrap; }
.ti-table tr:last-child td { border-bottom: 0; }
.ti-table tr.row-error td { background: #fff6f6; }
.ti-table tr.row-ok td { background: #fbfef2; }

.ti-tag {
    display: inline-block; padding: 2px 8px; margin: 1px 3px 1px 0;
    background: #eef2f4; border-radius: 12px; font-size: 12px; color: #525c69; white-space: nowrap;
}
.ti-cell-err { color: #c21b16; font-size: 12px; }
.ti-cell-ok { color: #688800; font-weight: 600; }
.ti-summary { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--ti-heading); }

/* Экран проверки доступа */
.ti-gate { display: flex; justify-content: center; padding: 80px 16px; }
.ti-gate-card {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    background: var(--ti-card); border: 1px solid var(--ti-line); border-radius: var(--ti-radius-lg);
    padding: 40px 48px; color: var(--ti-text-secondary); text-align: center;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,.06); max-width: 560px;
}
.ti-denied-title { font-size: 20px; font-weight: 600; color: var(--ti-heading); }

/* Заголовки шагов */
.ti-step-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--ti-heading); margin-bottom: 16px; }
.ti-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; background: var(--ti-primary); color: #fff; font-size: 13px; font-weight: 700;
}

.ti-step2-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.ti-check-all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ti-text-secondary); white-space: nowrap; cursor: pointer; }
.ti-step2-actions { margin-top: 16px; }
.ti-selected-count { color: var(--ti-text-subtle); font-size: 13px; }

/* Редактируемая таблица */
.ti-edit-table { table-layout: auto; }
.ti-edit-table th, .ti-edit-table td { vertical-align: middle; padding: 6px 8px; }
.ti-edit-table .c-inc { width: 34px; text-align: center; }
.ti-edit-table .c-num { width: 34px; color: var(--ti-text-subtle); }
.ti-edit-table .c-pri { width: 96px; }
.ti-edit-table .c-resp { width: 210px; }
.ti-edit-table .c-tags { width: 200px; }
.ti-edit-table .c-status { width: 200px; }
.ti-edit-table .c-exp { width: 34px; text-align: center; }
.ti-edit-table .ui-ctl-element { min-height: 32px; padding: 5px 8px; font-size: 13px; }
.ti-cell-select { min-width: 180px; }
.ti-inc { width: 17px; height: 17px; cursor: pointer; }

.ti-erow.row-error td { background: #fff6f6; }
.ti-erow.row-dup td { background: #fffaf0; }
.ti-erow.row-done td { background: #fbfef2; }
.ti-erow-desc > td { background: #f8fafb; padding: 12px 14px; }
.ti-erow-desc .ti-desc { width: 100%; margin-top: 6px; font-size: 13px; line-height: 1.5; }
.ti-erow-desc .ti-hint { margin-top: 6px; }
.ti-erow-extra { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; align-items: flex-start; }
.ti-erow-field { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; }
.ti-row-watchers { min-height: 116px; padding: 4px; }
.ti-row-group { max-width: 380px; }

.ti-expand-btn { border: 1px solid var(--ti-line-strong); background: #fff; color: var(--ti-text-secondary); border-radius: var(--ti-radius); width: 28px; height: 28px; cursor: pointer; line-height: 1; }
.ti-expand-btn:hover { background: #f1f4f6; }

/* Бейджи статуса строки */
.ti-rowstatus { line-height: 1.7; }
.ti-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.ti-badge-ok  { background: #f1fbd0; color: #506900; }
.ti-badge-dup { background: #fff1d6; color: #7a5100; }
.ti-badge-err { background: #ffe8e8; color: #9a0703; white-space: normal; }
.ti-badge a { color: inherit; text-decoration: underline; }

/* Поисковый выпадающий список */
.ti-ss { position: relative; }
.ti-ss > select { display: none !important; }
.ti-ss-box { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; cursor: text; padding: 4px 8px; min-height: 38px; }
.ti-ss-box.open { border-color: var(--ti-primary); }
.ti-ss-chip { font-size: 13px; color: var(--ti-text-secondary); overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ti-ss-chip.ti-ss-empty { color: var(--ti-text-subtle); }
.ti-ss-input { flex: 1 1 70px; min-width: 70px; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ti-text-secondary); padding: 2px 0; }
.ti-ss-list {
    position: fixed; z-index: 1000; background: #fff;
    border: 1px solid var(--ti-line-strong); border-radius: var(--ti-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); max-height: 260px; overflow-y: auto;
}
.ti-ss-item { padding: 7px 10px; font-size: 13px; color: var(--ti-text-secondary); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-ss-item:hover { background: #e5f2f8; }
.ti-ss-item.sel { background: #eef7fb; font-weight: 600; }
.ti-ss-item.sel::before { content: '✓ '; color: var(--ti-primary); }
.ti-ss-none { padding: 8px 10px; color: var(--ti-text-subtle); font-size: 12px; }

@media (max-width: 600px) {
    .ti-row { flex-direction: column; }
    .ti-field-narrow { max-width: none; }
}
