* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #1c2430; background: #f4f6f9; font-size: 14px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; }
.muted { color: #8a97a6; font-weight: normal; }

/* --- Логин --- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 36px 32px; border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.08); width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-box .brand { font-size: 20px; font-weight: 700; color: #1f4e79; text-align: center; margin-bottom: 8px; }
.login-box input { padding: 11px 13px; border: 1px solid #d5dbe2; border-radius: 8px; font-size: 14px; }
.login-box input:focus { outline: none; border-color: #1f4e79; }
.login-box button { padding: 11px; background: #1f4e79; color: #fff; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 15px; }
.login-box button:hover { background: #163a5c; }
.login-err { color: #d64545; font-size: 13px; text-align: center; min-height: 16px; }

/* --- Приложение --- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #1f2937; color: #cbd5e1; display: flex; flex-direction: column; padding: 18px 0; }
.brand-mark { font-weight: 700; color: #fff; padding: 0 20px 18px; font-size: 16px; }
.proj-select { padding: 4px 16px 14px; }
.proj-select label { display: block; font-size: 11px; color: #8a97a6; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.proj-select select { width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid #3a4655; background: #2b3646; color: #fff; font-size: 14px; }
.sidebar nav { display: flex; flex-direction: column; }
.form { display: flex; flex-direction: column; gap: 10px; max-width: 460px; background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.form input { padding: 9px 12px; border: 1px solid #d5dbe2; border-radius: 7px; font-size: 14px; }
.form button { padding: 9px; background: #1f4e79; color: #fff; border: none; border-radius: 7px; font-weight: 600; cursor: pointer; }
.form button:hover { background: #163a5c; }
.content h3 { font-size: 15px; }
.nav-item { padding: 11px 20px; cursor: pointer; color: #cbd5e1; text-decoration: none; font-size: 14px; }
.nav-item:hover { background: #2b3646; }
.nav-item.active { background: #2b3646; color: #fff; border-left: 3px solid #4f9cff; }
.sidebar-foot { margin-top: auto; padding: 14px 20px; font-size: 12px; color: #8a97a6; display: flex; justify-content: space-between; }
.sidebar-foot a { color: #6ea8ff; cursor: pointer; text-decoration: none; }

.content { flex: 1; padding: 26px 30px; overflow-x: auto; }
.content h2 { font-size: 19px; margin-bottom: 14px; }
.flt { width: 320px; padding: 8px 12px; border: 1px solid #d5dbe2; border-radius: 7px; margin-bottom: 14px; }

.tbl-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
table { width: 100%; border-collapse: collapse; }
th { background: #1f4e79; color: #fff; padding: 9px 11px; text-align: left; font-size: 12px; position: sticky; top: 0; }
td { padding: 8px 11px; border-bottom: 1px solid #eef1f4; }
tbody tr:hover { background: #f7fafd; }
.cr-good { color: #1a9955; font-weight: 700; }
.cr-mid { color: #b8860b; }
.cr-bad { color: #d64545; font-weight: 700; }
.acts button, td button { padding: 4px 10px; margin-right: 4px; border: 1px solid #cfd6de; background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; }
.acts button:hover, td button:hover { border-color: #1f4e79; color: #1f4e79; }
.alert { background: #fff4f4; border: 1px solid #f3c7c7; color: #a33; padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; }

/* панель правил полуавтомата */
.rules-box { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; background: #fff; padding: 16px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); margin-bottom: 16px; }
.rule-f { display: flex; flex-direction: column; gap: 4px; }
.rule-f label { font-size: 12px; color: #55606d; }
.rule-f input { width: 130px; padding: 8px 10px; border: 1px solid #d5dbe2; border-radius: 7px; font-size: 14px; }
.rules-box button { padding: 9px 14px; border: 1px solid #cfd6de; background: #fff; border-radius: 7px; cursor: pointer; font-size: 13px; }
.rules-box button:hover { border-color: #1f4e79; color: #1f4e79; }
.rules-box .save-r { border-color: #1a9955; color: #1a9955; font-weight: 600; }
.apply-btn { padding: 11px 18px; background: #b23b3b; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.apply-btn:hover { background: #922f2f; }

/* Пульт */
.pult-cfg { background: #fff; padding: 18px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); margin-bottom: 6px; }
.pult-row { display: flex; flex-direction: column; gap: 4px; }
.pult-row label { font-size: 12px; color: #55606d; }
.pult-row input, .pult-row select { padding: 8px 10px; border: 1px solid #d5dbe2; border-radius: 7px; font-size: 14px; }
.pult-targets { margin: 14px 0; }
.pult-targets > label { font-size: 12px; color: #55606d; display: block; margin-bottom: 6px; }
.wd-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wd span { font-size: 12px; color: #55606d; }
.wd input { width: 60px; padding: 7px 6px; border: 1px solid #d5dbe2; border-radius: 7px; text-align: center; font-size: 14px; }
.pult-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.plan-summary { background: #eef4fb; border: 1px solid #cfe0f2; border-radius: 9px; padding: 12px 15px; margin-bottom: 10px; font-size: 14px; line-height: 1.6; color: #1f2937; }

/* --- Грид рекламного кабинета --- */
.grid-head { margin-bottom: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.toolbar .flt { width: 300px; margin: 0; }
.toolbar select { padding: 8px 10px; border: 1px solid #d5dbe2; border-radius: 7px; background: #fff; font-size: 13px; }
.toolbar .chk { font-size: 13px; color: #55606d; display: flex; align-items: center; gap: 5px; cursor: pointer; }
/* панель массовых действий */
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 9px 12px; background: #eef2f6; border-radius: 8px; }
.bulkbar .sel-count { font-size: 13px; font-weight: 600; color: #1f4e79; margin-right: 4px; }
.bulkbar .sep { font-size: 12px; color: #55606d; margin-left: 10px; }
.bulkbar button { padding: 7px 12px; border: 1px solid #cfd6de; background: #fff; border-radius: 7px; cursor: pointer; font-size: 13px; }
.bulkbar button:hover { border-color: #1f4e79; color: #1f4e79; }
.bulkbar .b-on { border-color: #1a9955; color: #1a9955; }
.bulkbar .b-off { border-color: #b23b3b; color: #b23b3b; }
.bulkbar .bulk-lim { width: 80px; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; font-size: 13px; }
.bulkbar .bulk-scope { padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; font-size: 13px; background: #fff; }
.bulkbar .bulk-tag { width: 130px; padding: 7px 9px; border: 1px solid #cfd6de; border-radius: 7px; font-size: 13px; }
.bulkbar .export { margin-left: auto; border-color: #1a9955; color: #1a9955; font-weight: 600; }
/* период / календарь */
.period { margin-top: 8px; font-size: 14px; color: #1f4e79; font-weight: 600; }
.price-tag { color: #1a9955; font-weight: 700; }
/* плашка-сводка по квалам */
.kval-summary { margin-top: 8px; padding: 9px 13px; background: #eef4fb; border: 1px solid #cfe0f2; border-radius: 8px; font-size: 14px; color: #1f2937; }
.kval-summary .ext-hl { color: #b45309; }
.kval-summary .muted { margin-left: 6px; font-size: 12px; }
/* блок источников вне ГЦК */
.ext-block { margin-top: 22px; }
.ext-block h3 { font-size: 15px; margin-bottom: 8px; color: #b45309; }
.ext-block table th { background: #7c5417; }
.datebox { font-size: 13px; color: #55606d; display: flex; align-items: center; gap: 4px; }
.datebox input[type=date] { padding: 7px 8px; border: 1px solid #d5dbe2; border-radius: 7px; font-size: 13px; }
.presets button { padding: 7px 9px; border: 1px solid #cfd6de; background: #fff; border-radius: 7px; cursor: pointer; font-size: 12px; margin-right: 3px; }
.presets button:hover { border-color: #1f4e79; color: #1f4e79; }
/* дельта к прошлому периоду */
.dlt { font-size: 11px; font-weight: 600; line-height: 1.1; margin-top: 1px; }
.d-up { color: #1a9955; }
.d-down { color: #d64545; }
.d-zero { color: #a0aab6; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; position: relative; }
th.sortable:hover { background: #163a5c; }
/* грид с фиксированной раскладкой — ширины столбцов слушаются точно */
#grid { table-layout: fixed; }
#grid th, #grid td { overflow: hidden; text-overflow: ellipsis; }
/* ручка изменения ширины у правого края заголовка */
.col-resizer { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; }
.col-resizer:hover { background: rgba(255,255,255,.35); }
.chkcol { width: 34px; text-align: center; }
.fltrow td { background: #eef2f6; padding: 4px 5px; position: sticky; top: 30px; }
.fltrow .mm { display: flex; gap: 2px; }
.fltrow .mm input { width: 50%; min-width: 0; padding: 3px 3px; border: 1px solid #cfd6de; border-radius: 5px; font-size: 11px; }
.totals td { background: #eaf1f8; font-weight: 700; border-top: 2px solid #1f4e79; position: sticky; bottom: 0; }
.p-pos { color: #1a9955; font-weight: 700; }
.p-neg { color: #d64545; font-weight: 700; }
/* тренд очереди обзвона */
/* внешние изменения ГЦК в логах */
.log-ext { background: #fff8ef; border-left: 3px solid #e08a1e; }
/* пагинатор */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; }
.pager button { padding: 7px 12px; border: 1px solid #cfd6de; background: #fff; border-radius: 7px; cursor: pointer; font-size: 13px; }
.pager button:hover:not(:disabled) { border-color: #1f4e79; color: #1f4e79; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager span { color: #55606d; margin: 0 4px; }
.trend-up { color: #d64545; font-weight: 700; }
.trend-ok { color: #1a9955; font-weight: 700; }
#qtbl { table-layout: fixed; }
#qtbl td { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#qtbl th { white-space: nowrap; position: relative; overflow: hidden; }
#qtbl .q-hl { color: #b45309; }
#grid td { white-space: nowrap; }
