/* Periodic Maintenance Management System (PMMS) — Bin Quraya · UI (warm minimal) */
/* PWA/offline: system fonts only — no external CDN (Google Fonts removed). */

:root {
  --brand-red: #b91c1c;
  --brand-red-mid: #dc2626;
  --brand-red-deep: #991b1b;
  --brand-red-soft: rgba(185, 28, 28, 0.1);
  --brand-red-glow: rgba(220, 38, 38, 0.2);

  --ink: #1c1917;
  --ink-muted: #44403c;
  --muted: #78716c;
  --muted-2: #a8a29e;

  --bg: #f5f4f1;
  --bg-warm: #fafaf9;
  --surface: #ffffff;
  --surface-muted: #f5f5f4;

  --text: var(--ink);
  --border: #e7e5e4;
  --border-strong: #d6d3d1;

  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  --primary: var(--brand-red-mid);
  --primary-hover: var(--brand-red-deep);
  --red: #b91c1c;
  --green: #15803d;
  --brand-slate: #44403c;

  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;

  --shadow-xs: 0 1px 0 rgba(28, 25, 23, 0.04);
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 20px rgba(28, 25, 23, 0.07);
  --shadow-lg: 0 12px 40px rgba(28, 25, 23, 0.09);

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* App pages: fixed left sidebar (was bottom pill nav) */
  --app-nav-width: 228px;

  /* Unified header logo (dashboard + scan + field) */
  --pmms-logo-size: 72px;
  --pmms-logo-mark-size: 88px;
  --pmms-logo-mark-padding: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ——— App header (logo + product name + profile) ——— */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
  margin: 0 0 18px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.app-header--compact {
  padding: 10px 0 12px;
  margin: 0 0 16px;
}

.app-header__start {
  display: flex;
  align-items: center;
  gap: 12px 18px;
  min-width: 0;
  flex: 1 1 auto;
}

.app-header__end {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-left: auto;
}

/* Header notifications (bell + dropdown) */
.app-notify {
  position: relative;
  flex-shrink: 0;
}

.app-notify__anchor {
  position: relative;
}

.app-notify__btn {
  position: relative;
  z-index: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-muted, #f8fafc) 100%);
  color: var(--ink-muted);
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    var(--shadow-xs);
  transition:
    color 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.app-notify__btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.85;
  vector-effect: non-scaling-stroke;
}

.app-notify__btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 1) inset,
    var(--shadow-sm);
  transform: translateY(-1px);
}

.app-notify__btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.app-notify__btn[aria-expanded="true"] {
  color: var(--brand-red-deep);
  border-color: rgba(220, 38, 38, 0.32);
  background: linear-gradient(180deg, rgba(254, 242, 242, 0.95) 0%, rgba(255, 255, 255, 0.92) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 0 0 2px rgba(220, 38, 38, 0.12),
    0 4px 14px rgba(185, 28, 28, 0.12);
}

.app-notify__btn:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-notify__btn:focus:not(:focus-visible) {
  outline: none;
}

.app-notify__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  text-align: center;
  color: #fff;
  background: linear-gradient(165deg, #ef4444 0%, var(--brand-red-deep) 100%);
  border: 2px solid var(--surface);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 2px 6px rgba(185, 28, 28, 0.4);
  pointer-events: none;
}

.app-notify__badge:empty,
.app-notify__badge[hidden] {
  display: none;
}

.app-notify__panel {
  position: fixed;
  top: var(--app-notify-panel-top, 4.5rem);
  right: max(12px, env(safe-area-inset-right, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  width: auto;
  max-width: min(760px, calc(100vw - 24px));
  max-height: var(--app-notify-panel-max-h, min(85vh, 640px));
  margin-left: auto;
  margin-right: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 24px 56px -16px rgba(15, 23, 42, 0.22);
  z-index: 200;
  overflow: hidden;
}

.app-notify__panel[hidden] {
  display: none !important;
}

.app-notify__panel:not([hidden]) {
  display: flex;
}

.app-notify__panel-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-muted, #f8fafc) 0%, var(--surface) 100%);
}

.app-notify__panel-head::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-red-deep) 0%, var(--brand-red-mid) 50%, rgba(248, 113, 113, 0.75) 100%);
  pointer-events: none;
}

.app-notify__panel-titlewrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-notify__panel-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}

.app-notify__panel-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}

.app-notify__links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 2px;
}

.app-notify__link-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand-red-deep);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(220, 38, 38, 0.2);
  background: rgba(254, 242, 242, 0.55);
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    box-shadow 0.14s ease;
}

