*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { width: 100%; -webkit-text-size-adjust: 100%; }

:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #666;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success-bg: #f0fdf4;
    --success-border: #86efac;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    --warning-bg: #fffbeb;
    --warning-border: #fcd34d;
    --wb-color: #6366f1;
    --ozon-color: #f97316;
    --zero-color: #dc2626;
    --low-color: #d97706;
}

body { width: 100%; min-width: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       font-size: 14px; background: var(--bg); color: var(--text); }

/* NAV */
nav { display: flex; align-items: center; gap: 16px; background: var(--surface);
      border-bottom: 1px solid var(--border); padding: 0 18px; min-height: 52px; height: auto;
      position: sticky; top: 0; z-index: 100; }
.nav-brand { min-width: 0; flex-shrink: 0; font-weight: 700; font-size: 16px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.nav-seller { font-size: 12px; font-weight: 500; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }
.nav-links { display: flex; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; }
.nav-links a { padding: 6px 9px; border-radius: 6px; color: var(--text-muted);
               font-size: 13px; text-decoration: none; transition: background .15s; }
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--bg); color: var(--primary); font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }
.nav-mobile { display: none; }

/* MAIN */
main { width: 100%; min-width: 0; padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 600; }
.count { color: var(--text-muted); font-weight: 400; font-size: 15px; }
.empty { color: var(--text-muted); padding: 32px 0; }

/* ALERTS */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: #166534; }
.alert-error   { background: var(--error-bg);   border: 1px solid var(--error-border);   color: #991b1b; }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); color: #92400e; }

/* TABLE */
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--surface);
        border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600;
     font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
     border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.text-right { text-align: right; }

/* TABLE CELLS */
.td-photo { width: 60px; }
.td-mono { font-family: monospace; font-size: 13px; color: var(--text-muted); }
.td-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.td-qty { font-weight: 600; font-size: 15px; }
.td-reason { font-size: 12px; color: var(--text-muted); max-width: 280px; }
.td-set-stock { width: 200px; }

/* PRODUCT PHOTO */
.product-photo { width: 48px; height: 48px; object-fit: cover; border-radius: 4px;
                 border: 1px solid var(--border); }
.no-photo { width: 48px; height: 48px; background: var(--bg); border-radius: 4px;
            display: flex; align-items: center; justify-content: center;
            color: var(--text-muted); font-size: 11px; border: 1px solid var(--border); }
.product-name { font-weight: 500; margin-bottom: 4px; }
.photo-form { display: flex; gap: 4px; margin-top: 4px; }
.input-photo { flex: 1; font-size: 11px; padding: 3px 6px; border: 1px solid var(--border);
               border-radius: 4px; color: var(--text-muted); min-width: 0; }
.warehouse-photo-editor { display: none; }

