/* VeyyonONE v36.41 - iPhone-style mobile layer. Phones only (<=700px). Layout and spacing only: no data, no calculations, no features changed. */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { overscroll-behavior-x: none; -webkit-tap-highlight-color: transparent; }
  button, a, .chip, .vytile, tr[tabindex], .bcard { touch-action: manipulation; }
  .shell { min-height: 100vh; min-height: 100dvh; }
  /* iOS zooms the whole page when an input under 16px gets focus: that is the "screen gets bigger" problem */
  input, select, textarea { font-size: 16px !important; }
  input[type="checkbox"], input[type="radio"], input[type="color"], input[type="file"] { font-size: initial !important; }

  /* page frame */
  .main { padding: calc(6px + env(safe-area-inset-top, 0px)) 12px calc(78px + env(safe-area-inset-bottom, 0px)); gap: 10px; }

  /* page header: one slim sticky bar (back arrow + title + main action) */
  .topbar { position: sticky; top: 0; z-index: 25; gap: 8px; margin: 0 -12px; padding: 6px 12px; min-height: 48px; flex-wrap: wrap; align-items: center; row-gap: 6px;
    background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
  .topbar .ttile, .topbar .mobile-brand { display: none; }
  .topbar h1 { font-size: 19px; line-height: 1.2; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { font-size: 11.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .ttext { flex: 1 1 150px; min-width: 0; }
  .topbar.vytall { position: static; }
  .topbar .seg { flex: none; }
  .topbar .grow { display: none; }
  .topbar .backbtn { min-height: 36px; min-width: 36px; padding: 0; margin: 0 2px 0 -4px; border: 0; background: none; justify-content: center; font-size: 22px; }
  .topbar .backbtn .bl { display: none; }
  .topbar .btn { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; flex: none; }
  .topbar .btn svg { width: 15px; height: 15px; }
  /* home header: greeting + a single swipeable row of quick actions */
  .topbar:has(> .flow) { position: static; flex-wrap: wrap; border-bottom: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 4px 12px 0; min-height: 0; }
  .topbar:has(> .flow) .ttext { flex: 1 1 70%; }
  .topbar:has(> .flow) h1 { font-size: 20px; }
  .topbar:has(> .flow) .sub { font-size: 12px; }
  .topbar > .flow { order: 5; flex: 1 0 100%; display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding: 4px 12px 2px; margin: 0 -12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topbar > .flow::-webkit-scrollbar { display: none; }
  .topbar > .flow .btn { flex: none; }

  /* list pages: toolbar, chips on one swipeable row */
  .toolbar { gap: 8px; }
  .toolbar .search, .toolbar input { height: 40px; border-radius: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px; padding: 0 12px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; padding: 5px 12px; }
  .sumrow { font-size: 12px; gap: 4px 14px; line-height: 1.3; }

  /* tables turn into compact cards: code + status on the first line, names next, numbers in three columns */
  .tablewrap { overflow: visible; }
  table.t tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; padding: 10px 12px; margin-bottom: 8px; border-radius: 14px; box-shadow: var(--card-sh); }
  table.t tr:active { background: var(--panel-2); }
  table.t td { display: block; text-align: left; padding: 0; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; grid-column: span 1; }
  table.t td::before { display: block; font-size: 10.5px; line-height: 1.3; margin-bottom: 0; }
  table.t td.lead { grid-column: 1 / 3; font-size: 15px; }
  table.t td.wide { grid-column: 1 / -1; }
  table.t td:has(.pill):last-child { grid-column: 3; grid-row: 1; justify-self: end; text-align: right; }
  table.t td:has(.pill):last-child::before { display: none; }
  table.t td[data-label="Client"], table.t td[data-label="Work"], table.t td[data-label="Subject"], table.t td[data-label="Description"], table.t td[data-label="Name"], table.t td[data-label="Vendor"], table.t td[data-label="Company"], table.t td[data-label="Project"], table.t td[data-label="Party"], table.t td[data-label="Related to"], table.t td[data-label="Account"], table.t td[data-label="Item"], table.t td[data-label="Details"], table.t td[data-label="Notes"] { grid-column: 1 / -1; }
  table.t td[data-label="Client"]::before, table.t td[data-label="Work"]::before, table.t td[data-label="Subject"]::before, table.t td[data-label="Description"]::before, table.t td[data-label="Name"]::before, table.t td[data-label="Vendor"]::before, table.t td[data-label="Company"]::before, table.t td[data-label="Party"]::before { display: none; }
  table.t td[data-label="Client"], table.t td[data-label="Vendor"], table.t td[data-label="Company"], table.t td[data-label="Name"], table.t td[data-label="Party"] { font-weight: 600; }
  table.t td[data-label="Work"], table.t td[data-label="Description"] { color: var(--muted); font-size: 12.5px; }
  table.t td.r { text-align: left; white-space: normal; }
  table.t td.r::before { margin-bottom: 1px; }

  /* cards, KPI tiles */
  .card { padding: 12px 14px; border-radius: 14px; }
  .card h2 { font-size: 15px; }
  .kpis { gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 10px 12px; border-radius: 14px; }
  .kpi .l { font-size: 11.5px; padding-right: 0; }
  .kpi .v { font-size: 20px; }
  .kpi .s { font-size: 11px; }
  .kpi .kico { display: none; }

  .vyStatRow { gap: 8px; margin-bottom: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vyStat { gap: 2px; padding: 10px 12px; }
  .vyStatVal { font-size: 19px; }
  .vyStatSub { display: none; }
  .vySideGrid { gap: 10px; margin-top: 10px; }

  /* home */
  .vygs { margin: 0 0 6px; }
  .vygs input { height: 40px; padding: 8px 12px 8px 38px; border-radius: 12px; }
  .vyhgrid { gap: 10px; }
  .vyhgrid > .kpi { grid-column: span 4 !important; }
  .vyhgrid > .kpi .s, .vyhgrid > .kpi .kico { display: none; }
  .vyhgrid > .kpi .v { font-size: 18px; }
  .vyhgrid .card > h2 + .note { display: none; }
  .vymenu { gap: 10px 4px; }
  .vytile .vyic, .vyshgrid .vytile .vyic { width: 46px; height: 46px; border-radius: 12px; }
  .vytile .vyic svg, .vyshgrid .vytile .vyic svg { width: 24px; height: 24px; }
  .vytile .vylb { font-size: 11px; line-height: 1.15; }
  .vymenu.vyc .vytile:nth-of-type(n+9) { display: none; }
  .vymorebtn { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }
  .vymorebtn svg { width: 14px; height: 14px; transition: transform .2s; }
  .vymenu:not(.vyc) .vymorebtn svg { transform: rotate(180deg); }
  .vyeditmenu .vytile { display: flex !important; }

  /* leads board: swipe sideways across stages, scroll the page up and down (no scroll inside a column) */
  .boardwrap { scroll-snap-type: x proximity; margin: 0 -12px; padding: 0 12px 8px; }
  .boardwrap { scroll-padding: 0 12px; }
  .board { grid-auto-columns: 78vw; }
  .bcol { scroll-snap-align: start; min-height: 90px; }
  .blist { max-height: none; overflow: visible; }

  /* record drawer: full-screen sheet that scrolls smoothly */
  .scrim { align-items: stretch; }
  .drawer { width: 100%; height: 100%; height: 100dvh; }
  .drawer header { padding: 10px 14px; position: sticky; top: 0; background: var(--panel); z-index: 2; }
  .drawer .content { padding: 12px 14px 24px; gap: 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .drawer footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .f input, .f select, .f textarea { padding: 10px 12px; border-radius: 10px; }
  .modal .box { max-height: 86vh; max-height: 86dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

  /* bottom tab bar: translucent like iOS */
  .tabbar { background: color-mix(in srgb, var(--panel) 88%, transparent); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 24px); }

  /* keep form controls inside the screen */
  #main input, #main select, #main textarea { max-width: 100%; min-width: 0; box-sizing: border-box; }
  #main .row, #main .toolbar, #main .filters { flex-wrap: wrap; }

  /* ===== v36.41 iOS pass ===== */
  body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, sans-serif; font-size: 14.5px; letter-spacing: -.005em; background: var(--bg); }
  .main { gap: 8px; }

  /* home quick actions: small round icon buttons, no text */
  .topbar > .flow { gap: 10px; padding: 6px 12px 4px; }
  .topbar > .flow .btn { font-size: 0 !important; width: 42px; height: 42px; min-width: 42px; padding: 0 !important; border-radius: 50%; justify-content: center; align-items: center; gap: 0; display: inline-flex; box-shadow: var(--card-sh); }
  .topbar > .flow .btn svg { width: 20px; height: 20px; margin: 0; }

  /* stat tiles: always 2 per row, compact */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .kpi { padding: 10px 12px; border-radius: 14px; }
  .kpi .l { font-size: 11.5px; padding-right: 0; }
  .kpi .v { font-size: 19px; }
  .kpi .s { font-size: 11px; }
  .kpi svg { width: 14px; height: 14px; }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr) !important; gap: 8px; }
  .card { border-radius: 14px; }
  .card h2, .card h3 { font-size: 15px; }

  /* list rows (iOS style): one compact block per record, labels inline */
  table.t tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 10px 12px; margin-bottom: 6px; border-radius: 14px; box-shadow: none; }
  table.t td { flex: 0 1 auto; order: 2; font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 4px; align-items: baseline; grid-column: auto; }
  table.t td::before { display: inline; font-size: 11px; margin: 0; opacity: .8; }
  table.t td.lead, table.t td:first-child { order: 0; font-size: 12.5px; color: var(--muted); grid-column: auto; }
  table.t td:has(.pill):last-child { order: 1; margin-left: auto; grid-column: auto; grid-row: auto; }
  table.t td[data-label="Client"], table.t td[data-label="Work"], table.t td[data-label="Subject"], table.t td[data-label="Description"], table.t td[data-label="Name"], table.t td[data-label="Vendor"], table.t td[data-label="Company"], table.t td[data-label="Project"], table.t td[data-label="Party"], table.t td[data-label="Item"], table.t td[data-label="Details"], table.t td[data-label="Notes"] { order: 1; flex: 1 0 100%; display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
  table.t td[data-label="Work"], table.t td[data-label="Description"] { font-size: 12.5px; font-weight: 400; color: var(--muted); order: 1; }
  table.t td.vydash { display: none; }
  table.t td.r { text-align: left; }
  .vymenu .vytile { padding: 4px 0; }

  .vyStatRow { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .vyStat { padding: 10px 12px !important; border-radius: 14px; min-height: 0 !important; gap: 2px !important; }
  .vyStat .vyStatSub { display: none; }
  .vyStat [class*="Val"], .vyStat .v { font-size: 20px !important; }
  table.t td { justify-content: flex-start !important; text-align: left !important; width: auto !important; padding: 0 !important; }
  table.t td[data-label="Client"], table.t td[data-label="Work"], table.t td[data-label="Subject"], table.t td[data-label="Description"], table.t td[data-label="Name"], table.t td[data-label="Vendor"], table.t td[data-label="Company"], table.t td[data-label="Project"], table.t td[data-label="Party"], table.t td[data-label="Item"], table.t td[data-label="Details"], table.t td[data-label="Notes"] { width: 100% !important; }
  table.t td:has(.pill):last-child { order: 0 !important; }
  table.t td.lead, table.t td:first-child { order: 0 !important; }
  table.t tr { position: relative; }
  table.t td:has(.pill):last-child { position: absolute !important; top: 10px; right: 12px; margin: 0 !important; }

  /* v36.41 audit fixes */
  .vyacc h2 { justify-content: flex-start !important; text-align: left !important; gap: 12px; }
  .vyacc h2 .hico { margin: 0 !important; flex: none; }
  .vyacc h2::after { margin-left: auto !important; }
  .topbar h1 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .topbar .sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
  #main select { -webkit-appearance: none; appearance: none; height: 38px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--line); background-color: var(--panel); color: var(--ink);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23788' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
  #main input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]) { border-radius: 10px; }

  /* home cards: compact, long lists fold to 5 rows */
  .vyhgrid .card { padding: 12px !important; }
  .vyhgrid .card > div:first-child { flex-wrap: nowrap; align-items: center; }
  .vyhgrid .card > div:first-child h2 { min-width: 0; }
  .vyhgrid .card .btn.sm { height: 30px; font-size: 12px; padding: 0 10px; border-radius: 9px; flex: none; }
  .vyhgrid .card .btn.sm .vywa, .vyhgrid .card .btn.sm svg { width: 14px; height: 14px; }
  .vyhgrid .card .note { font-size: 12px; margin: 2px 0 6px; }
  .vyhgrid .card .list > * { padding: 8px 0 !important; font-size: 13.5px; }
  .vyhgrid .card .list > * .pill { font-size: 11px; padding: 2px 8px; }
  .vyhgrid .card .list .sub, .vyhgrid .card .list small { font-size: 11.5px; }
  .vyfolded > :nth-child(n+6) { display: none !important; }
  .vyfoldbtn { width: 100%; margin-top: 4px; height: 34px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--brand, #0b7285) 10%, transparent); color: var(--brand, #0b7285); font-weight: 600; font-size: 13px; }
  .vyteam .row2 { gap: 6px; }
  .vyteam .row2 > * { font-size: 12.5px; padding: 5px 10px; }
  .vyna .vynagrid { gap: 0; }

  /* saved desktop layout (6-wide / fixed-height blocks) must not apply on a phone */
  .vyhgrid:not(.vyedit) > .vyblk:not(.kpi), .vyhgrid:not(.vyedit) > .card, .vyhgrid:not(.vyedit) > .vymenu { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .vyhgrid:not(.vyedit) > * { height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; }
  .vyhgrid > .kpi { grid-column: span 4 !important; grid-row: auto !important; }
  .vyhgrid .card .list > * { min-width: 0; }
  .vyhgrid .card .list > * > :last-child { min-width: 0; }
}
