/* Yamarker Dashboard — базовый UX-стиль (system fonts, spacing scale 4px). */

:root {
  --c-bg:         #f4f6fa;
  --c-panel:      #ffffff;
  --c-panel-alt:  #fafbfc;
  --c-border:     #e4e7ed;
  --c-border-str: #d0d4dc;
  --c-text:       #1a2233;
  --c-text-sub:   #556072;
  --c-muted:      #6c7788; /* было #8993a4 — контраст поднят до WCAG AA */

  --c-brand:      #2166cf;
  --c-brand-dk:   #1a4e9c;
  --c-brand-bg:   #eaf1fc;

  --c-ok:         #1e9e51;
  --c-ok-bg:      #e6f6ec;
  --c-warn:       #cc7a00;
  --c-warn-bg:    #fdf3e0;
  --c-err:        #d13f43;
  --c-err-bg:     #fceaeb;

  --shadow-sm: 0 1px 2px rgba(20,30,55,0.05);
  --shadow-md: 0 2px 8px rgba(20,30,55,0.06), 0 1px 3px rgba(20,30,55,0.04);
  --radius: 8px;
  --radius-sm: 4px;

  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-dk); text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.85rem; color: var(--c-text); letter-spacing: -0.005em; }
.muted { color: var(--c-text-sub); }
.nowrap { white-space: nowrap; }

/* ===== SVG icons ===== */
.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -3px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 32px; height: 32px; }
.icon-hero { width: 56px; height: 56px; stroke-width: 1.75; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.55rem 1.5rem;
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-sm);
  min-height: var(--topbar-h);
}
/* компактные admin-статусы: cookies + region — в топбаре справа */
.admin-status { display: flex; gap: 0.25rem; align-items: center; }
.admin-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.65rem; color: var(--c-text-sub);
  border-radius: var(--radius-sm); text-decoration: none;
  border: 1px solid var(--c-border); background: var(--c-panel);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-size: 0.85rem;
}
.admin-chip:hover { color: var(--c-text); background: var(--c-panel-alt); text-decoration: none; }
.admin-chip.active { color: var(--c-brand); background: var(--c-brand-bg); border-color: var(--c-brand-bg); }
a.brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.05rem; color: var(--c-brand);
  text-decoration: none;
}
a.brand:hover { text-decoration: none; }

.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--c-text-sub); text-decoration: none;
  padding: 0.55rem 0.85rem; border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
  min-height: 40px;
}
.topbar nav a:hover { color: var(--c-text); background: var(--c-panel-alt); text-decoration: none; }
.topbar nav a.active { color: var(--c-brand); background: var(--c-brand-bg); font-weight: 500; }

.userbox { display: flex; gap: 0.75rem; align-items: center; color: var(--c-muted); font-size: 0.88rem; }
.userbox .email { color: var(--c-text-sub); }

/* ===== Layout ===== */
.content { max-width: 1400px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }

/* ===== Cards (stat) ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--c-border-str);
}
.card.ok::before   { background: var(--c-ok); }
.card.warn::before { background: var(--c-warn); }
.card.err::before  { background: var(--c-err); }
.card.brand::before{ background: var(--c-brand); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.card-label { color: var(--c-text-sub); font-size: 0.92rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.card-icon { color: var(--c-muted); }
.card.ok .card-icon   { color: var(--c-ok); }
.card.warn .card-icon { color: var(--c-warn); }
.card.err .card-icon  { color: var(--c-err); }
.card.brand .card-icon{ color: var(--c-brand); }

.card-value { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; color: var(--c-text); margin-top: 0.15rem; }
.card-sub { font-size: 0.95rem; color: var(--c-text-sub); margin-top: 0.4rem; }
.card-sub a { color: var(--c-brand); font-weight: 500; }

/* progress bar внутри карточки */
.progress { height: 6px; background: var(--c-border); border-radius: 999px; overflow: hidden; margin-top: 0.6rem; }
.progress > span { display: block; height: 100%; background: var(--c-brand); transition: width 0.4s ease; }
.progress.ok > span   { background: var(--c-ok); }
.progress.warn > span { background: var(--c-warn); }
.progress.err > span  { background: var(--c-err); }

