/* Sign-in extras (all widths) */
.btn-google { background: #fff; color: #1F1F1F; border-color: #DADCE0; gap: 12px; font-weight: 600; margin-top: 24px; }
.btn-google:hover { background: #F2F2F2; border-color: #DADCE0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; margin-top: 18px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.auth-form.tight { margin-top: 18px; }

/* Bottom tab bar: hidden on desktop */
.tabbar { display: none; }

/* ---------- Tablet & phone ---------- */
@media (max-width: 900px) {
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 28;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(6, 10, 16, .94); border-top: 1px solid var(--line);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border-radius: 12px; border: 0; background: none; cursor: pointer;
    color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em;
    -webkit-tap-highlight-color: transparent;
  }
  .tab:hover { text-decoration: none; }
  .tab svg { width: 21px; height: 21px; }
  .tab.danger svg { color: var(--red); }
  .tab[aria-current] { color: var(--mint); background: var(--mint-soft); }
  .tab[aria-current] svg { color: var(--mint); }

  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .topbar { top: 0; padding-block: calc(12px + env(safe-area-inset-top, 0px)) 12px; gap: 12px; }
  .savebar { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .side { padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Phone ---------- */
@media (max-width: 620px) {
  body { font-size: 15px; }
  /* 16px+ stops iOS Safari zooming into focused fields */
  .input, select.input { font-size: 16px; height: 48px; }
  .btn { min-height: 44px; }
  .btn-sm { height: 40px; min-height: 40px; }
  .switch { width: 50px; height: 30px; }
  .switch::after { width: 22px; height: 22px; }
  .switch[aria-checked="true"]::after { transform: translateX(20px); }
  .seg button { height: 40px; padding: 0 14px; }

  .pad { padding: 18px; }
  .wrap { padding-inline: 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar .t-sub { font-size: 12px; }
  .chip-btn { height: 34px; padding: 0 10px; }

  /* KPI tiles: 2 × 2 instead of four full-height cards */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.three > .kpi:last-child { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .kpi .lbl { font-size: 11px; }
  .kpi .val { font-size: 22px; margin-top: 6px; }
  .kpi .val small { font-size: 14px; }
  .kpi .foot { font-size: 11px; margin-top: 6px; }
  .kpi .spark { height: 34px; }
  .kpi.status .val { font-size: 15px; margin-top: 8px; gap: 8px; }
  .chart { height: 220px; }

  /* Tables become stacked cards; cells label themselves */
  .tbl-wrap:has(.tbl.cards) { overflow: visible; margin: 0; padding: 0; }
  .tbl.cards { min-width: 0; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .tbl.cards tr:last-child { border-bottom: 0; }
  .tbl.cards tr:hover { background: none; }
  .tbl.cards td { display: block; padding: 0; border: 0; text-align: left; font-size: 14px; min-width: 0; }
  .tbl.cards td.span { grid-column: 1 / -1; }
  .tbl.cards td.r.span { text-align: right; }
  .tbl.cards td.r.span .btn { width: 100%; }
  .tbl.cards td.hide-card { display: none; }
  .tbl.cards td[data-label]::before { content: attr(data-label); display: block; font-family: var(--font-ui); font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }

  /* Order ticket: two columns, instrument and button full width */
  .ticket { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ticket > .field:first-child, .ticket > button { grid-column: 1 / -1; }

  .rule { padding: 18px; }
  .savebar { padding: 10px; }
  .savebar .msg { min-width: 100%; }
  .savebar .btn { flex: 1; }
  .plan .price .big { font-size: 44px; }
  .estop h2 { font-size: 22px; }
  .note { padding: 14px; gap: 12px; }
  .auth-aside { display: none; }
  .hero .row .btn { flex: 1; }
}
