* { box-sizing: border-box; }
body { font-family: Arial, sans-serif; margin: 0; background: #f4f4f4; color: #222; }
.top { display:flex; justify-content:space-between; padding:10px 20px; background:#2c3e50; color:#fff; }
.top a { color:#fff; margin-left:15px; text-decoration:none; }
.container { max-width: 1200px; margin: 20px auto; background:#fff; padding:20px; border-radius:6px; }
.box { max-width:360px; margin:80px auto; background:#fff; padding:30px; border-radius:6px; }
h1 { margin-top:0; }
label { display:block; margin-top:6px; font-weight:bold; }
input, select, textarea { padding:6px; margin-top:4px; border:1px solid #ccc; border-radius:4px; }
textarea { width:100%; }
.inline-form { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
button { margin-top:8px; padding:8px 16px; background:#2980b9; color:#fff; border:none; border-radius:4px; cursor:pointer; }
button.danger { background:#c0392b; }
button.small { padding:2px 8px; margin:0; }
.button { display:inline-block; padding:8px 16px; background:#2980b9; color:#fff; text-decoration:none; border-radius:4px; }
table { width:100%; border-collapse:collapse; margin-top:10px; }
th, td { border:1px solid #ddd; padding:6px; text-align:left; vertical-align:top; }
th { background:#ecf0f1; }
.error { background:#fdecea; color:#c0392b; padding:10px; border-radius:4px; margin:10px 0; }

/* Настройки над бланком */
.settings-row { display:flex; gap:20px; flex-wrap:wrap; margin-bottom:15px; padding:10px; background:#f0f3f5; border-radius:6px; }

/* Бланк */
.blank { border:2px solid #333; padding:20px; margin-top:10px; }
.blank-header { display:flex; justify-content:space-between; align-items:flex-start; border-bottom:1px solid #999; padding-bottom:10px; margin-bottom:10px; }
.blank-logo { width:160px; height:90px; border:1px dashed #aaa; display:flex; align-items:center; justify-content:center; text-align:center; }
.blank-logo img { max-width:100%; max-height:90px; }
.logo-stub { color:#999; font-size:12px; }
.blank-from { flex:1; padding-left:20px; }
.section-title { font-weight:bold; margin:15px 0 5px; background:#eef2f4; padding:5px; }
.kv { width:auto; }
.kv td { border:none; padding:2px 8px; }
.kv-key { font-weight:bold; white-space:nowrap; }
.hint { color:#888; font-size:11px; font-style:italic; }
.inline-input { width:160px; }
.wide-input { width:100%; }
.works th { background:#dfe6e9; font-size:13px; text-align:center; }
.works td { font-size:13px; }
.row-num { text-align:center; }
.js-sum { text-align:right; white-space:nowrap; }
.total-label { text-align:right; font-weight:bold; }
.total-value { text-align:right; font-weight:bold; }
.info-box { border:1px solid #ccc; min-height:40px; padding:8px; }
.sign td { border:none; padding:8px; }
.sign-name { font-weight:bold; }
/* Заголовок бланка «Смета» / «КП» */
.blank-title {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    padding: 10px 0 8px;
    letter-spacing: 2px;
    border-bottom: 2px solid #333;
    margin-bottom: 10px;
}
/* Поиск позиций из базы */
.pick-wrap {
    position: relative;
    width: 100%;
}
.pick-input {
    width: 100%;
    padding: 6px;
    box-sizing: border-box;
}
.pick-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #2980b9;
    border-top: none;
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 4px 10px rgba(0,0,0,.15);
    display: none;
}
.pick-dropdown.open { display: block; }
.pick-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}
.pick-item:hover, .pick-item.active { background: #eaf3fb; }
.pick-item .pi-type { color: #888; font-size: 11px; }
.pick-item .pi-price { float: right; color: #27ae60; }
.works td { vertical-align: middle; }

/* ============================================================
   БЫСТРЫЙ ПОИСК — ПАНЕЛЬ
   ============================================================ */
.pick-wrap { position: relative; width: 100%; min-width: 150px; }
.pick-input {
    width: 100%; padding: 6px 8px 6px 26px; box-sizing: border-box;
    border: 1px solid #bdc3c7; border-radius: 4px; font-size: 13px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 6px center;
}
.pick-input:focus { outline: none; border-color: #2980b9; }
.pick-dropdown {
    position: fixed; background: #fff; border: 1px solid #2980b9;
    border-radius: 6px; max-height: 360px; overflow-y: auto;
    z-index: 9999; box-shadow: 0 8px 28px rgba(0,0,0,.22);
    display: none; width: 360px;
}
.pick-dropdown.open { display: block; }
.pick-header { padding: 6px 12px; font-size: 11px; color: #888; background: #f8f9fa; border-bottom: 1px solid #eee; position: sticky; top: 0; }
.pick-group { padding: 5px 12px 3px; font-size: 11px; font-weight: bold; text-transform: uppercase; color: #fff; }
.pick-group.group-service { background: #2980b9; }
.pick-group.group-material { background: #27ae60; }
.pick-item { display: flex; align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; gap: 10px; }
.pick-item:hover, .pick-item.active { background: #eaf4fb; }
.pick-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.pick-icon.icon-service { background: #d6eaf8; }
.pick-icon.icon-material { background: #d5f5e3; }
.pick-body { flex: 1; min-width: 0; }
.pick-name { font-size: 13px; font-weight: 600; color: #2c3e50; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-name mark { background: #fff3cd; border-radius: 2px; }
.pick-meta { font-size: 11px; color: #95a5a6; margin-top: 1px; }
.pick-price { text-align: right; flex-shrink: 0; }
.pick-price-val { font-size: 13px; font-weight: bold; color: #27ae60; white-space: nowrap; }
.pick-price-unit { font-size: 10px; color: #aaa; }
.pick-empty { padding: 20px; text-align: center; color: #aaa; font-size: 13px; }
.pick-footer { padding: 5px 12px; font-size: 10px; color: #bbb; background: #f8f9fa; border-top: 1px solid #eee; text-align: center; }

/* ============================================================
   КОМПАКТНАЯ ТАБЛИЦА МАТЕРИАЛОВ
   ============================================================ */
.items-table th,
.items-table td { padding: 3px 6px; font-size: 13px; vertical-align: middle; }
.items-table .cell-input {
    width: 100%; padding: 3px 6px; margin: 0;
    border: 1px solid transparent; border-radius: 3px;
    font-size: 13px; background: transparent;
}
.items-table .cell-input:disabled { color: #2c3e50; cursor: default; }
.items-table tr.editing { background: #fffbe6; }
.items-table tr.editing .cell-input { border-color: #2980b9; background: #fff; }
.items-table select { padding: 2px 4px; font-size: 13px; margin: 0; }
.items-table select:disabled { color: #2c3e50; background: transparent; border-color: transparent; }


/* ============================================================
   КНОПКИ-ИКОНКИ
   ============================================================ */
.btn-icon {
    display: inline-block;
    width: 32px;
    height: 30px;
    padding: 0;
    margin: 1px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    line-height: 30px;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    transition: transform .1s, filter .15s;
}
.btn-icon:hover { transform: scale(1.15); filter: brightness(1.05); }
.btn-icon:active { transform: scale(0.92); }
.btn-edit  { background: #fcf3cf; }
.btn-save  { background: #d5f5e3; }
.btn-del   { background: #fadbd8; }
.btn-word  { background: #d6eaf8; }
.btn-excel { background: #d5f5e3; }
.actions-cell { white-space: nowrap; }

/* ============================================================
   ВСПЛЫВАЮЩАЯ ПОДСКАЗКА (полный текст позиции) — СЛЕВА
   ============================================================ 
.pick-tooltip {
    position: fixed;
    left: 16px;
    background: #2c3e50;
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 320px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    z-index: 10000;
    display: none;
    pointer-events: none;
}
.pick-tooltip.show { display: block; }
.pick-tooltip .tt-name { font-weight: bold; font-size: 14px; margin-bottom: 6px; }
.pick-tooltip .tt-row { color: #bdc3c7; font-size: 12px; }
.pick-tooltip .tt-price { color: #2ecc71; font-weight: bold; font-size: 15px; margin-top: 6px; }
*/
/* ============================================================
   ВСПЛЫВАЮЩЕЕ ОКНО (ТУЛТИП) — полный текст позиции, слева
   ============================================================ */
.pick-tooltip {
    position: fixed;
    left: 16px;
    background: #2c3e50;
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 320px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    z-index: 10000;
    display: none;
    pointer-events: none;
}
.pick-tooltip.show { display: block; }
.pick-tooltip .tt-name { font-weight: bold; font-size: 14px; margin-bottom: 6px; }
.pick-tooltip .tt-row { color: #bdc3c7; font-size: 12px; }
.pick-tooltip .tt-price { color: #2ecc71; font-weight: bold; font-size: 15px; margin-top: 6px; }

/* ============================================================
   КНОПКА "ДОБАВИТЬ СТРОКУ" — справа, под колонкой быстрого поиска
   ============================================================ */
.add-row-wrap {
    display: flex;
    justify-content: flex-end;
    padding-right: 52px; /* под колонку поиска, левее колонки удаления */
    margin: 8px 0 16px;
}
.btn-add-row {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s, transform .1s;
}
.btn-add-row:hover { background: #229954; transform: translateY(-1px); }
.btn-add-row:active { transform: translateY(0); }