/* STOCK COLORS */
.qty-zero { color: var(--zero-color) !important; }
.qty-low  { color: var(--low-color)  !important; }
.delta-neg { color: var(--zero-color); }
.delta-pos { color: #16a34a; }

/* BADGES */
.badge { display: inline-block; padding: 2px 8px; border-radius: 9999px;
         font-size: 11px; font-weight: 600; background: var(--bg); color: var(--text-muted); }
.badge-wb    { background: #ede9fe; color: var(--wb-color); }
.badge-ozon  { background: #fff7ed; color: var(--ozon-color); }
.badge-admin { background: #eff6ff; color: var(--primary); }
.badge-uninitialized { background: #fef2f2; color: var(--danger); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 6px;
       border: 1px solid var(--border); background: var(--surface); cursor: pointer;
       font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text);
       transition: background .15s; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--error-bg); }
.btn-logout { padding: 4px 10px; font-size: 12px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }

/* FORMS */
.stock-form { display: flex; gap: 6px; align-items: center; }
.input-qty { width: 80px; padding: 5px 8px; border: 1px solid var(--border);
             border-radius: 6px; font-size: 14px; text-align: right; }
.td-inventory-actions { min-width: 235px; }
.td-inventory-actions details { display: inline-block; vertical-align: top; margin: 2px 4px 2px 0; }
.td-inventory-actions summary { list-style: none; }
.td-inventory-actions summary::-webkit-details-marker { display: none; }
.inventory-form { position: absolute; z-index: 40; width: 280px; margin-top: 6px;
                  padding: 12px; border: 1px solid var(--border); border-radius: 8px;
                  background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.inventory-form-opening { position: static; width: auto; margin-top: 0; box-shadow: none; }
.inventory-form label { display: block; margin-bottom: 8px; font-size: 12px;
                        color: var(--text-muted); }
.inventory-form input { display: block; width: 100%; margin-top: 3px; padding: 6px 8px;
                        border: 1px solid var(--border); border-radius: 6px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500;
                    margin-bottom: 4px; color: var(--text-muted); }
.form-group input[type=text],
.form-group input[type=password] {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-check label { display: flex; align-items: center; gap: 8px; font-weight: 400; }

/* CARD */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
        padding: 20px; margin-bottom: 24px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.form-inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }
.form-inline-sm { display: flex; gap: 6px; align-items: center; }
.form-inline-sm input { padding: 4px 8px; border: 1px solid var(--border);
                        border-radius: 6px; font-size: 13px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 8px 16px; border-radius: 6px 6px 0 0; font-size: 13px; font-weight: 500;
       color: var(--text-muted); text-decoration: none; border: 1px solid transparent;
       border-bottom: none; position: relative; bottom: -1px; }
.tab:hover { color: var(--text); background: var(--bg); }
.tab-active { color: var(--primary); background: var(--surface);
              border-color: var(--border); border-bottom-color: var(--surface); }

/* FORM GRID */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* TOOLTIP */
.tip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--border); color: var(--text-muted);
    font-size: 10px; font-weight: 700; font-style: normal;
    cursor: help; position: relative; margin-left: 5px;
    vertical-align: middle; flex-shrink: 0;
}
.tip::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: #1e293b; color: #f1f5f9;
    padding: 8px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 400; line-height: 1.5;
    width: 270px; white-space: normal;
    opacity: 0; pointer-events: none;
    transition: opacity 0.15s; z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.tip:hover::after { opacity: 1; }

/* FILTER BAR */
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
                     font-size: 13px; background: var(--surface); color: var(--text); }
