:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel-2: #1b1b1e;
  --line: #2a2a2e;
  --text: #ededed;
  --muted: #9a9a a0;
  --muted: #9a9aa0;
  --accent: #0083d0;
  --accent-soft: rgba(0, 131, 208, .14);
  --danger: #e2564a;
  --ok: #3fb96b;
  --radius: 12px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* hidden должен побеждать любой inline display, иначе скрытая модалка
   перехватывает клики по всей странице */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 80px; }

/* ── Шапка ───────────────────────────────────────────────── */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 11, 12, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .12em; font-size: 15px; }
.brand span { color: var(--accent); }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav.tabs a {
  padding: 7px 13px; border-radius: 8px; color: var(--muted);
  font-size: 13px; white-space: nowrap;
}
nav.tabs a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
nav.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.whoami { color: var(--muted); font-size: 12px; }

h1 { font-size: 24px; letter-spacing: .04em; margin: 28px 0 6px; }
h2 { font-size: 16px; letter-spacing: .04em; margin: 0 0 14px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* ── Карточки и формы ────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card > h2 { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: -8px 0 14px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=email], textarea, select {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-family: var(--mono); font-size: 13px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); background: #17171a;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 18px; font-family: var(--mono); font-size: 13px;
  font-weight: 600; cursor: pointer; letter-spacing: .04em;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; filter: none; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* ── Сообщения ───────────────────────────────────────────── */
.flash {
  border-radius: 8px; padding: 11px 15px; margin: 18px 0; font-size: 13px;
  border: 1px solid;
}
.flash.ok   { border-color: rgba(63,185,107,.4); background: rgba(63,185,107,.1); color: #86e0a6; }
.flash.err  { border-color: rgba(226,86,74,.45); background: rgba(226,86,74,.1); color: #f0928a; }
.flash.warn { border-color: rgba(214,170,60,.45); background: rgba(214,170,60,.1); color: #e3c777; }

/* ── Таблицы ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--muted); font-weight: 400; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 0 10px 9px; border-bottom: 1px solid var(--line);
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* На узком экране таблица прокручивается внутри карточки,
   а не растягивает всю страницу */
@media (max-width: 720px) {
  .card { overflow-x: auto; }
  .card table { min-width: 520px; }
  .top-in { gap: 10px; }
  nav.tabs { margin-left: 0; width: 100%; order: 3; }
  .whoami { margin-left: auto; }
}

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; border: 1px solid var(--line); color: var(--muted);
}
.pill.on  { border-color: rgba(63,185,107,.5); color: #86e0a6; }
.pill.off { border-color: rgba(226,86,74,.5); color: #f0928a; }
.pill.low { border-color: rgba(214,170,60,.5); color: #e3c777; }

/* ── Повторители ─────────────────────────────────────────── */
.rep-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px 2px; margin-bottom: 12px; background: var(--panel-2);
  position: relative;
}
.rep-item .rep-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; color: var(--muted); font-size: 12px;
}
.rep-del {
  background: none; border: 0; color: var(--danger); cursor: pointer;
  font-size: 12px; font-family: var(--mono); padding: 2px 6px;
}
.rep-del:hover { text-decoration: underline; }

/* ── Остатки ─────────────────────────────────────────────── */
.stock-table input { width: 100%; text-align: center; padding: 7px 4px; }
.stock-table th { text-align: center; }
.stock-table td { padding: 5px 4px; }
.stock-table td.color-name { text-align: left; white-space: nowrap; padding-right: 12px; }

/* ── Медиа ───────────────────────────────────────────────── */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px;
}
.media-item {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel-2); display: flex; flex-direction: column;
}
.media-item .thumb {
  aspect-ratio: 4/3; background: #000 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px;
}
.media-item .meta { padding: 9px 10px; font-size: 11px; color: var(--muted); }
.media-item .meta b { display: block; color: var(--text); font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 3px; }
.media-item .row { display: flex; gap: 8px; padding: 0 10px 10px; }
.media-item .row button, .media-item .row a { font-size: 11px; }

.drop {
  border: 1px dashed var(--line); border-radius: 10px; padding: 22px;
  text-align: center; color: var(--muted); font-size: 13px;
}
.drop.hot { border-color: var(--accent); color: var(--accent); }

/* ── Вход ────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box { width: 100%; max-width: 340px; }
.login-box .brand { font-size: 22px; margin-bottom: 4px; }
.login-box .sub { margin-bottom: 22px; }

/* ── Мелочи ──────────────────────────────────────────────── */
.mono-small { font-size: 11px; color: var(--muted); word-break: break-all; }
.right { text-align: right; }
.spacer { flex: 1; }
.sticky-save {
  position: sticky; bottom: 0; background: rgba(11,11,12,.94);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 14px 0; margin-top: 24px; display: flex; gap: 10px; align-items: center;
}
