/* The phone view — phone-first. Big targets, thumb-reachable navigation, no chrome. */

body.m { background: var(--bg); }

/* Sign-in on the phone: the same green ground as the desktop auth shell, with
   the card doing the work of the two-column rail there is no room for. */
.m-login { display: none; place-items: center; min-height: 100dvh; padding: 24px; }
.m-login.active { display: grid; }
.m-login {
  background-color: var(--accent-deep);
  background-image:
    linear-gradient(145deg, #245240, #132f22 70%),
    radial-gradient(rgba(255, 255, 255, 0.06) 1.5px, transparent 1.5px);
  background-size: auto, 26px 26px;
}
.m-login > div {
  background: var(--surface); border-radius: 22px;
  padding: 30px 26px; width: min(380px, 100%);
  box-shadow: 0 30px 60px -22px rgba(0, 0, 0, 0.55);
}
.m-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.m-logo .mark { flex: none; width: 40px; height: 40px; display: flex; }
.m-logo .mark img { width: 100%; height: 100%; object-fit: contain; }
.m-logo .wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.m-logo .name { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); }
.m-logo .product { font-size: 11px; font-weight: 500; letter-spacing: .1em; color: var(--text-faint); }
.m-login h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.m-login .sub { margin: 6px 0 22px; color: var(--text-faint); font-size: 14px; }
.m-login .sub a { color: var(--accent); }

.m-app { display: none; min-height: 100dvh; flex-direction: column; }
.m-app.active { display: flex; }

.m-top {
  display: flex; align-items: center; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.m-brand { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.m-brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.m-brand .dot.stale { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.m-top .meta { color: var(--text-faint); font-size: 12px; }

.m-alertbar:empty { display: none; }
.m-alertbar { border-bottom: 1px solid var(--crit); }
.m-alertlink {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  padding: 11px 16px; background: var(--crit-bg);
  font: inherit; font-size: 13px; color: var(--crit); font-weight: 550;
}
.m-alertlink:active { filter: brightness(1.06); }

.m-search { padding: 12px 16px 4px; position: sticky; top: 53px; background: var(--bg); z-index: 9; }
.m-search input { font-size: 16px; padding: 12px 14px; border-radius: 11px; } /* 16px stops iOS zoom-on-focus */

.m-app main { flex: 1; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.m-group { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.m-group:first-child { margin-top: 0; }
.m-group .name { font-weight: 600; font-size: 13px; }
.m-group .meta { color: var(--text-faint); font-size: 12px; margin-left: auto; }

.m-door {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  padding: 14px 15px; cursor: pointer; min-height: 62px;
}
.m-door:active { transform: scale(.99); }
.m-door .body { flex: 1; min-width: 0; }
.m-door .title { font-weight: 570; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-door .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.m-door .chev { color: var(--text-faint); font-size: 19px; flex: none; }
.m-door.crit { border-color: var(--crit); }

.m-empty { padding: 40px 16px; text-align: center; color: var(--text-faint); }

.m-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.m-foot .meta { color: var(--text-faint); font-size: 12px; margin-left: auto; }

.btn.m-big { width: 100%; padding: 14px; font-size: 16px; border-radius: 12px; }

/* Action sheet */
.m-sheet-backdrop {
  position: fixed; inset: 0; background: #000a; z-index: 50;
  display: none; align-items: flex-end;
}
.m-sheet-backdrop.open { display: flex; }
.m-sheet {
  width: 100%; background: var(--surface);
  border-radius: 18px 18px 0 0; border-top: 1px solid var(--border);
  padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  max-height: 88dvh; overflow: auto;
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.m-sheet h2 { margin: 0 0 3px; font-size: 18px; }
.m-sheet .where { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.m-sheet .m-actions { display: flex; flex-direction: column; gap: 9px; }

@media (min-width: 620px) {
  .m-sheet-backdrop { align-items: center; justify-content: center; padding: 20px; }
  .m-sheet { max-width: 460px; border-radius: 16px; border: 1px solid var(--border); }
}


/* ── Bottom tab bar ────────────────────────────────────────────────────────
   Sticky at the bottom rather than the top: on a phone held one-handed the
   thumb reaches the bottom third and not much else, and this view exists
   precisely for the moments when the other hand is holding a door open. */
.m-tabbar {
  position: sticky; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.m-tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; cursor: pointer;
  padding: 10px 4px 11px; min-height: 58px;
  font: inherit; font-size: 11px; font-weight: 560; letter-spacing: .01em;
  color: var(--text-faint);
}
.m-tabbar button svg {
  width: 21px; height: 21px; fill: none;
  stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.m-tabbar button.active { color: var(--accent); }
.m-tabbar button:active { background: var(--surface-2); }
/* The count rides on the bell rather than sitting beside the word: in a column
   layout an inline badge becomes a third row and shoves the labels out of line
   with the other two tabs. */
.m-tabbar .ic { position: relative; display: inline-flex; }
.m-tabbar .badge { display: none; }
.m-tabbar .badge.on {
  display: block; position: absolute; top: -5px; left: 11px;
  background: var(--crit); color: #fff; border: 2px solid var(--surface); border-radius: 9px;
  min-width: 17px; padding: 0 4px; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}

/* ── Alert cards ─────────────────────────────────────────────────────────── */
.m-alert {
  background: var(--surface); border: 1px solid var(--border);
  border-left-width: 3px; border-radius: 13px; padding: 13px 15px;
}
.m-alert.crit { border-left-color: var(--crit); }
.m-alert.warn { border-left-color: var(--warn); }
.m-alert .row { display: flex; align-items: center; gap: 8px; }
.m-alert .when { margin-left: auto; color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.m-alert .what { font-weight: 570; font-size: 15px; margin-top: 8px; }
.m-alert .where { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; color: var(--text-dim); }