.filter-count { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

/* STATS ROW */
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
             padding: 10px 18px; min-width: 80px; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.stat-new      { color: var(--primary); }
.stat-assembly { color: var(--low-color); }
.stat-done     { color: #16a34a; }
.stat-wb       { color: var(--wb-color); }
.stat-ozon     { color: var(--ozon-color); }

/* ACTION TOOLBAR */
.action-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
                  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
                  margin-bottom: 12px; position: sticky; top: 60px; z-index: 50; }
.selected-label { font-size: 13px; color: var(--text-muted); flex: 1; }

/* FBS STATUS BADGES */
.badge-status-new        { background: #eff6ff; color: #2563eb; }
.badge-status-in_assembly { background: #fff7ed; color: #d97706; }
.badge-status-ready      { background: #f0fdf4; color: #16a34a; }
.badge-status-done       { background: #dcfce7; color: #15803d; }
.badge-status-cancelled  { background: #fef2f2; color: #dc2626; }
.badge-inventory-reserved { background: #eff6ff; color: #2563eb; }
.badge-inventory-shipped { background: #dcfce7; color: #15803d; }
.badge-inventory-released,
.badge-inventory-cancelled,
.badge-inventory-legacy,
.badge-inventory-cancelled_after_handoff { background: #f3f4f6; color: #4b5563; }
.badge-inventory-uninitialized,
.badge-inventory-shortage,
.badge-inventory-unmapped { background: #fef2f2; color: #dc2626; }
.inventory-error { max-width: 230px; margin-top: 3px; font-size: 11px; color: var(--danger); }

/* ORDERS TABLE */
.row-new { background: #fefce8; }
.row-new:hover td { background: #fef9c3 !important; }
.td-mp-sku { font-size: 11px; color: var(--text-muted); font-family: monospace; margin-top: 2px; }

/* WB BREAK-EVEN RESULTS TABLE */
.row-below-be td { background: #fef2f2; }
.row-below-be:hover td { background: #fee2e2 !important; }
.row-neg-profit .td-profit { color: #dc2626; font-weight: 600; }
.td-below-be { background: #fef2f2; }

/* TABS */
.tab-nav { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
           padding-bottom: 0; }
.tab-link { padding: 8px 18px; border-radius: 6px 6px 0 0; text-decoration: none;
            font-size: 14px; font-weight: 500; color: var(--text-muted);
            border: 1px solid transparent; border-bottom: none; margin-bottom: -1px;
            display: inline-flex; align-items: center; gap: 6px; }
.tab-link:hover { background: var(--bg); color: var(--text); }
.tab-link.active { background: var(--surface); color: var(--primary);
                   border-color: var(--border); border-bottom-color: var(--surface); }
.tab-badge { background: var(--primary); color: #fff; border-radius: 9999px;
             font-size: 10px; font-weight: 700; padding: 1px 6px; }

/* SECTION CARD */
.section-card { background: var(--surface); border: 1px solid var(--border);
                border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between;
                  margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.section-header h3 { font-size: 15px; font-weight: 600; margin: 0; }

/* MODE BADGES */
.mode-badge { display: inline-block; padding: 3px 10px; border-radius: 9999px;
              font-size: 11px; font-weight: 600; }
.mode-sandbox { background: #ede9fe; color: var(--wb-color); }
.mode-dryrun  { background: #fef9c3; color: #854d0e; }

/* LOGIN */
body.login-page { display: flex; align-items: center; justify-content: center;
                  min-height: 100vh; background: var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
             padding: 40px; width: 360px; }
.login-box h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

/* ── ECONOMICS / P&L ─────────────────────────────────────────────────────── */

/* Деньги: цвета */
.money-neg { color: #dc2626; }
.money-pos { color: #16a34a; }
.money-neutral { color: var(--text-muted); }

/* Карточки-итоги */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            gap: 12px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
            padding: 16px 20px; }
.kpi-card.kpi-highlight { border-color: var(--primary); background: #eff6ff; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase;
             letter-spacing: .05em; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--text); }
.kpi-card.kpi-highlight .kpi-value { color: var(--primary); }

/* Полосы разбивки удержаний */
.breakdown-section { margin-bottom: 24px; }
.breakdown-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.breakdown-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
                     font-size: 13px; }
.breakdown-bar-label { width: 130px; flex-shrink: 0; color: var(--text); }
.breakdown-bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 16px;
                       overflow: hidden; border: 1px solid var(--border); }
.breakdown-bar-fill  { height: 100%; background: #f97316; border-radius: 3px;
                       transition: width .3s; min-width: 2px; }
.breakdown-bar-fill.fill-commission   { background: #6366f1; }
.breakdown-bar-fill.fill-logistics    { background: #0ea5e9; }
.breakdown-bar-fill.fill-acquiring    { background: #8b5cf6; }
.breakdown-bar-fill.fill-fine         { background: #ef4444; }
.breakdown-bar-fill.fill-return       { background: #f59e0b; }
.breakdown-bar-fill.fill-subscription { background: #14b8a6; }
.breakdown-bar-fill.fill-storage      { background: #a78bfa; }
.breakdown-bar-fill.fill-packaging    { background: #fb7185; }
.breakdown-bar-fill.fill-advertising  { background: #22c55e; }
.breakdown-bar-fill.fill-other        { background: #94a3b8; }
.breakdown-bar-amount { width: 110px; text-align: right; flex-shrink: 0;
                        font-variant-numeric: tabular-nums; color: var(--text-muted); }

/* Инлайн-форма себестоимости */
.inline-cost-form { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.inline-cost-form input { width: 80px; padding: 3px 6px; border: 1px solid var(--border);
                           border-radius: 4px; font-size: 12px; }

/* Форма периода */
.econ-toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
                margin-bottom: 20px; }
.econ-toolbar .form-group { margin-bottom: 0; }
.econ-toolbar .form-group label { font-size: 12px; }
.econ-toolbar input[type=date] { padding: 7px 10px; border: 1px solid var(--border);
                                  border-radius: 6px; font-size: 13px; }

/* Нераспределённые */
.unallocated-block { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
                     padding: 14px 18px; margin-bottom: 20px; }
.unallocated-block h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px;
                         color: #92400e; }

/* Форма настроек — select */
.econ-settings-form select { padding: 7px 10px; border: 1px solid var(--border);
                              border-radius: 6px; font-size: 13px; background: var(--surface); }
.econ-settings-form input[type=number] { width: 90px; padding: 7px 8px;
                                          border: 1px solid var(--border);
                                          border-radius: 6px; font-size: 13px; }

/* Панель ввода себестоимости */
.cost-panel { background: var(--surface); border: 1px solid var(--border);
              border-radius: 8px; margin-bottom: 24px; overflow: hidden; }
.cost-panel-summary { padding: 14px 20px; font-size: 15px; font-weight: 600;
                      cursor: pointer; user-select: none; list-style: none;
                      display: flex; align-items: center; gap: 8px; }
.cost-panel-summary::-webkit-details-marker { display: none; }
.cost-panel-summary::before { content: "▶"; font-size: 10px; color: var(--text-muted);
                               transition: transform .2s; }
details[open] .cost-panel-summary::before { transform: rotate(90deg); }
.cost-panel-body { padding: 0 20px 20px; }
.cost-panel-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.cost-table { font-size: 13px; }
.cost-table th { font-size: 11px; }
.cost-table td { padding: 8px 12px; vertical-align: middle; }

/* ── Вкладки маркетплейсов (Аналитика) ─────────────────────────────────── */
.mp-tabs { display: flex; gap: 4px; margin: 20px 0 0; border-bottom: 2px solid var(--border); }
.mp-tab {
  padding: 8px 22px; border: none; background: none; color: var(--text-muted);
  font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s;
}
.mp-tab:hover { color: var(--text); background: var(--bg-card); }
.mp-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg-card); }

/* ── История себестоимости ──────────────────────────────────────────────── */
.cost-history-row { display:flex; align-items:center; gap:8px; margin-bottom:4px; font-size:13px; }
.cost-history-date { color:var(--text-muted); min-width:90px; }
.cost-history-val { font-weight:500; min-width:80px; }
.btn-icon-del { background:none; border:none; color:var(--text-muted); cursor:pointer;
                font-size:11px; padding:2px 5px; border-radius:3px; }
.btn-icon-del:hover { color:var(--error); background:rgba(255,80,80,.1); }
.cost-delete-form { display:inline; }

/* ── Модалка себестоимости ──────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45); align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; width: 520px; max-width: calc(100vw - 32px);
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg); border-radius: 12px 12px 0 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 20px;
  cursor: pointer; padding: 2px 8px; border-radius: 6px; line-height: 1;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); margin-bottom: 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

.modal-hist-row {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 12px; border-radius: 8px; transition: background .1s;
  border: 1px solid transparent;
}
.modal-hist-row:hover { background: var(--bg); border-color: var(--border); }
.modal-hist-date {
  color: var(--text-muted); font-size: 13px; width: 110px; flex-shrink: 0;
}
.modal-hist-cost { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }

.modal-add-divider {
  border: none; border-top: 1px solid var(--border); margin: 20px 0 16px;
}
.modal-add-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.modal-add-row .form-group { margin-bottom: 0; }
.modal-add-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.modal-add-row input[type=date],
.modal-add-row input[type=number] {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 10px; font-size: 14px; outline: none;
}
.modal-add-row input[type=date] { width: 150px; }
.modal-add-row input[type=number] { width: 120px; }
.modal-add-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }

.modal-hist-empty {
  color: var(--text-muted); font-size: 13px; padding: 16px 12px;
  background: var(--bg); border-radius: 8px; text-align: center;
  border: 1px dashed var(--border);
}

/* ── Compact WB Analytics / WB Break-even results (2026-07-21) ───────────── */
/* Goal: no horizontal scrolling on the primary table at 1366px+, without
   shrinking primary text below ~12.5-14px. Achieved via compact column
   widths and wrapping secondary detail lines instead of forcing nowrap. */

.econ-toolbar-card { margin-bottom: 16px; padding: 14px 20px; }
.econ-sync-form { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.econ-mp-select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border);
                  background: var(--surface); color: var(--text); }

.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.mgmt-tax-note { font-size: 12px; color: var(--text-muted); margin: -8px 0 16px; line-height: 1.5; }

/* One-line arithmetic reconciliation */
.pnl-reconciliation { background: var(--surface); border: 1px solid var(--border);
                       border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.pnl-reconciliation-line { font-size: 14px; font-weight: 600; display: flex; gap: 8px;
                           align-items: baseline; flex-wrap: wrap; }
.pnl-reconciliation-line .op { color: var(--text-muted); font-weight: 400; }
.pnl-reconciliation-labels { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
                             font-size: 11px; color: var(--text-muted); }
.pnl-reconciliation-labels span:not(:last-child)::after { content: ""; }

.wb-reconciliation-warnings { margin: 8px 0 0 16px; font-size: 12px; color: #92400e; }

.tech-fields { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; }

/* Compact WB product table (Analytics) — 8 primary columns */
.wb-compact-section { margin-bottom: 24px; }
.wb-compact-table { font-size: 13px; width: 100%; }
.wb-compact-table th { font-size: 11px; white-space: normal; }
.wb-compact-table td { white-space: normal; vertical-align: top; }
.wb-compact-table .td-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: normal; }

/* Compact WB BE results table — 8 primary columns */
.be-compact-table { font-size: 13px; width: 100%; table-layout: auto; }
.be-compact-table th { font-size: 11px; white-space: normal; padding: 8px 10px; }
.be-compact-table td { white-space: normal; vertical-align: top; padding: 8px 10px; }
.be-compact-table .td-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.be-compact-table .td-operational { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }

.diff-badge { display: inline-block; padding: 1px 6px; border-radius: 9999px;
              font-size: 10px; font-weight: 700; margin-left: 4px; }
.diff-badge-up   { background: #fef2f2; color: #dc2626; }
.diff-badge-down { background: #f0fdf4; color: #16a34a; }

.be-status-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.be-badge-warn { background: #fef2f2; color: #dc2626; }

/* <details> "Подробнее" cells — compact summary, expanded technical block */
.details-summary { cursor: pointer; font-size: 12px; color: var(--primary); user-select: none; }
.warn-dot { color: #92400e; font-weight: 600; margin-right: 4px; }
.details-block { font-size: 11.5px; white-space: normal; max-width: 320px; margin-top: 6px;
                  color: var(--text); line-height: 1.5; }
.details-block-wide { max-width: 420px; }
.details-section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase;
                          letter-spacing: .04em; color: var(--text-muted); margin: 10px 0 4px; }
.details-section-label:first-child { margin-top: 0; }
.details-cat-row { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.details-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

@media (max-width: 900px) {
  .wb-compact-table, .be-compact-table { font-size: 12.5px; }
}

/* ── Mobile shell and fulfillment warehouse ─────────────────────────────── */
@media (max-width: 760px) {
  body { overflow-x: hidden; font-size: 15px; }

  nav {
    min-height: 58px; height: auto; padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }
  .nav-brand { flex: 1; gap: 6px; font-size: 17px; white-space: nowrap; }
  .nav-seller {
    display: block; min-width: 0; max-width: 46vw; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; font-size: 11px;
  }
  .nav-links-desktop, .nav-user-desktop { display: none; }
  .nav-mobile { display: block; flex: 0 0 auto; }
  .nav-mobile > summary {
    min-height: 42px; display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-size: 14px;
    font-weight: 600; cursor: pointer; list-style: none;
  }
  .nav-mobile > summary::-webkit-details-marker { display: none; }
  .nav-mobile[open] > summary { background: var(--bg); color: var(--primary); }
  .nav-mobile-panel {
    position: absolute; top: 100%; left: 0; right: 0; padding: 12px;
    background: var(--surface); border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border); box-shadow: 0 10px 24px rgba(0,0,0,.14);
  }
  .nav-mobile-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .nav-mobile-link {
    min-height: 44px; display: flex; align-items: center; padding: 9px 11px;
    border-radius: 8px; color: var(--text); background: var(--bg);
    text-decoration: none; font-size: 14px;
  }
  .nav-mobile-link.active { color: var(--primary); background: #eff6ff; font-weight: 700; }
  .nav-mobile-user {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 13px;
  }

  main {
    max-width: none; padding: 16px 12px 32px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .page-header { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 14px; }
  .page-header h2 { font-size: 21px; line-height: 1.25; }
  .page-header .count { display: block; margin-top: 3px; font-size: 14px; }
  .page-header form, .page-header .btn { width: 100%; }
  .page-header .btn { min-height: 44px; justify-content: center; }
  .alert { padding: 12px 13px; font-size: 14px; line-height: 1.45; }

  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 42px; justify-content: center; }

  .warehouse-table-wrap { overflow: visible; }
  .warehouse-table { display: block; border: 0; border-radius: 0; background: transparent; }
  .warehouse-table thead { display: none; }
  .warehouse-table tbody { display: grid; gap: 12px; }
  .warehouse-table tr {
    display: grid; min-width: 0; padding: 14px;
    grid-template-columns: 56px repeat(5, minmax(0, 1fr));
    grid-template-areas:
      "photo product product product product product"
      "sku sku sku sku sku sku"
      "onhand onhand reserved reserved available available"
      "status status status status status status"
      "actions actions actions actions actions actions"
      "updated updated updated updated updated updated";
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  .warehouse-table tr:hover td { background: transparent; }
  .warehouse-table td { display: block; min-width: 0; padding: 0; border: 0; }
  .warehouse-photo { grid-area: photo; width: 56px; align-self: start; }
  .warehouse-photo .product-photo, .warehouse-photo .no-photo { width: 56px; height: 56px; }
  .warehouse-product { grid-area: product; padding-left: 12px !important; align-self: center; }
  .warehouse-product .product-name { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 650; }
  .warehouse-photo-form-desktop { display: none; }
  .warehouse-photo-editor { display: block; margin-top: 7px; }
  .warehouse-photo-editor > summary {
    color: var(--primary); font-size: 13px; cursor: pointer; list-style: none;
  }
  .warehouse-photo-editor > summary::-webkit-details-marker { display: none; }
  .warehouse-photo-editor > summary::before { content: "＋ "; }
  .warehouse-photo-editor[open] > summary::before { content: "− "; }
  .warehouse-photo-editor .photo-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin-top: 8px; }
  .warehouse-photo-editor .input-photo { width: 100%; padding: 8px 9px; }

  .warehouse-sku {
    grid-area: sku; margin-top: 12px; padding-top: 10px !important;
    border-top: 1px solid var(--border) !important; overflow-wrap: anywhere;
    font-size: 12px;
  }
  .warehouse-sku::before, .warehouse-updated::before, .warehouse-status::before {
    content: attr(data-label); margin-right: 7px; color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  }
  .warehouse-metric {
    margin-top: 12px; padding: 10px 5px !important; text-align: center !important;
    background: var(--bg) !important; font-size: 20px; line-height: 1.1;
  }
  .warehouse-metric::before {
    content: attr(data-label); display: block; margin-bottom: 6px;
    color: var(--text-muted); font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em;
  }
  .warehouse-on-hand { grid-area: onhand; border-radius: 8px 0 0 8px; }
  .warehouse-reserved { grid-area: reserved; border-left: 1px solid var(--border) !important; }
  .warehouse-available { grid-area: available; border-left: 1px solid var(--border) !important; border-radius: 0 8px 8px 0; }
  .warehouse-status { grid-area: status; margin-top: 12px; padding: 11px !important; background: var(--error-bg) !important; border-radius: 8px; }
  .warehouse-status::before { display: block; margin: 0 0 6px; }

  .warehouse-actions { grid-area: actions; width: 100%; min-width: 0; margin-top: 12px; }
  .warehouse-actions details { display: block; width: 100%; margin: 6px 0 0; }
  .warehouse-actions details:first-child { margin-top: 0; }
  .warehouse-actions details > summary { width: 100%; min-height: 44px; justify-content: center; }
  .warehouse-actions .inventory-form {
    position: static; width: 100%; margin-top: 8px; padding: 12px;
    border-radius: 8px; box-shadow: none; background: var(--bg);
  }
  .warehouse-actions .inventory-form-opening { margin-top: 0; }
  .warehouse-actions .inventory-form label { font-size: 13px; }
  .warehouse-actions .inventory-form input { min-height: 44px; background: var(--surface); }
  .warehouse-actions .inventory-form .btn { width: 100%; }

  .warehouse-updated {
    grid-area: updated; margin-top: 10px; padding-top: 9px !important;
    border-top: 1px dashed var(--border) !important; font-size: 12px;
  }
}
