/* Phone: an app, not a shrunken website. Soft light surface with a blue wash on top, white rounded cards, a floating tab bar in thumb reach,
   windows as sheets, lists as cards. Everything phone-only lives here, so the desktop screens stay as they are. */
@media (max-width: 760px) {
  :root { --m-safe-b: max(10px, env(safe-area-inset-bottom)); --top-h: calc(58px + env(safe-area-inset-top)); --tab-h: calc(62px + var(--m-safe-b)); --m-gut: 16px; --m-r: 20px; --m-r-sm: 14px;
    --font-serif: var(--font-sans) !important; --font-mono: var(--font-sans) !important; --radius: 14px !important; --radius-sm: 12px !important; --radius-lg: 20px !important; --blur: 0px !important; }
  :root { --m-ink: #0f1b33; --m-on-ink: #fff; --m-wash: #c8dbf8; --m-wash-2: #e2ebfa; --m-shadow: 0 10px 26px -16px rgba(22, 44, 88, .32), 0 1px 2px rgba(22, 44, 88, .05); --m-bar: rgba(255, 255, 255, .86); --m-soft: #e6eefb; }
  :root[data-theme="dark"] { --m-ink: #f1f4fb; --m-on-ink: #0f1b33; --m-wash: #1b2d4f; --m-wash-2: #121a2b; --m-shadow: 0 10px 26px -16px rgba(0, 0, 0, .7); --m-bar: rgba(30, 37, 52, .88); --m-soft: #22304a; }
  :root[data-mode="system"], :root[data-mode="light"] {
    --bg: #f1f4f9 !important; --surface: #fff !important; --surface-2: #f3f5fa !important; --surface-3: #eaeef5 !important; --surface-solid: #fff !important; --overlay: #fff !important;
    --fg: #0f1b33 !important; --fg-2: #47536b !important; --fg-3: #76819a !important; --fg-4: #a4adbf !important; --border: #e8ecf3 !important; --border-strong: #d4dae6 !important;
    --accent-text: #1d3f73 !important; --icon: #1d3f73 !important; }
  :root[data-mode="dark"] {
    --bg: #0c111c !important; --surface: #171d2b !important; --surface-2: #1e2534 !important; --surface-3: #252d3f !important; --surface-solid: #171d2b !important; --overlay: #171d2b !important;
    --fg: #f1f4fb !important; --fg-2: #c2c9d8 !important; --fg-3: #8e98ad !important; --fg-4: #606a7f !important; --border: #262d3d !important; --border-strong: #343c50 !important;
    --accent-text: #8fb2ee !important; --icon: #8fb2ee !important; }
  /* clip, not hidden: hidden would turn the body into a scroller and the sticky top bar would scroll away */
  html, body { overflow-x: clip; -webkit-text-size-adjust: 100%; }
  html { background: var(--bg); }
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; background: linear-gradient(180deg, var(--m-wash) 0, var(--m-wash-2) 170px, var(--bg) 340px) no-repeat, var(--bg); color: var(--fg); }
  * { min-width: 0; }
  .aurora { display: none; }
  a, button, label { touch-action: manipulation; }

  /* top bar: lives under the status bar, always tappable */
  .nx-top { position: sticky; top: 0; z-index: 30; height: var(--top-h); padding: env(safe-area-inset-top) var(--m-gut) 0; display: flex; align-items: center; gap: 8px; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; --top-fg: var(--fg); --top-fg-2: var(--fg-2); --top-fg-3: var(--fg-3); --top-hover: var(--surface-2); --top-line: var(--border); }
  .nx-top::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: var(--m-top-solid, 0); background: color-mix(in srgb, var(--m-wash) 94%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); transition: opacity .18s; }
  body.m-scrolled, body.nav-open { --m-top-solid: 1; }
  .nx-burger, .nx-clock, .nx-search, .nx-adm, .nx-lang, #nx-mode { display: none !important; }
  .nx-brand { padding: 0; border: 0; flex: none; background: none; }
  .nx-logo { display: flex; align-items: center; height: 40px; padding: 0 12px; border-radius: 20px; background: #fff; box-shadow: var(--m-shadow); }
  .nx-logo img { height: 24px; background: none !important; padding: 0 !important; }
  .nx-back { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--fg); box-shadow: var(--m-shadow); }
  .nx-back span { display: none; } .nx-back svg { width: 20px; height: 20px; }
  .nx-back:not([hidden]) ~ .nx-actions { margin-left: auto; }
  .nx-actions { margin-left: auto; gap: 8px; display: flex; align-items: center; }
  .nx-actions .icon-btn, .user-chip { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface); color: var(--fg); box-shadow: var(--m-shadow); display: grid; place-items: center; }
  .user-chip { background: var(--m-ink); color: var(--m-on-ink); font-size: 13px; font-weight: 800; }

  /* page */
  .nx-body { display: block; background: transparent; }
  .nx-content { padding: 6px var(--m-gut) calc(var(--tab-h) + 14px); max-width: 100vw; overflow-x: clip; background: transparent; }
  .page-head { display: block; margin-bottom: 12px; }
  .page-head h1 { font-size: 30px; font-weight: 800; line-height: 1.12; letter-spacing: -.6px; }
  .page-sub { font-size: 13px; margin-top: 3px; color: var(--fg-2); text-transform: none; letter-spacing: 0; }
  .page-actions { display: flex; gap: 8px; overflow-x: auto; margin: 12px calc(var(--m-gut) * -1) 0; padding: 2px var(--m-gut); scrollbar-width: none; flex-wrap: nowrap; }
  .page-actions:empty { display: none; }
  .page-actions .btn { flex: none; }
  .page-actions::-webkit-scrollbar, .mod-tabs::-webkit-scrollbar, .filters-bar::-webkit-scrollbar, .toolbar::-webkit-scrollbar, .tabs::-webkit-scrollbar, .doc-list::-webkit-scrollbar { display: none; }

  /* pills: module screens and filters */
  .mod-tabs { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0 calc(var(--m-gut) * -1) 14px; padding: 2px var(--m-gut); width: auto; max-width: none; background: transparent; border: 0; box-shadow: none; border-radius: 0; scrollbar-width: none; }
  .mod-tabs > * { flex: none; min-height: 38px; display: inline-flex; align-items: center; padding: 0 15px; border: 0; border-radius: 19px; background: var(--surface); color: var(--fg-2); font-size: 13.5px; font-weight: 700; box-shadow: var(--m-shadow); }
  .mod-tabs a.on, .mod-tabs > .on { background: var(--m-ink) !important; color: var(--m-on-ink) !important; }
  .sub-tabs { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0 calc(var(--m-gut) * -1) 14px; padding: 2px var(--m-gut); border: 0; scrollbar-width: none; }
  .sub-tabs::-webkit-scrollbar { display: none; }
  .sub-tabs > * { flex: none; min-height: 38px; padding: 0 15px; border: 0 !important; border-radius: 19px; background: var(--surface); color: var(--fg-2); font-size: 13.5px; font-weight: 700; white-space: nowrap; box-shadow: var(--m-shadow); }
  .sub-tabs > .on, .sub-tabs > .active { background: var(--m-ink) !important; color: var(--m-on-ink) !important; }
  .filters-bar { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0 calc(var(--m-gut) * -1) 12px; padding: 4px var(--m-gut); background: transparent; border: 0; box-shadow: none; border-radius: 0; scrollbar-width: none; }
  .filters-bar > * { flex: none; }
  .filters-bar :is(input, select), .nx-flt { min-height: 40px !important; height: 40px; border: 0 !important; border-radius: 20px !important; background-color: var(--surface) !important; box-shadow: var(--m-shadow); font-size: 14px !important; }
  .filters-bar input:not([type=checkbox]):not([type=radio]) { padding: 0 14px; }
  .filters-bar .search, .nx-flt { flex: 0 0 170px; }
  .filter-chip { flex: none; min-height: 38px; padding: 0 14px; border: 0 !important; border-radius: 19px; background: var(--surface) !important; color: var(--fg-2); font-size: 13.5px; font-weight: 700; box-shadow: var(--m-shadow); }
  .filter-chip.active { background: var(--m-ink) !important; color: var(--m-on-ink); }
  .filter-chip small, .filter-chip em, .filter-chip i { opacity: .7; font-style: normal; }
  .filter-count { display: none; }
  .seg { flex: none; border-radius: 20px; padding: 3px; border: 0; background: var(--surface); box-shadow: var(--m-shadow); }
  .seg button { min-height: 34px; padding: 0 12px; border-radius: 17px; font-size: 13px; font-weight: 700; }
  .seg button.on { background: var(--m-ink); color: var(--m-on-ink); }

  /* controls: comfortable targets, iOS does not zoom on 16px fields */
  .btn { min-height: 44px; padding: 9px 16px; border-radius: 22px; font-weight: 700; box-shadow: none; }
  .btn:not(.primary):not(.danger) { background: var(--surface); border-color: transparent; box-shadow: var(--m-shadow); }
  .btn.primary { background: var(--m-ink); color: var(--m-on-ink); border-color: transparent; }
  .btn.sm { min-height: 38px; padding: 7px 13px; }
  .btn:hover, .flow-b:hover, .p-tile:hover { transform: none; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; min-height: 46px; border-radius: 14px; }
  textarea { min-height: 84px; }
  .fld label { font-size: 12.5px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--fg-2); margin-bottom: 5px; }

  /* floating tab bar: the current screen is a dark pill with its name, the others just an icon */
  .m-tabbar { position: fixed; z-index: 45; left: var(--m-gut); right: var(--m-gut); bottom: var(--m-safe-b); height: 62px; padding: 6px; display: flex; gap: 2px; border-radius: 31px; background: var(--m-bar); -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6); box-shadow: 0 16px 34px -14px rgba(16, 32, 68, .42), 0 1px 3px rgba(16, 32, 68, .08); transition: transform .2s; }
  body:has(input:not([type=checkbox]):not([type=radio]):focus, textarea:focus) .m-tabbar { transform: translateY(140%); }
  .m-tabbar > * { position: relative; flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 7px; height: 50px; padding: 0; border: 0; border-radius: 25px; background: none; color: var(--fg-3); font: inherit; font-size: 13px; font-weight: 800; text-decoration: none; transition: flex-grow .24s cubic-bezier(.2, .8, .2, 1), background .18s; }
  .m-tabbar span { display: none; }
  .m-tabbar .ic, .m-tabbar svg { width: 23px; height: 23px; flex: none; }
  .m-tabbar .on, body.nav-open #m-more, .m-tabbar:not(:has(a.on)) #m-more { flex: 2.6 1 0; padding: 0 14px; background: var(--m-ink); color: var(--m-on-ink); }
  .m-tabbar .on span, body.nav-open #m-more span, .m-tabbar:not(:has(a.on)) #m-more span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.nav-open .m-tabbar .on:not(#m-more) { flex: 1 1 0; padding: 0; background: none; color: var(--fg-3); }
  body.nav-open .m-tabbar .on:not(#m-more) span { display: none; }
  .m-tabbar .nx-badge { position: absolute; top: 5px; left: calc(50% + 5px); min-width: 17px; height: 17px; margin: 0; padding: 0 4px; border-radius: 9px; font-size: 10px; line-height: 17px; text-align: center; background: #e5484d; color: #fff; font-style: normal; font-family: inherit; }
  .m-tabbar .on .nx-badge { position: static; flex: none; }

  /* "More": who is signed in, every module as a soft tile, settings as a grouped list */
  .nx-side { position: fixed; z-index: 40; inset: 0; width: auto; height: auto; padding: calc(var(--top-h) + 4px) var(--m-gut) calc(var(--tab-h) + 24px); overflow-y: auto; display: block; transform: translateY(24px); opacity: 0; visibility: hidden; transition: transform .24s cubic-bezier(.2, .8, .2, 1), opacity .18s, visibility .24s; background: linear-gradient(180deg, var(--m-wash) 0, var(--m-wash-2) 170px, var(--bg) 340px) no-repeat, var(--bg); border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; --side-fg: var(--fg); --side-fg-2: var(--fg-2); --side-fg-3: var(--fg-3); --side-hover: transparent; --side-line: var(--border); --side-active: var(--fg); overscroll-behavior: contain; }
  body.nav-open .nx-side { transform: none; opacity: 1; visibility: visible; }
  html:has(body.nav-open) { overflow: hidden; }
  body.nav-open .nx-scrim-side { display: none; }
  body.nav-open .nx-top { z-index: 46; }
  body.nav-open .nx-logo, body.nav-open .nx-back { visibility: hidden; }
  .m-me { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 12px; border-radius: var(--m-r); background: var(--surface); box-shadow: var(--m-shadow); color: var(--fg); }
  .m-me > span { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--m-ink); color: var(--m-on-ink); font-weight: 800; }
  .m-me div { display: grid; line-height: 1.25; } .m-me b { font-size: 16px; font-weight: 800; } .m-me small { font-size: 12.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nx-side .nx-search { position: relative; display: flex !important; align-items: center; gap: 8px; width: auto; max-width: none; height: 46px; margin: 0 0 18px; padding: 0 14px; border: 0; border-radius: 23px; background: var(--surface); box-shadow: var(--m-shadow); color: var(--fg-3); }
  .nx-side .nx-search input { flex: 1; min-height: 0; height: 40px; border: 0; padding: 0; background: transparent; color: var(--fg); box-shadow: none; outline: 0; }
  .nx-side .nx-search .ic { flex: none; width: 19px; height: 19px; }
  .nx-search kbd { display: none; }
  .nx-side .nx-search .ac-list { position: absolute; left: 0; right: 0; top: 50px; z-index: 5; max-height: 50dvh; overflow: auto; border-radius: var(--m-r-sm); }
  .nx-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 6px; padding: 0; }
  .nx-nav .nx-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 7px; height: auto; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--fg); font-size: 11.5px; font-weight: 700; line-height: 1.15; text-align: center; }
  .nx-nav .nx-item.on, .nx-nav .nx-item:hover { background: none; color: var(--fg); }
  .nx-nav .nx-item::before { display: none; }
  .nx-nav .nx-item svg { box-sizing: border-box; flex: none; width: 58px; height: 58px; padding: 16px; border-radius: 20px; background: linear-gradient(160deg, var(--surface), var(--m-soft)); color: var(--accent-text); box-shadow: 0 12px 22px -14px rgba(22, 44, 88, .5), inset 0 1px 0 rgba(255, 255, 255, .55); }
  .nx-nav .nx-item.on svg { background: var(--m-ink); color: var(--m-on-ink); }
  .nx-nav .nx-item span { white-space: normal; overflow-wrap: anywhere; hyphens: auto; }
  .nx-nav .nx-item .nx-badge { position: absolute; top: -3px; left: calc(50% + 15px); right: auto; margin: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; line-height: 18px; font-size: 10.5px; font-family: inherit; background: #e5484d; color: #fff; }
  .nx-look, .nx-foot { display: none !important; }
  .m-tools { display: block; margin-top: 22px; padding: 0 14px; border-radius: var(--m-r); background: var(--surface); box-shadow: var(--m-shadow); color: var(--fg); }
  .m-tools > * { position: relative; width: 100%; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 22px 0 0; border: 0; border-bottom: 1px solid var(--border); background: none; color: inherit; font: inherit; font-size: 15px; font-weight: 600; text-align: left; }
  .m-tools > *:last-child { border-bottom: 0; }
  .m-tools > *::after { content: ''; position: absolute; right: 3px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border: solid var(--fg-4); border-width: 2px 2px 0 0; transform: rotate(45deg); }
  .m-tools svg { flex: none; box-sizing: border-box; width: 34px; height: 34px; padding: 8px; border-radius: 11px; background: var(--m-soft); color: var(--accent-text); }
  .m-tools select { flex: 1; min-height: 40px; padding: 0; border: 0; background: transparent; color: inherit; font-weight: 600; -webkit-appearance: none; appearance: none; }
  .m-tools select option { color: #111; }
  .m-tools [data-m="logout"] { color: #d23f45; } .m-tools [data-m="logout"] svg { background: color-mix(in srgb, #e5484d 13%, transparent); color: #d23f45; } .m-tools [data-m="logout"]::after { display: none; }

  /* lists as cards: label left, value right, the first cells read as the title */
  .grid-card, .glass { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .grid-card { background: transparent; border: 0; box-shadow: none !important; padding: 0; overflow: visible; }
  .toolbar { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; margin: 0 calc(var(--m-gut) * -1) 10px; padding: 2px var(--m-gut) 8px; scrollbar-width: none; background: transparent; border: 0; }
  .toolbar .btn { flex: none; }
  .toolbar:empty, .toolbar.extra:empty { display: none; }
  .grid-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 0 10px; background: transparent; border: 0; }
  .grid-tools .search { flex: 1 1 100%; max-width: none; height: 46px; border: 0; border-radius: 23px; background: var(--surface); box-shadow: var(--m-shadow); }
  .grid-tools .search input { min-height: 0; border: 0; background: transparent; }
  .grid-tools [data-cols], .grid-tools [data-csv] { display: none; }
  .grid-scroll { overflow: visible; max-height: none; border: 0; background: transparent; }
  table.m-cards-table { display: block; width: 100% !important; min-width: 0 !important; table-layout: auto; border: 0; background: transparent; }
  table.m-cards-table > thead { display: none; }
  table.m-cards-table > tbody, table.m-cards-table > tfoot { display: block; }
  table.m-cards-table > tbody > tr { display: block; position: relative; margin-bottom: 10px; padding: 12px 14px; border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--m-shadow); }
  table.m-cards-table > tbody > tr.sel > td, table.m-cards-table > tbody > tr:hover > td { background: transparent; color: inherit; }
  table.m-cards-table > tbody > tr.sel { box-shadow: 0 0 0 2px var(--m-ink), var(--m-shadow); background: var(--surface); }
  table.m-cards-table > tbody > tr > td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; width: auto !important; min-width: 0 !important; padding: 3px 0 !important; border: 0 !important; background: transparent; white-space: normal; text-align: right; font-size: 14px; overflow-wrap: anywhere; font-family: inherit; }
  table.m-cards-table > tbody > tr > td[data-l]::before { content: attr(data-l); flex: none; max-width: 46%; color: var(--fg-3); font-size: 12.5px; font-weight: 600; text-align: left; font-family: var(--font-sans); }
  table.m-cards-table > tbody > tr > td:empty { display: none; }
  table.m-cards-table > tbody > tr > td.g-chev { position: absolute; top: 13px; right: 14px; padding: 0 !important; font-size: 22px; line-height: 1; color: var(--fg-4); }
  table.m-cards-table > tbody > tr.g-open > td.g-chev { transform: rotate(90deg); }
  table.m-cards-table > tbody > tr > td:first-child:not(.g-chev):not(:has(.art-th)):not(:has(input)):not(:has(select)) { font-weight: 800; font-size: 15px; }
  table.m-cards-table > tbody > tr:has(> td.g-chev) > td:nth-child(2) { display: block; padding-right: 22px !important; text-align: left; font-weight: 800; font-size: 16px; line-height: 1.25; }
  table.m-cards-table > tbody > tr:has(> td.g-chev) > td:nth-child(2)::before { display: none; }
  /* the opened card shows everything, so the closed one stays short */
  table.m-cards-table > tbody > tr:has(> td.g-chev):not(.g-open) > td:nth-child(n+6) { display: none; }
  table.m-cards-table > tbody > tr.g-detail { margin-top: -6px; padding: 12px 14px; }
  table.m-cards-table > tbody > tr.g-detail > td { display: block; text-align: left; padding: 0 !important; }
  table.m-cards-table > tbody > tr.empty-row, table.m-cards-table > tbody > tr:has(> td.empty-row) { background: transparent; box-shadow: none; }
  table.m-cards-table > tbody > tr.empty-row > td, table.m-cards-table > tbody > tr > td[colspan] { display: block; text-align: left; }
  table.m-cards-table > tbody > tr.empty-row > td { text-align: center; color: var(--fg-3); }
  table.m-cards-table > tfoot > tr { display: block; padding: 10px 14px; border-radius: 16px; background: var(--m-soft); } table.m-cards-table > tfoot td { display: inline-block; padding: 2px 8px 2px 0 !important; border: 0 !important; background: transparent; font-weight: 800; }
  table td, table th { white-space: normal !important; overflow-wrap: anywhere; text-overflow: clip !important; overflow: visible !important; }
  .ar-card figcaption * { white-space: normal; overflow-wrap: anywhere; max-width: 100%; } .ar-link { display: block; }
  .g-body { position: static; width: auto !important; max-width: none; }
  .g-body .kv { grid-template-columns: 1fr 1fr; }
  .tbl-scroll { overflow: visible; }
  #cl { min-width: 0; }
  table:not(.m-cards-table) { max-width: 100%; }
  .w-table { display: block; } .w-table tbody { display: block; }
  .w-table tr:not([data-ml]) { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .w-table tr:not([data-ml]) td { padding: 0; border: 0; }
  .w-table tr:not([data-ml]) td:nth-child(2) { flex: 1 1 60%; }
  /* a picture in a card sits beside its title */
  table.m-cards-table > tbody > tr:has(.art-th) { padding-left: 78px; min-height: 80px; }
  table.m-cards-table > tbody > tr:has(.art-th) > td:has(.art-th) { position: absolute; left: 14px; top: 14px; padding: 0 !important; }
  table.m-cards-table > tbody > tr:has(.art-th) > td:has(.art-th)::before { display: none; }
  table.m-cards-table > tbody > tr:has(.art-th) > td:nth-child(3) { display: block; text-align: left; font-weight: 800; padding-right: 22px !important; }
  table.m-cards-table > tbody > tr:has(.art-th) > td:nth-child(3)::before { display: none; }
  table.m-cards-table > tbody > tr:has(.art-th) > td:nth-child(4) { display: block; text-align: left; color: var(--fg-2); }
  table.m-cards-table > tbody > tr:has(.art-th) > td:nth-child(4)::before { display: none; }
  .art-th { width: 52px; height: 52px; border-radius: 13px; object-fit: cover; }

  /* line editors in cards */
  table.lines-edit.m-cards-table > tbody > tr > td { display: block; text-align: left; padding: 5px 0 !important; }
  table.lines-edit.m-cards-table > tbody > tr > td[data-l]::before { display: block; max-width: none; margin-bottom: 3px; }
  table.lines-edit input, table.lines-edit select { width: 100%; }
  .pack-row > td:first-child { display: none !important; }

  /* windows are sheets from the bottom */
  .modal-back { padding: 0; place-items: end stretch; overflow: hidden; }
  .modal, .modal.wide { width: 100%; max-width: none; height: auto; max-height: calc(100dvh - env(safe-area-inset-top) - 10px); border-radius: 26px 26px 0 0; border: 0; background: var(--surface); animation: m-sheet .26s cubic-bezier(.2, .8, .2, 1); }
  @keyframes m-sheet { from { transform: translateY(40%); opacity: .5; } }
  .modal > header { position: relative; padding: 22px var(--m-gut) 10px; background: transparent; border: 0; }
  .modal > header::before { content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--border-strong); }
  .modal > header h2 { font-size: 19px; font-weight: 800; }
  .modal-body { padding: 8px var(--m-gut) var(--m-gut); overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .modal-body .actions:last-child { position: sticky; bottom: calc(var(--m-gut) * -1); z-index: 3; margin: 14px calc(var(--m-gut) * -1) calc(var(--m-gut) * -1); padding: 10px var(--m-gut) calc(10px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px; background: var(--surface); border-top: 1px solid var(--border); }
  .modal-body .actions:last-child > .btn { flex: 1 1 40%; }
  :is(.modal-body, .card, .od-sec, .acc-row, .p-detail) table.m-cards-table > tbody > tr { background: var(--surface-2); box-shadow: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .fld, .fld.s2, .fld.s3, .fld.s4, .s2, .s3, .s4 { grid-column: 1 / -1 !important; }
  .doc-view { height: auto; max-height: 72dvh; display: block; border-radius: 14px; }
  .doc-view .pdf-pages { max-height: 72dvh; }
  .doc-view img, .doc-prev img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
  .tabs { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; border: 0; }
  .tabs button { flex: none; min-height: 38px; padding: 0 14px; border: 0; border-radius: 19px; background: var(--surface-2); font-weight: 700; }
  .tabs button.on, .tabs button.active { background: var(--m-ink); color: var(--m-on-ink); }

  /* notifications and small menus: a sheet of cards */
  .nx-pop.nx-notes, .nx-pop.nx-menu, .nx-pop.nx-co-menu, .st-menu { max-width: none; position: fixed !important; left: var(--m-gut) !important; right: var(--m-gut) !important; top: calc(var(--top-h) + 4px) !important; width: auto !important; max-height: calc(100dvh - var(--top-h) - var(--tab-h) - 20px); overflow-y: auto; z-index: 50; border: 0; border-radius: var(--m-r); background: var(--surface); box-shadow: 0 24px 60px -18px rgba(16, 32, 68, .45); }
  .nx-brand, .nx-back, .nx-actions > .icon-btn, .nx-user { position: relative; z-index: 2; }
  .nx-pop.nx-notes { left: 0 !important; right: 0 !important; top: 0 !important; bottom: 0; z-index: 1; max-width: none; max-height: none; height: 100dvh; padding: calc(var(--top-h) + 4px) var(--m-gut) calc(var(--tab-h) + 24px); border-radius: 0; background: linear-gradient(180deg, var(--m-wash) 0, var(--m-wash-2) 170px, var(--bg) 340px) no-repeat, var(--bg); box-shadow: none; overscroll-behavior: contain; }
  .nx-notes h4 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; padding: 0; border: 0; background: none; color: var(--fg); font-family: inherit; font-size: 22px; font-weight: 800; letter-spacing: -.3px; text-transform: none; }
  .nx-notes h4:first-child { font-size: 30px; letter-spacing: -.6px; } .nx-notes h4 + * { margin-top: 0; } .nx-notes a + h4 { margin-top: 22px; }
  .nx-notes a { position: relative; display: block; margin-bottom: 10px; padding: 13px 34px 13px 14px; border: 0; border-radius: 18px; background: var(--surface); color: var(--fg); font-size: 14.5px; font-weight: 600; line-height: 1.35; box-shadow: var(--m-shadow); overflow-wrap: anywhere; }
  .nx-notes a b { font-weight: 800; }
  .nx-notes a small { display: block; margin-top: 4px; font-family: inherit; font-size: 12.5px; font-weight: 500; color: var(--fg-3); }
  .nx-notes a::after { content: ''; position: absolute; right: 15px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border: solid var(--fg-4); border-width: 2px 2px 0 0; transform: rotate(45deg); }
  .nx-notes a { border-left: 0 !important; } .nx-notes a.nf-new { padding-left: 30px; background: var(--surface); } .nx-notes a.nf-new::before { content: ''; position: absolute; left: 13px; top: 20px; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; }
  .nx-notes a.nf-read { color: var(--fg-2); font-weight: 500; }
  html:has(.nx-notes:not([hidden])) { overflow: hidden; }
  body:has(.nx-notes:not([hidden])) .nx-top { z-index: 31; }
  .ar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .ar-card { border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--m-shadow); } .ar-thumb { border: 0; aspect-ratio: 4 / 3; } .ar-ext { font-size: 15px; padding: 9px 12px; } .ar-card figcaption { overflow-wrap: anywhere; font-size: 12.5px; } .ar-acts { flex-wrap: wrap; padding: 4px 10px 10px; }
  .nx-menu > * { min-height: 48px; }

  /* cards everywhere */
  .card, .od-sec, .acc-row, .p-detail, .rep-card, .fin-card { border: 0 !important; border-radius: var(--m-r); background: var(--surface); box-shadow: var(--m-shadow); }

  /* accordion cards: orders, requests */
  .acc-list { gap: 12px; }
  .acc-head, .rq-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px; align-items: start; background: transparent !important; }
  .acc-chev, .rq-pick { display: none; }
  .acc-no { grid-column: 1; grid-row: 1; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 700; color: var(--fg-3); white-space: normal; }
  .acc-amount { grid-column: 2; grid-row: 1 / 3; text-align: right; font-size: 16px; font-weight: 800; white-space: nowrap; }
  .acc-main { grid-column: 1; grid-row: 2; min-width: 0; } .acc-name { font-size: 16px; font-weight: 800; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; } .acc-sub { font-size: 13px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; color: var(--fg-2); margin-top: 2px; }
  .acc-head.rq-head { grid-template-columns: minmax(0, 1fr) auto; }
  .acc-head.rq-head .acc-status { grid-column: 1 / -1; grid-row: auto; }
  .rq-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
  .acc-status { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
  .acc-status .steps { order: 3; flex: 1 1 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .acc-status .steps.q-steps { grid-template-columns: repeat(4, 1fr); }
  .acc-status .steps i { width: auto; height: 6px; border: 0; border-radius: 3px; }
  .acc-status .work-st { flex: 1 1 0; margin: 0; min-height: 38px !important; height: 38px; padding: 0 28px 0 12px; border-radius: 19px; font-size: 14px !important; }
  .acc-qty, .acc-date { display: none; }
  .acc-body { padding: 0 14px 14px; }
  .acc-grid { display: block; } .kv { grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 12px; }
  .kv > * { overflow-wrap: anywhere; }
  .acc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .acc-actions .spacer { display: none; } .acc-actions .btn { width: 100%; justify-content: center; white-space: normal; background: var(--surface-2); box-shadow: none; } .acc-actions .btn.primary { background: var(--m-ink); }
  .doc-list { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 2px 14px; scrollbar-width: none; } .doc-list .btn { flex: none; }
  .doc-prev iframe { height: 62dvh; }
  .doc-prev .pdf-pages { max-height: none; }
  .st-pill { padding: 5px 12px; font-size: 12.5px; }

  /* order page */
  .od-head { display: block; padding: 16px; } .od-who { flex-wrap: wrap; } .od-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; } .od-total { text-align: left; } .od-ws { margin: 8px 0; } .od-ws .work-st { width: 100%; }
  .od-accept { display: block; } .od-accept .btn { width: 100%; margin-top: 8px; }
  .od-sec { padding: 0 14px; }
  #od-flow { padding: 14px; }
  .flow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .flow-b { min-height: 82px; border-radius: 16px; }
  .flow-grid .flow-send { grid-column: 1 / -1; min-height: 46px; border-radius: 16px; font-size: 15px; font-weight: 700; }
  .flow-grid.has-send > .flow-b:nth-child(-n+2) { order: 1; } .flow-grid.has-send > .flow-send { order: 2; } .flow-grid.has-send > .flow-b:nth-child(n+3) { order: 3; }
  .flow-head { display: block; } .flow-head .work-st { width: 100%; margin-top: 6px; }
  .order-form > .actions { position: sticky; bottom: var(--tab-h); z-index: 5; margin: 12px calc(var(--m-gut) * -1) 0; padding: 10px var(--m-gut); background: transparent; border: 0; display: flex; gap: 8px; } .order-form > .actions .btn { flex: 1; }
  body:has(.od-head) .mod-tabs { display: none; }

  /* overview: two by two, the chosen one is the dark card */
  .p-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .p-tile { padding: 14px; min-height: 142px; gap: 2px; border: 0; border-radius: 22px; background: var(--surface); box-shadow: var(--m-shadow); }
  .p-ic { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 8px; border-radius: 12px; background: var(--m-soft); color: var(--accent-text); } .p-ic svg { width: 19px; height: 19px; }
  .p-l { font-size: 13px; font-weight: 700; opacity: 1; color: var(--fg-2); }
  .p-tile b { font-size: 21px; font-weight: 800; letter-spacing: -.4px; line-height: 1.15; }
  .p-tile small { font-size: 12px; line-height: 1.25; opacity: 1; color: var(--fg-3); overflow-wrap: anywhere; }
  .p-tile.sz-l b { font-size: 32px; } .p-tile.sz-l .p-l { font-size: 15px; } .p-tile.sz-l small { font-size: 13.5px; }
  .p-glow, .p-spark { display: none; } .p-tile.sz-l .p-spark { display: flex; left: 14px; right: 14px; bottom: 14px; height: 40%; } .p-tile.on .p-spark i { background: var(--m-on-ink); }
  .p-tile.on { box-shadow: var(--m-shadow); border: 0; background: var(--m-ink); color: var(--m-on-ink); }
  .p-tile.on .p-l, .p-tile.on small { color: var(--m-on-ink); opacity: .72; } .p-tile.on .p-ic { background: color-mix(in srgb, var(--m-on-ink) 16%, transparent); color: var(--m-on-ink); }
  .p-detail { padding: 16px; margin-top: 12px; } .p-detail h3 { font-size: 16px; font-weight: 800; }
  .p-blocks { display: block; } .p-block + .p-block { margin-top: 22px; } .p-cols { height: 160px; gap: 4px; } .p-col i { border-radius: 8px 8px 3px 3px; } .p-col small { font-size: 9.5px; } .p-donut svg { width: 150px; height: 150px; margin: 0 auto; }
  .p-bar { margin-bottom: -2px; } .p-bar .p-edit { min-height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--m-shadow); font-weight: 700; }
  /* arranging the board: a sheet with rows, no dragging */
  .p-todo { border-radius: 20px; padding: 14px; } .p-todo-list { margin-left: 0; width: 100%; } .p-todo-list .btn { flex: 1 1 100%; min-height: 42px; justify-content: space-between; white-space: normal; text-align: left; }
  .page-export { min-height: 36px; margin: 8px 0 0; border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--m-shadow); font-weight: 700; }
  .stm-tools label { flex: 1 1 45%; display: grid; gap: 2px; } .stm-tools input { width: 100%; } .stm-tools .spacer { display: none; } .stm-tools .btn { flex: 1 1 30%; min-height: 40px; justify-content: center; }
  .pk-row { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px 0; } .pk-row label { font-size: 12.5px; } .pk-row input { min-height: 42px; } .pk-row .btn { grid-column: 1 / -1; min-height: 44px; justify-content: center; }
  .pn-list { display: grid; gap: 8px; }
  .pn-tabs { position: sticky; top: -8px; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; padding: 4px; border-radius: 22px; background: var(--surface-2); } .pn-tabs button { min-height: 40px; padding: 2px 6px; border: 0; border-radius: 18px; background: transparent; color: inherit; font: inherit; font-size: 13.5px; font-weight: 700; } .pn-tabs button.on { background: var(--m-ink); color: var(--m-on-ink); }
  .pn-row { flex-wrap: wrap; } .pn-row .pn-size { position: static; flex: 1 1 100%; display: flex; gap: 6px; } .pn-row .pn-size button { flex: 1; width: auto; height: 34px; padding: 0 4px; border: 0; border-radius: 11px; font-size: 13px; font-weight: 600; } .pn-row .pn-size button.on { background: var(--m-ink); color: var(--m-on-ink); font-weight: 800; }
  .pn-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 54px; padding: 7px 8px 7px 10px; border: 0; border-radius: 16px; background: rgba(127, 127, 127, .1); color: inherit; font: inherit; text-align: left; box-sizing: border-box; }
  .pn-row i { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--m-soft); color: var(--accent-text); } .pn-row i svg { width: 18px; height: 18px; }
  .pn-row span { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
  .pn-row button { flex: none; width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--surface); color: inherit; font-size: 17px; } .pn-row button:disabled { opacity: .3; } .pn-row .del { color: var(--err, #b91c1c); font-size: 20px; }
  .pn-add em { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--m-ink); color: var(--m-on-ink); font-style: normal; font-size: 20px; font-weight: 700; }
  .pn-mod { margin: 14px 0 6px; font-size: 12px; font-weight: 700; opacity: .6; }
  .m-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .m-card { padding: 14px; border: 0 !important; border-radius: 20px; background: var(--surface); box-shadow: var(--m-shadow); }
  .m-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .m-card span { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 700; color: var(--fg-2); }
  .m-card b { font-size: 20px; font-weight: 800; letter-spacing: -.3px; overflow-wrap: anywhere; }
  .m-card.strong { background: var(--m-ink); color: var(--m-on-ink); } .m-card.strong :is(span, small, b) { color: var(--m-on-ink); }

  /* foot of every page, above the tab bar */
  .nx-content { padding-bottom: calc(var(--tab-h) + 14px); }
  .nx-page-foot { flex-direction: column; gap: 6px; margin-top: 26px; padding: 22px 0 6px; text-align: center; }
  .nx-page-foot img { height: 30px; padding: 6px 12px; box-sizing: content-box; border-radius: 16px; background: #fff; box-shadow: var(--m-shadow); }
  .nx-page-foot span { justify-items: center; font-size: 13px; } .nx-page-foot b { font-weight: 800; color: var(--fg); }
  .nx-to-top { margin: 6px 0 0; min-height: 40px; padding: 0 16px; border-radius: 20px; background: var(--surface); color: var(--fg); font-size: 13px; font-weight: 700; box-shadow: var(--m-shadow); }

  .m-sec > header { display: block; } .m-sec > header > span { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

  /* language in More */
  .m-tools .m-lang { padding-right: 0; flex-wrap: wrap; } .m-tools .m-lang::after { display: none; } .m-lang > span { flex: 1; }
  .m-lang .m-seg { flex: none; padding: 3px; } .m-lang .m-seg button { min-height: 36px; padding: 0 10px; font-size: 13px; }

  /* supplier choice: each offer a card, no columns to squeeze */
  .pp-line { min-width: 0; margin: 0 0 12px; padding: 12px; border: 0; border-radius: 18px; background: var(--surface-2); }
  .pp-line legend { float: left; width: 100%; padding: 0 0 8px; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; } .pp-line legend + * { clear: both; }
  .modal .pp-line { margin: 0 0 12px; padding: 12px; }
  .pp-quotes, .pp-quotes tbody { display: block; width: 100%; }
  .pp-quotes tr { display: grid; grid-template-columns: 30px repeat(3, minmax(0, 1fr)); gap: 2px 8px; align-items: start; padding: 10px; margin-bottom: 6px; border-radius: 14px; background: var(--surface); }
  .pp-quotes tr.best td { background: transparent; } .pp-quotes tr.best { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ok) 55%, transparent); }
  .modal .pp-quotes td, .pp-quotes td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; font-size: 14px; }
  .pp-quotes td:nth-child(1) { grid-row: 1 / span 3; padding-top: 2px; } .pp-quotes td:nth-child(1) input { width: 22px; height: 22px; }
  .pp-quotes td:nth-child(2) { grid-column: 2 / -1; overflow-wrap: anywhere; line-height: 1.35; }
  .pp-quotes td:nth-child(n+3) { grid-row: 2; margin-top: 6px; } .pp-quotes td:nth-child(6) { grid-row: 3; grid-column: 2 / -1; margin-top: 2px; }
  .pp-quotes td:empty { display: none; }
  .pp-manual { display: grid; gap: 8px; } .pp-manual select, .pp-manual input { width: 100%; font-size: 16px; }
  .pp-sum { padding: 4px 0; } .pp-sum .tag-s { white-space: normal; overflow-wrap: anywhere; }

  /* e-mail window: rows like a phone's mail app */
  .mail-form { min-width: 0; gap: 12px; } .mail-form .chk { align-items: flex-start; font-size: 14px; overflow-wrap: anywhere; line-height: 1.35; } .mail-form .chk input { flex: none; margin-top: 2px; }
  .mail-att { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; } .mail-att .chk { flex: 1 1 100%; min-width: 0; }
  .rc-group { border: 0; background: var(--surface-2); border-radius: 16px; }
  .rc-row { align-items: center; padding: 6px 12px; } .rc-row > label { width: 36px; padding: 0; font-size: 13.5px; }
  .rc-box { min-height: 40px; } .rc-chip { padding: 6px 12px; border-radius: 16px; font-size: 14px; background: var(--surface); box-shadow: var(--m-shadow); } 
  .rc-in { min-height: 38px !important; height: 38px; flex-basis: 100px; font-size: 16px !important; border-radius: 0; }
  .rc-more { font-size: 13px; font-weight: 700; }
  .rc-ac { border-radius: 14px; } .rc-ac .ac-item { padding: 11px 12px; }
  .att-list li { min-height: 46px; padding: 6px 8px 6px 12px; border-radius: 14px; background: var(--surface-2); } .att-list button { width: 36px; height: 36px; font-size: 20px; }
  .att-add { display: inline-flex; align-items: center; } .att-hint { display: block; margin: 6px 0 0; }
  .mail-compose { padding: 14px; border-radius: var(--m-r); background: var(--surface); box-shadow: var(--m-shadow); }

  .rc-depts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding-bottom: 2px; } .rc-dept { flex: none; min-height: 34px; padding: 0 13px; border: 0; border-radius: 17px; background: var(--surface-2); color: var(--fg-2); font-size: 13.5px; font-weight: 700; } .rc-dept.on { background: var(--m-ink); color: #fff; }
  .rc-grp { min-height: 38px; padding: 0 14px; border: 0; border-radius: 19px; background: var(--surface-2); color: var(--fg); font-size: 14px; font-weight: 700; }
  .rc-chip.unknown { background: color-mix(in srgb, #d97706 18%, var(--surface)); color: #b45309; }
  .rc-unknown li { padding: 11px 14px; border-radius: 14px; font-size: 15px; }
  .inbox-mail .mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 15px; line-height: 1.45; }
  .sent-files { display: grid; gap: 8px; } .sent-file { display: block; width: 100%; min-height: 48px; padding: 8px 14px; border-radius: 14px; background: var(--surface-2); font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }

  /* papers of an order step: big targets, the camera is one tap away */
  .fd-list li { min-height: 58px; border-radius: 16px; } .fd-open { padding: 10px 14px; } .fd-open b { font-weight: 700; font-size: 14.5px; } .fd-open small { font-size: 12.5px; } .fd-del { width: 44px; height: 44px; font-size: 22px; }
  .fd-add { padding: 14px; border-radius: 18px; background: var(--surface-2); border: 0; } .fd-plus { width: 42px; height: 42px; font-size: 22px; background: var(--m-ink); color: var(--m-on-ink); } .fd-add b { font-size: 15px; font-weight: 800; }

  #toasts { left: var(--m-gut); right: var(--m-gut); bottom: calc(var(--tab-h) + 10px); }
  #toasts .toast { width: 100%; max-width: none; border-radius: 16px; }
  html:has(.modal-back) { overflow: hidden; }
}
@media (min-width: 761px) { .m-tabbar, .m-tools, .m-me, .p-ic { display: none; } }

@media (max-width: 760px) { .modal .modal-body, .modal.large .modal-body { --mb-x: var(--m-gut); } }
