/* Phone layout (loaded after the other stylesheets; desktop is untouched). */
.m-jump { display: none; }
@media (max-width: 860px) {
  /* deal / contact page: section bar, then the side sections (folded), then the activity */
  .record { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .record > * { order: 3; }
  .record > .m-jump { order: 0; }
  .record > :first-child, .record > .m-head { order: 1; }
  .record > .side-cards { order: 2; display: grid; gap: 10px; grid-template-columns: 1fr; }
  .m-jump {
    position: sticky; top: 58px; z-index: 12; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin: -4px -14px 0; padding: 8px 14px; background: color-mix(in srgb, var(--bg) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .m-jump::-webkit-scrollbar { display: none; }
  .m-jump button {
    flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
    padding: 6px 12px; font: 600 12.5px/1.2 var(--font); white-space: nowrap; cursor: pointer;
  }
  .m-jump button:active { background: var(--gold-soft); border-color: var(--gold); }
  .side-cards > .card.m-fold > .card-head { cursor: pointer; }
  .side-cards > .card.m-fold > .card-head::after {
    content: ""; flex: none; width: 9px; height: 9px; margin-left: 4px; border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s;
  }
  .side-cards > .card.m-fold.m-closed > .card-head::after { transform: rotate(-45deg); }
  .side-cards > .card.m-fold.m-closed > :not(.card-head) { display: none !important; }
  .side-cards > .card.m-fold.m-closed > .card-head { border-bottom: 0; }
  .card-head { flex-wrap: wrap; }
  .card-head h2, .card-head h3 { min-width: 0; }
  .rec-head { padding: 16px; }
  .quick-acts { gap: 4px; justify-content: space-between; }
  .timeline { padding: 4px 12px 12px; }
  .composer { padding: 12px; }
  /* page tops and tool rows */
  .page-head { align-items: stretch; }
  .page-head .toolbar > * { flex: 1 1 auto; }
  .filters > select, .filters > input { flex: 1 1 140px; width: auto; }
  .pipe-banner { height: 88px; }
  .pipe-banner p { display: none; }
  .hero { min-height: 0; }
  .hero .copy { padding: 20px; }
  .kpi { padding: 13px 14px; }
  .kpi .value { font-size: 23px; margin-top: 6px; }
  .money-row { gap: 10px; }
  .money-row span { min-width: 0; }
  .panel-body { padding: 16px; }
  .modal { max-height: 92vh; overflow-y: auto; }
}

@media (max-width: 760px) {
  /* every table that isn't already laid out for phones becomes a stack of labelled cards */
  .table-wrap table:not(.cardify) thead { display: none; }
  .table-wrap table:not(.cardify), .table-wrap table:not(.cardify) tbody { display: block; width: 100%; }
  .table-wrap table:not(.cardify) tr {
    display: block; margin: 10px 12px; padding: 6px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  }
  .table-wrap table:not(.cardify) td {
    display: grid; grid-template-columns: minmax(84px, 34%) minmax(0, 1fr); gap: 10px; align-items: start;
    padding: 7px 12px; border: 0; text-align: left !important; overflow-wrap: anywhere;
  }
  .table-wrap table:not(.cardify) td + td { border-top: 1px dashed var(--line-soft); }
  .table-wrap table:not(.cardify) td::before {
    content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .01em; padding-top: 2px;
  }
  .table-wrap table:not(.cardify) td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  .table-wrap table:not(.cardify) td[data-label=""]::before { display: none; }
  .table-wrap table:not(.cardify) td.hide-sm { display: none !important; }
  .table-wrap table:not(.cardify) td:empty { display: none; }
  .table-wrap table:not(.cardify) td .row { flex-wrap: wrap; }
  .table-wrap table:not(.cardify) td .btn, .table-wrap table:not(.cardify) td .pill { justify-self: start; }
  .table-wrap table:not(.cardify) td > .btn + .btn { margin-top: 6px; }
  .table-wrap table:not(.cardify) tr.click:hover td { background: transparent; }
  .table-wrap table:not(.cardify) tr.click:hover td:first-child { box-shadow: none; }
  /* a tick-box column sits on its own, top right of the card */
  .table-wrap table:not(.cardify) tr { position: relative; }
  .table-wrap table:not(.cardify) td.m-check { position: absolute; top: 8px; right: 6px; display: block; padding: 4px; border: 0; }
  .table-wrap table:not(.cardify) td.m-check::before { display: none; }
  .table-wrap table:not(.cardify) td.m-check + td { border-top: 0; padding-right: 44px; }
  .table-wrap table:not(.cardify) input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }
  /* small inline tables (e.g. the production forecast) */
  .card-body table:not(.cardify) td { padding: 5px 0; }
}
