:root {
    --navy: #102b52;
    --navy-deep: #0a2145;
    --blue: #087fc7;
    --text: #1b304e;
    --muted: #718198;
    --line: #dce6f1;
    --bg: #f4f7fb;
    --shadow: 0 10px 28px rgba(24,58,102,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
.brand { display: inline-flex; align-items: center; color: inherit; text-decoration: none; flex: 0 0 auto; }
.brand-logo { display: block; width: 230px; height: 73px; object-fit: contain; object-position: left center; }
.admin-topbar { min-height: 98px; height: auto; background: white; border-bottom: 1px solid #e3eaf2; padding: 10px clamp(20px,5vw,72px); display: flex; align-items: center; justify-content: space-between; }
.admin-top-actions { display: flex; align-items: center; gap: 20px; }
.admin-indicator { color: #61738a; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.admin-indicator i { width: 7px; height: 7px; background: #27a36a; border-radius: 50%; }
.logout-button { background: white; border: 1px solid #d6e1ed; border-radius: 8px; color: #425772; padding: 9px 14px; cursor: pointer; font-size: 12px; }
.logout-button:hover { background: #f4f8fc; }
.admin-container { max-width: 1260px; margin: 0 auto; padding: 36px 28px 60px; }
.eyebrow { color: #1682bd; font-size: 10px; font-weight: 800; letter-spacing: .15em; margin-bottom: 9px; }
.admin-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.admin-heading h1 { margin: 0; color: var(--navy-deep); font-size: 32px; letter-spacing: -.035em; }
.admin-heading p { margin: 9px 0 0; font-size: 13px; color: var(--muted); }
.user-site-link { color: #1678b6; font-size: 12px; text-decoration: none; border-bottom: 1px solid #b9d8ec; padding-bottom: 3px; }
.admin-search-panel { padding: 27px 30px 22px; border-radius: 15px; border: 1px solid #e0e9f3; background: white; box-shadow: var(--shadow); }
.panel-caption { color: #7e91a8; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.admin-search-panel h2 { margin: 8px 0 6px; color: var(--navy); font-size: 21px; }
.admin-search-panel > p { margin: 0 0 18px; color: #7b8ba0; font-size: 12px; }
.admin-search-form { display: flex; gap: 10px; }
.admin-search-form input { flex: 1; min-width: 0; border: 1px solid #d7e2ee; outline: none; border-radius: 9px; padding: 14px 16px; font-size: 13px; color: var(--text); }
.admin-search-form input:focus { border-color: #6ba9d6; box-shadow: 0 0 0 3px rgba(28,133,194,.08); }
.admin-search-form button { border: 0; border-radius: 9px; padding: 13px 21px; background: linear-gradient(110deg,#078dcc,#0875be); color: white; font-size: 12px; font-weight: 700; cursor: pointer; }
.admin-search-form button:disabled { opacity: .65; cursor: wait; }
.admin-status { min-height: 0; margin-top: 12px; font-size: 12px; }
.admin-status:empty { display: none; }
.admin-status.loading { color: #3478aa; }
.admin-status.success { color: #23835e; }
.admin-status.error { color: #b74c4c; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin: 30px 0 14px; }
.section-title-row .eyebrow { margin-bottom: 5px; }
.section-title-row h2 { margin: 0; font-size: 22px; color: var(--navy); }
.auto-label, .history-hint, .admin-result-count { color: #76879d; font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.metric-card { background: white; border: 1px solid #e2eaf3; border-radius: 13px; padding: 19px 21px; box-shadow: var(--shadow); position: relative; }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.metric-icon.blue { background: #e8f3ff; color: #167bc1; }
.metric-icon.green { background: #e6f7ef; color: #23a36a; }
.metric-icon.violet { background: #f0edff; color: #7665c7; }
.metric-label { color: #718198; font-size: 11px; }
.metric-value { color: var(--navy); font-size: 29px; line-height: 1.2; font-weight: 800; margin: 4px 0 6px; }
.metric-description { color: #96a2b1; font-size: 10px; }
.averages-panel { display: flex; align-items: center; gap: 34px; padding: 19px 22px; margin-top: 13px; border-radius: 12px; background: #eaf3fc; }
.averages-panel > div:first-child { margin-right: auto; }
.averages-panel .eyebrow { font-size: 8px; margin-bottom: 5px; }
.averages-panel strong { color: #1d3d64; font-size: 13px; }
.average-item { display: flex; flex-direction: column; gap: 4px; min-width: 65px; }
.average-item span { color: #72869e; font-size: 10px; }
.average-item strong { font-size: 17px; }
.metric-note { margin: 10px 2px 0; color: #8997a8; font-size: 10px; }
.admin-results-list { display: grid; gap: 12px; }
.admin-book-card { display: grid; grid-template-columns: 105px minmax(220px,.9fr) minmax(280px,1.1fr); gap: 20px; padding: 17px; background: white; border: 1px solid #e1e9f2; border-radius: 12px; box-shadow: var(--shadow); }
.admin-book-cover { width: 105px; height: 143px; background: #f0f4f8; border-radius: 5px; overflow: hidden; display: grid; place-items: center; }
.admin-book-cover img { width: 100%; height: 100%; object-fit: contain; }
.admin-cover-placeholder { color: #8ba8c4; font-weight: 800; font-size: 21px; }
.admin-book-main { min-width: 0; }
.admin-book-topline { display: flex; align-items: center; gap: 10px; }
.admin-rank { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #eaf3fc; color: #23689e; font-size: 11px; font-weight: 800; }
.relevant-tag, .not-relevant-tag { font-size: 10px; padding: 5px 9px; border-radius: 20px; font-weight: 700; }
.relevant-tag { color: #168051; background: #e5f6ed; }
.not-relevant-tag { color: #b44c4c; background: #fff0ef; }
.admin-book-main h3 { color: #16345b; font-size: 15px; line-height: 1.4; margin: 10px 0 9px; }
.similarity { color: #8492a5; font-size: 10px; }
.similarity strong { color: #42607e; }
.admin-book-main a { display: inline-block; margin-top: 13px; text-decoration: none; color: #1677b5; font-size: 11px; font-weight: 700; }
.admin-book-metadata { border-left: 1px solid #e4ebf3; padding-left: 18px; }
.admin-book-metadata > strong { display: block; color: #35516f; font-size: 11px; margin-bottom: 10px; }
.admin-metadata-row { display: grid; grid-template-columns: minmax(90px, 115px) 1fr; gap: 10px; margin-bottom: 7px; font-size: 10px; line-height: 1.4; }
.admin-metadata-row span { color: #8493a6; }
.admin-metadata-row p { margin: 0; color: #455b75; overflow-wrap: anywhere; }
.muted { color: #98a5b4; font-size: 11px; }
.history-section { margin-top: 34px; }
.history-list { overflow: hidden; background: white; border: 1px solid #e1e9f2; border-radius: 12px; }
.history-row { display: grid; grid-template-columns: 35px 1fr 100px 100px; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid #edf1f5; font-size: 11px; }
.history-row:last-child { border-bottom: 0; }
.history-number { color: #96a4b5; }
.history-query { color: #324c6c; overflow-wrap: anywhere; }
.history-value { color: #657d98; text-align: right; }
.history-empty { padding: 22px; color: #8998aa; font-size: 12px; text-align: center; }
.admin-disclaimer { margin-top: 20px; padding: 13px 16px; border-radius: 9px; background: #edf3f9; color: #7a8ba0; font-size: 10px; line-height: 1.5; }
.admin-disclaimer strong { color: #4c627d; }
.hidden { display: none !important; }

/* Страница входа */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: linear-gradient(135deg,#f6f9fd,#e8f2fc); }
.login-shell { width: min(100%, 440px); }
.login-shell > .brand { margin: 0 0 25px 8px; }
.login-shell > .brand .brand-logo { width: 236px; height: 76px; }
.login-card { padding: 34px; background: white; border: 1px solid #e0e9f3; border-radius: 16px; box-shadow: 0 20px 55px rgba(24,58,102,.10); }
.login-symbol { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 12px; background: #eaf4fd; color: #1679b9; font-size: 27px; margin-bottom: 22px; }
.login-card h1 { margin: 0; color: var(--navy); font-size: 25px; }
.login-card > p { margin: 9px 0 23px; color: #8291a4; font-size: 12px; line-height: 1.5; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 7px; color: #4c6079; font-size: 11px; font-weight: 700; }
.login-form input { width: 100%; padding: 13px 12px; border: 1px solid #d9e3ed; border-radius: 8px; outline: none; color: var(--text); }
.login-form input:focus { border-color: #71add5; box-shadow: 0 0 0 3px rgba(28,133,194,.08); }
.login-form button { margin-top: 13px; padding: 14px; border: 0; border-radius: 8px; color: white; background: linear-gradient(110deg,#078dcc,#0875be); font-size: 12px; font-weight: 700; cursor: pointer; }
.login-form button span { margin-left: 8px; }
.back-link { display: block; margin-top: 20px; color: #247db3; font-size: 11px; text-decoration: none; }
.login-foot { margin-top: 17px; text-align: center; color: #92a0b0; font-size: 10px; }
.login-error { margin-bottom: 12px; padding: 10px 12px; border-radius: 7px; background: #fff0ef; color: #b04c4c; font-size: 11px; }
@media (max-width: 760px) {
    .admin-container { padding: 25px 15px 40px; }
    .admin-heading { align-items: flex-start; flex-direction: column; }
    .admin-heading h1 { font-size: 26px; }
    .admin-search-panel { padding: 21px 17px; }
    .metric-grid { grid-template-columns: 1fr; }
    .averages-panel { flex-wrap: wrap; gap: 17px 23px; }
    .averages-panel > div:first-child { width: 100%; }
    .admin-book-card { grid-template-columns: 78px 1fr; gap: 13px; }
    .admin-book-cover { width: 78px; height: 110px; }
    .admin-book-metadata { grid-column: 1 / -1; border-left: 0; border-top: 1px solid #e4ebf3; padding: 13px 0 0; }
    .history-row { grid-template-columns: 23px 1fr 70px 70px; gap: 6px; padding: 11px 9px; font-size: 9px; }
    .section-title-row { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
    .admin-topbar { min-height: 82px; padding: 8px 13px; }
    .admin-topbar .brand-logo { width: 190px; height: 61px; }
    .brand-name { font-size: 7px; }
    .brand-mark { font-size: 33px; }
    .admin-indicator { display: none; }
    .admin-search-form { flex-direction: column; }
    .admin-search-form button { padding: 13px; }
    .auto-label { font-size: 9px; }
    .admin-metadata-row { grid-template-columns: 88px 1fr; }
}

/* Массовая проверка запросов */
.admin-tool-panel {
    margin-top: 26px;
    padding: 25px 28px;
    border: 1px solid #e0e9f3;
    border-radius: 14px;
    background: white;
    box-shadow: var(--shadow);
}
.admin-tool-panel h2 { margin: 8px 0 7px; color: var(--navy); font-size: 21px; }
.admin-tool-panel > p { margin: 0 0 18px; color: #7b8ba0; font-size: 12px; line-height: 1.6; }
.batch-upload-row { display: flex; align-items: center; gap: 13px; margin-bottom: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.file-upload-button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid #cfe0f1; border-radius: 8px; color: #176fa9; background: #f6faff; font-size: 11px; font-weight: 700; cursor: pointer; }
.file-upload-button:hover { background: #eaf4fd; }
.file-upload-button span { font-size: 17px; line-height: 10px; }
.batch-textarea { display: block; width: 100%; min-height: 145px; resize: vertical; padding: 13px 15px; border: 1px solid #d9e3ed; border-radius: 9px; color: var(--text); font: inherit; font-size: 12px; line-height: 1.65; outline: none; }
.batch-textarea:focus, .book-field input:focus, .book-field textarea:focus { border-color: #73add5; box-shadow: 0 0 0 3px rgba(28,133,194,.08); }
.batch-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.primary-button, .secondary-button, .stop-button { border: 0; border-radius: 8px; padding: 11px 16px; font-size: 11px; font-weight: 700; cursor: pointer; transition: background .18s ease, transform .18s ease, opacity .18s ease; }
.primary-button { color: white; background: linear-gradient(110deg,#078dcc,#0875be); }
.primary-button:hover { background: linear-gradient(110deg,#087db6,#075fa3); transform: translateY(-1px); }
.secondary-button { color: #236d9e; background: #edf5fc; border: 1px solid #d4e5f3; }
.secondary-button:hover { background: #e2f0fb; }
.stop-button { color: #9b4f4b; background: #fff1f0; border: 1px solid #f2d6d3; }
.primary-button:disabled, .secondary-button:disabled, .stop-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.batch-preview-section { margin-top: 20px; padding-top: 17px; border-top: 1px solid #eaf0f6; }
.batch-preview-heading, .batch-progress-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #385575; font-size: 11px; }
.batch-query-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 250px; overflow-y: auto; border: 1px solid #e7edf4; border-radius: 9px; }
.batch-query-list li { display: grid; grid-template-columns: 31px 1fr; gap: 10px; align-items: start; padding: 9px 12px; border-bottom: 1px solid #edf1f5; color: #425b77; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.batch-query-list li:last-child { border-bottom: 0; }
.batch-query-number { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #eaf3fc; color: #246da5; font-size: 10px; font-weight: 800; }
.batch-progress-section { margin-top: 20px; padding: 16px; border-radius: 10px; background: #f3f8fd; }
.batch-progress-track { height: 8px; margin: 12px 0 8px; overflow: hidden; border-radius: 20px; background: #dce8f4; }
.batch-progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#19a2d3,#176fc0); transition: width .25s ease; }
.batch-summary-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e9eff5; }
.batch-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.batch-metric-grid .metric-card { padding: 16px; }
.batch-metric-grid .metric-value { font-size: 25px; }
.batch-results-table { margin-top: 17px; overflow-x: auto; border: 1px solid #e1e9f2; border-radius: 10px; background: white; }
.batch-table-head, .batch-table-row { display: grid; grid-template-columns: 35px minmax(220px,1fr) 95px 80px 80px 85px; gap: 10px; align-items: center; min-width: 680px; padding: 11px 13px; font-size: 10px; }
.batch-table-head { color: #73869d; background: #f4f8fc; font-weight: 800; }
.batch-table-row { color: #415975; border-top: 1px solid #edf1f5; }
.batch-table-row.failed { color: #a34d4d; background: #fffafa; }
.batch-table-query { overflow-wrap: anywhere; }
.batch-table-query small { display: block; margin-top: 4px; color: #b15a54; line-height: 1.4; }

/* Добавление книги */
.book-add-form { margin-top: 18px; }
.book-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px 15px; }
.book-field { display: grid; gap: 7px; min-width: 0; }
.book-field > span { color: #4c6079; font-size: 10px; font-weight: 700; }
.book-field input, .book-field textarea { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid #d9e3ed; border-radius: 8px; outline: none; color: var(--text); background: white; font: inherit; font-size: 11px; }
.book-field textarea { resize: vertical; line-height: 1.55; }
.book-field-wide { grid-column: 1 / -1; }
.book-new-checkbox { display: inline-flex; align-items: center; gap: 9px; margin: 16px 0; color: #526a84; font-size: 11px; cursor: pointer; }
.book-new-checkbox input { accent-color: #167cba; width: 15px; height: 15px; }
.book-add-form > .primary-button { display: block; min-width: 180px; }

@media (max-width: 760px) {
    .admin-tool-panel { padding: 21px 17px; }
    .batch-metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .book-form-grid { grid-template-columns: 1fr; }
    .book-field-wide { grid-column: auto; }
}
@media (max-width: 480px) {
    .batch-metric-grid { grid-template-columns: 1fr; }
    .batch-actions { flex-direction: column; }
    .batch-actions button { width: 100%; }
    .batch-preview-heading, .batch-progress-heading { align-items: flex-start; flex-direction: column; }
}


/* Настройка дополнительной проверки пользовательской выдачи */
.search-filter-panel { margin-bottom: 18px; }
.search-filter-toggle { display: flex; align-items: flex-start; gap: 12px; max-width: 780px; padding: 15px 17px; border: 1px solid #dce8f2; border-radius: 10px; background: #f8fbfe; cursor: pointer; }
.search-filter-toggle input { flex: 0 0 auto; width: 18px; height: 18px; margin: 1px 0 0; accent-color: #087fc7; cursor: pointer; }
.search-filter-toggle input:disabled { cursor: wait; }
.search-filter-copy { display: grid; gap: 5px; }
.search-filter-copy strong { color: #294767; font-size: 12px; }
.search-filter-copy small { color: #788ba1; font-size: 11px; line-height: 1.55; }
