/* Консоль MeRa: те же цвета, что в приложении ТСД. */
:root {
  --canvas: #f2f2f7;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --muted: #8e8e93;
  --hairline: #e5e5ea;
  --brand: #2f5bea;
  --brand-soft: #e8eefd;
  --laser: #ff3b30;
  --green: #34c759;
  --amber: #ff9500;
  --teal: #30b0c7;
  --row-hover: #f7f8fc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0f1115;
    --surface: #1a1d23;
    --ink: #f2f2f7;
    --muted: #9a9aa2;
    --hairline: #2b2f37;
    --brand: #5a7ff2;
    --brand-soft: #1f2a4a;
    --row-hover: #20242c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.4px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Каркас ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand b { font-size: 21px; letter-spacing: -.4px; }
.brand .sub { font-size: 12px; color: var(--muted); line-height: 1.2; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; color: var(--ink); font-weight: 500;
}
.nav a:hover { background: var(--row-hover); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .badge { margin-left: auto; }
.nav .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; flex: none; }
.sidebar .spacer { flex: 1; }
.who { padding: 10px; border-top: 1px solid var(--hairline); margin-top: 8px; font-size: 13px; }
.who b { display: block; font-size: 14px; }
.main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Карточки и плитки ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: block; color: var(--ink); }
.tile:hover { text-decoration: none; outline: 2px solid var(--brand-soft); }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-top: 4px; }
.tile .hint { font-size: 12px; color: var(--muted); }
.tile.warn .value { color: var(--amber); }
.tile.bad .value { color: var(--laser); }
.tile.ok .value { color: var(--green); }

/* ---------- Таблицы ---------- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--row-hover); }
td .sub { display: block; color: var(--muted); font-size: 13px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- Плашки ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: rgba(52, 199, 89, .14); color: #1f9e46; }
.pill.warn { background: rgba(255, 149, 0, .14); color: #c26f00; }
.pill.bad { background: rgba(255, 59, 48, .12); color: #d62d23; }
.pill.info { background: var(--brand-soft); color: var(--brand); }
.pill.gray { background: var(--canvas); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); margin-right: 6px; }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }

/* ---------- Формы ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.toolbar input[type=search] { min-width: 260px; flex: 1; max-width: 420px; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field input, label.field select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn {
  font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap;
  /* <a class="btn"> и <button> одной высоты, текст по центру по обеим осям. */
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 20px; text-decoration: none; vertical-align: middle;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.danger { background: rgba(255, 59, 48, .12); color: var(--laser); }
.btn.ghost { background: transparent; color: var(--brand); padding: 6px 8px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.error-text { color: var(--laser); font-size: 13px; margin: 8px 0; min-height: 1px; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.login .logo svg { width: 64px; height: 64px; }
.login .btn.primary { width: 100%; padding: 12px; margin-top: 4px; }
.login .links { text-align: center; margin-top: 14px; font-size: 14px; }

/* ---------- Окна ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 17, 21, .45); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: rise .2s; }
.modal.wide { max-width: 860px; }
.modal h2 { font-size: 20px; margin-bottom: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.secret { font-size: 26px; font-weight: 700; letter-spacing: 2px; text-align: center; padding: 14px; background: var(--canvas); border-radius: 12px; margin: 10px 0; user-select: all; }
.qr { display: grid; place-items: center; padding: 10px; background: #fff; border-radius: 12px; }
.qr svg, .qr img { width: 240px; height: 240px; }
pre.details { background: var(--canvas); border-radius: 10px; padding: 12px; font-size: 12px; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; }
#toast .t { background: #1c1c1e; color: #fff; padding: 10px 16px; border-radius: 12px; margin-top: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: rise .2s; }
#toast .t.bad { background: var(--laser); }

.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.list-item { padding: 11px 14px; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.list-item:hover, .list-item.active { background: var(--row-hover); }
.list-item:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; }
.kv div:nth-child(odd) { color: var(--muted); }
.more { text-align: center; padding: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand, .sidebar .spacer { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 8px; font-size: 14px; }
  .nav .ico { width: 22px; height: 22px; }
  .who { border-top: none; margin: 0; padding: 6px 8px; width: 100%; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile .value { font-size: 24px; }
  .main { padding: 18px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- Фото товара ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo { margin: 0; }
.photo img, .photo .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--canvas); display: block; cursor: zoom-in; }
.photo figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ---------- Права, задачи, сверка ---------- */
fieldset.perms { border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 14px 6px; margin: 0 0 12px; }
fieldset.perms legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; flex-wrap: wrap; }
label.check select { margin-left: 6px; }
.assignees { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 12px; padding: 0 0 6px 26px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
textarea { width: 100%; resize: vertical; }
.found { max-height: 240px; overflow: auto; margin-bottom: 8px; border-radius: 10px; }
tr.diff td { background: rgba(255, 149, 0, .10); }
tr.extra td { background: rgba(48, 176, 199, .10); }
.file-row { display: flex; gap: 10px; align-items: center; padding: 4px 0; }
.card.issues { padding: 12px 16px; margin-bottom: 12px; box-shadow: none; background: var(--canvas); }
.issue { padding: 6px 0; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.issue:last-child { border-bottom: none; }
.issue.bad { color: var(--laser); }
.issue.warn::before { content: "⚠ "; color: var(--amber); }
.issue.bad::before { content: "⛔ "; }
@media (max-width: 900px) { .row3 { grid-template-columns: 1fr; } .assignees { padding-left: 0; } }

/* Шапка страницы: фильтры и главная кнопка в одну линию, по центру друг относительно друга. */
.head-actions { align-items: center; gap: 10px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--brand-soft); }
.segmented a {
  display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px;
  border-radius: 9px; font-size: 13px; font-weight: 600; line-height: 1; color: var(--brand); text-decoration: none; white-space: nowrap;
}
.segmented a:hover { background: rgba(47, 91, 234, .08); }
.segmented a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.head-actions .btn { height: 38px; }
.reply-box { margin: 10px 0; padding: 12px; border-radius: 12px; background: rgba(255, 59, 48, .07); }
.reply-box textarea { width: 100%; }
tr.off td { opacity: .55; }
/* Товары: дерево папок слева от списка, «хлебные крошки», постраничный вывод. */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; padding: 12px 14px 8px; border-bottom: 1px solid var(--hairline); }
#list { max-height: calc(100vh - 190px); overflow: auto; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs span.sep { color: var(--muted); }
.folder-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--hairline); }
.folder-row:hover { background: var(--row-hover); }
.folder-row .ico { width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 149, 0, .16); color: var(--amber); font-size: 14px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.photo-tile { position: relative; }
.photo-tile .photo-del {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 15px; line-height: 28px; display: none;
}
.photo-tile:hover .photo-del, .photo-tile:focus-within .photo-del { display: block; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--ink); margin: 0 0 10px; }
.card.onec { margin: 16px 0 22px; }
.card.onec p { max-width: 820px; }
