/* =====================================================================
   Кабинет Продавана — стили интерфейса
   Темы: светлая (по умолчанию), тёмная — по системной настройке или
   переключателем (data-theme на <html>, см. theme.js).
   ===================================================================== */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --surface-3: #e6e8f2;
  --text: #16182b;
  --muted: #6b6f85;
  --border: #e4e6ef;
  --accent: #0b7d71;
  --accent-hover: #096a60;
  --accent-soft: #e3f5f2;
  --accent-text: #0a6f65;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #178a54;
  --ok-soft: #e5f6ed;
  --warn-bg: #fff5e2;
  --warn-text: #8a5800;
  --shadow-sm: 0 1px 2px rgba(22, 24, 43, .04), 0 2px 6px rgba(22, 24, 43, .05);
  --shadow-md: 0 10px 30px rgba(22, 24, 43, .10);
  --shadow-lg: 0 24px 64px rgba(22, 24, 43, .18);
  --radius: 16px;
  --radius-sm: 12px;
  --ozon: #005bff;
  --wildberries: #cb11ab;
  --yandex: #ffcc00;
  /* ряды графиков: слоты 1–2 проверенной категориальной палитры */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --hero-1: linear-gradient(135deg, #3d8bfd 0%, #2a62d6 55%, #4b3fd6 100%);
  --hero-2: linear-gradient(135deg, #ff9a5a 0%, #eb6834 60%, #d9483b 100%);
  --brand-gradient: linear-gradient(135deg, #0e8f82 0%, #0b7d71 50%, #096a60 100%);
  --grid: #eceef4;
  --axis: #c3c7d3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1016;
    --surface: #171a23;
    --surface-2: #1d2130;
    --surface-3: #262b3c;
    --text: #eceef6;
    --muted: #9196ad;
    --border: #2a2f41;
    --accent: #2cc4ae;
    --accent-hover: #4fd8c4;
    --accent-soft: #10302c;
    --accent-text: #4fd8c4;
    --danger: #ff6b6f;
    --danger-soft: #3a1c22;
    --ok: #3fcf8e;
    --ok-soft: #14302a;
    --warn-bg: #32260e;
    --warn-text: #f5cf7a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #252a39;
    --axis: #3d4356;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #171a23;
  --surface-2: #1d2130;
  --surface-3: #262b3c;
  --text: #eceef6;
  --muted: #9196ad;
  --border: #2a2f41;
  --accent: #2cc4ae;
  --accent-hover: #4fd8c4;
  --accent-soft: #10302c;
  --accent-text: #4fd8c4;
  --danger: #ff6b6f;
  --danger-soft: #3a1c22;
  --ok: #3fcf8e;
  --ok-soft: #14302a;
  --warn-bg: #32260e;
  --warn-text: #f5cf7a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #252a39;
  --axis: #3d4356;
  color-scheme: dark;
}

/* ---------- основа ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.placeholder { padding: 40px; color: var(--muted); }
.placeholder.error { color: var(--danger); }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- поля и кнопки ---------- */

input, select, textarea, button, summary { font: inherit; color: var(--text); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"],
input:not([type]), select, textarea {
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { padding-right: 32px; cursor: pointer; }

button, .button, summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, color .15s;
}
button:hover:not(:disabled), .button:hover, summary:hover { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary, a.button.primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(11, 125, 113, .28);
}
button.primary:hover:not(:disabled), a.button.primary:hover { filter: brightness(1.06); border-color: transparent; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

button.link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: none;
}
button.link:hover:not(:disabled) { text-decoration: underline; border: 0; }
button.link.danger-link { color: var(--danger); }

.icon-button, .theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.icon-button:hover, .theme-toggle:hover { color: var(--text); }
.mobile-only { display: none !important; }

/* ---------- каркас: боковое меню + рабочая область ---------- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--text);
  text-decoration: none;
}
.logo-mark { width: 36px; height: 36px; border-radius: 11px; flex: none; box-shadow: 0 6px 16px rgba(11, 125, 113, .3); }
.logo-text { font-size: 15px; font-weight: 750; line-height: 1.15; letter-spacing: -0.01em; }

.tabs { display: flex; flex-direction: column; gap: 4px; }
.tabs a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); color: var(--accent-text); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
}
.account-email { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: flex; gap: 8px; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar { display: flex; flex-direction: column; gap: 16px; padding: 24px 28px 14px; }
.page-head { display: flex; align-items: baseline; gap: 14px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
#last-sync { font-size: 13px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { position: relative; flex: 1 1 260px; max-width: 380px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }

.sync-line { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.auto-sync { max-width: 380px; line-height: 1.35; }
.auto-sync:empty { display: none; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 15;
  min-width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.menu-body a { padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; }
.menu-body a:hover { background: var(--surface-2); }

.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border-radius: 12px; }
.segmented button {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.segmented button:hover:not(:disabled) { color: var(--text); border: 0; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.period-nav { display: inline-flex; align-items: center; gap: 6px; }
.period-nav > button:not(#fin-today) { width: 40px; padding: 0; font-size: 18px; }
.period-label { min-width: 170px; text-align: center; font-weight: 700; }

.banner {
  margin: 0 28px 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 13px;
}
.banner > div + div { margin-top: 4px; }
.banner a { color: inherit; font-weight: 700; }

/* ---------- доска ---------- */

.board {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(272px, 1fr);
  gap: 16px;
  padding: 4px 28px 24px;
  overflow-x: auto;
  min-height: 0;
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 18px;
  transition: border-color .15s, background .15s, opacity .15s;
}
.column-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; }
.column-head::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.stage-new .column-head::before { background: var(--accent); }
.stage-assembly .column-head::before { background: #f59e0b; }
.stage-ready .column-head::before { background: #6366f1; }
.stage-shipping .column-head::before { background: #3b82f6; }
.stage-done .column-head::before { background: var(--ok); }
.stage-cancelled .column-head::before { background: var(--danger); }
.column-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.column-head .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.column-head .sum { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }

.column-body { flex: 1; overflow-y: auto; padding: 2px 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.column .empty { padding: 24px 0; color: var(--muted); font-size: 13px; text-align: center; }
.column .more { height: 34px; border-style: dashed; background: transparent; color: var(--accent-text); }

.column.drop-local, .column.drop-remote { border-style: dashed; }
.column.drop-local { border-color: var(--axis); }
.column.drop-remote { border-color: var(--accent); background: var(--accent-soft); }
.column.drop-forbidden, .column.drop-disabled { opacity: .42; }
.column.drop-over { border-style: solid; border-color: var(--accent); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px 12px 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
}
.card::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--muted); }
.card.mp-ozon::before { background: var(--ozon); }
.card.mp-wildberries::before { background: var(--wildberries); }
.card.mp-yandex::before { background: var(--yandex); }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.locked { cursor: pointer; }
.card.dragging { opacity: .45; }
.card.pending { opacity: .6; pointer-events: none; }
.card.pending::after { content: "выполняется…"; font-size: 11px; color: var(--muted); }

.card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.badge, .mp-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--muted);
}
.card.mp-ozon .badge, .mp-badge.mp-ozon { background: var(--ozon); }
.card.mp-wildberries .badge, .mp-badge.mp-wildberries { background: linear-gradient(135deg, #cb11ab, #8a1fe0); }
.card.mp-yandex .badge, .mp-badge.mp-yandex { background: var(--yandex); color: #1c1f24; }
.card .number { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .tag {
  flex: none;
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}
.card .tag + .tag { margin-left: 0; }
.card .article, .card .store-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .store-name { font-size: 12px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.card-meta > span:first-child { color: var(--text); font-weight: 700; font-size: 13px; }
.card .status { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.onboarding { grid-column: 1 / -1; margin: auto; max-width: 440px; padding: 40px 16px; text-align: center; }
.onboarding h2 { margin: 0 0 8px; font-size: 22px; }
.onboarding p { margin: 0 0 20px; }

/* ---------- диалоги ---------- */

dialog {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(14, 16, 28, .5); backdrop-filter: blur(3px); }
dialog.wide { width: min(680px, calc(100vw - 32px)); }
dialog h2 { margin: 0 0 14px; font-size: 19px; font-weight: 750; }
dialog h3 { margin: 18px 0 10px; font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 20px 0 0; }
.warn { padding: 8px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-size: 13px; }
.warn.small { margin: 10px 0 0; font-size: 12px; }

#card-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
#card-fields dt { color: var(--muted); }
#card-fields dd { margin: 0; word-break: break-word; }
.moves { display: flex; flex-wrap: wrap; gap: 8px; }
.moves h3, .moves p { flex-basis: 100%; margin-bottom: 0; }

.card-docs { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--border); }
.docs { display: flex; flex-direction: column; gap: 8px; }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comment { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.comment-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.comment-meta button.link { padding: 0; min-height: 0; }
.comment-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.comment-form textarea { flex: 1; min-width: 0; resize: vertical; font: inherit; }
.doc { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; }
.doc-preview {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
}
.doc-preview img { width: 100%; height: 100%; object-fit: cover; }
.doc-icon { font-size: 12px; font-weight: 700; color: var(--accent-text); }
.doc-meta { display: flex; flex-direction: column; min-width: 0; }
.doc-meta a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.doc-delete { width: 36px; height: 36px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 15px; }
.doc-delete:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- уведомления ---------- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 12px 14px 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in .2s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- финансы ---------- */

.finance { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 4px 28px 28px; overflow-y: auto; min-height: 0; }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.warn-notice { background: var(--warn-bg); color: var(--warn-text); }
.warn-notice .link { color: inherit; font-weight: 700; }
.coverage { font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.kpi-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { margin-top: 4px; font-size: 22px; font-weight: 750; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-sub { margin-top: 2px; font-size: 12px; }
.kpi.hero { grid-column: span 2; position: relative; overflow: hidden; color: #fff; padding: 20px 22px; }
.kpi.hero::after { content: ""; position: absolute; right: -40px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.kpi.hero.series-1 { background: var(--hero-1); }
.kpi.hero.series-2 { background: var(--hero-2); }
.kpi.hero .kpi-title, .kpi.hero .kpi-sub { color: rgba(255, 255, 255, .85); }
.kpi.hero .kpi-value { font-size: 32px; }

.panel { padding: 18px 20px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-sm); }
.panel h2 { margin: 0 0 12px; font-size: 16px; font-weight: 750; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.blank { background: transparent; }

.chart-box { position: relative; width: 100%; overflow: hidden; }
.chart-svg { display: block; max-width: 100%; height: auto; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis-zero { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .hover-band { fill: var(--text); opacity: .05; }
.chart-tip {
  position: absolute;
  min-width: 210px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  pointer-events: none;
}
.tip-title { margin-bottom: 4px; font-weight: 700; }
.tip-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 6px; }
.tip-row strong, .tip-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.table-view { margin-top: 10px; }
.table-view summary { height: auto; padding: 4px 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

.tax-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.tax-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.tax-row input { width: 110px; }
#costs-search { width: 100%; margin: 6px 0; }
.only-missing { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.costs-table-wrap { max-height: 50vh; overflow-y: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 14px; }
.costs-table th { position: sticky; top: 0; background: var(--surface); }
.costs-table input { width: 120px; text-align: right; }

/* ---------- магазины ---------- */

.settings { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 4px 28px 28px; overflow-y: auto; min-height: 0; max-width: 1200px; }
.stores-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.stores-head p { margin: 0; }

.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.store-card { display: flex; flex-direction: column; gap: 10px; }
.store-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.store-card-head h2 { margin: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-status { margin: 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; background: var(--surface-2); }
.store-status.ok { background: var(--ok-soft); color: var(--ok); }
.store-status.error { background: var(--danger-soft); color: var(--danger); }
.store-status.warn { background: var(--warn-bg); color: var(--warn-text); }
.store-status.off, .store-status.pending { color: var(--muted); }
.store-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; }
.store-actions .danger-link { margin-left: auto; }

.onboarding-panel { padding: 28px; }
.onboarding-panel h2 { margin: 0 0 6px; font-size: 20px; }

.mp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 16px 0 0; }
.mp-tile {
  height: auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px;
  border-radius: var(--radius);
  text-align: left;
  white-space: normal;
}
.mp-tile::before { content: ""; width: 36px; height: 36px; margin-bottom: 8px; border-radius: 11px; background: var(--muted); }
.mp-tile.mp-ozon::before { background: var(--ozon); }
.mp-tile.mp-wildberries::before { background: linear-gradient(135deg, #cb11ab, #8a1fe0); }
.mp-tile.mp-yandex::before { background: var(--yandex); }
.mp-tile:hover:not(:disabled) { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.mp-tile-title { font-size: 16px; font-weight: 750; }

.settings-card .panel-head { align-items: center; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

#dlg-store { width: min(820px, calc(100vw - 32px)); }
.wizard h2 { margin: 0 0 4px; }
.wizard > p { margin: 0 0 12px; }
.wizard-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; margin-top: 10px; }
.wizard-fields { display: flex; flex-direction: column; gap: 14px; }
.wizard-help { padding: 16px 18px; border-radius: 16px; background: var(--accent-soft); font-size: 13px; }
.wizard-help h3 { margin: 0 0 8px; color: var(--accent-text); text-transform: none; letter-spacing: 0; font-size: 14px; }
.wizard-help ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.wizard-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.wizard fieldset { margin: 0; padding: 0; border: 0; }
.radio, .checkbox { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.radio input, .checkbox input { accent-color: var(--accent); width: 16px; height: 16px; }
.campaigns { display: flex; flex-direction: column; max-height: 200px; overflow-y: auto; }
.form-error { min-height: 1em; margin: 10px 0 0; color: var(--danger); font-size: 13px; white-space: pre-wrap; }

/* ---------- вход и регистрация ---------- */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--bg);
}
.auth-promo {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 56px;
  color: #fff;
  background:
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, .18) 0, transparent 38%),
    radial-gradient(circle at 10% 90%, rgba(255, 154, 90, .35) 0, transparent 40%),
    linear-gradient(140deg, #12a594 0%, #0b7d71 45%, #063f3a 100%);
}
.auth-promo .logo { color: #fff; padding: 0; }
.auth-promo .logo-mark { box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.auth-promo h2 { margin: 0; max-width: 480px; font-size: 36px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.auth-promo ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; max-width: 460px; font-size: 15px; }
.auth-promo li { position: relative; padding-left: 32px; color: rgba(255, 255, 255, .88); }
.auth-promo li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  font-size: 12px;
  font-weight: 700;
}
.auth-promo b { color: #fff; }

.auth-side { position: relative; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.auth-side > .theme-toggle { position: absolute; top: 16px; right: 16px; }
.auth-card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.auth-card p { margin: 0; font-size: 13px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-card input { height: 46px; font-size: 15px; }
.auth-card button[type="submit"] { height: 46px; font-size: 15px; }
.auth-logo { display: none; padding: 0; }
.auth-tabs { width: 100%; }
.auth-tabs button { flex: 1; }
.auth-error { min-height: 1em; color: var(--danger); }
.auth-info { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }

/* ---------- пользователи (администратор) ---------- */

.tabs a { position: relative; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.nav-badge[hidden] { display: none; }
.count-pill {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}
.user-list { display: flex; flex-direction: column; }
.user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.user-row:first-child { border-top: 0; }
.user-main { min-width: 0; }
.user-login { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 650; overflow-wrap: anywhere; }
.role-tag { padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; font-weight: 700; }
.role-tag.muted-tag { background: var(--surface-2); color: var(--muted); }
.user-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ---------- планшет и телефон ---------- */

@media (max-width: 1100px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; align-items: center; }
  .logo { padding: 0; }
  .logo-text, .tabs a span, .account-email { display: none; }
  .tabs a { justify-content: center; padding: 12px; }
  .nav-badge { position: absolute; top: 2px; right: 2px; margin: 0; }
  .sidebar-foot { padding: 12px 0 0; align-items: center; }
  .sidebar-actions { flex-direction: column; }
  .auth-promo { padding: 40px; }
  .auth-promo h2 { font-size: 30px; }
}

@media (max-width: 760px) {
  .app { display: block; height: auto; min-height: 100dvh; }
  .workspace { min-height: 100dvh; overflow: visible; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* боковое меню превращается в нижнюю панель, как в мобильном приложении */
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    flex-direction: row;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(22, 24, 43, .06);
  }
  .sidebar .logo, .sidebar-foot { display: none; }
  .tabs { flex-direction: row; width: 100%; gap: 4px; }
  .tabs a { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; }
  .tabs a span { display: inline; }
  .tabs a .icon { width: 22px; height: 22px; }
  .nav-badge { right: calc(50% - 24px); min-width: 18px; height: 18px; font-size: 10px; }
  .user-row { grid-template-columns: auto minmax(0, 1fr); }
  .user-actions { grid-column: 1 / -1; justify-content: flex-start; }

  .topbar { padding: 16px 14px 10px; gap: 12px; position: sticky; top: 0; z-index: 10; background: var(--bg); }
  .page-head { align-items: center; }
  .page-head h1 { font-size: 24px; }
  #last-sync { display: none; }
  .mobile-only { display: inline-flex !important; margin-left: auto; }

  .controls { gap: 8px; }
  .search { flex: 1 1 100%; max-width: none; }
  .controls select { flex: 1 1 0; min-width: 0; }
  .sync-line { margin-left: 0; width: 100%; }
  .auto-sync { max-width: none; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 0 4px; }
  .period-nav { width: 100%; justify-content: space-between; }
  .period-label { flex: 1; min-width: 0; }
  #fin-costs { flex: 1 1 auto; }

  .banner { margin: 0 14px 10px; font-size: 12px; }

  .board {
    flex: none; /* иначе flex: 1 растягивает доску на всю высоту карточек */
    height: calc(100dvh - 360px - env(safe-area-inset-bottom));
    min-height: 360px;
    grid-auto-columns: 86vw;
    gap: 12px;
    padding: 4px 14px 16px;
    scroll-snap-type: x mandatory;
  }
  .column { scroll-snap-align: center; }

  .finance, .settings { padding: 4px 14px 20px; overflow: visible; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 18px; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi.hero .kpi-value { font-size: 28px; }
  .panel { padding: 16px; }
  .store-grid { grid-template-columns: 1fr; }

  dialog, dialog.wide, #dlg-store { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 18px; border-radius: 20px; }
  .wizard-body { grid-template-columns: 1fr; }
  .wizard-help { order: -1; }
  .moves button, .doc-actions button, .wizard-actions button, .store-actions button:not(.link) { flex: 1 1 auto; min-height: 42px; }
  .doc-delete { width: 42px; height: 42px; }
  input, select, textarea { font-size: 16px; } /* iOS не приближает страницу при вводе */

  .auth-screen { grid-template-columns: 1fr; }
  .auth-promo { display: none; }
  .auth-side { align-items: flex-start; padding: 64px 16px 24px; }
  .auth-card { padding: 24px; }
  .auth-logo { display: flex; }
  .toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: none; }
}
