/* Phone layout (requested 2026-10-17): balanced type sizes, a header that fits, even button rows,
   brand tabs that scroll in one line each, and the brands list as cards. Loaded last. */

.ws-mains, .ws-subs { position: relative; }   /* lets the active tab be scrolled into view on phones */

@media (max-width: 640px) {
  /* ---------- Type scale: one step down everywhere, in proportion ---------- */
  .page-head h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.015em; }
  .page-head .sub { font-size: 14px; }
  .page-head .eyebrow, .ws-head .eyebrow { font-size: 11px; letter-spacing: .09em; }
  .page-head > div:first-child:not(.avatar):not(.actions)::before { width: 56px; height: 4px; margin-bottom: 10px; }
  .card-h h3 { font-size: 15px; }
  .kn-hero, .mail-hero { margin-top: 2vh; }
  .kn-hero h1, .mail-hero h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.025em; margin: 8px 0 12px; }
  .kn-hero p, .mail-hero p { font-size: 15.5px; line-height: 1.5; margin-bottom: 20px; }
  .kn-hero .eyebrow, .mail-hero .eyebrow { font-size: 11px; }

  /* ---------- Header: compact logo, everything inside the bar ---------- */
  .gnav { padding: 8px 10px 0; }
  .gnav-in { height: 54px; padding: 0 8px 0 0; gap: 4px; border-radius: 18px; }
  .gnav-logo.wcp { order: -1; margin: 0 4px 0 0; }
  .gnav-logo.wcp img { height: 20px; padding: 16px 16px; border-radius: 17px 10px 10px 17px; }
  .gnav-logo.wcp .wcp-mark { height: 54px; padding: 0 14px; gap: 4px; border-radius: 17px 10px 10px 17px; }
  .gnav-logo.wcp .wcp-mark img { height: 17px; padding: 0; }
  .gnav-logo.wcp .wcp-mark small { font-size: 7px; letter-spacing: .3em; margin-right: -.3em; }
  .gnav .burger { order: 10; }
  .gnav-right { gap: 4px; }
  .gnav .icon-btn { width: 34px; height: 34px; }
  .gnav .icon-btn svg { width: 17px; height: 17px; }
  .gnav .me .avatar { width: 30px; height: 30px; font-size: 11px; }
  .shell.top .content { padding: 18px 14px 44px; }

  /* ---------- Page actions: even rows of equal buttons ---------- */
  .page-head { gap: 10px; margin-bottom: 16px; }
  .page-head .actions { width: 100%; margin-left: 0; gap: 8px; }
  .page-head .actions > .btn { flex: 1 1 auto; justify-content: center; height: 40px; font-size: 14px; }
  .page-head .actions > .btn.primary { order: -1; flex-basis: 100%; }

  /* ---------- Brand workspace head: small avatar beside the name ---------- */
  .ws-head { display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 12px; row-gap: 12px; align-items: center; }
  .ws-head > .avatar + div::before { display: none; }
  .ws-head .avatar.md { width: 48px; height: 48px; font-size: 17px; }
  .ws-head .ws-title h1 { font-size: 24px; }
  .ws-head h1 { font-size: 24px; }
  .ws-head .acc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; margin-top: 6px; }
  .ws-head .acc-head .badge { font-size: 11.5px; }
  .ws-head .actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 42px; gap: 8px; }
  .ws-head .actions .ws-switch { grid-column: 1 / 4; height: 42px; }
  .ws-head .actions #ws-all { grid-column: 4; width: 42px; height: 42px; padding: 0; font-size: 0; }
  .ws-head .actions #ws-all svg { width: 18px; height: 18px; }
  .ws-head .actions #a-del { grid-column: 4; width: 42px; padding: 0; }
  .ws-head .actions .ws-switch select { max-width: none; flex: 1; }
  .ws-head .actions > .btn { height: 38px; padding: 0 8px; font-size: 13px; justify-content: center; gap: 5px; }
  .ws-head .actions > .btn svg { width: 15px; height: 15px; }

  /* ---------- Brand tabs: the main tabs and the sub-menu each scroll sideways on one line ---------- */
  .ws-top { margin-bottom: 14px; }
  .ws-mains, .ws-subs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
  .ws-nav button { font-size: 13px; padding: 7px 10px; gap: 5px; }
  .ws-nav button svg { width: 14px; height: 14px; }

  /* ---------- Numbers: balanced KPI cards ---------- */
  .kpis, .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 16px 14px 14px; border-radius: 16px; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi::before { height: 3px; }
  .kpi .lbl { font-size: 12px; }
  .kpi .val, .dash-kpis .val { font-size: 22px; line-height: 1.15; margin-top: 6px; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .kpi .val small { font-size: 12px !important; }
  .kpi .meta { font-size: 11.5px; line-height: 1.35; }
  .qbr .kpis.kpis-6 .kpi .val { font-size: 20px; }

  /* Brand health: ring beside its reasons */
  .dash-health { flex-wrap: nowrap; gap: 14px; padding: 16px; align-items: flex-start; }
  .dash-health .ring { width: 84px; height: 84px; }
  .dash-health .ring > div { width: 66px; height: 66px; }
  .dash-health .ring b { font-size: 24px; }
  .dash-health .ring small { font-size: 10px; }
  .dash-reasons li { font-size: 13px; }

  /* ---------- Cards and grids: one column, tidy headers ---------- */
  .g2, .g3, .g4, .grid.g-main { grid-template-columns: minmax(0, 1fr); }
  .card { border-radius: 18px; }
  .card-h { padding: 12px 14px; }
  .card-h h3 { flex: 1 1 150px; min-width: 0; }
  .card-b { padding: 14px; }
  .list-item { padding: 12px 14px; }
  .alert { font-size: 13.5px; }

  /* ---------- Brands list: filters in an even grid ---------- */
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .toolbar .spacer { display: none; }
  .toolbar input[type=search] { grid-column: 1 / -1; width: 100%; }
  .toolbar select { width: 100%; min-width: 0; height: 40px; font-size: 14px; }
  .toolbar > select:last-of-type:nth-of-type(odd) { grid-column: 1 / -1; }

  /* Brands list as cards: name on top, then status, then labelled facts in three columns */
  #ac-table table, #ac-table tbody { display: block; }
  #ac-table thead { display: none; }
  #ac-table tr.grp-row { display: block; }
  #ac-table tr.grp-row td { display: block; padding: 12px 16px 10px; border-bottom: 1px solid var(--border); }
  #ac-table tr.click { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  #ac-table tr.click:last-child { border-bottom: 0; }
  .card:has(> #ac-table) { overflow: hidden; }
  #ac-table tr.click:active { background: var(--hover); }
  #ac-table tr.click td, #ac-table tr.click:hover td { background: none !important; box-shadow: none !important; }
  #ac-table tr.click td { padding: 0; border: 0; text-align: left; font-size: 13px; min-width: 0; white-space: normal; }
  #ac-table tr.click td:nth-child(1), #ac-table tr.click td:nth-child(2) { grid-column: 1 / -1; }
  #ac-table tr.click td:nth-child(2) { display: flex; flex-wrap: wrap; gap: 6px; }
  #ac-table td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }
  #ac-table .name-cell b { font-size: 15.5px; }

  /* Team view as cards too: the account manager on top, then the labelled numbers in three columns */
  table.tv, table.tv tbody { display: block; }
  table.tv thead { display: none; }
  table.tv tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.tv tr:last-child { border-bottom: 0; }
  .table-wrap:has(> table.tv) { overflow: hidden; }
  table.tv td { padding: 0; border: 0; text-align: left; font-size: 13px; min-width: 0; white-space: normal; }
  table.tv td:first-child { grid-column: 1 / -1; }
  table.tv td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }
  table.tv .tv-n, table.tv .tv-h { margin: -4px 0 0 -8px; text-align: left; }
}

/* Room for the phone bottom bar (am.css) under the last card. */
@media (max-width: 640px) {
  .shell.top .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* Team & Roles as cards on phones, so an admin can let a sign-up in without scrolling sideways: the person on
   top, then role and greeting, then the labelled numbers, Active and the Login button. */
@media (max-width: 640px) {
  table.tm, table.tm tbody { display: block; }
  table.tm thead { display: none; }
  table.tm tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.tm tr:last-child { border-bottom: 0; }
  .table-wrap:has(> table.tm) { overflow: hidden; }
  table.tm td { padding: 0; border: 0; text-align: left; font-size: 13px; min-width: 0; white-space: normal; }
  table.tm td, table.tm tr:hover td { background: none !important; box-shadow: none !important; }
  table.tm td:first-child { grid-column: 1 / -1; }
  table.tm td select.inline { width: 100%; max-width: 100%; }
  table.tm td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }
  table.tm td:last-child { align-self: end; }
}
