/* Оформление админки Look-Angel.
   Палитра и шрифты — из brand/BRAND.md. Внешние шрифты не подключаем:
   админка должна открываться даже без интернета, только с сервера магазина. */

:root {
  --primary: #3FC4B9;
  --primary-dark: #2FA69C;
  --primary-light: #E6F8F6;
  --text: #2E3A38;
  --muted: #717F7C;
  --border: #DFE6E5;
  --bg: #FFFFFF;
  --bg-alt: #F7FAF9;
  --danger: #E5484D;
  --danger-light: #FDECEC;
  --warn: #B26A00;
  --warn-light: #FFF6E5;
  --ok: #2FA69C;

  --radius: 10px;
  --shadow: 0 2px 10px rgba(46, 58, 56, .08);
  --shadow-lg: 0 12px 40px rgba(46, 58, 56, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Variable",
    Tahoma, Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-alt);
}

h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }

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

.boot {
  padding: 60px;
  text-align: center;
  color: var(--muted);
  font-size: 18px;
}

/* ---------------------------- каркас ---------------------------- */

.layout {
  display: grid;
  grid-template-columns: 246px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img { width: 42px; height: auto; }
.sidebar-logo b { font-size: 17px; display: block; }
.sidebar-logo span { font-size: 12px; color: var(--muted); }

.nav { padding: 10px 8px; flex: 1; }
.nav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 14px 12px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.nav a:hover { background: var(--bg-alt); text-decoration: none; }
.nav a.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav .badge-count {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  font-size: 13px;
  color: var(--muted);
}
.sidebar-user b { color: var(--text); display: block; font-size: 14px; }

.main { padding: 24px 28px 60px; min-width: 0; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---------------------------- элементы ---------------------------- */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2, .card > h3 { margin-top: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr); }
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }

.truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 42px;
}
.btn:hover:not(:disabled) { background: var(--bg-alt); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c93b40; border-color: #c93b40; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-alt); }
.btn-sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-big { min-height: 50px; font-size: 16px; padding: 12px 22px; }

/* поля */
label.field { display: block; margin-bottom: 14px; }
label.field > span.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}
label.field > span.hint {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 42px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
textarea.code {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  min-height: 130px;
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg-alt); color: var(--muted); }
input.narrow, select.narrow { width: 110px; }
input.inline-num { width: 88px; min-height: 34px; padding: 5px 8px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary-dark); }

/* переключатель «видно / скрыто» */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px;
  background: #C9D5D3; position: relative; transition: background .15s;
  flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary-dark); outline-offset: 2px; }
.switch .switch-label { font-size: 13px; color: var(--muted); }

/* фильтры */
.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.filters label.field { margin: 0; }
.filters .f-search { min-width: 260px; flex: 1; }
.filters .f-date input { width: 150px; }

