/* Core One — the phone layout (with public/mobile.js).
   Loaded after style.css and pos.css. Wide screens only see the offline bar and the
   overlays' base rules; everything else lives under the phone breakpoint. */

/* ---------- everywhere ---------- */
.m-burger, .m-tabs { display: none; }
.m-offline {
  position: fixed; left: 12px; right: 12px; width: fit-content; margin: 0 auto; bottom: 18px; z-index: 300;
  background: #2a1d00; color: #ffd27a; border: 1px solid #6b4f12; border-radius: 999px;
  padding: 9px 16px; font-size: 13px; font-weight: 600; box-shadow: var(--e3); max-width: calc(100vw - 24px);
}
body:has(.m-offline-screen) .m-offline { display: none; }   /* the screen already says it */
.m-offline-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--hero, #0d0032); }
.mos-card { background: var(--paper); color: var(--ink); border-radius: 24px; padding: 34px 28px; max-width: 360px; text-align: center; box-shadow: var(--e3); }
.mos-card h2 { font-size: 22px; font-weight: 600; margin: 14px 0 8px; }
.mos-card p { color: var(--muted); margin-bottom: 22px; line-height: 1.5; }
.mos-ico { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--paper)); color: var(--accent-ink, var(--accent)); }
.mos-svg { width: 26px; height: 26px; }

/* overlays: a dimmed back and a panel that slides in */
html.m-locked, html.m-locked body { overflow: hidden; }
.m-overlay { position: fixed; inset: 0; z-index: 250; background: rgba(13, 0, 50, 0); transition: background .22s ease; }
.m-overlay.in { background: rgba(13, 0, 50, .48); }
.m-ico { width: 23px; height: 23px; }
.m-x { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--line-2); color: var(--ink-2);
  display: grid; place-items: center; }
.m-x .m-ico { width: 18px; height: 18px; }

.m-drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); background: var(--paper);
  display: flex; flex-direction: column; box-shadow: var(--e3); transform: translateX(-102%); transition: transform .24s cubic-bezier(.32, .72, 0, 1);
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.m-overlay.in .m-drawer { transform: none; }
.m-dhead { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; font-weight: 600; font-size: 17px; border-bottom: 1px solid var(--line-2); }
.m-dico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.m-dico .ico { width: 17px; height: 17px; }
.m-dlist { flex: 1; overflow-y: auto; padding: 8px 10px 14px; }
.m-dsec { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.m-ditem { display: block; padding: 12px 12px; border-radius: 12px; color: var(--ink); font-weight: 500; font-size: 15px; }
.m-ditem:active { background: var(--line-2); }
.m-ditem.on { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); color: var(--accent-ink, var(--accent)); font-weight: 600; }
.m-dempty { color: var(--muted); padding: 16px 12px; }
.m-dall { display: flex; align-items: center; gap: 12px; margin: 0 12px 12px; padding: 14px 14px; border-radius: 14px;
  background: var(--line-2); color: var(--ink); font-weight: 600; }

.m-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; background: var(--paper);
  border-radius: 24px 24px 0 0; box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, .45);
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(102%); transition: transform .26s cubic-bezier(.32, .72, 0, 1); }
.m-overlay.in .m-sheet { transform: none; }
.m-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 8px; }
.m-sh-head { display: flex; align-items: center; padding: 4px 2px 12px; }
.m-sh-head h3 { font-size: 18px; font-weight: 600; }
.m-newgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.m-newit { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 16px;
  background: var(--raised); border: 1px solid var(--line-2); color: var(--ink); font-size: 12.5px; font-weight: 600; text-align: center; }
