/* ============================================================
   Kasa — layout shell a breakpointy
   compact < 600 px (mobil) / medium 600–1024 (tablet na výšku)
   expanded > 1024 (terminál, tablet na šířku)
   ============================================================ */

#app { height: 100dvh; display: flex; overflow: hidden; }

#shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#screen {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
  padding: var(--sp-5);
  padding-inline: max(var(--sp-5), env(safe-area-inset-left, 0px));
  padding-bottom: calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
  scroll-padding-top: var(--sp-5);
}

/* ---------- Horní lišta ---------- */
#topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding-inline: var(--sp-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.topbar-title { font-size: var(--fs-title); font-weight: 660; letter-spacing: -0.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 460; }

.offline-chip {
  display: none; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: var(--r-full);
  background: var(--warning-soft); color: var(--warning);
  font-size: var(--fs-caption); font-weight: 640;
}
body.is-offline .offline-chip { display: inline-flex; }
.offline-chip .ic { width: 15px; height: 15px; stroke-width: 2.2; }

.topbar-clock { font-size: var(--fs-sm); font-weight: 620; color: var(--ink-2); }
.bell-btn { position: relative; }
.bell-dot {
  position: absolute; top: 8px; right: 8px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 680;
  display: grid; place-items: center;
}

/* ---------- Levý rail (terminál) ---------- */
#rail {
  width: var(--rail-w); flex: none;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: var(--sp-4) var(--sp-2);
  border-right: 1px solid var(--line);
  background: var(--surface);
  z-index: 25;
}
.rail-logo {
  display: grid; place-items: center;
  height: 56px; margin-bottom: var(--sp-3);
}
.rail-logo svg { width: 40px; height: 40px; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 60px; padding: var(--sp-2) 4px;
  border: none; background: transparent;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 11px; font-weight: 590;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.rail-btn:hover { background: var(--surface-2); color: var(--ink); }
.rail-btn[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 660; }
html[data-theme="dark"] .rail-btn[aria-current="page"] { color: var(--accent-strong); }
.rail-spacer { flex: 1; }

/* ---------- Dolní tab bar (mobil) ---------- */
#tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: none; background: transparent;
  color: var(--ink-3);
  font-size: 11px; font-weight: 580;
  cursor: pointer;
  padding-top: 8px;
}
.tab-btn .ic { width: 25px; height: 25px; }
.tab-btn[aria-current="page"] { color: var(--accent); font-weight: 650; }
html[data-theme="dark"] .tab-btn[aria-current="page"] { color: var(--accent-strong); }
.tab-badge {
  position: absolute; translate: 14px -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 680; display: grid; place-items: center;
}
.tab-btn { position: relative; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; z-index: 35;
  right: max(var(--sp-5), env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + var(--sp-4));
  height: 60px; padding: 0 var(--sp-5);
  border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-base); font-weight: 640;
  box-shadow: var(--e2);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.fab:active { transform: scale(.96); }

/* ============================================================
   Expanded (terminál / tablet na šířku)
   ============================================================ */
@media (min-width: 1025px) {
  #tabbar, .fab { display: none !important; }
  #screen { padding-bottom: var(--sp-8); }
}

/* ============================================================
   Medium (tablet na výšku 600–1024): rail zůstává, tenčí
   ============================================================ */
@media (min-width: 601px) and (max-width: 1024px) {
  #rail { width: 76px; }
  #tabbar, .fab { display: none !important; }
}

/* ============================================================
   Compact (mobil < 600): tab bar, žádný rail
   ============================================================ */
@media (max-width: 600px) {
  #rail { display: none; }
  #tabbar { display: flex; }
  #screen {
    padding: var(--sp-4);
    padding-bottom: calc(var(--tabbar-h) + var(--sp-8));
  }
  #topbar { padding-inline: var(--sp-4); }
}

/* ---------- DASHBOARD mřížka ---------- */
.dash-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(2, 1fr);
  align-items: stretch;
}
@media (min-width: 901px) {
  .dash-grid { grid-template-columns: repeat(4, 1fr); }
  .dash-grid .card--span2 { grid-column: span 2; }
  .dash-grid .card--span4 { grid-column: span 4; }
}
@media (max-width: 900px) and (min-width: 601px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid .card--span4 { grid-column: span 2; }
}
@media (max-width: 600px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .card--span2, .dash-grid .card--span4 { grid-column: span 1; }
}

.kpi { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-1); min-height: 128px; }
.kpi-label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--ink-2); font-weight: 560; }
.kpi-label .ic { width: 18px; height: 18px; color: var(--ink-3); }
.kpi-value { font-size: var(--fs-headline); font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; margin-top: auto; }
.kpi-value--big { font-size: var(--fs-display); }
.kpi-delta { font-size: var(--fs-sm); font-weight: 560; display: flex; align-items: center; gap: 4px; }
.kpi-delta .ic { width: 15px; height: 15px; stroke-width: 2.2; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ---------- POS mřížka (terminál: grid + košík vpravo) ---------- */
.pos-layout { display: flex; gap: var(--sp-5); align-items: stretch; min-height: 100%; }
.pos-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.pos-products {
  flex: 1;
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start;
}
.cart-aside {
  width: var(--cart-w); flex: none;
  align-self: flex-start;
  position: sticky; top: 0;
  max-height: calc(100dvh - var(--topbar-h) - var(--sp-10));
  display: flex; flex-direction: column;
}

/* Na terminálu na výšku a medium: košík = vysouvací panel zprava */
@media (max-width: 1024px) {
  .pos-layout { flex-direction: column; }
  .cart-aside { display: none; }
  .pos-products { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
}

/* ---------- Obecné dvousloupcové obrazovky ---------- */
.two-col { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
@media (min-width: 901px) { .two-col--report { grid-template-columns: 3fr 2fr; } }

/* ---------- View transitions ---------- */
::view-transition-old(root) { animation: vt-fade-out var(--t-med) var(--ease); }
::view-transition-new(root) { animation: vt-fade-in var(--t-med) var(--ease); }
@keyframes vt-fade-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-fade-in { from { opacity: 0; transform: translateY(6px); } }