/* ===== Panel ===== */
.panel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-head .tools { display: flex; gap: 0.5rem; align-items: center; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
/* sticky-заголовки требуют убрать overflow с ближайшего скроллируемого контейнера */
.table-wrap.sticky-thead { overflow-x: visible; overflow-y: visible; border: 1px solid var(--c-border); }
@media (max-width: 900px) {
  .table-wrap.sticky-thead { overflow-x: auto; }
}
.table { width: 100%; border-collapse: collapse; background: var(--c-panel); }
.table th, .table td {
  padding: 0.62rem 0.75rem; border-bottom: 1px solid var(--c-border);
  text-align: left; vertical-align: middle;
}
.table thead th {
  background: var(--c-panel-alt);
  font-weight: 600; color: var(--c-text-sub);
  font-size: 0.88rem; text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--c-border-str);
}
/* sticky thead под topbar */
.sticky-thead thead th {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  box-shadow: 0 1px 0 var(--c-border-str);
}
.table tbody tr:hover { background: var(--c-panel-alt); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.table.small th, .table.small td { padding: 0.4rem 0.6rem; font-size: 0.88em; }
.table td.name { max-width: 380px; }
.table td.ellipsis { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Sortable header */
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--c-brand); }
.table th.sortable::after { content: '↕'; opacity: 0.35; margin-left: 0.35rem; font-size: 0.75em; }
.table th.sort-asc::after  { content: '↑'; opacity: 1; color: var(--c-brand); }
.table th.sort-desc::after { content: '↓'; opacity: 1; color: var(--c-brand); }

