:root {
  --primary: #f7561b;
  --primary-dark: #d4400f;
  --primary-soft: #6476a0;
  --accent: #ffb919;
  --navy: #0c132d;
  --navy-2: #1e2b66;
  --bg: #f5f4f2;
  --panel: #ffffff;
  --border: #e8e5e0;
  --text: #1b1a17;
  --muted: #6b6a63;
  --green: #16a34a;
  --orange: #d97706;
  --red: #dc2626;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 238px;
  background: var(--navy);
  color: #e6e9f5;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.logo { font-size: 1.1rem; font-weight: 800; color: #fff; margin-bottom: 2px; letter-spacing: -.01em; }
.logo:before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; background: linear-gradient(135deg, #ffb919, #f7561b 70%, #e33b1e); vertical-align: 0; }
.logo-sub { font-size: .72rem; color: #8f9bc4; margin-bottom: 22px; line-height: 1.45; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #bcc6e3;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: .88rem;
  font-weight: 500;
  transition: background .15s;
}
.sidebar nav a:hover { background: #18234a; color: #fff; }
.sidebar nav a.active { background: linear-gradient(135deg, #f7561b, #e33b1e); color: #fff; }
.side-foot { font-size: .72rem; color: #5f6c99; margin-top: 20px; line-height: 1.45; }

.main { flex: 1; padding: 22px 28px; max-width: 1280px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; }
.userbox { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.demo-chip {
  background: #fee2e2;
  color: #991b1b;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .7rem;
}
.flash {
  background: #fff4ec;
  border: 1px solid #f9cdb0;
  color: #8a3000;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .88rem;
}
.content { display: flex; flex-direction: column; gap: 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow-x: auto;
}
.panel h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.cards > * { min-width: 0; }
.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.metric-label { font-size: .8rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.metric-value { font-size: 1.65rem; font-weight: 800; color: var(--primary); letter-spacing: -.01em; }
.metric-value.orange { color: var(--orange); }
.metric-value.red { color: var(--red); }
.metric-value.gray { color: var(--muted); }
.metric-sub { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > * { min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: .76rem;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}
td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .73rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge.soft { background: #f1f5f9; color: #334155; }
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #f1f5f9; border-color: transparent; color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-sm { padding: 4px 10px; font-size: .76rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.inline-form { display: inline; }

.ok-bar {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: .88rem;
}
.err-bar {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: .88rem;
}

.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.flow-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  flex: 1;
  min-width: 110px;
}
.flow-item b { display: block; font-size: .86rem; }
.flow-item span { font-size: .73rem; color: var(--muted); }
.flow-arrow { align-self: center; color: var(--muted); font-size: 1.05rem; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.step b { display: block; margin-bottom: 4px; }
.step span { font-size: .85rem; color: var(--muted); }
ul.plain { list-style: none; display: flex; flex-direction: column; gap: 8px; }
ul.plain li { font-size: .87rem; color: #334155; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: .78rem; font-family: ui-monospace, Menlo, monospace; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input[type=text], .filters select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .84rem;
  font-family: inherit;
}
.status-dots { display: flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }
.dot.off { background: #cbd5e1; }

.detail-grid { display: grid; grid-template-columns: 220px 1fr; gap: 6px 14px; font-size: .88rem; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { font-weight: 600; }

/* Автотесты */
.tests-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 1.05rem;
}
.tests-summary.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.tests-summary.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* Подсказки */
.hint {
  background: #fff6ee;
  border: 1px solid #fbe0cb;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  margin-bottom: 4px;
  overflow: hidden;
}
.hint summary {
  cursor: pointer;
  padding: 13px 18px;
  font-size: .9rem;
  font-weight: 700;
  color: #9a3407;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(247,86,27,.045);
}
.hint summary::-webkit-details-marker { display: none; }
.hint summary:after { content: '▾'; margin-left: auto; color: #f3a26e; font-weight: 700; }
.hint[open] summary:after { content: '▴'; }
.hint-ico { color: var(--primary); font-size: .72rem; }
.hint-body {
  padding: 14px 20px 18px 42px;
  font-size: .88rem;
  color: #4d3b2e;
  border-top: 1px dashed #f3cba8;
  line-height: 1.6;
}
.hint-body p { margin: 8px 0 8px; }
.hint-body ul, .hint-body ol { list-style: none; padding-left: 0; margin-bottom: 8px; }
.hint-body li { margin-bottom: 7px; padding-left: 18px; position: relative; }
.hint-body li:before { content: '•'; position: absolute; left: 0; color: var(--primary); font-weight: 800; }
.hint-body code { background: #ffe0c4; color: #7c2c04; }
.hint-body .hint-flag { color: #991b1b; font-weight: 700; }

/* Тултип на наведении */
.tt {
  position: relative;
  border-bottom: 1px dashed #f2a06a;
  cursor: help;
  font-weight: 700;
  color: #b03a0f;
}
.tt:after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: 140%;
  transform: translate(-50%, 6px);
  z-index: 60;
  background: var(--navy);
  color: #e6e9f5;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .75rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  width: 250px;
  box-shadow: 0 10px 26px rgba(12,19,45,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.tt:after:empty { display: none; }
.tt:hover:after, .tt:focus:after {
  opacity: 1;
  transform: translate(-50%, 0);
}
.tt:hover { color: var(--primary-dark); }
.tt.tt-flip:after { left: auto; right: 0; transform: translateY(6px); }
.tt.tt-flip:hover:after, .tt.tt-flip:focus:after { transform: translateY(0); }

/* Раскрытие строк таблицы */
tr.exp-tr { cursor: pointer; }
.tr-toggle {
  display: inline-block;
  width: 20px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
  transition: transform .15s ease;
}
tr.exp-tr.open .tr-toggle { transform: rotate(90deg); color: var(--primary); }
tr.exp-body { display: none; }
tr.exp-body > td { background: #f8fafc; border-bottom: 1px solid var(--border); }
.exp-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 6px 16px;
  font-size: .85rem;
  padding: 6px 8px 6px 28px;
}
.exp-grid dt { color: var(--muted); }
.exp-grid dd { font-weight: 600; margin: 0; }
.exp-wide { grid-column: 1 / -1; border-top: 1px dashed #e2e8f0; padding-top: 8px; }

/* Хинты внутри таблиц и схемы */
.mini-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: .8rem;
}
.mini-flow code { background: #ffe0c4; }

.mini-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px dashed #e2e8f0; }

/* Витрина 2ГИС — предпросмотр «как увидит покупатель» */
.vitrina {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  max-width: 420px;
  background: #fff;
}
.v-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e2b66, #273e93);
  color: #fff;
  font-size: .78rem;
}
.v-brand { letter-spacing: .01em; }
.v-stock {
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .74rem;
}
.v-stock.in { background: rgba(255,255,255,.16); color: #ffe08a; }
.v-stock.out { background: rgba(255,255,255,.14); color: #ffd0c4; }
.v-name { padding: 14px 16px 6px; font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.v-meta { padding: 0 16px; font-size: 1.05rem; font-weight: 800; color: #0c132d; }
.v-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: .88rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.v-btn:hover { background: var(--primary-dark); }
.v-foot { padding: 0 16px 14px; }
.vitrina:hover { box-shadow: 0 10px 30px rgba(247,86,27,.12); }

/* Диф «было → стало» */
.diff-from { color: #b91c1c; text-decoration: line-through; text-decoration-color: rgba(185,28,28,.5); }
.diff-to { color: #166534; font-weight: 700; }
.diff-arrow { color: var(--primary); font-weight: 800; margin: 0 2px; }

@media (max-width: 760px) {
  .vitrina { max-width: 100%; }
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .exp-grid { grid-template-columns: 1fr; }
  .tt:after { width: 200px; left: 0; transform: translate(0, 6px); }
  .tt:hover:after, .tt:focus:after { transform: translate(0, 0); }
}
/* Логин */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(247,86,27,.35), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(255,185,25,.22), transparent 55%),
    linear-gradient(150deg, #0c132d 0%, #1e2b66 70%, #2b3a7a 100%);
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 460px; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 34px 36px;
  box-shadow: 0 24px 60px rgba(7,12,30,.5);
}
.login-logo { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -.02em; }
.login-logo:before { content: ''; display: inline-block; width: 16px; height: 16px; border-radius: 4px; margin-right: 10px; background: linear-gradient(135deg, #ffb919, #f7561b 70%, #e33b1e); vertical-align: 2px; }
.login-sub { font-size: .84rem; color: var(--muted); margin-bottom: 20px; line-height: 1.55; }
.login-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.login-form label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: .92rem;
  font-family: inherit;
  margin-bottom: 10px;
}
.login-form .btn { padding: 10px; font-size: .9rem; font-weight: 800; }
.login-card .hint .hint-body { font-size: .8rem; }

/* Планшеты и узкие окна: широкие таблицы уже скроллятся панелью (.panel overflow-x) */

/* Мобильные */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; padding: 14px 14px 10px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar nav a { flex: 1 1 44%; text-align: center; padding: 7px 6px; font-size: .8rem; }
  .side-foot { display: none; }
  .logo-sub { margin-bottom: 12px; }

  .main { padding: 12px; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 1.15rem; }
  .userbox { flex-wrap: wrap; }

  .two-col { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .panel { padding: 14px; }

  .filters { flex-direction: column; align-items: stretch; }
  .filters .inline-form, .filters form { width: 100%; }
  .filters input[type=text], .filters select, .filters .btn, .filters a.btn { width: 100%; }
  .filters > div { margin-left: 0 !important; }

  table { min-width: 640px; }
  th, td { padding: 8px 8px; }
  td { white-space: normal; }

  .detail-grid { grid-template-columns: 1fr; }
  .exp-grid { grid-template-columns: 1fr 1fr; padding-left: 14px; }
  .exp-wide { grid-column: 1 / -1; }

  .tt:after { width: min(210px, 70vw); left: 50%; transform: translate(-50%, 6px); }
  .tt:hover:after, .tt:focus:after { transform: translate(-50%, 0); }

  .hint-body { padding: 12px 14px 16px 18px; }
  .hint summary { padding: 12px 14px; }

  .flow { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); align-self: flex-start; margin-left: 4px; }

  .login-card { padding: 26px 20px; }
  .tests-summary { flex-direction: column; gap: 6px; align-items: flex-start; }
}

@media (max-width: 430px) {
  .sidebar nav a { flex: 1 1 100%; }
  .metric-value { font-size: 1.4rem; }
}