/* The phone. Loaded last. A phone is not the desktop made narrow: it has a
   frame and layouts of its own, built for a thumb and a glance, and drawn
   from what the most used billing apps on a phone have in common.

   - Five tabs at the foot: Home, Bills, Parties, Items, More. The two lists a
     shop lives in (who owes, what is in stock) are tabs, not menu items.
   - What a screen makes is one button above the tabs, named for it
     ("New invoice", "New customer"). It never floats over a record or a form.
   - Home leads with what is owed both ways, then the things made every day.
   - A list is a column of rows: who, how much, how it stands. No columns.
   - A record pins the one or two things done most at the foot of the screen. */

.fab, .dock { display: none; }
.m-only { display: none !important; }

/* ---------- the frame (phones and small tablets) ---------- */
@media (max-width: 999px) {
  /* the bar at the foot: light, flat, the tab in hand marked with the one accent */
  .tabbar { background: var(--surface); border-top: 1px solid var(--line); box-shadow: none; }
  .tabbar div { max-width: 600px; height: 58px; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0 2px; }
  .tabbar a, .tabbar button { gap: 2px; font-size: 10.5px; font-weight: 500; color: #7b7d85; }
  .tabbar span { width: 46px; height: 28px; border-radius: 9px; }
  .tabbar [aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabbar [aria-current="page"] span { background: #fbeebf; color: var(--ink); }
  .tabbar .pip { top: 7px; left: calc(50% + 8px); right: auto; box-shadow: 0 0 0 2px var(--surface); }

  /* what this screen makes, named, above the tabs */
  .fab:not([hidden]) { position: fixed; right: 14px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 19; display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 14px; cursor: pointer; font-size: 14.5px; font-weight: 600; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px rgba(22, 23, 26, 0.22); }
  .fab:active { transform: scale(0.97); }
  body:has(dialog[open]) .fab, body:has(.stickybar) .fab, body:has(.dock) .fab { display: none; }
  .page-head [data-key="create"] { display: none; }
  body:has(.fab:not([hidden])) .page { padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }

  /* the one or two things done most on a record, and the buttons that send a bill: one bar, sitting on the tabs */
  .dock, .stickybar, .stickybar.glass { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom, 0px)); z-index: 19; display: flex; gap: 8px; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--surface); box-shadow: 0 -6px 16px rgba(22, 23, 26, 0.05); }
  .dock .pill { flex: 1 1 0; min-width: 0; height: 46px; font-size: 14.5px; font-weight: 600; }
  .dock .pill.round { flex: none; width: 46px; }
  .dock .pill.in { background: var(--ok); color: #fff; box-shadow: none; }
  .dock .pill:first-child:not(.in):not(.round) { background: var(--ink); color: var(--on-dark); box-shadow: none; }
  .dock .pill.dark + .pill.dark { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(22, 23, 26, 0.14); }
  .stickybar .pill.wide { height: 46px; }
  body:has(dialog[open]) .dock { display: none; }
  body:has(.dock) .page, body:has(.stickybar) .page { padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
  body:has(.dock) .toast, body:has(.stickybar) .toast { bottom: calc(136px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 699px) {
  .m-only { display: revert !important; }
  span.avatar.m-only { display: grid !important; }

  /* ---------- Home ---------- */
  .home-m { display: grid; gap: 12px; }
  .home-m .card { padding: 16px; }
  .owes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .owe { display: grid; gap: 2px; align-content: start; min-width: 0; padding: 14px 14px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(22, 23, 26, 0.05); }
  .owe span { font-size: 12.5px; color: var(--muted); }
  .owe b { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .owe small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .owe small.bad { color: var(--bad); font-weight: 500; }
  .owe.get b { color: var(--ok); }
  .qa-card { padding: 14px 8px 12px !important; }
  .qa-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 0; }
  .qa { display: grid; justify-items: center; gap: 6px; padding: 0 2px; border: 0; background: none; cursor: pointer; font-size: 12px; line-height: 1.25; text-align: center; color: var(--ink); }
  .qa span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--paper); color: var(--ink); }
  .qa.lead span { background: var(--accent); color: var(--accent-ink); }
  .qa:active span { transform: scale(0.95); }
  .sales-m { display: grid; gap: 8px; }
  .sales-m-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .sales-m-top > div { display: grid; min-width: 0; }
  .sales-m-top span { font-size: 12.5px; color: var(--muted); }
  .sales-m-top b { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sales-m-top .pill { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .sales-m-top .pill span { font-size: 12.5px; color: inherit; }
  .sales-m small { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
  .sales-m .spark { height: 56px; gap: 3px; margin-top: 4px; }
  .sales-m .spark i { background: #dcdbd4; border-radius: 3px 3px 0 0; }
  .sales-m .spark i.now { background: var(--accent); }
  .mini-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .home-m .mini { display: grid; gap: 2px; padding: 14px; min-width: 0; }
  .mini span { font-size: 12.5px; color: var(--muted); }
  .mini b { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
  .mini small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ---------- lists: who, how much, how it stands ---------- */
  .stage:has(> .card.index) > .page-head .page-sub { display: none; }
  .stage:has(> .card.index) > .page-head { margin-bottom: 10px; }
  .index-sum { padding: 8px 14px 6px; }
  .card.index { border-radius: 14px; }
  .index-top { padding: 8px 10px 4px; }
  .index-top .searchbox { order: -1; flex-basis: 100%; }
  .views button { height: 34px; padding: 0 12px; border-radius: 9px; background: var(--paper); margin-right: 4px; }
  .views [aria-selected="true"] { background: var(--ink); color: var(--on-dark); }
  .views [aria-selected="true"] small { background: rgba(255, 255, 255, 0.18); color: #fff; }
  .index-table tr { padding: 12px 14px; }
  .index-table .c-amt { font-weight: 600; }
  /* a party: a face, the name, one line about it; what is owed at the right */
  .index-table.parties tr { position: relative; grid-template-areas: "party unpaid" "party due"; padding-left: 64px; }
  .index-table.parties .avatar { position: absolute; left: 14px; top: 50%; width: 38px; height: 38px; margin-top: -19px; border-radius: 11px; font-size: 13px; background: var(--paper); color: var(--ink); }
  .index-table.parties .c-party { display: block; white-space: normal; }
  .index-table.parties .c-party a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .index-table.parties .c-party small { display: none; }
  .index-table.parties .c-party small.m-sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
  .index-table.parties .c-extra { display: none; }
  .index-table.parties .c-unpaid { font-weight: 600; }
  .index-table.parties .c-due { font-size: 12.5px; }
  .index-table.parties .c-due .quiet { color: var(--muted); }

  /* ---------- a party's account ---------- */
  .acct { display: grid; gap: 14px; padding: 16px; margin-bottom: 12px; }
  .acct-top { display: flex; align-items: center; gap: 12px; }
  .acct-top .avatar { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; background: var(--paper); color: var(--ink); }
  .acct-top > div { flex: 1; min-width: 0; }
  .acct-top .page-title { display: block; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .acct-top .page-sub { margin-top: 1px; }
  .acct-bal { display: grid; gap: 2px; padding: 14px; border-radius: 12px; background: var(--paper); }
  .acct-bal span { font-size: 12.5px; color: var(--muted); }
  .acct-bal b { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
  .acct-bal small { font-size: 12.5px; color: var(--muted); }
  .acct-bal small.bad { color: var(--bad); font-weight: 500; }
  .acct-bal.get b { color: var(--ok); }
  .acct-acts { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
  .acct-acts a, .acct-acts button { display: grid; justify-items: center; gap: 5px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--ink); }
  .acct-acts span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--paper); }
  .acct-acts :active span { transform: scale(0.95); }
}

/* ---------- the team on a phone: a letter for each mark, one thumb ---------- */
@media (max-width: 699px) {
  .att-day { padding: 14px; gap: 14px; margin-bottom: 12px; border-radius: 14px; }
  .att-when .st-stepper { max-width: none; }
  .att-fig b { font-size: 26px; }
  /* the day and the count take as little as they can: the people are what the screen is for */
  .stage:has(> .att-day) > .page-head { display: none !important; }
  .att-when .st-date { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; }
  .att-when .st-date .field { width: 132px; height: 34px; font-size: 13px; }
  .att-now { grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 8px 12px; }
  .att-now .att-hello, .att-now .att-key { display: none; }
  .att-now .att-bar { grid-column: 1 / -1; grid-row: 2; }
  .att-now .att-line { text-align: right; font-size: 13px; }
  .att-note { font-size: 13px; }
  .att .index-top { gap: 8px; }
  .att-tools { flex-basis: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .att-tools .pill { flex: none; height: 34px; }
  .att-group { padding: 8px 14px; }
  .att-row { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 6px 10px; padding: 11px 14px; }
  .att-row .face { width: 38px; height: 38px; border-radius: 11px; grid-row: 1 / 3; align-self: start; }
  .att-who { grid-column: 2; grid-row: 1; }
  .att-marks { grid-column: 3; grid-row: 1 / 3; align-self: center; gap: 5px; }
  .att-marks button { width: 38px; min-width: 0; height: 38px; padding: 0; border-radius: 11px; font-size: 14px; font-weight: 600; }
  .att-marks .w { display: none; }
  .att-marks .l { display: inline; }
  .att-week { grid-column: 2; grid-row: 2; gap: 2px; }
  .att-week i { width: 15px; height: 15px; border-radius: 4px; font-size: 0; }
  .att-more { grid-column: 1 / -1; grid-row: 3; justify-content: flex-start; padding-left: 48px; }
  .att-more:not(:has(.tag, .st-hours, .st-extra.on)) { display: none; }
  .att-more .st-extra:not(.on) { display: none; }
  .att-hint kbd { display: none; }
  .att-hint { font-size: 12px; }
  .index-table.people tr { position: relative; grid-template-areas: "party unpaid" "party due"; padding-left: 64px; }
  .index-table.people .c-party { display: block; white-space: normal; }
  .index-table.people .c-party .face { position: absolute; left: 14px; top: 50%; width: 38px; height: 38px; margin-top: -19px; border-radius: 11px; }
  .index-table.people .c-party a { display: block; }
  .index-table.people .c-party small { display: none; }
  .index-table.people .c-party small.m-sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
  .index-table.people .c-unpaid small { display: inline; margin-left: 4px; }
  .dept-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .dept { padding: 16px; border-radius: 14px; }
  .who-lead .face.big { width: 44px; height: 44px; border-radius: 13px; font-size: 15px; }
}

@media (max-width: 699px) {
  .index-table.people .c-unpaid { display: block; grid-area: unpaid; justify-self: end; }
  .index-table.people .c-due { display: block; grid-area: due; justify-self: end; font-size: 12.5px; }
  .index-table.reps tr { grid-template-areas: "party due" "extra extra"; }
  .index-table.reps .c-due { display: block; grid-area: due; justify-self: end; font-size: 12.5px; }
  .index-table.reps td.c-extra:nth-child(2) { display: block; grid-area: extra; font-size: 12.5px; color: var(--muted); }
  .index-table.reps td.c-extra:nth-child(2):empty { display: none; }
}

@media (max-width: 699px) {
  .index-table .c-no.num { text-align: left; }
  .index-title small { display: none; }
  .sbar-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .rep-kpis .kpi { padding: 12px 14px; }
}
