/* Installable app, phone tabs, two-factor set-up and the Security dialog (G2). Loaded after phone.css. */
.phone-tabs, .data-freshness { display:none; }
.link-button { background:transparent; color:#087f83; border:0; padding:4px 0; font-weight:600; text-decoration:underline; text-underline-offset:3px; }
html[data-content-theme=dark] .link-button { color:#5eead4; }
#loginSecondFactor { margin-bottom:12px; }
#loginSecondFactor label { margin-bottom:8px; }

/* Two-factor set-up (shares the login backdrop) */
.totp-card { max-width:460px; width:100%; }
.login .totp-card { padding:30px; }
.totp-card h1 { font-size:24px; }
.totp-steps { margin:10px 0; padding-left:20px; font-size:14px; line-height:1.5; }
.totp-qr { display:block; width:200px; height:200px; margin:8px auto; image-rendering:pixelated; border-radius:8px; background:#fff; }
.totp-secret-line { font-size:13px; text-align:center; overflow-wrap:anywhere; }
.totp-secret-line code { font-size:14px; letter-spacing:1px; }
.totp-card .secondary { margin-top:10px; width:100%; }
.totp-codes { list-style:none; padding:0; margin:14px 0; display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.totp-codes li { font:600 15px/1.4 Consolas,monospace; letter-spacing:1px; padding:8px; text-align:center; border:1px dashed #9fb6c1; border-radius:6px; background:#f7fafb; }
html[data-content-theme=dark] .totp-card { background:#1b2a3f; color:#e2e8f0; border-color:#364b68; }
html[data-content-theme=dark] .totp-card p, html[data-content-theme=dark] .totp-card li { color:#cbd5e1; }
html[data-content-theme=dark] .totp-codes li { background:#152238; border-color:#52657c; color:#e2e8f0; }

/* Security dialog */
.security-dialog { width:min(520px,calc(100vw - 32px)); border:1px solid #dfe7ec; border-radius:12px; padding:18px 20px; color:#182e3c; background:#fff; box-shadow:0 12px 40px #102d3b40; }
.security-dialog::backdrop { background:#102d3b80; }
.security-close-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:6px; }
.security-close-row h2 { margin:0; }
.security-close-row button { padding:7px 12px; font-size:13px; }
.security-dialog section { border-top:1px solid #e4ebef; padding:12px 0 4px; }
.security-dialog h3 { font-size:15px; margin:0 0 4px; }
.security-dialog p { margin:4px 0 8px; font-size:13px; }
.security-dialog .actions { margin-top:6px; }
.security-dialog .actions button { padding:8px 14px; font-size:13px; }
.security-priority { gap:10px; margin:4px 0; font-weight:600; }
.security-priority select { padding:6px 8px; }
.security-note { font-size:12px; }
html[data-content-theme=dark] .security-dialog { background:#1b2a3f; color:#e2e8f0; border-color:#364b68; }
html[data-content-theme=dark] .security-dialog section { border-color:#364b68; }
html[data-content-theme=dark] .security-dialog .muted { color:#a9bbd3; }
html[data-content-theme=dark] .security-dialog select { background:#152238; color:#e2e8f0; border-color:#52657c; }
html[data-content-theme=dark] .security-dialog .secondary { background:#152238; color:#e2e8f0; border-color:#52657c; }

/* User Management */
.user-remote { flex-direction:row; align-items:center; gap:8px; margin:0 0 8px; }
.user-remote input { width:18px; height:18px; }

/* Install prompt: a bottom sheet on phones */
.install-sheet { position:fixed; left:0; right:0; bottom:0; z-index:60; padding:18px 18px calc(18px + env(safe-area-inset-bottom));
  background:#fff; color:#182e3c; border-radius:18px 18px 0 0; box-shadow:0 -8px 30px #0005; }
.install-sheet-row { display:flex; gap:12px; align-items:center; }
.install-sheet-icon { width:56px; height:56px; border-radius:14px; flex-shrink:0; }
.install-sheet h3 { margin:0; font-size:17px; }
.install-sheet p { margin:4px 0 0; font-size:13px; color:#5f7481; line-height:1.45; }
.install-sheet ul { margin:14px 0; padding-left:18px; font-size:13px; line-height:1.7; }
.install-sheet-actions { display:flex; gap:10px; margin-top:12px; }
.install-sheet-actions button { flex:1; }
html[data-content-theme=dark] .install-sheet { background:#1b2a3f; color:#e2e8f0; }
html[data-content-theme=dark] .install-sheet p { color:#a9bbd3; }
html[data-content-theme=dark] .install-sheet .secondary { background:#152238; color:#e2e8f0; border-color:#52657c; }

@media screen and (max-width:600px) {
  /* Room for the tab bar under the last card. */
  html body main { padding-bottom:calc(84px + env(safe-area-inset-bottom)) !important; }
  .phone-tabs {
    position:fixed; left:0; right:0; bottom:0; z-index:45; display:grid; grid-template-columns:repeat(4,1fr); gap:0;
    margin:0; padding:6px 4px calc(6px + env(safe-area-inset-bottom));
    background:var(--phone-bar, #f7faff); border-top:1px solid var(--phone-bar-border, #d7e2e6);
  }
  html[data-content-theme=dark] .phone-tabs { --phone-bar:#152238; --phone-bar-border:#364b68; }
  .phone-tabs > a, .phone-tabs > button {
    display:flex; flex-direction:column; align-items:center; gap:2px; min-height:48px; padding:4px 0;
    background:transparent; border:0; border-radius:8px; color:#5f7481; font-size:11px; font-weight:600; text-decoration:none;
  }
  .phone-tabs > [hidden] { display:none; }
  /* The More tab is a button: undo the shared 34 px button size (ui-consistency.css). */
  html body .phone-tabs > button { height:auto !important; min-height:48px !important; padding:4px 0 !important; font-size:11px !important; gap:2px; justify-content:flex-start; }
  html body .phone-tabs svg { flex:0 0 22px; width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
  .phone-tabs > a.active { color:#087f83; }
  html[data-content-theme=dark] .phone-tabs > a, html[data-content-theme=dark] .phone-tabs > button { color:#a9bbd3; }
  html[data-content-theme=dark] .phone-tabs > a.active { color:#5eead4; }
  body.sidebar-open .phone-tabs { display:none; }

  .data-freshness {
    display:block; position:fixed; left:0; right:0; z-index:44; bottom:calc(61px + env(safe-area-inset-bottom));
    margin:0; padding:3px 12px; font-size:11px; line-height:1.4; text-align:center;
    color:#2f5d4f; background:#e7f6ef; border-top:1px solid #cfe7dc;
  }
  .data-freshness[hidden] { display:none; }
  .data-freshness[data-state=stale], .data-freshness[data-state=offline] { color:#7a4a00; background:#fff3dd; border-color:#f2d7a6; }
  html[data-content-theme=dark] .data-freshness { color:#a7f3d0; background:#123029; border-color:#1f4d42; }
  html[data-content-theme=dark] .data-freshness:is([data-state=stale],[data-state=offline]) { color:#fde68a; background:#3a2e12; border-color:#5c4a1c; }
  body.sidebar-open .data-freshness { display:none; }

  .login .totp-card { padding:22px 18px; }
  .totp-qr { width:180px; height:180px; }
}
@media screen and (min-width:601px) { .install-sheet { display:none; } }

/* Account buttons: Security takes its own row above Password, Theme and Sign out when the
   menu is open (a grid, so the three never wrap while the menu slides open). */
body.sidebar-open .account-actions { display:grid; grid-template-columns:minmax(0,1fr) 43px minmax(0,1fr); }
body.sidebar-open .account-actions .security-action { grid-column:1 / -1; width:auto; }
body.sidebar-open .account-actions button { min-width:0; }
@media (max-width:900px) {
  .account-actions { display:grid; grid-template-columns:minmax(0,1fr) 43px minmax(0,1fr); }
  .account-actions .security-action { grid-column:1 / -1; width:auto; }
  .account-actions button { min-width:0; }
}

.user-role-help { font-size:12px; margin:0 0 10px; }