/* таблицы */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.tbl th, table.tbl td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl th {
  background: var(--bg-alt);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.tbl tbody tr:hover { background: var(--bg-alt); }
table.tbl tr.problem { background: var(--danger-light); }
table.tbl tr.problem:hover { background: #fbdedf; }
table.tbl td.cell-clip { max-width: 220px; }
table.tbl td.cell-clip-wide { max-width: 320px; }

.thumb {
  width: 44px; height: 58px; border-radius: 6px;
  object-fit: cover; background: var(--bg-alt);
  border: 1px solid var(--border);
  display: block;
}
.thumb-empty {
  width: 44px; height: 58px; border-radius: 6px;
  background: var(--bg-alt); border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 10px; text-align: center;
}

/* плашки */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag-ok { background: var(--primary-light); border-color: #BEE9E5; color: #1F7C74; }
.tag-bad { background: var(--danger-light); border-color: #F6C9CA; color: #B4272C; }
.tag-warn { background: var(--warn-light); border-color: #F0DDB4; color: var(--warn); }
.tag-new { background: #EAF2FF; border-color: #CBDDF8; color: #1F5FA8; }

/* плитки сводки */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: block;
  color: var(--text);
}
.tile .tile-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.tile .tile-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .tile-extra { font-size: 13px; color: var(--muted); margin-top: 4px; }
a.tile:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); }
.tile-problem { border-color: #F0C4C5; background: var(--danger-light); }
.tile-problem .tile-value { color: #B4272C; }
.tile-problem .tile-label { color: #8E2B2F; }
.tile-quiet .tile-value { font-size: 22px; }

/* график */
.chart { width: 100%; height: 260px; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--primary-light); }
.chart .bar:hover { fill: #C6EDE9; }
.chart .line { fill: none; stroke: var(--primary-dark); stroke-width: 2; }
.chart .dot { fill: var(--primary-dark); }
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* состояния */
.state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.state h3 { color: var(--text); }
.state-error { color: #B4272C; }
.skeleton {
  background: linear-gradient(90deg, #EDF2F1 25%, #F7FAF9 50%, #EDF2F1 75%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: 6px;
  height: 14px;
  margin: 10px 0;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.spinner {
  width: 16px; height: 16px; flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger) .spinner {
  border-color: var(--border); border-top-color: var(--primary-dark);
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner-msg {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.banner-msg.err { background: var(--danger-light); border-color: #F0C4C5; color: #8E2B2F; }
.banner-msg.warn { background: var(--warn-light); border-color: #F0DDB4; color: #7A4A08; }
.banner-msg.ok { background: var(--primary-light); border-color: #BEE9E5; color: #1F7C74; }
.banner-msg h3 { margin: 0 0 4px; font-size: 15px; }

/* всплывающие сообщения */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
  max-width: 420px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.toast.ok { background: #1F7C74; }
.toast.err { background: #B4272C; }
.toast button {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0; opacity: .8;
}

/* модальные окна */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(46, 58, 56, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
  z-index: 50;
}
.dialog {
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  padding: 22px 24px 20px;
}
.dialog.wide { max-width: 820px; }
.dialog h2 { margin-bottom: 10px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* экран входа */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(160deg, var(--primary-light), var(--bg-alt) 60%);
}
.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  padding: 30px 32px 26px;
}
.login-box img.logo { width: 150px; height: auto; display: block; margin: 0 auto 6px; }
.login-box h1 { font-size: 21px; text-align: center; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* карточка заказа / товара */
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.items-list { display: flex; flex-direction: column; }
.item-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 90px 110px 110px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.item-row:last-child { border-bottom: none; }
.item-row img, .item-row .thumb-empty { width: 60px; height: 76px; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.timeline li {
  padding: 8px 0 8px 16px;
  border-left: 2px solid var(--border);
  position: relative;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}
.timeline .when { color: var(--muted); font-size: 12px; }

.gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.gallery img {
  width: 104px; height: 138px; object-fit: cover;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-alt);
}

.override-note {
  background: var(--warn-light);
  border: 1px solid #F0DDB4;
  color: #7A4A08;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.pager { display: flex; justify-content: center; padding: 16px 0 4px; }

/* --- дополнения для отдельных экранов --- */

/* Подпись под значением в плитке: «проверено вчера», «на счету 120» */
.tile-note { margin-top: 6px; color: var(--muted); line-height: 1.35; }

/* Строка таблицы, до которой сейчас нет дела (например, товар ещё не пришёл) */
table.tbl tr.quiet-row td { color: var(--muted); }

/* Красный текст для короткого ответа рядом с кнопкой проверки */
.danger-text { color: var(--danger); }

/* Технические данные «было/стало» в журнале действий */
pre.code-block {
  margin: 6px 0 14px;
  padding: 10px 12px;
  max-height: 240px;
  overflow: auto;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Свёрнутый раздел «для технического специалиста» */
details.card > summary {
  cursor: pointer;
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
  content: "▸ ";
  color: var(--muted);
}
details.card[open] > summary::before { content: "▾ "; }

/* На узких экранах (ноутбук 1280–1500) сжимаем колонки, чтобы в таблице
   заказов было видно и накладную, а не только начало строки. */
@media (max-width: 1500px) {
  table.tbl { font-size: 13px; }
  table.tbl th, table.tbl td { padding: 9px 9px; }
  table.tbl td.cell-clip { max-width: 160px; }
  table.tbl td.cell-clip-wide { max-width: 220px; }
}
