/* OENOD fit 3.9: every screen fits on phone, tablet, laptop and wide screens.
   Loaded last so it can correct older modules without touching them. */

/* 1. Layout tracks can never be pushed wider than the screen */
.shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
.shell > *, .main, .content, #view { min-width: 0; }
.grid > *, .row > .grow, .page-head > *, .card, .kpi { min-width: 0; }
.content { margin-inline: auto; }
@media (max-width: 980px) { .shell { grid-template-columns: minmax(0, 1fr); } }
img, video, canvas, svg { max-width: 100%; }
.kpi .v { overflow-wrap: anywhere; }

/* 2. Top bar: one clean line at every width */
.top > * { flex-shrink: 0; }
.top .search { flex: 1 1 200px; min-width: 0; max-width: 460px; }
.top .search .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; }
.top .search kbd { white-space: nowrap; flex: none; }
.top .btn, .top .me b { white-space: nowrap; }
.top .sp { flex: 1 1 0; min-width: 0; }
@media (min-width: 981px) { .top a.applogo { display: none; } }
@media (max-width: 1280px) and (min-width: 761px) {
  .top { gap: 8px; padding-inline: 20px; }
  .top .search kbd { display: none; }
  .top .g6-top .lbl { display: none; }
  .top .g6-top { padding-inline: 10px; }
}
@media (max-width: 1160px) and (min-width: 761px) {
  .top .btn.ai-top { font-size: 0; gap: 0; padding: 0; width: 40px; height: 40px; justify-content: center; flex: none; }
  .top .btn.ai-top .i, .top .btn.ai-top svg { width: 18px; height: 18px; margin: 0; }
  .top .me b { display: none; }
}
@media (max-width: 880px) and (min-width: 761px) {
  .top .search { flex: 0 0 40px; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .top .search .lbl { display: none; }
}

/* 3. First-visit page tip: a small corner card above the help buttons, never over the page body */
.g6-coach { inset-inline-start: auto !important; inset-inline-end: 20px; bottom: 86px !important; width: min(330px, calc(100vw - 40px)); }
.content { padding-bottom: 110px; }

/* 4. Profit & labor */
.p3-top { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.p3-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.p3-health { min-width: 0; }
.p3-health > div:last-child { min-width: 0; }
.p3-health .btn { white-space: normal; }
@media (max-width: 1440px) {
  .p3-top { grid-template-columns: minmax(0, 1fr); }
  .p3-health { flex-direction: row; text-align: start; }
  .p3-health .row { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .p3-health { flex-direction: column; text-align: center; }
  .p3-health .row { justify-content: center; }
  .p3-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
.p3-recs { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.rangebar { gap: 8px; }
.rangebar .input[type=date] { flex: 1 1 150px; min-width: 0; max-width: 200px; }
.rangebar .seg { overflow-x: auto; max-width: 100%; }

/* 5. Floating help buttons stay small on phones so they never hide buttons */
@media (max-width: 700px) {
  .g6-fab { width: 46px; height: 46px !important; padding: 0 !important; justify-content: center; border-radius: 16px; }
  .g6-fab > span:not(.g6-dot) { display: none; }
  .g6-fab .g6-dot { top: 4px; inset-inline-end: 4px; }
}

/* 6. Page titles keep a readable width; buttons drop under the title instead of squeezing it */
@media (min-width: 761px) {
  .page-head .t { flex: 1 1 400px; min-width: min(400px, 100%); }
  .page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .page-head h1 { text-wrap: balance; }
  .page-head p { max-width: 70ch; }
}
.seg button, .tabs a, .tabs button { white-space: nowrap; }
@media (max-width: 760px) {
  .page-head { flex-wrap: nowrap; }
  .page-head > .t, .page-head > .actions { max-width: none; min-width: 0; width: auto; }
}
@media (max-width: 760px) {
  .content { overflow-x: clip; }
  .card .btn, .empty .btn, .modal .btn { max-width: 100%; white-space: normal; text-align: center; }
  .row.wrap > .btn { flex: 0 1 auto; }
}

/* 7. Small polish */
img.fit-broken { display: none !important; }
.ix-logo { text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
@media (max-width: 760px) { body { overflow-x: clip; } .auth, .hero { overflow-x: clip; } }

/* 8. Buttons and search rows inside cards never poke out of their card */
.card .btn { max-width: 100%; }
.card .btn:not(.iconbtn) { white-space: normal; text-align: center; line-height: 1.25; }
.row:has(> .input), .row:has(> select) { flex-wrap: wrap; }
.row > .input, .row > select.input { min-width: 0; }
@media (max-width: 760px) { .row:has(> .input) > .input { flex: 1 1 160px; } }
.page-head .actions label.row { flex-wrap: nowrap; white-space: nowrap; }

/* 9. Right-to-left languages (Arabic, Urdu): the menu drawer slides in from the right, next to its button */
@media (max-width: 980px) {
  [dir=rtl] .side { left: auto; right: 0; transform: translateX(100%); }
  [dir=rtl] .side.open { transform: none; }
}
[dir=rtl] .ai-fab { right: auto; left: 22px; }
@media (max-width: 760px) { [dir=rtl] .ai-fab { left: 16px; } }

/* logo-fit 2: new URL so browsers drop the old cropped logo image */
.wordmark:not(.custom) { -webkit-mask-image: url('oenod-wordmark.png?v=lf2') !important; mask-image: url('oenod-wordmark.png?v=lf2') !important; }
.v6root.v6root { --logo: url('oenod-wordmark.png?v=lf2'); }
