:root{
  --navy:#17365D;
  --navy-2:#0f2b4d;
  --blue-bg:#dbeaf7;
  --green-bg:#e4f1da;
  --green:#2f7d32;
  --red:#b42318;
  --red-bg:#fee4e2;
  --amber:#9a6700;
  --amber-bg:#fff4cc;
  --text:#17202a;
  --muted:#667085;
  --line:#e4e7ec;
  --surface:#ffffff;
  --page:#f5f7fa;
  --shadow:0 8px 24px rgba(16,24,40,.07);
  --safe-bottom:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
html{background:var(--page);color-scheme:light}
body{margin:0;background:var(--page);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;-webkit-font-smoothing:antialiased}
button,input,select{font:inherit}
button{cursor:pointer}
.hidden{display:none!important}
.app-shell{min-height:100vh;padding-bottom:calc(76px + var(--safe-bottom))}
.topbar{position:sticky;top:0;z-index:30;height:66px;padding:10px 16px;display:flex;align-items:center;justify-content:space-between;background:rgba(255,255,255,.94);backdrop-filter:blur(14px);border-bottom:1px solid rgba(228,231,236,.8)}
.brand{display:flex;align-items:center;gap:10px;min-width:0}
.brand-mark{width:40px;height:40px;border-radius:12px;background:linear-gradient(145deg,#2bd28c,#18b7a7);box-shadow:inset -8px 0 0 rgba(23,54,93,.16),0 5px 14px rgba(23,54,93,.12);color:white;font-weight:800;display:grid;place-items:center;font-size:22px}
.brand-text{display:flex;flex-direction:column;line-height:1.05}
.brand-text strong{font-size:17px;letter-spacing:.04em;color:var(--navy)}
.brand-text span{font-size:12px;color:var(--muted);margin-top:4px}
.sync-pill{border:0;border-radius:999px;padding:8px 11px;display:flex;align-items:center;gap:7px;font-size:13px;font-weight:700;background:#f2f4f7;color:#475467}
.sync-dot{width:8px;height:8px;border-radius:50%;background:#98a2b3;box-shadow:0 0 0 3px rgba(152,162,179,.14)}
.sync-pill.sync-ok{background:#eaf5e6;color:#286b2b}.sync-pill.sync-ok .sync-dot{background:#38a169}
.sync-pill.sync-running{background:#e8f1fb;color:#1d5f9c}.sync-pill.sync-running .sync-dot{background:#3182ce;animation:pulse 1.2s infinite}
.sync-pill.sync-warning{background:#fff4cc;color:#7a5b00}.sync-pill.sync-warning .sync-dot{background:#d69e2e}
.sync-pill.sync-error{background:#fee4e2;color:#8f1d16}.sync-pill.sync-error .sync-dot{background:#d92d20}
@keyframes pulse{50%{opacity:.4}}
.period-bar{position:sticky;top:66px;z-index:25;background:rgba(245,247,250,.96);backdrop-filter:blur(10px);padding:8px 12px;display:grid;grid-template-columns:1fr 1fr 94px;gap:7px;border-bottom:1px solid var(--line)}
.date-field,.scope-field{height:42px;border:1px solid var(--line);border-radius:12px;background:#fff;display:flex;align-items:center;overflow:hidden}
.date-field span{padding-left:10px;font-size:10px;text-transform:uppercase;color:#98a2b3;font-weight:800}
.date-field input{min-width:0;width:100%;height:100%;border:0;outline:0;background:transparent;padding:0 8px;color:var(--navy);font-size:13px;font-weight:700}
.scope-field select{width:100%;height:100%;border:0;outline:0;background:#fff;padding:0 9px;color:var(--navy);font-size:13px;font-weight:700}
.content{max-width:920px;margin:0 auto;padding:14px 12px 26px}
.view{display:none}.view.active{display:block}
.notice{border-radius:13px;padding:11px 13px;margin-bottom:12px;font-size:13px;line-height:1.35}
.notice-warning{background:var(--amber-bg);color:#6f5100;border:1px solid #f1d77b}
.notice-offline{background:#f2f4f7;color:#475467;border:1px solid #d0d5dd}
.problem-card{background:#fff;border-radius:17px;border:1px solid #f1d2cf;box-shadow:var(--shadow);margin-bottom:12px;overflow:hidden}
.problem-card .section-heading{padding:14px 14px 8px;margin:0}
.problem-list{padding:0 10px 10px}
.problem-row{display:flex;align-items:center;gap:10px;padding:10px;border-radius:12px;background:#fff7f6;margin-top:6px}
.problem-row.warning{background:#fff9e8}
.problem-dot{width:9px;height:9px;border-radius:50%;background:#d92d20;flex:0 0 auto}
.problem-row.warning .problem-dot{background:#d69e2e}
.problem-copy{min-width:0;flex:1}
.problem-copy strong{display:block;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.problem-copy span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
.kpi-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.kpi-card{min-height:148px;border-radius:16px;padding:14px 10px 11px;border:1px solid rgba(23,54,93,.08);display:flex;flex-direction:column;align-items:center;text-align:center;justify-content:flex-start;box-shadow:0 3px 10px rgba(16,24,40,.035)}
.kpi-card.blue{background:var(--blue-bg)}
.kpi-card.green{background:var(--green-bg)}
.kpi-card.neutral{background:#f3f4f6}
.kpi-title{font-size:15px;color:var(--navy);font-weight:850;letter-spacing:.015em}
.kpi-value{font-size:36px;line-height:1;font-weight:850;color:#050505;margin-top:18px;letter-spacing:-.025em}
.kpi-value.money{font-size:28px;margin-top:25px}
.kpi-value.medium{font-size:31px;margin-top:22px}
.kpi-kg{font-size:16px;line-height:1.1;color:#475467;font-weight:750;margin-top:8px;min-height:18px}
.kpi-micro{font-size:12px;color:#2f7d32;margin-top:auto;padding-top:8px;line-height:1.2;min-height:24px}
.kpi-micro.lower{padding-top:15px}
.kpi-micro.negative{color:#b42318}
.kpi-micro.neutral{color:#667085}
.secondary-strip{margin-top:8px;background:#fff0c2;border:1px solid #f2d98a;border-radius:15px;padding:11px 6px;display:grid;grid-template-columns:repeat(3,1fr);gap:4px;text-align:center}
.secondary-strip div{min-width:0;padding:0 3px;border-right:1px solid rgba(122,91,0,.15)}
.secondary-strip div:last-child{border-right:0}
.secondary-strip span{display:block;color:#7a5b00;font-size:10px;font-weight:700;white-space:nowrap}
.secondary-strip strong{display:block;font-size:14px;color:#181818;margin-top:3px;white-space:nowrap}
.home-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:12px}
.action-card{border:1px solid var(--line);background:#fff;border-radius:15px;padding:13px 11px;display:flex;align-items:center;text-align:left;box-shadow:0 3px 10px rgba(16,24,40,.035);color:var(--text)}
.action-icon{width:34px;height:34px;border-radius:10px;background:#edf3f9;color:var(--navy);display:grid;place-items:center;font-size:20px;flex:0 0 auto}
.action-card>span:nth-child(2){min-width:0;margin-left:9px;flex:1}
.action-card strong{display:block;color:var(--navy);font-size:14px}
.action-card small{display:block;color:var(--muted);font-size:10px;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chev{font-size:22px;color:#98a2b3}
.section-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin:6px 2px 12px}
.section-heading.compact{align-items:center}
.section-heading h1,.section-heading h2{margin:1px 0 0;color:var(--navy);font-size:25px;letter-spacing:-.02em}
.section-heading h2{font-size:20px}
.eyebrow{text-transform:uppercase;letter-spacing:.08em;font-size:9px;color:#98a2b3;font-weight:850}
.text-button{border:0;background:transparent;color:#2f6fed;font-weight:700;padding:8px}
.text-button.danger{color:#b42318}
.chart-card{position:relative;background:#fff;border:1px solid var(--line);border-radius:18px;padding:14px 10px 12px;box-shadow:var(--shadow)}
.chart-legend{display:flex;gap:18px;justify-content:center;font-size:12px;color:#475467;margin-bottom:8px}
.legend-dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:6px}
.legend-dot.orders{background:#2f6fed}.legend-dot.profit{background:#2f8a57}
#dynamics-chart{width:100%;height:300px;display:block;touch-action:none}
.chart-note{text-align:center;color:#667085;font-size:11px;margin-top:7px}
.chart-tooltip{position:absolute;z-index:10;pointer-events:none;background:rgba(23,54,93,.94);color:white;border-radius:10px;padding:7px 9px;font-size:11px;line-height:1.35;box-shadow:0 4px 16px rgba(0,0,0,.18);transform:translate(-50%,-110%)}
.segmented{display:flex;background:#e9edf2;padding:3px;border-radius:11px}
.segmented button{border:0;background:transparent;border-radius:8px;padding:6px 8px;font-size:10px;font-weight:750;color:#667085}
.segmented button.active{background:#fff;color:var(--navy);box-shadow:0 1px 4px rgba(16,24,40,.08)}
.products-list{display:grid;gap:9px}
.product-card{background:#fff;border:1px solid var(--line);border-left:5px solid #d0d5dd;border-radius:16px;padding:12px 13px;box-shadow:0 3px 10px rgba(16,24,40,.035)}
.product-card.critical{border-left-color:#d92d20}.product-card.warning{border-left-color:#d69e2e}.product-card.ok{border-left-color:#38a169}
.product-top{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.product-name{font-weight:800;color:var(--navy);font-size:14px;line-height:1.25}
.product-badge{border-radius:999px;padding:4px 7px;font-size:9px;font-weight:850;white-space:nowrap;background:#ecfdf3;color:#027a48}
.product-card.critical .product-badge{background:#fee4e2;color:#b42318}
.product-card.warning .product-badge{background:#fff4cc;color:#9a6700}
.product-metrics{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:12px}
.product-metrics div{background:#f8fafc;border-radius:10px;padding:7px 4px;text-align:center;min-width:0}
.product-metrics span{display:block;font-size:9px;color:#98a2b3;font-weight:700}
.product-metrics strong{display:block;font-size:13px;color:#344054;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.service-card{background:#fff;border:1px solid var(--line);border-radius:17px;padding:14px;margin-bottom:10px;box-shadow:0 3px 10px rgba(16,24,40,.035)}
.service-head{display:flex;align-items:flex-start;justify-content:space-between}
.service-head h3{margin:2px 0 0;color:var(--navy);font-size:18px}
.badge{display:inline-flex;align-items:center;border-radius:999px;padding:5px 8px;background:#eaf5e6;color:#286b2b;font-size:10px;font-weight:850}
.badge.neutral{background:#f2f4f7;color:#667085}
.badge.error{background:#fee4e2;color:#b42318}
.badge.warning{background:#fff4cc;color:#9a6700}
.badge.running{background:#e8f1fb;color:#1d5f9c}
.service-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin:14px 0}
.service-grid>div{background:#f8fafc;border-radius:10px;padding:8px 6px;text-align:center;min-width:0}
.service-grid dt{font-size:9px;color:#98a2b3;font-weight:700}
.service-grid dd{margin:4px 0 0;font-size:12px;color:#344054;font-weight:800;overflow:hidden;text-overflow:ellipsis}
.primary-button,.secondary-button{width:100%;border-radius:12px;padding:11px 13px;font-weight:800}
.primary-button{border:0;background:var(--navy);color:#fff}
.primary-button:disabled{opacity:.55}
.secondary-button{border:1px solid #cfd8e3;background:#f7f9fb;color:var(--navy)}
.secondary-button:disabled{opacity:.6;cursor:default}
.service-help{font-size:11px;color:#667085;line-height:1.4;margin:9px 1px 0}
.service-actions{display:flex;gap:8px;margin-top:12px}.service-actions>*{flex:1}
.bottom-nav{position:fixed;left:0;right:0;bottom:0;z-index:40;height:calc(66px + var(--safe-bottom));padding:5px 8px var(--safe-bottom);background:rgba(255,255,255,.96);backdrop-filter:blur(16px);border-top:1px solid var(--line);display:grid;grid-template-columns:repeat(4,1fr)}
.bottom-nav button{border:0;background:transparent;color:#98a2b3;border-radius:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
.bottom-nav button span{font-size:20px;line-height:1}
.bottom-nav button small{font-size:10px;font-weight:700}
.bottom-nav button.active{color:var(--navy);background:#edf3f9}
.loading-overlay{position:fixed;inset:0;z-index:100;background:rgba(245,247,250,.82);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;color:var(--navy);font-size:13px;font-weight:700}
.spinner{width:34px;height:34px;border:3px solid #d8e2ec;border-top-color:var(--navy);border-radius:50%;animation:spin .75s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.toast{position:fixed;z-index:120;left:50%;bottom:calc(82px + var(--safe-bottom));transform:translateX(-50%);background:#101828;color:#fff;border-radius:12px;padding:10px 13px;font-size:12px;box-shadow:0 8px 30px rgba(0,0,0,.22);max-width:88%;text-align:center}
.login-screen{position:fixed;inset:0;z-index:200;background:linear-gradient(180deg,#eef4f9 0,#f9fbfd 60%,#fff 100%);display:grid;place-items:center;padding:20px}
.login-card{width:min(360px,100%);background:#fff;border:1px solid var(--line);border-radius:24px;padding:28px;box-shadow:0 18px 48px rgba(23,54,93,.13);text-align:center}
.login-logo{width:68px;height:68px;border-radius:21px;margin:0 auto 14px;background:linear-gradient(145deg,#2bd28c,#18b7a7);box-shadow:inset -14px 0 0 rgba(23,54,93,.16);display:grid;place-items:center;color:white;font-weight:850;font-size:36px}
.login-card h1{margin:0;color:var(--navy);letter-spacing:.08em}.login-card p{margin:4px 0 22px;color:#667085}
.login-card label{text-align:left;display:block}.login-card label span{display:block;font-size:11px;color:#667085;font-weight:700;margin-bottom:6px}
.login-card input{width:100%;height:46px;border:1px solid #cfd8e3;border-radius:12px;padding:0 12px;outline:none;margin-bottom:12px}
.login-card input:focus{border-color:#5f8fc2;box-shadow:0 0 0 3px rgba(47,111,237,.1)}
.login-error{min-height:18px;margin-top:9px;color:#b42318;font-size:11px}
@media(min-width:700px){
  .content{padding-left:20px;padding-right:20px}
  .kpi-grid{grid-template-columns:repeat(3,1fr)}
  .home-actions{grid-template-columns:repeat(2,220px)}
  .products-list{grid-template-columns:1fr 1fr}
  .period-bar{max-width:920px;margin:0 auto;grid-template-columns:190px 190px 120px;justify-content:center}
  .kpi-card{min-height:156px}
}


/* ==========================================================================
   v0.2 — mobile information density
   ========================================================================== */
.data-context{
  min-height:36px;
  margin-bottom:9px;
  border-radius:12px;
  border:1px solid #ead890;
  background:#fff7d9;
  color:#765a08;
  padding:8px 11px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-align:center;
  font-size:11px;
  font-weight:750;
  line-height:1.25;
}
.context-sep{color:#b59a43}
.problem-summary{
  min-height:58px;
  margin-bottom:10px;
  padding:9px 10px 9px 12px;
  border-radius:15px;
  border:1px solid #efcfcc;
  background:#fff;
  box-shadow:0 3px 10px rgba(16,24,40,.035);
  display:flex;
  align-items:center;
  gap:9px;
}
.problem-summary-dot{
  width:10px;height:10px;border-radius:50%;
  background:#d92d20;flex:0 0 auto;
  box-shadow:0 0 0 4px rgba(217,45,32,.09);
}
.problem-summary.warning .problem-summary-dot{
  background:#d69e2e;
  box-shadow:0 0 0 4px rgba(214,158,46,.10);
}
.problem-summary-copy{min-width:0;flex:1}
.problem-summary-copy strong{
  display:block;
  color:#1d2939;
  font-size:13px;
  line-height:1.2;
}
.problem-summary-copy span{
  display:block;
  color:#667085;
  font-size:10px;
  margin-top:3px;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.problem-open{flex:0 0 auto;font-size:12px;padding:7px 5px}

.kpi-card{min-height:143px}
.kpi-micro{
  font-size:14px;
  font-weight:650;
  letter-spacing:-.01em;
  padding-top:8px;
}
.kpi-micro.lower{padding-top:13px}
.agent-note{
  margin-top:9px;
  border-radius:11px;
  padding:10px 11px;
  background:#f7f9fb;
  border:1px solid #e4e7ec;
  color:#667085;
  font-size:11px;
  font-weight:700;
  text-align:center;
}
@media(max-width:430px){
  .content{padding-top:10px}
  .data-context{font-size:10.5px;padding-left:7px;padding-right:7px}
  .problem-summary{min-height:54px}
  .kpi-card{min-height:139px;padding-top:12px}
  .kpi-value{margin-top:15px}
  .kpi-value.money{margin-top:21px}
  .kpi-value.medium{margin-top:19px}
  .kpi-micro{font-size:13px}
}


/* ==========================================================================
   v0.3 — restored top visual hierarchy + more readable KPI comparisons
   ========================================================================== */

/* Native date input remains clickable, while compact dd.mm.yy text is shown. */
.date-field{position:relative}
.date-field .date-prefix{
  position:relative;z-index:1;
  padding-left:10px;
  font-size:10px;
  text-transform:uppercase;
  color:#98a2b3;
  font-weight:850;
}
.date-display{
  position:relative;z-index:1;
  margin-left:8px;
  color:var(--navy);
  font-size:13px;
  font-weight:800;
  letter-spacing:.01em;
  white-space:nowrap;
}
.date-field input[type="date"]{
  position:absolute;
  inset:0;
  z-index:3;
  width:100%;
  height:100%;
  opacity:0;
  cursor:pointer;
}

/* Two compact information chips instead of an unstyled text line. */
.data-context{
  margin-bottom:9px;
  min-height:0;
  padding:0;
  border:0;
  background:transparent;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
.context-chip{
  min-height:40px;
  border-radius:13px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:8px 8px;
  border:1px solid var(--line);
  box-shadow:0 2px 8px rgba(16,24,40,.025);
  white-space:nowrap;
}
.context-chip.orders{background:#eef6fd;border-color:#d7e7f6}
.context-chip.finance{background:#eef7e9;border-color:#d8e8ce}
.context-chip .context-dot{
  width:7px;height:7px;border-radius:50%;flex:0 0 auto
}
.context-chip.orders .context-dot{background:#2f6fed}
.context-chip.finance .context-dot{background:#38a169}
.context-chip .context-label{
  color:#667085;
  font-size:10px;
  font-weight:750;
}
.context-chip strong{
  color:#344054;
  font-size:12px;
  font-weight:850;
}

/* Compact alert is still visually a card, not raw text. */
.problem-summary{
  min-height:58px;
  padding:9px 10px 9px 12px;
  border-radius:15px;
  border:1px solid #efcbc7;
  background:linear-gradient(90deg,#fff7f6 0%,#fff 74%);
  box-shadow:0 3px 12px rgba(16,24,40,.045);
}
.problem-summary.warning{
  border-color:#eedda2;
  background:linear-gradient(90deg,#fff9e8 0%,#fff 74%);
}
.problem-summary-copy strong{
  font-size:14px;
  font-weight:850;
}
.problem-summary-copy span{
  font-size:11px;
  margin-top:3px;
}
.problem-open{
  color:#2f6fed;
  font-size:12px;
  font-weight:850;
}

/* More readable comparison layer. Main KPI remains dominant. */
.kpi-micro{
  width:100%;
  min-height:27px;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:4px;
  font-size:15px;
  line-height:1.15;
  font-weight:700;
  padding-top:8px;
  white-space:nowrap;
}
.kpi-micro.lower{padding-top:13px}
.kpi-micro.two-line{
  min-height:42px;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  gap:3px;
  white-space:normal;
}
.kpi-micro .micro-main{
  display:block;
  font-size:15px;
  line-height:1.1;
}
.kpi-micro .micro-secondary{
  display:block;
  font-size:13px;
  line-height:1.05;
  color:#667085;
  font-weight:700;
}
.kpi-micro.negative .micro-secondary{color:#8a4a44}
.kpi-micro:not(.negative) .micro-secondary{color:#4d7650}

/* Slightly more room where two-line microcopy is used. */
.kpi-grid{align-items:stretch}
.kpi-card{min-height:145px}

/* Service informational block. */
.agent-note{
  background:#f3f6f9;
  border-color:#dde3ea;
  color:#536273;
}

@media(max-width:430px){
  .period-bar{grid-template-columns:1fr 1fr 88px;gap:6px}
  .date-display{font-size:12.5px;margin-left:6px}
  .context-chip{padding-left:5px;padding-right:5px}
  .context-chip .context-label{font-size:9.5px}
  .context-chip strong{font-size:11.5px}
  .problem-summary{min-height:56px}
  .problem-summary-copy strong{font-size:13.5px}
  .problem-summary-copy span{font-size:10.5px}
  .kpi-micro{font-size:14.5px}
  .kpi-micro .micro-main{font-size:14.5px}
  .kpi-micro .micro-secondary{font-size:12.5px}
}


/* v0.4 — Profit/kg becomes the second information line in "Прибыль / шт",
   visually identical to kg in "Реализовано". */
#kpi-profit-kg{
  color:#475467;
  font-size:16px;
  line-height:1.1;
  font-weight:750;
  margin-top:8px;
  min-height:18px;
}


/* ==========================================================================
   v0.5 — resilient/compact offline state
   ========================================================================== */
.notice-offline{
  min-height:32px;
  margin:0 0 8px;
  padding:7px 11px;
  border-radius:11px;
  display:flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:11px;
  line-height:1.1;
  font-weight:700;
  background:#f2f4f7;
  color:#667085;
  border:1px solid #d0d5dd;
}
.sync-pill.sync-offline{
  background:#f2f4f7;
  color:#667085;
}
.sync-pill.sync-offline .sync-dot{
  background:#98a2b3;
  box-shadow:0 0 0 3px rgba(152,162,179,.14);
}
@media(max-width:430px){
  .notice-offline{
    min-height:30px;
    padding:6px 9px;
    font-size:10.5px;
  }
}