/* ===== Forms ===== */
label { display: block; margin-bottom: 0.85rem; font-size: 0.88rem; color: var(--c-text-sub); }
label > input, label > select, textarea, input.field {
  display: block; width: 100%; padding: 0.55rem 0.7rem;
  border: 1px solid var(--c-border-str); border-radius: var(--radius-sm);
  font: inherit; margin-top: 0.3rem; background: var(--c-panel);
  color: var(--c-text); transition: border-color 0.12s, box-shadow 0.12s;
}
label > input:focus, textarea:focus, input.field:focus {
  outline: none; border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(33,102,207,0.12);
}
textarea { font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; font-size: 0.85rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border: 1px solid var(--c-border-str);
  background: var(--c-panel); border-radius: var(--radius-sm);
  cursor: pointer; font: inherit; color: var(--c-text);
  transition: background 0.12s, border-color 0.12s;
  min-height: 40px; text-decoration: none;
}
.btn:hover { background: var(--c-panel-alt); border-color: var(--c-muted); text-decoration: none; }
.btn.btn-primary { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.btn.btn-primary:hover { background: var(--c-brand-dk); border-color: var(--c-brand-dk); color: #fff; }
.btn.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-sub); }
.btn.btn-ghost:hover { background: var(--c-panel-alt); color: var(--c-text); }
.btn.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; min-height: 32px; }
.btn.btn-danger { color: var(--c-err); border-color: var(--c-err); background: var(--c-panel); }
.btn.btn-danger:hover { color: #fff; background: var(--c-err); border-color: var(--c-err); }

.btn-link { border: none; background: none; color: var(--c-brand); cursor: pointer; padding: 0; font: inherit; }
.btn-link:hover { text-decoration: underline; }

.row { display: flex; gap: 0.85rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ===== Search input ===== */
.search {
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--c-border-str); background: var(--c-panel);
  border-radius: var(--radius-sm); padding: 0 0.7rem;
  min-width: 220px; transition: border-color 0.12s, box-shadow 0.12s;
}
.search:focus-within { border-color: var(--c-brand); box-shadow: 0 0 0 3px rgba(33,102,207,0.12); }
.search .icon { color: var(--c-muted); }
.search input {
  border: none; outline: none; padding: 0.5rem 0; background: transparent;
  font: inherit; flex: 1; color: var(--c-text); min-height: 36px;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; border: 1px solid; display: flex; gap: 0.6rem; align-items: flex-start;
}
.alert-ok    { border-color: var(--c-ok);   background: var(--c-ok-bg);   color: #12572d; }
.alert-warn  { border-color: var(--c-warn); background: var(--c-warn-bg); color: #7a4700; }
.alert-error { border-color: var(--c-err);  background: var(--c-err-bg);  color: #7a1e21; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  border: 1px solid transparent;
  white-space: nowrap;
}
/* Full-width для страниц со списком товаров */
body.wide .content { max-width: 100%; padding-left: 1.5rem; padding-right: 1.5rem; }

/* Кнопка "Войти с Яндекс ID" — фирменный стиль Yandex ID */
.btn-yandex {
  display: inline-flex; align-items: center;
  background: #000; color: #fff !important; border: 0;
  padding: 0.85rem 1.25rem; border-radius: 12px;
  font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-yandex:hover {
  background: #1a1a1a;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.btn-yandex:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.btn-yandex .yid-logo {
  width: 24px; height: 24px; margin-right: 0.7rem; flex-shrink: 0;
}
/* Легенда бэйджей под фильтрами */
.badge-legend {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.75rem 1rem; background: var(--c-panel);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-size: 0.88rem; color: var(--c-text-sub); margin-bottom: 1rem;
}
.badge-legend .badge { margin-right: 0.15rem; }
/* Счётчик в chip-фильтре */
.chip-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 0.4rem;
  border-radius: 999px; background: var(--c-panel-alt); color: var(--c-text-sub);
  font-size: 0.78rem; font-weight: 600; margin-left: 0.25rem;
}
.filters a.active .chip-count { background: rgba(255,255,255,0.25); color: #fff; }
.badge.ok   { background: var(--c-ok-bg);   color: #12572d; border-color: #b4e0c2; }
.badge.warn { background: var(--c-warn-bg); color: #7a4700; border-color: #f0d19a; }
.badge.err  { background: var(--c-err-bg);  color: #7a1e21; border-color: #f0b5b7; }
.badge.muted{ background: var(--c-panel-alt); color: var(--c-text-sub); border-color: var(--c-border); }

/* ===== Filters chip list ===== */
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.filters a, .filters button {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.85rem; border: 1px solid var(--c-border-str);
  border-radius: 999px; text-decoration: none;
  color: var(--c-text-sub); background: var(--c-panel);
  cursor: pointer; font: inherit; min-height: 34px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.filters a:hover { background: var(--c-panel-alt); color: var(--c-text); text-decoration: none; }
.filters a.active { color: #fff; background: var(--c-brand); border-color: var(--c-brand); }
.filters a.active:hover { background: var(--c-brand-dk); }

/* ===== KV list ===== */
.kv { list-style: none; padding: 0; margin: 0; }
.kv li {
  padding: 0.5rem 0; border-bottom: 1px dashed var(--c-border);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.kv li:last-child { border: none; }
.kv li span:first-child { color: var(--c-muted); font-size: 0.88rem; }
.kv li strong { font-weight: 600; }

/* ===== Chart ===== */
.chart-wrap { position: relative; height: 280px; margin-bottom: 0.75rem; }
.chart-wrap.tall { height: 340px; }
.chart-wrap.short { height: 200px; }

/* ===== Status hero — большой светофор наверху экрана ===== */
.status-hero {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1.5rem 1.75rem; border-radius: var(--radius);
  background: var(--c-panel); border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm); margin-bottom: 1.5rem;
}
.status-hero.ok  { background: linear-gradient(90deg, var(--c-ok-bg), var(--c-panel) 70%); border-color: #b4e0c2; }
.status-hero.err { background: linear-gradient(90deg, var(--c-err-bg), var(--c-panel) 70%); border-color: #f0b5b7; }
.status-hero.warn{ background: linear-gradient(90deg, var(--c-warn-bg), var(--c-panel) 70%); border-color: #f0d19a; }
.status-hero .ic { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--c-panel-alt); flex-shrink: 0; }
.status-hero.ok .ic  { background: var(--c-ok);  color: #fff; }
.status-hero.err .ic { background: var(--c-err); color: #fff; }
.status-hero.warn .ic{ background: var(--c-warn);color: #fff; }
.status-hero .ic .icon { stroke: #fff; width: 36px; height: 36px; }
.status-hero .body h1 { margin: 0 0 0.3rem; font-size: 1.5rem; letter-spacing: -0.01em; }
.status-hero .body .sub { color: var(--c-text-sub); font-size: 1rem; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0.15rem; border-bottom: 1px solid var(--c-border); margin-bottom: 1rem; }
.tabs button, .tabs a {
  background: transparent; border: none; padding: 0.65rem 1rem;
  font: inherit; color: var(--c-text-sub); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none;
}
.tabs button:hover, .tabs a:hover { color: var(--c-text); }
.tabs button.active, .tabs a.active { color: var(--c-brand); border-bottom-color: var(--c-brand); font-weight: 500; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Login ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(180deg, var(--c-bg), #e6ecf5);
}
.login-card {
  background: var(--c-panel); padding: 2rem 2.25rem;
  border-radius: var(--radius); border: 1px solid var(--c-border);
  max-width: 360px; width: 92%; box-shadow: var(--shadow-md);
}
.login-card h1 { margin: 0; color: var(--c-brand); font-size: 1.55rem; text-align: center; }
.login-card .subtitle { color: var(--c-muted); margin: 0.35rem 0 1.5rem; text-align: center; }

/* ===== Empty state ===== */
.empty {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--c-muted);
}
.empty .icon { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 0.75rem; }
.empty p { margin: 0.3rem 0; }

/* ===== Tooltip (native) ===== */
[title] { position: relative; }

/* Responsive tweaks */
@media (max-width: 900px) {
  .topbar { padding: 0.5rem 1rem; gap: 0.5rem; }
  .topbar nav { overflow-x: auto; }
  .topbar nav a span:not(.icon) { display: none; }
  .content { padding: 1rem; }
  .userbox .email { display: none; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head .tools { justify-content: flex-start; }
}

/* Small utility */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