.app-notify__link-chip:hover {
  background: rgba(254, 242, 242, 0.95);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--brand-red-mid);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.12);
}

.app-notify__link-chip:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-notify__link-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  margin: 0;
  padding: 0;
  color: var(--ink-muted);
  text-decoration: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    color 0.14s ease,
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.14s ease;
}

.app-notify__link-eye:hover {
  color: var(--brand-red-deep);
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(254, 242, 242, 0.65);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.1);
  transform: translateY(-1px);
}

.app-notify__link-eye:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-notify__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 16px;
  min-height: 0;
  background: var(--bg-warm, #f8fafc);
}

/* Inbox tables — match Alerts page (alerts-card / alerts-table) */
.app-notify__scroll .alerts-card.app-notify__card {
  margin-bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl, 18px);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.app-notify__scroll .alerts-table-wrap {
  overflow-x: auto;
}

.app-notify__scroll .alerts-table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.app-notify__scroll .alerts-table th,
.app-notify__scroll .alerts-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.app-notify__scroll .alerts-table th {
  background: rgba(15, 18, 25, 0.04);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-notify__scroll .alerts-table tr:last-child td {
  border-bottom: none;
}

.app-notify__scroll .alerts-table tbody tr[data-inbox-href] {
  cursor: pointer;
  transition: background 0.12s ease;
}

.app-notify__scroll .alerts-table tbody tr[data-inbox-href]:hover td {
  background: rgba(250, 250, 249, 0.95);
}

.app-notify__scroll .alerts-table tr.alerts-row--unread td {
  background: rgba(254, 226, 226, 0.55);
  border-bottom-color: rgba(220, 38, 38, 0.14);
}

.app-notify__scroll .alerts-table tr.alerts-row--unread td:first-child {
  box-shadow: inset 3px 0 0 var(--brand-red-mid);
}

.app-notify__scroll .alerts-table tr.alerts-row--unread:hover td {
  background: rgba(254, 202, 202, 0.65);
}

.app-notify__scroll .alerts-preview {
  margin: 0;
  max-width: none;
  min-width: 10rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  word-break: break-word;
}

.app-notify__scroll .alerts-table .alerts-sev-pill {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
}

.app-notify__scroll .alerts-table .alerts-sev-pill.critical {
  background: #ffebee;
  color: #b71c1c;
}
.app-notify__scroll .alerts-table .alerts-sev-pill.high {
  background: #fff3e0;
  color: #e65100;
}
.app-notify__scroll .alerts-table .alerts-sev-pill.medium {
  background: #e3f2fd;
  color: #1565c0;
}
.app-notify__scroll .alerts-table .alerts-sev-pill.low {
  background: #e8f5e9;
  color: #2e7d32;
}

.app-notify__scroll .alerts-table .app-notify__st {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.app-notify__scroll .alerts-table .app-notify__st--fault-pending {
  background: #fff8e1;
  color: #f57f17;
  border-color: #ffe082;
}

.app-notify__scroll .alerts-table .app-notify__st--fault-approved {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #c8e6c9;
}

.app-notify__scroll .alerts-table .app-notify__st--fault-rejected {
  background: #fce4ec;
  color: #c2185b;
  border-color: #f8bbd9;
}

.app-notify__section {
  margin-bottom: 18px;
}

.app-notify__section:last-child {
  margin-bottom: 0;
}

.app-notify__section-title {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 0 2px;
}

.app-notify__section-title-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
  flex: 1;
}

.app-notify__section-eye {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  width: 32px;
  height: 32px;
}

.app-notify__section-name {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.app-notify__section-meta {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.app-notify__item {
  display: block;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.14s ease;
}

.app-notify__item:last-child {
  margin-bottom: 0;
}

.app-notify__item:hover {
  background: var(--surface);
  border-color: rgba(220, 38, 38, 0.18);
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.06),
    0 0 0 1px rgba(220, 38, 38, 0.06);
  transform: translateY(-1px);
}

.app-notify__item:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-notify__item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 6px;
}

.app-notify__item-time {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.app-notify__sev {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
}

.app-notify__sev.critical {
  background: #ffebee;
  color: #b71c1c;
}
.app-notify__sev.high {
  background: #fff3e0;
  color: #e65100;
}
.app-notify__sev.medium {
  background: #e3f2fd;
  color: #1565c0;
}
.app-notify__sev.low {
  background: #e8f5e9;
  color: #2e7d32;
}

.app-notify__st {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.app-notify__st--open {
  background: #ffebee;
  color: #b71c1c;
  border-color: #ffcdd2;
}

.app-notify__st--acknowledged {
  background: #fff3e0;
  color: #e65100;
  border-color: #ffe0b2;
}

.app-notify__st--fault-pending {
  background: #fff8e1;
  color: #f57f17;
  border-color: #ffe082;
}

.app-notify__st--fault-approved {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #c8e6c9;
}

.app-notify__st--fault-rejected {
  background: #fce4ec;
  color: #c2185b;
  border-color: #f8bbd9;
}

.app-notify__st--wo-open {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.app-notify__st--wo-pending {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.app-notify__item-title {
  font-size: 0.84375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.015em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.app-notify__empty {
  margin: 4px 0 0;
  padding: 22px 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.55;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.app-header__end .app-profile {
  margin-left: 0;
}

.app-header__product {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(0.68rem, 1.35vw, 0.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.app-header--compact .app-header__product {
  font-size: clamp(0.62rem, 2.2vw, 0.78rem);
  -webkit-line-clamp: 3;
}

.app-header__brand,
.pmms-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  width: var(--pmms-logo-mark-size);
  height: var(--pmms-logo-mark-size);
  padding: var(--pmms-logo-mark-padding);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Unified Bin Quraya logo — dashboard, scan, hub, field pages */
.pmms-logo,
.app-header__logo,
.scan-top__logo,
.hub-brand .pmms-logo,
.hub-brand img:not([class]),
.sh-brand .pmms-logo,
.sh-brand img:not([class]),
.pmms-logo-mark img {
  display: block;
  width: var(--pmms-logo-size);
  height: var(--pmms-logo-size);
  max-width: var(--pmms-logo-size);
  max-height: var(--pmms-logo-size);
  object-fit: contain;
  flex-shrink: 0;
}

/* body.app-page img { height: auto } must not flatten header logos */
body.app-page img.pmms-logo,
body.app-page img.app-header__logo,
body.app-page img.scan-top__logo,
body.app-page .pmms-logo-mark img,
body.app-page .pmms-logo-mark .pmms-logo,
body.app-page .pmms-logo-mark .scan-top__logo {
  width: var(--pmms-logo-size);
  height: var(--pmms-logo-size);
  max-width: var(--pmms-logo-size);
  max-height: var(--pmms-logo-size);
  object-fit: contain;
}

.scan-top--dark .pmms-logo-mark {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Profile — compact “account chip” (role in trigger + sign out + panel) */
.app-profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  margin-left: auto;
  padding: 5px 6px 5px 5px;
  max-width: min(100%, 420px);
  background: linear-gradient(165deg, #ffffff 0%, #fafaf9 55%, #f5f5f4 100%);
  border: 1px solid rgba(231, 229, 228, 0.95);
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-xs),
    0 1px 2px rgba(28, 25, 23, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.app-profile__identity {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  padding: 2px 10px 2px 8px;
  flex-shrink: 0;
}

.app-profile__role.role-pill {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.app-profile__role.role-pill.admin {
  color: #3f3f46;
  background: linear-gradient(180deg, #f4f4f5 0%, #e4e4e7 100%);
  border-color: #d4d4d8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.app-profile__role.role-pill.user {
  color: #047857;
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.app-profile__role.role-pill.supervisor {
  color: #b45309;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.app-profile__role.role-pill.technician {
  color: #1d4ed8;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #93c5fd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.app-profile__role.role-pill.driver {
  color: #c2410c;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fdba74;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.app-profile__signout {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-left: 2px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.app-profile__signout::before {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5a2 2 0 0 0-2 2v3h2V5h14v14H5v-3H3v3a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5a2 2 0 0 0-2 2v3h2V5h14v14H5v-3H3v3a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.app-profile__signout:hover {
  color: var(--brand-red-mid);
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.app-profile__signout:hover::before {
  opacity: 1;
}

.app-profile__signout:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

/* Profile: open name + role to see full account details */
.app-profile__trigger {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: calc(var(--radius-xl) - 5px);
  flex: 0 1 auto;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.app-profile__trigger:hover {
  background: rgba(28, 25, 23, 0.04);
}

.app-profile__trigger:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-profile__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 100;
  min-width: min(300px, calc(100vw - 32px));
  max-width: min(360px, calc(100vw - 24px));
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  filter: drop-shadow(0 12px 32px rgba(28, 25, 23, 0.12));
}

.app-profile__panel-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-md);
}

.app-profile__panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-profile__panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.25;
}

.app-profile__panel-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin: -6px -8px 0 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--ink-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.app-profile__panel-close:hover {
  background: var(--border);
  color: var(--ink);
}

.app-profile__panel-close:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.app-profile__dl {
  margin: 0 0 12px;
  padding: 0;
}

.app-profile__dl > div {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.app-profile__dl > div:last-of-type {
  border-bottom: none;
}

.app-profile__dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-profile__dl dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

.app-profile__panel-note {
  margin: 0 0 14px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.app-profile__panel-sub {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.app-profile__perms {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-profile__perm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.app-profile__perm:last-child {
  margin-bottom: 0;
}

.app-profile__perm span:first-child {
  font-weight: 500;
  color: var(--ink);
}

.app-profile__perm span:last-child {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.app-profile__perm--yes span:last-child {
  color: #047857;
}

.app-profile__perm--no span:last-child {
  color: var(--muted-2);
}

@media (max-width: 560px) {
  .app-profile {
    width: 100%;
    max-width: none;
    justify-content: space-between;
    margin-left: 0;
    margin-top: 6px;
    padding: 6px 8px;
  }

  .app-profile__identity {
    flex: 1;
    min-width: 0;
    padding-inline: 8px 10px;
    justify-content: flex-start;
  }

  .app-profile__signout {
    margin-left: 0;
    flex-shrink: 0;
  }

  .app-profile__panel {
    left: 0;
    right: 0;
    min-width: 0;
    max-width: none;
  }
}

/* ——— Side navigation (left column on app pages) ——— */
.bottom-nav {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 3px;
  width: var(--app-nav-width);
  max-width: min(var(--app-nav-width), 42vw);
  min-height: 0;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    10px
    max(12px, env(safe-area-inset-bottom, 0px))
    max(10px, env(safe-area-inset-left, 0px));
  border-radius: 0;
  font-family: var(--font-body);
  isolation: isolate;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(248, 250, 252, 0.94) 100%
  );
  border-right: 1px solid rgba(226, 232, 240, 0.95);
  backdrop-filter: saturate(185%) blur(14px);
  -webkit-backdrop-filter: saturate(185%) blur(14px);
  box-shadow:
    1px 0 0 rgba(255, 255, 255, 0.9) inset,
    4px 0 24px rgba(15, 23, 42, 0.06);
}

.bottom-nav a {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
  transition:
    background 0.22s var(--ease),
    box-shadow 0.22s var(--ease);
}

.bottom-nav a .bottom-nav__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  color: #64748b;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 3px 8px rgba(15, 23, 42, 0.07);
  transition:
    background 0.22s var(--ease),
    color 0.22s var(--ease),
    border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease),
    transform 0.22s var(--ease),
    opacity 0.22s var(--ease);
}

.bottom-nav a .bottom-nav__icon {
  position: relative;
}

.bottom-nav a .bottom-nav__icon svg {
  display: block;
  flex-shrink: 0;
  width: 21px;
  height: 21px;
}

.bottom-nav__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: linear-gradient(165deg, #ef4444 0%, var(--brand-red-deep) 100%);
  border: 2px solid #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 2px 6px rgba(185, 28, 28, 0.4);
  pointer-events: none;
}

.bottom-nav__badge:empty,
.bottom-nav__badge[hidden] {
  display: none;
}

.bottom-nav a .bottom-nav__label {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
  line-height: 1.25;
  color: #64748b;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.22s var(--ease);
}

.bottom-nav a:hover {
  background: rgba(15, 23, 42, 0.04);
}

.bottom-nav a:hover .bottom-nav__icon {
  color: #334155;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-color: #cbd5e1;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 4px 10px rgba(15, 23, 42, 0.08);
  transform: scale(1.03);
}

.bottom-nav a:hover .bottom-nav__label {
  color: #334155;
}

.bottom-nav a.active {
  background: linear-gradient(
    180deg,
    rgba(200, 16, 46, 0.12) 0%,
    rgba(200, 16, 46, 0.04) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(200, 16, 46, 0.12);
}

.bottom-nav a.active .bottom-nav__icon {
  background: linear-gradient(150deg, var(--brand-red-mid) 0%, var(--brand-red-deep) 100%);
  border-color: rgba(127, 29, 29, 0.55);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 6px 16px rgba(200, 16, 46, 0.32),
    0 0 0 3px rgba(200, 16, 46, 0.12);
  transform: none;
}

.bottom-nav a.active .bottom-nav__label {
  color: var(--brand-red-deep);
  font-weight: 800;
}

.bottom-nav a:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.bottom-nav a:focus-visible .bottom-nav__icon {
  outline: none;
}

.shell h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.45rem, 2.4vw, 1.75rem);
  letter-spacing: -0.04em;
  color: var(--ink);
  margin: 0;
}

/* ——— Login (light / warm) ——— */
body.login-page {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--text);
  background-color: #f0eeeb;
  background-image:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(254, 242, 242, 0.7), transparent 55%),
    radial-gradient(ellipse 90% 70% at 100% 0%, rgba(250, 250, 249, 0.95), transparent 50%),
    radial-gradient(ellipse 80% 55% at 50% 100%, rgba(255, 255, 255, 0.85), transparent 60%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.login-app-header {
  position: relative;
  z-index: 2;
  padding: 12px 20px;
  text-align: center;
  font-size: clamp(0.7rem, 1.5vw, 0.8rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--ink-muted);
  border-bottom: 1px solid rgba(231, 229, 228, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

.login-app-header__title {
  display: inline-block;
  max-width: min(52ch, 100%);
}

.login-page__mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Ccircle cx='28' cy='28' r='1' fill='%2344403c' fill-opacity='0.06'/%3E%3C/svg%3E");
  background-size: 56px 56px;
}

.login-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 32px) 18px clamp(24px, 4vw, 40px);
  box-sizing: border-box;
}

.login-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 1024px;
  background: var(--surface);
  border: 1px solid rgba(214, 211, 209, 0.85);
  border-radius: 24px;
  box-shadow:
    0 1px 2px rgba(28, 25, 23, 0.04),
    0 24px 48px -12px rgba(28, 25, 23, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  overflow: hidden;
}

@media (max-width: 800px) {
  .login-split {
    grid-template-columns: 1fr;
    max-width: 440px;
    border-radius: 18px;
  }
}

.login-hero {
  position: relative;
  padding: 0;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  background: linear-gradient(160deg, #fafaf9 0%, #ffffff 42%, #f7f6f4 100%);
  overflow: hidden;
}

.login-hero__accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #78716c 0%, var(--brand-red-mid) 50%, #78716c 100%);
  opacity: 0.85;
  z-index: 2;
}

.login-hero__glow {
  position: absolute;
  width: 100%;
  height: 85%;
  top: -20%;
  right: -20%;
  background: radial-gradient(ellipse 70% 55% at 85% 20%, rgba(254, 226, 226, 0.35), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.login-hero__inner {
  position: relative;
  z-index: 1;
  padding: 40px 44px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 280px;
}

@media (max-width: 800px) {
  .login-hero__inner {
    text-align: center;
    align-items: center;
    padding: 32px 28px 28px;
    min-height: 0;
  }
}

.login-hero__logo-wrap {
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(231, 229, 228, 0.95);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.04);
}

/* Login / scan hero: wide logo mark — overrides square .pmms-logo-mark (88×88) */
.login-hero__logo-wrap.pmms-logo-mark--hero {
  width: auto;
  height: auto;
  min-width: 0;
  max-width: min(100%, 320px);
  padding: 14px 20px;
}

.login-hero__logo-wrap.pmms-logo-mark--hero .login-hero__logo,
.login-hero__logo-wrap.pmms-logo-mark--hero img {
  display: block;
  width: min(100%, 280px);
  height: auto;
  max-width: 280px;
  max-height: none;
  object-fit: contain;
}

.login-hero__logo {
  display: block;
  width: min(100%, 280px);
  height: auto;
}

.login-hero__tagline {
  margin: 18px 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: -0.01em;
}

@media (max-width: 800px) {
  .login-hero__tagline {
    margin-top: 14px;
  }
}

.login-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 44px 52px;
  background: linear-gradient(180deg, #fcfcfb 0%, #ffffff 35%, #fafaf9 100%);
  border-left: 1px solid rgba(231, 229, 228, 0.9);
}

@media (max-width: 800px) {
  .login-panel {
    padding: 8px 28px 44px;
    border-left: none;
    border-top: 1px solid rgba(231, 229, 228, 0.9);
  }
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid rgba(231, 229, 228, 0.85);
  border-radius: 16px;
  padding: 28px 26px 26px;
  box-shadow: 0 4px 24px rgba(28, 25, 23, 0.05);
}

@media (max-width: 800px) {
  .login-card {
    border-radius: 14px;
    padding: 24px 22px 22px;
  }
}

.login-card::before {
  display: none;
}

.login-card h1 {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.6vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.login-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-muted);
}

.login-card input {
  width: 100%;
  margin-bottom: 14px;
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--ink);
  background: #fafaf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(28, 25, 23, 0.03);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.login-card input::placeholder {
  color: var(--muted-2);
}

.login-card input:hover {
  border-color: var(--border-strong);
}

.login-card input:focus {
  background: #fff;
  border-color: rgba(220, 38, 38, 0.4);
  box-shadow: 0 0 0 3px var(--brand-red-soft), inset 0 1px 2px rgba(28, 25, 23, 0.02);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #dc2626 0%, var(--brand-red-deep) 100%);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.25);
  transition: filter 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}

.login-card button[type="submit"]:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 4px 16px rgba(185, 28, 28, 0.3);
}

.login-card button[type="submit"]:active:not(:disabled) {
  transform: translateY(1px);
}

.login-card button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.login-card .msg {
  margin-top: 14px;
  min-height: 1.25em;
  font-size: 0.875rem;
  color: var(--muted);
}

.login-card .msg.error {
  color: var(--red);
  font-weight: 600;
}

.login-card .msg.ok {
  color: #0d7d4d;
  font-weight: 600;
}

.login-card__lead {
  margin: -10px 0 18px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.login-card select {
  width: 100%;
  margin-bottom: 14px;
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--ink);
  background: #fafaf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(28, 25, 23, 0.03);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.login-card select:hover {
  border-color: var(--border-strong);
}

.login-card select:focus {
  background: #fff;
  border-color: rgba(220, 38, 38, 0.4);
  box-shadow: 0 0 0 3px var(--brand-red-soft), inset 0 1px 2px rgba(28, 25, 23, 0.02);
}

.login-card button.login-card__submit {
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #dc2626 0%, var(--brand-red-deep) 100%);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.25);
  transition: filter 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}

.login-card button.login-card__submit:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 4px 16px rgba(185, 28, 28, 0.3);
}

.login-card button.login-card__submit:active:not(:disabled) {
  transform: translateY(1px);
}

.login-card button.login-card__submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

body.login-page.page-scan-entry .login-split {
  width: 100%;
}

body.login-page.page-scan-entry .login-hero__inner {
  min-height: 200px;
}

@media (max-width: 800px) {
  body.login-page.page-scan-entry .login-hero__inner {
    min-height: 160px;
  }
}

body.login-page.page-scan-entry .login-card form {
  margin: 0;
}

body.login-page.page-scan-entry #nameGroup:not([hidden]),
body.login-page.page-scan-entry #profileGroup:not([hidden]) {
  margin-top: 4px;
}

.login-card__reset-offer {
  margin: 4px 0 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.login-card__reset-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  min-height: 44px;
  border: 1px solid #dc2626;
  border-radius: 12px;
  background: #fff;
  color: #b91c1c;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.login-card__reset-btn:hover {
  background: #fef2f2;
}

@media (prefers-reduced-motion: reduce) {
  .login-card input,
  .login-card select,
  .login-card button[type="submit"],
  .login-card button.login-card__submit {
    transition: none;
  }

  .login-card button[type="submit"]:active:not(:disabled),
  .login-card button.login-card__submit:active:not(:disabled) {
    transform: none;
  }
}

body.login-page.page-scan-entry img,
body.login-page.page-scan-entry video,
body.login-page.page-scan-entry svg {
  max-width: 100%;
  height: auto;
}

/* ——— Inner app pages ——— */
body.app-page {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: calc(var(--app-nav-width) + env(safe-area-inset-left, 0px));
  -webkit-font-smoothing: antialiased;
}

body.app-page > .shell {
  min-width: 0;
}

/* ——— Global responsive (phones, tablets, notched desktops) ——— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body.app-page,
body.login-page {
  overflow-x: hidden;
}

/* Field scan pages use app-page chrome but not the dashboard side nav */
body.app-page.page-fault-scan {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

html[dir="rtl"] body.app-page.page-fault-scan {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

body.app-page .app-header {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
}

body.app-page .app-header--compact {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}

body.app-page img,
body.app-page video,
body.app-page svg,
body.login-page img,
body.login-page video,
body.login-page svg {
  max-width: 100%;
  height: auto;
}

body.app-page .dash-chart-wrap canvas {
  max-width: 100%;
}

body.login-page .login-app-header {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

body.login-page .login-shell {
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}

@media (max-width: 900px) {
  body.app-page button:not(.app-profile__trigger):not(.app-profile__panel-close):not(.fr-chip),
  body.app-page .btn-primary,
  body.app-page .btn-secondary,
  body.app-page input[type="submit"] {
    min-height: 44px;
  }

  body.app-page .bottom-nav a {
    min-height: 44px;
  }

  body.app-page input[type="text"],
  body.app-page input[type="search"],
  body.app-page input[type="password"],
  body.app-page input[type="number"],
  body.app-page input[type="email"],
  body.app-page input[type="date"],
  body.app-page input[type="tel"],
  body.app-page input[type="url"],
  body.app-page select,
  body.app-page textarea {
    font-size: 16px;
  }
}

/* ——— Language switcher (English / Arabic / Urdu) ——— */
.pmms-lang {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.pmms-lang__inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 5px 4px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 4px 14px rgba(15, 23, 42, 0.06);
}

.pmms-lang__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--brand-red-mid);
  background: rgba(254, 242, 242, 0.85);
  flex-shrink: 0;
}

.pmms-lang__icon svg {
  width: 15px;
  height: 15px;
}

.pmms-lang__tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
}

.pmms-lang__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 2.35rem;
  padding: 0 10px;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  cursor: pointer;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.pmms-lang__tab-short {
  display: inline;
}

.pmms-lang__tab-full {
  display: none;
}

.pmms-lang__tab:hover:not(.pmms-lang__tab--active) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.pmms-lang__tab:focus-visible {
  outline: 2px solid var(--brand-red-mid);
  outline-offset: 2px;
}

.pmms-lang__tab--active {
  color: #fff;
  background: linear-gradient(165deg, var(--brand-red-mid) 0%, var(--brand-red-deep) 100%);
  box-shadow:
    0 2px 8px rgba(185, 28, 28, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.pmms-lang__tab--active:active {
  transform: scale(0.97);
}

.pmms-lang--fixed {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 120;
}

.pmms-lang--fixed .pmms-lang__inner {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 8px 24px rgba(15, 23, 42, 0.12);
}

/* Admin zone: language switcher is scan-only (see pmms-i18n.js isScanAppPath). */
.pmms-admin-ui .pmms-lang,
.pmms-admin-ui #pmmsLangSwitcher {
  display: none !important;
}

.login-card .pmms-lang {
  margin-bottom: 14px;
  justify-content: flex-end;
  width: 100%;
}

.hub-top .pmms-lang {
  margin-left: auto;
}

@media (min-width: 520px) {
  .pmms-lang__tab {
    min-width: 0;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  .pmms-lang__tab-short {
    display: none;
  }

  .pmms-lang__tab-full {
    display: inline;
  }

  .pmms-lang__tab[data-lang="ar"] .pmms-lang__tab-full,
  .pmms-lang__tab[data-lang="ur"] .pmms-lang__tab-full {
    font-size: 0.82rem;
  }
}

@media (max-width: 400px) {
  .pmms-lang__icon {
    display: none;
  }

  .pmms-lang__inner {
    padding: 3px;
  }
}

html[dir="rtl"] .app-header__start {
  flex-direction: row-reverse;
}

html[dir="rtl"] .app-header__end {
  flex-direction: row-reverse;
}

html[dir="rtl"] .pmms-lang__inner {
  flex-direction: row-reverse;
}

html[dir="rtl"] .hub-top .pmms-lang {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] body.app-page {
  padding-left: 0;
  padding-right: calc(var(--app-nav-width) + env(safe-area-inset-right, 0px));
}

html[dir="rtl"] .bottom-nav {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow:
    -1px 0 0 rgba(255, 255, 255, 0.9) inset,
    -4px 0 24px rgba(15, 23, 42, 0.06);
}

html[dir="rtl"] .bottom-nav a {
  flex-direction: row-reverse;
}

html[dir="rtl"] .bottom-nav a .bottom-nav__label {
  text-align: end;
}

@media (max-width: 720px) {
  :root {
    --app-nav-width: 76px;
  }

  body.app-page {
    padding-left: calc(var(--app-nav-width) + env(safe-area-inset-left, 0px));
  }

  html[dir="rtl"] body.app-page {
    padding-left: 0;
    padding-right: calc(var(--app-nav-width) + env(safe-area-inset-right, 0px));
  }

  .bottom-nav {
    padding-left: max(6px, env(safe-area-inset-left, 0px));
    padding-right: 6px;
  }

  .bottom-nav a {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
  }

  .bottom-nav a .bottom-nav__label {
    font-size: 0.52rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.1;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  html[dir="rtl"] .bottom-nav a {
    flex-direction: column;
  }
}

html[dir="rtl"] .app-profile__dl > div {
  direction: rtl;
}

html.pmms-rtl .fault-scan-table th,
html.pmms-rtl .fault-scan-table td,
html.pmms-rtl .alerts-table th,
html.pmms-rtl .alerts-table td {
  text-align: right;
}

/* ——— Approvals sidebar popover ——— */
.approvals-popover {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.approvals-popover.is-open {
  pointer-events: auto;
}

.approvals-popover__backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: transparent;
  pointer-events: none;
}

.approvals-popover.is-open .approvals-popover__backdrop {
  pointer-events: auto;
}

body.pmms-approvals-open .shell {
  pointer-events: none;
  user-select: none;
}

body.pmms-approvals-open .shell * {
  pointer-events: none !important;
}

body.pmms-approvals-open .bottom-nav,
body.pmms-approvals-open .bottom-nav *,
body.pmms-approvals-open .approvals-popover,
body.pmms-approvals-open .approvals-popover * {
  pointer-events: auto !important;
}

.approvals-popover__panel {
  position: fixed;
  z-index: 121;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  max-width: min(480px, calc(100vw - var(--app-nav-width, 228px) - 24px));
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: #fff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 20px 48px -12px rgba(15, 23, 42, 0.22);
  overflow: visible;
  pointer-events: auto;
}

.approvals-popover__panel::before {
  content: "";
  position: absolute;
  left: -7px;
  top: var(--caret-top, 28px);
  transform: translateY(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: #fff;
  border-left: 1px solid rgba(226, 232, 240, 0.95);
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: -2px 2px 4px rgba(15, 23, 42, 0.04);
}

.approvals-popover__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 14px 14px 0 0;
  background: #fff;
}

.approvals-popover__head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.35;
}

.approvals-popover__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.approvals-popover__close:hover {
  background: rgba(15, 23, 42, 0.1);
}

.approvals-popover__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  border-radius: 0 0 14px 14px;
  background: #fff;
}

.approvals-popover__stack {
  display: flex;
  flex-direction: column;
}

.approvals-popover-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.approvals-popover-row:last-child {
  border-bottom: none;
}

.approvals-popover-row__main {
  flex: 1;
  min-width: 0;
}

.approvals-popover-row__title {
  margin: 0 0 4px;
  font-size: 0.84rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.approvals-popover-row__sub {
  margin: 0 0 6px;
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.35;
}

.approvals-popover-row__link {
  padding: 0;
  border: none;
  background: none;
  font-size: 0.76rem;
  font-weight: 700;
  color: #2563eb;
  cursor: pointer;
  font-family: var(--font-body);
}

.approvals-popover-row__link:hover {
  text-decoration: underline;
}

.approvals-popover-row__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  width: 96px;
}

.approvals-popover-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
}

.approvals-popover-btn:active {
  transform: scale(0.98);
}

.approvals-popover-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.approvals-popover-btn--approve {
  background: linear-gradient(165deg, #22c55e 0%, #15803d 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.22);
}

.approvals-popover-btn--reject {
  background: #fff;
  color: #b91c1c;
  border-color: #fecaca;
}

.approvals-popover-btn--reject:hover {
  background: #fef2f2;
}

.approvals-popover__back {
  display: block;
  margin: 12px 16px 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2563eb;
  cursor: pointer;
  font-family: var(--font-body);
}

.approvals-popover-detail {
  margin: 10px 16px 16px;
  display: grid;
  gap: 10px;
}

.approvals-popover-detail__row {
  display: grid;
  gap: 2px;
}

.approvals-popover-detail__row dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.approvals-popover-detail__row dd {
  margin: 0;
  font-size: 0.84rem;
  color: #0f172a;
  line-height: 1.4;
}

.approvals-popover__status,
.approvals-popover__empty,
.approvals-popover__err {
  margin: 0;
  padding: 20px 16px;
  text-align: center;
  font-size: 0.84rem;
  color: #64748b;
}

.approvals-popover__err {
  color: #b91c1c;
}

.approvals-popover-temp-pw {
  padding: 4px 2px 8px;
}

.approvals-popover-temp-pw__lede {
  margin: 0 0 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #475569;
}

.approvals-popover-temp-pw__code-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  padding: 14px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.approvals-popover-temp-pw__code {
  flex: 1 1 160px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f8fafc;
  word-break: break-all;
  user-select: all;
}

.approvals-popover-temp-pw__note {
  margin: 0 0 14px;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

.approvals-popover-temp-pw__note--ok {
  color: #15803d;
}

.approvals-popover-temp-pw__done {
  width: 100%;
  justify-content: center;
}

.bottom-nav a.nav-approvals-trigger--open {
  background: rgba(254, 242, 242, 0.85);
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.18);
  color: var(--brand-red-deep, #b91c1c);
}

html[dir="rtl"] .approvals-popover__panel {
  left: auto;
  right: calc(var(--app-nav-width, 228px) + 12px);
}

html[dir="rtl"] .approvals-popover__panel::before {
  left: auto;
  right: -7px;
  border-left: none;
  border-bottom: none;
  border-right: 1px solid rgba(226, 232, 240, 0.95);
  border-top: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 2px -2px 4px rgba(15, 23, 42, 0.04);
}

