:root {
  color-scheme: light;
  --ink: #17282d;
  --ink-soft: #385057;
  --muted: #71858b;
  --line: #dce7e8;
  --line-strong: #c9d8da;
  --canvas: #f3f7f7;
  --panel: #ffffff;
  --navy: #123238;
  --navy-2: #1d454b;
  --accent: #008f7e;
  --accent-dark: #006f63;
  --accent-soft: #e4f5f2;
  --fish: #eaf0fb;
  --fish-ink: #405d91;
  --warning: #c26a18;
  --warning-soft: #fff2e5;
  --danger: #b64b3c;
  --shadow: 0 10px 30px rgba(19, 50, 56, .07);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a.button { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; }

.app-header { position: sticky; top: 0; z-index: 20; background: rgba(18, 50, 56, .96); color: #fff; border-bottom: 1px solid rgba(255,255,255,.09); backdrop-filter: blur(12px); }
.header-inner { min-height: 68px; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 11px; margin-right: auto; color: #fff; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, #a9ebe2, #68cec0); color: var(--navy); font-size: 12px; font-weight: 900; letter-spacing: -.03em; box-shadow: inset 0 1px rgba(255,255,255,.65); }
.brand > span:last-child { display: grid; line-height: 1.16; }
.brand strong { font-size: 15px; letter-spacing: -.015em; }
.brand small { color: #a9c0c4; font-size: 11px; font-weight: 550; margin-top: 3px; }
.header-status { display: inline-flex; align-items: center; gap: 7px; color: #c4d6d8; font-size: 12px; font-weight: 650; }
.main-nav { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.main-nav a { border-radius: 8px; color: #c4d6d8; padding: 7px 10px; font-size: 12px; font-weight: 750; text-decoration: none; }
.main-nav a:hover, .main-nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #70dbc9; box-shadow: 0 0 0 4px rgba(112,219,201,.12); }
.logout { appearance: none; border: 1px solid rgba(255,255,255,.2); border-radius: 9px; background: rgba(255,255,255,.07); color: #e7f0f1; padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.logout:hover { background: rgba(255,255,255,.13); }

.page { padding: 38px 0 60px; }
.hero, .detail-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 6px; color: var(--accent-dark); font-size: 11px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
h1 { margin: 0; color: var(--ink); font-size: clamp(28px, 3.2vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin: 0; font-size: 21px; line-height: 1.2; letter-spacing: -.025em; }
.lede { max-width: 760px; margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.hero-date { min-width: 180px; display: grid; gap: 4px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.65); text-align: right; }
.hero-date span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.hero-date strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { min-height: 122px; display: flex; align-items: center; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 3px 12px rgba(19,50,56,.025); }
.kpi-icon { flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #edf3f3; color: var(--ink-soft); font-size: 13px; font-weight: 900; }
.kpi > div { min-width: 0; display: grid; }
.kpi small { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .045em; }
.kpi strong { margin-top: 3px; overflow: hidden; color: var(--ink); font-size: 25px; line-height: 1.15; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi em { margin-top: 4px; color: #8a9a9f; font-size: 11px; font-style: normal; }
.kpi.accent { border-color: #b8dfda; background: linear-gradient(150deg, #ffffff 35%, #edf9f7); }
.kpi.accent .kpi-icon { background: var(--accent-soft); color: var(--accent-dark); }
.kpi.warning .kpi-icon { background: var(--warning-soft); color: var(--warning); }

.surface { margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.section-heading { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.result-count { border-radius: 99px; background: #edf3f3; color: var(--muted); padding: 6px 11px; font-size: 12px; white-space: nowrap; }
.result-count b { color: var(--ink); }
.filter-bar { display: flex; align-items: flex-end; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); background: #fbfdfd; }
.search-field { min-width: 280px; flex: 1; position: relative; }
.search-field span { position: absolute; left: 13px; top: 50%; color: #829499; font-size: 21px; line-height: 1; transform: translateY(-52%); }
.search-field input, .select-field select { width: 100%; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: #fff; color: var(--ink); }
.search-field input { padding: 0 14px 0 40px; }
.search-field input:focus, .select-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,143,126,.11); }
.select-field { min-width: 176px; display: grid; gap: 4px; }
.select-field span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .055em; }
.select-field select { padding: 0 32px 0 11px; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; padding: 10px 16px; font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:hover { background: var(--accent-dark); }
.button.secondary { border: 1px solid var(--line-strong); background: #fff; color: var(--ink-soft); }
.button.secondary:hover { background: #edf4f4; }
.button.excel { min-width: 188px; background: #167b60; box-shadow: 0 7px 20px rgba(22,123,96,.18); }
.button.excel:hover { background: #0e624b; }
.button.excel span { font-size: 19px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 18px; border-bottom: 1px solid #e5eded; text-align: left; vertical-align: middle; }
.data-table th { position: relative; background: #f8fbfb; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .065em; text-transform: uppercase; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .15s ease; }
.data-table .number { text-align: right; font-variant-numeric: tabular-nums; }
.clickable-row { cursor: pointer; outline: 0; }
.clickable-row:hover, .clickable-row:focus { background: #f1faf8; }
.clickable-row:focus { box-shadow: inset 3px 0 var(--accent); }
.restaurant-link { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.restaurant-link > span:last-child { display: grid; }
.restaurant-link strong { font-size: 14px; }
.restaurant-link small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.restaurant-avatar { flex: 0 0 35px; width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 900; }
.status-pill, .group-pill { display: inline-flex; align-items: center; border-radius: 99px; background: var(--accent-soft); color: var(--accent-dark); padding: 4px 9px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.group-pill { background: #eef3f3; color: #52686e; }
.group-pill.fish { background: var(--fish); color: var(--fish-ink); }
.muted-number { color: var(--muted); }
.order-total, .recommended { color: var(--accent-dark); font-weight: 850; }
.row-arrow { width: 34px; color: #8ca0a5; font-size: 18px; text-align: right !important; }
.filtered-empty, .empty-cell { padding: 34px 20px !important; color: var(--muted); text-align: center !important; }

.backtest-section { box-shadow: none; }
.backtest-section > summary { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; cursor: pointer; list-style: none; }
.backtest-section > summary::-webkit-details-marker { display: none; }
.backtest-section > summary > span:first-child { display: grid; }
.backtest-section > summary strong { font-size: 18px; }
.summary-action { color: var(--accent-dark); font-size: 12px; font-weight: 800; }
.backtest-section[open] .summary-action { font-size: 0; }
.backtest-section[open] .summary-action::after { content: "Скрыть детализацию"; font-size: 12px; }
.backtest-section[open] .table-wrap { border-top: 1px solid var(--line); }

.breadcrumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; color: var(--muted); font-size: 12px; }
.breadcrumbs a { color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.detail-hero { align-items: center; }
.detail-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.method-card { margin: 0 0 18px; overflow: hidden; border: 1px solid #b9dfda; border-radius: 13px; background: #f1faf8; }
.method-card summary { padding: 14px 18px; color: #225b54; font-weight: 800; cursor: pointer; }
.method-card > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding: 0 18px 16px; color: #466762; font-size: 12px; }
.method-card p { margin: 0; }
.filter-stack { border-bottom: 1px solid var(--line); background: #fbfdfd; }
.filter-stack .filter-bar { border-bottom: 0; }
.product-filter .search-field { max-width: 620px; }
.chips { display: flex; gap: 8px; padding: 0 22px 15px; overflow-x: auto; }
.chip { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 99px; background: #fff; color: var(--ink-soft); padding: 6px 12px; font-size: 12px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: #9fc5c1; background: #f1faf8; }
.chip.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip span { margin-left: 5px; opacity: .75; }
.detail-table { max-height: min(68vh, 820px); overflow: auto; }
.detail-table thead { position: sticky; top: 0; z-index: 2; }
.product-cell { min-width: 280px; }
.product-cell strong, .product-cell small { display: block; }
.product-cell strong { font-size: 13px; }
.product-cell small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.supplier-cell { min-width: 180px; }
.supplier-cell strong { color: var(--ink-soft); font-size: 11px; }
.warehouse-receipt { min-width: 180px; }
.warehouse-receipt strong, .warehouse-receipt small { display: block; }
.warehouse-receipt strong { color: var(--ink-soft); font-size: 12px; }
.warehouse-receipt small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.detail-actions { display: flex; align-items: flex-end; gap: 12px; }
.receipt-freshness { min-width: 238px; display: grid; gap: 3px; border: 1px solid #b8dfda; border-radius: 12px; background: #f1faf8; padding: 11px 14px; }
.receipt-freshness span { color: var(--accent-dark); font-size: 9px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.receipt-freshness strong { color: var(--ink); font-size: 19px; }
.receipt-freshness small { color: var(--muted); font-size: 9px; }
.pack-cell { min-width: 120px; }
.pack-cell strong, .pack-cell small, .recommended small, .minmax small { display: block; }
.pack-cell strong { color: var(--ink-soft); font-size: 11px; }
.pack-cell small, .recommended small, .minmax small { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 500; }
.minmax { color: #315a57; font-weight: 750; }
.negative { color: var(--danger); font-weight: 800; }
.coverage { color: var(--muted); }
.page-note { margin: 16px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

/* Prepared-product intraday pilot */
.prepared-hero { margin-bottom: 18px; }
.date-form { display: flex; align-items: flex-end; gap: 8px; }
.date-form label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.date-form input, .percent-input, .shelf-control input { height: 42px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); padding: 0 10px; outline: 0; }
.date-form input:focus, .percent-input:focus, .shelf-control input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,143,126,.11); }
.notice { margin: 10px 0; border: 1px solid var(--line); border-radius: 11px; padding: 11px 14px; }
.warning-notice { border-color: #efd0ae; background: var(--warning-soft); color: #81501f; }
.prepared-actions { display: flex; align-items: center; gap: 10px; }
.freshness { color: var(--muted); font-size: 11px; }
.freshness.unavailable, .warning-text { color: var(--warning); font-weight: 750; }
.mode-tabs { display: flex; gap: 6px; padding: 14px 22px 0; }
.mode-tabs a { border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink-soft); padding: 8px 12px; font-size: 12px; font-weight: 800; text-decoration: none; }
.mode-tabs a.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.table-hint { margin: 12px 22px; color: var(--muted); font-size: 11px; }
.prepared-table-wrap { max-height: min(70vh, 860px); overflow: auto; border-top: 1px solid var(--line); }
.prepared-table { min-width: 1180px; }
.prepared-table thead { position: sticky; top: 0; z-index: 3; }
.prepared-table th small { display: block; margin-top: 3px; color: #94a5a9; font-size: 8px; letter-spacing: 0; }
.prepared-table .product-cell { min-width: 230px; }
.prepared-table .product-cell .link-button { display: block; margin-top: 5px; }
.product-warning { display: block; margin-top: 4px; max-width: 240px; font-size: 9px; line-height: 1.25; }
.history-pair strong, .history-pair small, .average strong, .average small { display: block; white-space: nowrap; }
.history-pair small, .average small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.percent-cell { min-width: 130px; white-space: nowrap; }
.percent-input { width: 78px; height: 34px; text-align: right; }
.icon-button { width: 32px; height: 32px; margin-left: 5px; border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 900; cursor: pointer; }
.link-button { border: 0; background: transparent; color: var(--accent-dark); padding: 0; font-size: 10px; font-weight: 750; text-decoration: underline; cursor: pointer; }
.prepared-table .target { background: #f1faf8; color: var(--accent-dark); font-size: 14px; }
.prepared-table .balance { color: var(--ink-soft); }
.muted-row { opacity: .58; }
.prepared-footer { display: flex; justify-content: space-between; gap: 12px; padding: 13px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.prepared-footer a { color: var(--accent-dark); font-weight: 750; }
.shelf-control { display: flex; align-items: center; gap: 8px; min-width: 230px; }
.shelf-control input { width: 110px; }

/* Login */
.login-shell { width: min(440px, calc(100% - 32px)); min-height: 100vh; display: grid; place-items: center; margin: 0 auto; }
.login-shell .panel { width: 100%; border: 1px solid var(--line); border-radius: 18px; background: #fff; padding: 30px; box-shadow: var(--shadow); }
.login-shell form { display: grid; gap: 14px; margin-top: 24px; }
.login-shell label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.login-shell input { height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 12px; outline: 0; }
.login-shell input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,143,126,.11); }
.login-shell button { min-height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; cursor: pointer; }
.login-error { border-radius: 9px; background: var(--warning-soft); color: #8a4d15; padding: 10px 12px; font-size: 12px; }

@media (max-width: 1020px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .method-card > div { grid-template-columns: 1fr; gap: 9px; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 1320px); }
  .header-inner { min-height: 60px; }
  .header-status { display: none; }
  .main-nav { margin-left: 0; }
  .brand small { display: none; }
  .page { padding: 26px 0 42px; }
  .hero, .detail-hero { align-items: flex-start; flex-direction: column; gap: 16px; }
  .detail-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .date-form { width: 100%; align-items: stretch; flex-direction: column; }
  .date-form .button { width: 100%; }
  .prepared-heading { align-items: stretch; flex-direction: column; }
  .prepared-actions { width: 100%; justify-content: space-between; }
  .receipt-freshness { min-width: 0; width: 100%; }
  .hero-date { width: 100%; text-align: left; }
  .detail-hero .button { width: 100%; }
  .kpi-grid, .detail-kpis { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 104px; padding: 15px; }
  .kpi strong { font-size: 21px; }
  .section-heading { min-height: 72px; padding: 15px; }
  .filter-bar { align-items: stretch; flex-direction: column; padding: 14px; }
  .search-field, .select-field, .product-filter .search-field { min-width: 0; max-width: none; width: 100%; }
  .filter-bar .button { width: 100%; }
  .chips { padding: 0 14px 14px; }
  .data-table { min-width: 780px; }
  .restaurant-table { min-width: 700px; }
  .data-table th, .data-table td { padding: 12px 14px; }
  .detail-table { max-height: 68vh; padding: 10px; background: #f5f9f9; }
  .detail-table .data-table, .detail-table tbody { min-width: 0; display: block; }
  .detail-table thead { display: none; }
  .detail-table tbody { display: grid; gap: 10px; }
  .detail-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .detail-table tr[hidden] { display: none; }
  .detail-table td, .detail-table .number { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; padding: 0; border: 0; text-align: left; white-space: normal; }
  .detail-table .product-cell, .detail-table .supplier-cell { min-width: 0; grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .detail-table td:not(.product-cell)::before { margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
  .detail-table td:nth-child(2)::before { content: "Поставщик"; }
  .detail-table td:nth-child(3)::before { content: "Группа"; }
  .detail-table td:nth-child(4)::before { content: "Остаток"; }
  .detail-table td:nth-child(5)::before { content: "MIN"; }
  .detail-table td:nth-child(6)::before { content: "MAX"; }
  .detail-table td:nth-child(7)::before { content: "Упаковка"; }
  .detail-table td:nth-child(8)::before { content: "К заказу"; }
  .detail-table td:nth-child(9)::before { content: "Дни + запас"; }
  .detail-table .pack-cell { grid-column: 1 / -1; }
  .detail-table .recommended { margin: -5px; border-radius: 8px; background: var(--accent-soft); padding: 5px; }
  .backtest-section > summary { padding: 15px; }
}

@media (max-width: 480px) {
  .header-inner { gap: 8px; }
  .brand { margin-right: 0; }
  .brand > span:last-child { display: none; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 6px 7px; font-size: 10px; }
  .kpi-grid, .detail-kpis { grid-template-columns: 1fr; }
  .kpi { min-height: 92px; }
  h1 { font-size: 31px; }
  .logout { margin-left: auto; padding: 7px 8px; font-size: 10px; }
  .surface { border-radius: 13px; }
}

/* M&F weekly set plan --------------------------------------------------- */
/* The grid must keep its shape on a point with no data: a week is always
   seven columns wide, otherwise the day headers collapse into each other. */
.set-plan-table { min-width: 760px; table-layout: fixed; }
.set-plan-table th:first-child, .set-plan-table td:first-child { width: 34%; min-width: 220px; }
.set-plan-table th.number, .set-plan-table td.number { width: 9.4%; min-width: 62px; }
.set-plan-table th.number strong { display: block; font-size: 12px; letter-spacing: 0; text-transform: none; }
.set-plan-table th.number small { display: block; color: var(--muted); font-weight: 600; font-size: 10px; }
.set-plan-table .anchor-row { background: #f2f8f8; }
.set-plan-table .anchor-row td { border-bottom: 2px solid var(--line); }
.set-plan-table .anchor-cell strong { font-size: 18px; }
.set-plan-table .product-cell { font-size: 13px; }
.warnings p { margin: 0 0 8px; }
.warnings p:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .set-plan-table th:first-child, .set-plan-table td:first-child { min-width: 180px; }
}
