:root {
    --bg: #0f1220;
    --card: #171a2b;
    --muted: #7e86a3;
    --accent: #3b82f6;
    --ok: #22c55e;
    --bad: #ef4444;
    --text: #e5e7eb;
    --border: #262b45;
    --ctl-h: 42px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

h1,
h2 {
    margin: 0 0 16px;
    font-weight: 700;
}

h2 {
    font-size: 22px;
    color: var(--text);
}

.pager { display:flex; gap:8px; margin-top:12px; }
.pager a { color:#fff; text-decoration:none; }
.pager a.active { font-weight:700; text-decoration:underline; }


.container {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    overflow-x: auto;
}

.row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

label {
    font-size: 14px;
    color: var(--muted);
}

.small {
    font-size: 12px;
    color: var(--muted);
}

.hidden {
    display: none !important;
}

input[type="text"],
input[type="password"],
select {
    background: #0e1224;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    height: var(--ctl-h);
    padding: 0 12px;
    line-height: 1;
    outline: none;
    min-width: 240px;
}

button,
input[type="submit"] {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 10px;
    height: var(--ctl-h);
    padding: 0 14px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

button:hover,
input[type="submit"]:hover {
    filter: brightness(1.05);
}

button:disabled,
input[type="submit"]:disabled {
    opacity: .6;
    cursor: not-allowed;
}

button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--ctl-h);
    padding: 0 14px;
    line-height: 1;
    border-width: 1px;
}

button + button,
button + input[type="submit"],
input[type="submit"] + button {
    margin-left: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    min-width: 720px;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-weight: 600;
}

tr:nth-child(even) {
    background: transparent;
}

tr:hover {
    background: rgba(255, 255, 255, .02);
}

.message {
    color: var(--bad);
    margin-top: 20px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, .5);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.open {
    display: flex;
}

.modal-content {
    width: min(560px, 92vw);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    position: relative;
}

.close {
    position: absolute;
    right: 18px;
    top: 12px;
    color: var(--muted);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

.close:hover,
.close:focus {
    color: #fff;
}

.modal label {
    display: block;
    margin: 10px 0 6px;
    color: var(--muted);
}

.modal input[type="text"],
.modal input[type="password"],
.modal select {
    width: 100%;
    margin-bottom: 12px;
    min-width: 0;
}

.modal .actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#searchForm {
    margin-bottom: 20px;
    margin-top: 20px;
}

.nav {
    margin-bottom: 16px;
}

.nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.nav a + a {
    margin-left: 10px;
}

/* Кнопки действий — в одну строку */
.actions-cell{
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;      /* не переносить кнопки */
}
.actions-cell button{ margin:0; }   /* убираем авто-отступы между инлайнами */

/* Pager */
.pager{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-start;
  margin-top:12px;
  overflow-x:auto;          /* на всякий случай */
  padding:6px 0;
}

.pager-link, .pager-btn{
  display:inline-flex;
  min-width:34px;
  height:34px;
  padding:0 10px;
  border:1px solid var(--border);
  border-radius:8px;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  color:var(--text);
  background:#0e1224;
  font-weight:600;
  user-select:none;
}

.pager-link:hover, .pager-btn:hover{
  filter:brightness(1.05);
}

.pager-link.active{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
  cursor:default;
}

.pager-btn.disabled{
  opacity:.5;
  cursor:not-allowed;
  pointer-events:none;
}

/* inline edit brand */
td.brand-name.editing { padding: 0; }
.brand-inline-input{
  width: 100%;
  height: var(--ctl-h);
  background:#0e1224;
  color: var(--text);
  border:1px solid var(--border);
  border-radius:8px;
  padding: 0 10px;
  outline:none;
}
td.brand-name.saving { opacity: .6; }

/* actions-cell с кнопкой "Другие цены" */
.actions-cell {
  display: flex;
  flex-direction: column;   /* кнопка вниз */
  gap: 6px;
  align-items: stretch;     /* чтобы full тянулась */
}

.actions-cell .actions-top {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.actions-cell .btn-other-prices.full {
  width: 100%;
  text-align: center;
}

/* Унификация модалок */
.modal-content {
    width: min(900px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, .45);
    position: relative;
    font-size: 14px;
    color: var(--text);
}

/* Заголовок модалки */
.modal-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text);
}

/* шире сама модалка, чтобы табличка дышала */
#otherPricesModal .modal-content{
  max-width: 880px;
}

/* предсказуемая сетка */
#otherPricesModal table{ table-layout: fixed; }

/* 5-я колонка — под кнопку */
#otherPricesModal th:nth-child(5),
#otherPricesModal td:nth-child(5){
  width: 120px;               /* достаточно для кнопки */
}

/* выравнивание и запрет переноса*/
#otherPricesModal .op-actions{
  text-align: right;
  white-space: nowrap;
}

/* компактная кнопка */
#otherPricesModal .btn-refresh-price{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  font-weight: 600;
}

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  margin-left:6px;
  border:1px solid var(--border);
  border-radius:50%;
  background:transparent;
  color:var(--text);
  font-weight:700;
  cursor:pointer;
  line-height:1;
}
.icon-btn:hover{ filter:brightness(1.05); }
.icon-btn:disabled{ opacity:.6; cursor:not-allowed; }

/* значок ошибки цены */
.price-error {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  margin-left:6px;
  border-radius:50%;
  background: transparent;
  color: #ef4444;            /* красный */
  font-weight:800;
  border:1px solid #ef4444;
  line-height:1;
  font-size:12px;
}

/* ===== Цены (модалка): прокрутка таблицы ===== */
#otherPricesModal .modal-content{
  max-height: 90vh;            /* чтобы модалка не вылезала за экран */
  display: flex;
  flex-direction: column;
}

#otherPricesModal .op-table-scroll{
  flex: 1;
  max-height: 60vh;            /* высота области с таблицей */
  overflow-y: auto;            /* вертикальная прокрутка */
  margin-top: 8px;
  border-radius: 8px;
}

/* чтобы шапка таблицы оставалась видимой при скролле */
#otherPricesModal .op-table-scroll thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: #202634;         /* подберите под вашу тему */
}

/* косметика */
#otherPricesModal .op-table-scroll table{
  width: 100%;
  border-collapse: collapse;
}

/* ===== Мои сайты (модалка): прокрутка таблицы ===== */
#ownSourcesModal .modal-content{
  max-height: 90vh;                 /* не вылезать за экран */
  display: flex;
  flex-direction: column;
}

#ownSourcesModal .own-table-scroll{
  flex: 1;                           /* занять доступную высоту */
  max-height: 60vh;                  /* видно ~60% экрана, остальное — скролл */
  overflow-y: auto;
  margin-top: 8px;
  border-radius: 8px;
}

/* фиксированная шапка таблицы при прокрутке */
#ownSourcesModal .own-table-scroll thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: #202634;               /* под тёмную тему; подстройте при необходимости */
}

/* косметика */
#ownSourcesModal .own-table-scroll table{
  width: 100%;
  border-collapse: collapse;
}