.m-newit.here { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }
.m-nico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--line-2); color: var(--ink-2); }
.m-nico .ico, .m-nico .m-ico { width: 22px; height: 22px; }
.m-me { display: flex; align-items: center; gap: 14px; padding: 6px 2px 16px; }
.m-me-av { width: 52px; height: 52px; border-radius: 50%; background: var(--signal, #3cd95d); color: var(--signal-ink, #0d0032);
  display: grid; place-items: center; font-weight: 700; font-size: 17px; flex: none; }
.m-me b { display: block; font-size: 17px; font-weight: 600; }
.m-me div span { color: var(--muted); font-size: 13px; }
.m-group { margin-bottom: 12px; }
.m-glabel { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 2px 8px; }
.m-seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--line-2); border-radius: 12px; padding: 3px; gap: 3px; }
.m-seg button { border: 0; background: none; padding: 10px 6px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.m-seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--e1); }
.m-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  border: 1px solid var(--line-2); background: var(--raised); border-radius: 14px; padding: 13px 14px; margin-bottom: 10px; color: var(--ink); }
.m-row b { font-weight: 600; font-size: 15px; }
.m-row span { font-size: 12.5px; color: var(--muted); }
.m-row.m-out b { color: var(--danger); }
.m-row.m-static { cursor: default; }

