/* Пульс продажів — Mini App adaptation of dashboard.html.
   Mobile-first, app-like: sticky header, stacked location cards, vertical
   plan/fact bars, bottom tab bar. Tokens carried over from the design. */
:root {
  --bg: #f5f5f3;
  --card: #ffffff;
  --ink: #0f0f0f;
  --ink-2: #4a4a4a;
  --muted: #9b9b9b;
  --line: #ececea;
  --line-2: #f3f3f1;
  --wine: #720000;
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.08);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.1);
  --red: #c81e1e;
  --red-bg: rgba(200, 30, 30, 0.08);
  --highlight: #fafaf6;
  --bar-plan: #e6e2d8;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum", "ss01";
}
body {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
.mono { font-family: "JetBrains Mono", monospace; }

/* top progress bar */
#bar {
  position: fixed; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--wine), #b53a3a);
  opacity: 0; transition: opacity 0.25s; z-index: 60;
}

/* HEADER (sticky, compact) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 10px;
  background: rgba(245, 245, 243, 0.86);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.topbar .live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; color: var(--green);
  background: var(--green-bg); padding: 4px 9px; border-radius: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.topbar .live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.subbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 4px; font-size: 12px;
}
.subbar .user { color: var(--ink-2); font-weight: 600; }
.subbar .ts { color: var(--muted); font-size: 11px; }

#root { padding: 10px 14px 24px; }
.banner { text-align: center; color: var(--muted); padding: 56px 16px; line-height: 1.5; font-size: 15px; }

/* SUMMARY — 2×2 KPI grid */
.summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;
}
.summary .item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 3px;
}
.summary .k-label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.09em; font-weight: 600;
}
.summary .k-val {
  font-family: "Lora", serif; font-size: 24px; font-weight: 600;
  line-height: 1.05; letter-spacing: -0.01em;
}
.summary .k-val .cur { font-size: 13px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.summary .trend { font-size: 11px; color: var(--green); font-weight: 600; }
.summary .trend.down { color: var(--red); }

/* MATRIX — stacked location cards */
.matrix { display: flex; flex-direction: column; gap: 14px; }
.col {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; overflow: hidden;
}
.col.highlight { background: var(--highlight); border-color: #ddd9d2; }

.col-header { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.col-header .name { font-family: "Lora", serif; font-size: 17px; font-weight: 600; }
.col-header .meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 5px; font-size: 12px; color: var(--muted); gap: 10px;
}
.col-header .meta .today-sum { color: var(--ink); font-weight: 600; }
.col-header .meta .share {
  background: var(--line); padding: 2px 7px; border-radius: 10px;
  color: var(--ink-2); font-size: 11px; margin-left: 4px;
}

/* PLAN ROW */
.plan-row {
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
}
.plan-row:last-child { border-bottom: 0; }

.plan-meta { display: flex; flex-direction: column; min-width: 0; }
.plan-meta .label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 600;
}
.plan-meta .amount-row { display: flex; align-items: baseline; gap: 9px; margin-top: 3px; flex-wrap: wrap; }
.plan-meta .amount { font-size: 21px; font-weight: 600; line-height: 1; letter-spacing: -0.01em; }
.plan-meta .amount .cur { font-size: 13px; color: var(--muted); margin-left: 3px; }
.plan-meta .pct-badge {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  line-height: 1; white-space: nowrap;
}
.pct-badge.g { color: var(--green); background: var(--green-bg); }
.pct-badge.a { color: var(--amber); background: var(--amber-bg); }
.pct-badge.r { color: var(--red); background: var(--red-bg); }
.plan-meta .target { font-size: 11px; color: var(--muted); margin-top: 5px; }
.plan-meta .delta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.plan-meta .delta.g { color: var(--green); }
.plan-meta .delta.r { color: var(--red); }

/* VERTICAL BARS */
.vbars { display: flex; align-items: flex-end; gap: 7px; height: 76px; flex-shrink: 0; }
.vbar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  height: 100%; justify-content: flex-end;
}
.vbar { width: 17px; border-radius: 4px 4px 0 0; min-height: 3px; transition: height 0.6s ease; }
.vbar.plan { background: var(--bar-plan); }
.vbar.fact.g { background: var(--green); }
.vbar.fact.a { background: var(--amber); }
.vbar.fact.r { background: var(--red); }
.vbar-wrap .cap {
  font-size: 9px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 600;
}

/* BOTTOM TAB BAR */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbtn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative;
}
.tabbtn .ti { width: 22px; height: 22px; opacity: 0.85; }
.tabbtn.active { color: var(--wine); }
.tabbtn.active .ti { opacity: 1; }
.tabbtn:disabled { opacity: 0.5; }
.tabbtn .soon {
  position: absolute; top: 6px; left: 50%; transform: translateX(18px);
  font-size: 8px; font-weight: 700; color: #fff; background: var(--muted);
  padding: 1px 5px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.04em;
}
