:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #e3e6ea;
    --text: #1f2430;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #0e7490;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Шапка ── */
.topbar {
    background: #111827;
    color: #fff;
    padding: 0 20px;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.topbar .brand { font-weight: 700; font-size: 17px; color: #fff; }
.topbar .brand span { color: #60a5fa; }
.topbar nav a { color: #d1d5db; margin-right: 18px; font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; text-decoration: none; }

.container { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
/* Лента тендеров — шире, чтобы все колонки (в т.ч. «Приём до») помещались. */
.container.wide { max-width: 1800px; }

h1 { font-size: 22px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 18px; }

/* ── Карточки ── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 18px;
}

/* ── Форма фильтров ── */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 14px;
}
.filter-grid .full { grid-column: 1 / -1; }
.filter-grid .span2 { grid-column: span 2; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field input, .field select {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
.range { display: flex; gap: 6px; align-items: center; }
.filter-actions { display: flex; gap: 10px; margin-top: 14px; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ── Таблица ── */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.toolbar .count { color: var(--muted); }
.toolbar-actions { display: inline-flex; gap: 10px; align-items: center; }
.toolbar-actions .btn { padding: 6px 12px; }

/* Фильтр методов: поле с «чипами» + автодополнение */
.ms { position: relative; }
.ms-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px;
    padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: text; }
.ms-chip { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; color: #3730a3;
    border-radius: 6px; padding: 2px 6px; font-size: 13px; }
.ms-chip button { border: 0; background: transparent; cursor: pointer; color: #6366f1;
    font-size: 14px; line-height: 1; padding: 0; }
.ms-input { flex: 1; min-width: 160px; border: 0; outline: none; padding: 4px; font: inherit; background: transparent; }
.ms-drop { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff;
    border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; max-height: 260px;
    overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.ms-item { padding: 8px 10px; cursor: pointer; }
.ms-item:hover { background: #f1f5f9; }

table.grid { width: 100%; border-collapse: collapse; background: var(--card); }
table.grid th, table.grid td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
/* Длинные названия/заказчики не должны раздувать таблицу — ограничиваем и переносим. */
table.grid td { overflow-wrap: anywhere; }
.cust-cell { max-width: 240px; }
table.grid th {
    background: #f9fafb;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    white-space: nowrap;
}
table.grid th a { color: var(--muted); }
table.grid tbody tr:hover { background: #f8fafc; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.title-cell { max-width: 300px; }
.title-cell .ext { color: var(--muted); font-size: 12px; }
/* Номер объявления не переносится, а длинное имя площадки под ним — переносится,
   иначе оно растягивает первую колонку и выталкивает «Приём до» за пределы экрана. */
.src-cell { max-width: 160px; }
.src-name { display: block; font-size: 12px; white-space: normal; overflow-wrap: anywhere; margin-top: 2px; }

/* ── Бейджи ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}
.cat-goods { background: #e0f2fe; color: #075985; }
.cat-work { background: #fef3c7; color: #92400e; }
.cat-service { background: #dcfce7; color: #166534; }
.cat-unknown { background: #f1f5f9; color: #475569; }

.status { background: #eef2ff; color: #3730a3; }
.st-RUNNING { background: #fef9c3; color: #854d0e; }
.st-SUCCESS { background: #dcfce7; color: #166534; }
.st-FAILED { background: #fee2e2; color: #991b1b; }

/* ── Пагинация ── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: #cbd5e1; }
/* переход на произвольную страницу */
.pagination .page-jump { display: inline-flex; gap: 6px; align-items: center; padding: 0; border: 0; background: transparent; margin-left: 8px; }
.pagination .page-jump input { width: 72px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; }
.pagination .page-jump button { padding: 6px 11px; border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer; }

/* ── Детали ── */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin-top: 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.section-title { font-size: 16px; margin: 22px 0 10px; }
.lot { border-left: 3px solid var(--primary); }
.empty { color: var(--muted); padding: 30px; text-align: center; }
.flash-error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash-info { background: #e0f2fe; color: #075985; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.back-link { display: inline-block; margin-bottom: 12px; }

/* Документы лота на странице деталей */
.lot-docs { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.doc-list { margin: 6px 0 0; padding-left: 18px; }
.doc-list li { margin: 2px 0; }

/* ── Пользователь в шапке ── */
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-name { color: #d1d5db; font-weight: 500; }
.logout-form { margin: 0; }
.link-btn {
    background: transparent; border: 0; color: #d1d5db; cursor: pointer;
    font: inherit; font-weight: 500; padding: 0;
}
.link-btn:hover { color: #fff; text-decoration: underline; }
/* Ненавязчивая ссылка в шапке (напр. «Обратная связь») — приглушённее имени/меню. */
.topbar-link { color: #9ca3af; font-size: 13px; font-weight: 500; }
.topbar-link:hover { color: #fff; text-decoration: none; }

/* ── Уведомления: колокольчик + бейдж + модалка ── */
.notif-bell {
    position: relative; background: transparent; border: 0; padding: 2px; cursor: pointer;
    color: #d1d5db; display: inline-flex; align-items: center; line-height: 0;
}
.notif-bell:hover { color: #fff; }
.notif-badge {
    position: absolute; top: -5px; right: -6px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff;
    font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; box-sizing: border-box;
}
.notif-overlay {
    position: fixed; inset: 0; background: rgba(17, 24, 39, .55); z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px;
}
.notif-overlay[hidden] { display: none; }
.notif-modal {
    background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.28);
    width: 100%; max-width: 540px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
    color: var(--text);
}
.notif-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 16px;
}
.notif-close {
    background: transparent; border: 0; font-size: 22px; line-height: 1; color: var(--muted);
    cursor: pointer; padding: 0 4px;
}
.notif-close:hover { color: var(--text); }
.notif-list { overflow-y: auto; padding: 6px 0; }
.notif-item { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.notif-unread { background: #eff6ff; }
.notif-item-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.notif-item-title { font-weight: 600; }
.notif-item-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.notif-item-content { margin-top: 4px; white-space: pre-wrap; color: var(--text); font-size: 14px; }
.notif-empty { padding: 22px 18px; text-align: center; color: var(--muted); }

/* ── Страница «Обратная связь» ── */
.contact-list { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; margin: 6px 0 0; }
.contact-list dt { color: var(--muted); font-weight: 500; }
.contact-list dd { margin: 0; }
.contact-note { margin-top: 16px; white-space: pre-wrap; color: var(--text); }
.contact-intro { color: var(--muted); margin: 0 0 14px; white-space: pre-wrap; }

/* ── Экран входа / регистрации ── */
.auth-wrap { max-width: 400px; margin: 60px auto; padding: 0 20px; }
.auth-card { background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 24px; }
.auth-card h1 { text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.auth-field input,
.auth-field textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
.auth-field textarea { resize: vertical; font-family: inherit; }
/* Ряд из нескольких кнопок формы (напр. «Сохранить» + «Отмена») — в строку. */
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.auth-field .err { color: #991b1b; font-size: 12px; margin-top: 4px; }
.auth-actions { margin-top: 18px; }
.auth-actions .btn { width: 100%; text-align: center; }
.auth-alt { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 13px; }
.auth-alt::before, .auth-alt::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; color: var(--text); font-weight: 600; text-decoration: none;
}
.btn-google:hover { background: #f3f4f6; text-decoration: none; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 13px; }

/* ── Флеши доступа/успеха ── */
.flash-success { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash-warn { background: #fef9c3; color: #854d0e; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* ── Таблица пользователей ── */
.users-table td, .users-table th { vertical-align: middle; }
.inline-form { display: inline; margin: 0; }
.role-chip { display: inline-block; background: #eef2ff; color: #3730a3;
    border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 1px 2px; }
.pill-on { color: #166534; font-weight: 600; }
.pill-off { color: #991b1b; font-weight: 600; }

/* ── ИИ-выжимка документа ── */
.ai-btn { margin-left: 6px; }
.ai-row td { background: #f9fafb; }
.ai-row-inline { margin: 6px 0 4px; }
.ai-panel { padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5; }
.ai-panel.ai-ready { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--text); }
.ai-panel.ai-pending { background: #f3f4f6; border: 1px solid var(--border); color: var(--muted); }
.ai-panel.ai-warn { background: #fef9c3; border: 1px solid #fde68a; color: #854d0e; }
.ai-panel .ai-text { white-space: pre-wrap; margin-top: 6px; }
.ai-spinner {
    display: inline-block; width: 12px; height: 12px; vertical-align: -1px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: ai-spin 0.7s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-retry {
    background: transparent; border: 0; color: var(--primary); cursor: pointer;
    font: inherit; font-weight: 600; padding: 0; text-decoration: underline;
}