/* ---------- the phone ---------- */
@media (max-width: 760px) {
  :root { --tb: calc(54px + env(safe-area-inset-top)); --tabbar: 62px; --below: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  /* iOS zooms into any field under 16px; at 16px it stays put. */
  input, select, textarea { font-size: 16px !important; }
  /* …but never smaller than they were designed to be */
  .sheet .title-input, .t-count-in input { font-size: 22px !important; }
  .po-field input { font-size: 20px !important; }
  .door-input { font-size: 19px !important; }
  .ch-composer input { min-width: 0; }

  /* top bar: ☰, the app, and nothing that will not fit */
  .topbar { height: var(--tb); padding-top: env(safe-area-inset-top); gap: 6px; }
  .topbar .home-btn, .topbar .menubar, .topbar .theme-btn, .topbar .tbtimer, .topbar .user-chip { display: none !important; }
  .m-burger { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; border: 0;
    background: rgba(255, 255, 255, .1); color: #fff; }
  .topbar .brand-name { display: inline; margin: 0 4px; font-size: 16px; }
  .topbar .appname ~ .spacer { display: none; }
  .topbar .appname { font-size: 15px; gap: 8px; padding: 5px 12px 5px 6px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar:has(.appname) .brand-name { display: none; }
  .loadbar { top: var(--tb); }

  /* the bottom tab bar */
  #main { padding-bottom: calc(var(--below) + 12px); }
  .m-tabs { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    height: var(--below); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line); }
  .m-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%;
    border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; -webkit-tap-highlight-color: transparent; }
  .m-tab.on { color: var(--accent-ink, var(--accent)); }
  .m-tab:active { transform: scale(.94); }
  .m-new .m-plus { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px;
    background: var(--signal, #3cd95d); color: var(--signal-ink, #0d0032);
    box-shadow: 0 10px 22px -8px rgba(28, 160, 60, .85), 0 0 0 5px var(--paper); }
  .m-plus-svg { width: 26px; height: 26px; stroke-width: 2.6; }
  .m-av { width: 24px; height: 24px; border-radius: 50%; background: var(--signal, #3cd95d); color: var(--signal-ink, #0d0032);
    display: grid; place-items: center; font-size: 9.5px; font-weight: 800; }
  .m-badge { position: absolute; top: 6px; left: 52%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: #d6342c; color: #fff; font-size: 10px; font-weight: 700; font-style: normal; display: grid; place-items: center; }
  /* under the top bar, where it covers nothing you type into */
  .m-offline { top: calc(var(--tb) + 8px); bottom: auto; }
  /* a full-screen document preview owns the whole screen */
  body:has(.docs-view) .m-tabs { display: none; }

  /* toasts and dialogs sit above the bar; dialogs become bottom sheets */
  #toasts { left: 12px; right: 12px; bottom: calc(var(--below) + 12px); }
  .toast { max-width: none; }
  .dlg-back { align-items: flex-end; }
  .dlg, .dlg.wide { width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; max-height: 88vh; overflow-y: auto;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  .dlg .fieldrow { grid-template-columns: 1fr; gap: 4px; }
  .dlg-suggest { margin-left: 0; }
  .dlg .dlg-actions { position: sticky; bottom: -1px; background: var(--paper); padding-top: 12px; margin-top: 18px; }
  .dlg .dlg-actions .btn { flex: 1; padding: 12px; }

  /* screens that pin themselves under the bar */
  .chat { inset: var(--tb) 0 var(--below); }
  .ch-thread { inset: var(--tb) 0 var(--below); }
  .appgrid-wrap { min-height: calc(100vh - var(--tb)); }
  .report-side, .acc-rail { top: calc(var(--tb) + 12px); }

  /* list screens: search first, pager small, no view switch (lists are cards) */
  .cpanel.odoo .cp-top { gap: 8px; padding: 10px 12px; }
  .cpanel.odoo .cp-top .crumbs { order: -1; flex: 1 1 100%; font-size: 20px; }
  #sharelink { display: none !important; }
  .cpanel.odoo .cp-search { padding: 8px 12px; }
  .kpistrip { padding: 10px 12px 0; overflow-x: auto; flex-wrap: nowrap !important; scrollbar-width: none; }
  .view-wrap { padding: 12px; }
  .m-cards { display: flex; flex-direction: column; gap: 8px; }
  .m-card { display: flex; flex-direction: column; gap: 6px; padding: 13px 14px; border-radius: 16px; background: var(--paper);
    border: 1px solid var(--line); box-shadow: var(--e1); color: var(--ink); -webkit-tap-highlight-color: transparent; }
  .m-card:active { transform: scale(.985); background: var(--raised); }
  .mc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
  .mc-title { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .mc-sub { font-size: 13px; color: var(--muted); align-items: center; }
  .mc-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mc-meta { display: inline-flex; align-items: center; gap: 8px; flex: none; white-space: nowrap; }
  .mc-meta .badge { font-size: 11px; padding: 2px 9px; }
  /* a pipeline board: one column at a time, swiped */
  .kanban { scroll-snap-type: x mandatory; gap: 10px; padding: 0 2px 10px; }
  .kcol { flex: 0 0 84vw; min-width: 84vw; scroll-snap-align: start; }

  /* the list's total chips: one swipeable row, never wrapped */
  .kchip { flex: none; white-space: nowrap; }
  /* forms: actions scroll sideways in one row; the stage bar is full width */
  /* the record fills the width; the documents button sits above it, at the right */
  .sheet-wrap { flex-direction: column; align-items: stretch; }
  .doc-side-pill { position: static; order: -1; align-self: flex-end; margin: 0 2px 10px; }
  .cpanel.odoo .form-actions, .form-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .form-actions .btn { flex: none; }
  .sheet-wrap { padding: 12px 10px 24px; }
  .sheet { padding: 20px 16px; border-radius: 18px; }
  .smartbar { padding: 10px 10px 0; overflow-x: auto; flex-wrap: nowrap; }
  .smartbtn { flex: none; }
  table.lines { display: block; overflow-x: auto; white-space: nowrap; }
  .chatter { padding: 0 10px; }

  /* reports and dashboards */
  .report { overflow-x: auto; padding: 18px 14px; }
  .rrow.cmp { grid-template-columns: minmax(0, 1fr) 84px 84px 44px; gap: 6px; }
  .dash { padding: 12px 10px 40px; }
  .kpis { gap: 10px; }
  .kpi { padding: 16px; }
  .kv { font-size: 24px; }
  .chart { gap: 6px; }
  .bar { width: 12px; }
  .rtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rtab { flex: none; }
  .period { flex-wrap: wrap; gap: 8px; }
}

/* installed and opened from the home screen: no browser bar, so the top bar takes the notch */
@media (display-mode: standalone) and (max-width: 760px) {
  body { overscroll-behavior-y: none; }
}
@media (prefers-reduced-motion: reduce) {
  .m-overlay, .m-drawer, .m-sheet { transition: none; }
}
