/* =========================================================
   Ember & Olive — phones & small tablets
   Nothing may overflow sideways; loaded after the other styles.
   ========================================================= */
html, body { overflow-x: clip; max-width: 100%; }

/* keep chart tooltips on the edge bars inside the card */
.bars .bar:nth-last-child(-n+2) .bar-tip, .rbars .rb:nth-last-child(-n+2) .bar-tip { left: auto; right: 0; transform: translateY(6px); }
.bars .bar:first-child .bar-tip, .rbars .rb:first-child .bar-tip { left: 0; transform: translateY(6px); }
.bars .bar:nth-last-child(-n+2):hover .bar-tip, .bars .bar.peak:nth-last-child(-n+2) .bar-tip,
.rbars .rb:nth-last-child(-n+2):hover .bar-tip, .bars .bar:first-child:hover .bar-tip,
.bars .bar.peak:first-child .bar-tip, .rbars .rb:first-child:hover .bar-tip { transform: none; }

@media (max-width: 820px) {
  .blob { display: none; }
  body { padding-bottom: 88px; }
  .app { padding: 10px; gap: 10px; }
  .main, .view, #view-overview, .grid, .kpis, .r-grid, .side, .c-tls, .tv-side { gap: 10px; }

  /* sidebar becomes a fixed bottom navigation bar */
  .sidebar {
    position: fixed; top: auto; bottom: 10px; left: 10px; right: 10px; height: 62px; min-height: 0;
    flex-direction: row; align-items: center; justify-content: space-between; gap: 2px;
    padding: 0 8px; border-radius: 22px; overflow: visible; z-index: 90;
    box-shadow: 0 16px 34px -12px rgba(0, 0, 0, .55);
  }
  .sidebar .logo { display: none; }
  .nav, .nav-bottom { flex-direction: row; gap: 2px; margin: 0; }
  .nav { flex: 7; justify-content: space-between; }
  .nav-bottom { flex: 2; justify-content: space-around; }
  .nav-btn, .nav-ind { width: 36px; height: 36px; }
  .nav-btn i[data-i] { width: 17px; height: 17px; }
  .nav-badge { top: -2px; right: -3px; }
  .toasts { bottom: 86px; right: 10px; left: 10px; align-items: stretch; }
  .toast { max-width: none; }

  /* top bar: logo + essentials only */
  .topbar { flex-wrap: nowrap; gap: 8px; }
  .pill-group { width: auto; flex: 1; min-width: 0; overflow: visible; padding: 4px; gap: 2px; }
  #refreshBtn, #checkAllBtn, .pill-group .divider { display: none; }
  .profile { padding: 2px; }
  .icon-btn { width: 36px; height: 36px; }
  .tb-right { width: auto; gap: 6px; }
  .greet { display: flex; margin: 0; }
  .greet div { display: none; }
  .greet-mark { width: 36px; height: 36px; }
  #todayLabel { display: none; }
  .date-pill { padding: 0 8px 0 4px; gap: 6px; }
  .icon-btn.sq { width: 40px; height: 40px; }
  .menu.right { right: 0; }
  .popover { width: min(320px, calc(100vw - 20px)); right: -46px; }
  #quickMenu { left: auto; right: -84px; }

  /* page heading */
  .page-head { gap: 12px; align-items: flex-start; }
  .title-wrap { gap: 12px; align-items: center; }
  h1 { font-size: 27px; }
  .burst { width: 46px; height: 46px; flex: none; }
  .burst svg { width: 22px; height: 22px; }
  .burst-arrow { width: 20px; height: 20px; margin-left: -22px; align-self: flex-end; }
  .head-controls { width: 100%; gap: 8px; }
  .head-controls .pill.static { margin-left: auto; }
  .pill { height: 38px; }
  #headAction { flex: 1; justify-content: space-between; }

  /* cards & stats */
  .card { padding: 14px; border-radius: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px 14px; }
  .kpi-v { font-size: 20px; }
  .kpi.small-v .kpi-v { font-size: 14px; white-space: normal; }
  .kpi-ic { width: 26px; height: 26px; }
  .kpi > small { font-size: 10px; }
  .v-bar { gap: 10px; }
  .v-bar .tabs, .tabs { width: 100%; }
  .v-bar-r { width: 100%; }
  .v-bar-r .search { flex: 1; }
  .seg { max-width: 100%; }
  #oMode { width: 100%; }
  #oMode button { flex: 1; padding: 0 8px; }

  /* overview */
  .big-num { font-size: 26px; }
  .ana-stat .val { font-size: 22px; }
  .bars { gap: 3px; }
  .x-axis { gap: 3px; margin-left: 52px; }
  .y-axis { width: 42px; }
  .split { margin: 12px -14px -14px; }
  .kit-top { gap: 12px; }
  .c-pro { min-height: 280px; }
  .c-pro h2 { font-size: 26px; max-width: 220px; }
  .cloche { width: 70%; }
  .assign { grid-template-columns: 1fr; }
  .cov-body { grid-template-columns: minmax(0, 1fr); }
  .prep-tile { height: 120px; }
  .dark-panel { padding: 14px; border-radius: 24px; }
  .dp-nav { gap: 8px; }
  .bolt-circle { width: 40px; height: 40px; }
  .dp-tabs { flex-wrap: wrap; overflow: visible; width: 100%; order: 3; border-radius: 20px; }
  .dp-tabs button { flex: 1 1 40%; height: 34px; padding: 0 10px; font-size: 12px; }
  .dp-right { margin-left: auto; }
  .icon-btn.dark { width: 40px; height: 40px; }
  .dp-title { margin: 16px 0; gap: 10px; }
  .dp-title h2 { font-size: 34px; text-align: center; }
  .q-big, .f-big { font-size: 36px; }
  .f-col { height: 170px; }
  .f-col b { font-size: 18px; }
  .ai-bar { padding: 6px; }
  .prompt { height: 46px; padding: 0 4px 0 12px; gap: 8px; font-size: 14px; }
  .mic { width: 34px; height: 34px; }
  .go { width: 38px; height: 38px; }
  .ans-row { grid-template-columns: 22px 26px minmax(0, 1fr) auto; }
  .ans-row .bar { display: none; }
  .res-grid, .q-grid, .def-grid { grid-template-columns: minmax(0, 1fr); }
  .res-card { flex-wrap: wrap; }
  .rc-acts { width: 100%; justify-content: flex-end; }

  /* tables stack into labelled cards */
  .table-wrap { overflow: visible; margin: 0; }
  .dtable, .dtable tbody, .tx table, .tx tbody { display: block; width: 100%; }
  .dtable thead, .tx thead { display: none; }
  .dtable tr, .tx tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
  .dtable td, .tx td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; white-space: normal; min-width: 0; text-align: left !important; }
  .dtable td::before, .tx td::before { content: attr(data-label); font-size: 10px; color: var(--muted); font-weight: 500; }
  .dtable td:first-child, .tx td:first-child, .dtable td:last-child { grid-column: 1 / -1; }
  .dtable td:first-child::before, .tx td:first-child::before { display: none; }
  .dtable td:empty { display: none; }
  .dtable .ellip { max-width: none; white-space: normal; }
  .dtable.inv tr.s-critical td:first-child, .dtable.inv tr.s-low td:first-child { box-shadow: none; }
  .dtable.inv tr.s-critical { border-left: 4px solid #e4652e; }
  .dtable.inv tr.s-low { border-left: 4px solid #f0b43c; }
  .dtable tr td[colspan] { grid-column: 1 / -1; }
  .stock { min-width: 0; }
  .row-acts { flex-wrap: wrap; flex-direction: row; }
  .tx { overflow: visible; }
  .tx tr { background: #fafaf7; }

  /* staff schedule: compact day grid */
  #sched { overflow: visible; }
  .sched, .sched tbody { display: block; width: 100%; }
  .sched thead, .sched tfoot { display: none; }
  .sched tr { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
  .sched td { display: block; border: 0; padding: 0; background: none !important; }
  .sched td:first-child { grid-column: 1 / 7; padding: 0 0 4px; }
  .sched td:last-child { grid-column: 7; grid-row: 1; text-align: right; padding: 0; align-self: center; }
  .day { min-width: 0; height: 40px; font-size: 0; display: grid; place-items: center; }
  .day::before { content: attr(data-day); font-size: 10.5px; }
  .sched td.today .day { box-shadow: 0 0 0 2px var(--ink); }

  /* other screens */
  .tv-layout, .help-cols { grid-template-columns: minmax(0, 1fr); }
  .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
  .tbl { height: 76px; }
  .tbl.round { width: 76px; }
  .t-legend { gap: 8px 12px; }
  .td-acts { grid-template-columns: 1fr; }
  .mgrid, .sgrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
  .board { grid-template-columns: minmax(0, 1fr); }
  .b-col { min-height: 0; }
  .rchart { height: 200px; }
  .r-y { width: 46px; }
  .rbars, .rlabels { gap: 2px; }
  .donut-wrap { justify-content: center; }
  .rank li { grid-template-columns: 22px 36px minmax(0, 1fr) auto; gap: 8px; }
  .rank .rk-bar { display: none; }
  .hbars li { grid-template-columns: 64px 1fr auto; }
  .data-card, .set-actions { flex-direction: column; align-items: stretch; }
  .data-acts { flex-direction: column; }
  .help-hero { padding: 18px; }
  .help-hero h2 { font-size: 23px; }
  .help-hero .search { min-width: 0; width: 100%; }
  .credits { grid-template-columns: minmax(0, 1fr); }
  .photo-pick { flex-wrap: wrap; }
  .po { flex-wrap: wrap; }
  .po-main { flex-basis: calc(100% - 60px); }

  /* dialogs become bottom sheets */
  .modal-wrap, .modal-wrap.side { padding: 0; place-items: end stretch; }
  .modal, .modal.wide, .modal-wrap.side .modal { width: 100%; height: auto; max-height: calc(100vh - 30px); border-radius: 24px 24px 0 0; transform: translateY(40px); }
  .modal-wrap.open .modal, .modal-wrap.side.open .modal { transform: none; }
  .modal-f { position: sticky; bottom: 0; background: #fff; border-radius: 0; }
  .modal-f button { flex: 1 1 auto; }
  .steps small { font-size: 9px; }
  .pos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 300px; }
  .pos-item .pi-e { height: 70px; }
  .amount-pick { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
  h1 { font-size: 24px; }
  .kpi-v { font-size: 18px; }
  .nav-btn, .nav-ind { width: 33px; height: 33px; }
  .sidebar { padding: 0 5px; left: 6px; right: 6px; }
  .pill-group .icon-btn.ghost { width: 32px; height: 32px; }
  .head-controls .pill.static { display: none; }
  .card-head { flex-wrap: wrap; }
}
@media (max-width: 350px) {
  .nav-btn, .nav-ind { width: 29px; height: 29px; }
  .nav-btn i[data-i] { width: 15px; height: 15px; }
  .nav, .nav-bottom { gap: 0; }
  .sidebar { padding: 0 4px; left: 4px; right: 4px; }
  .app { padding: 8px; }
}
