/* ============================================================
   BoraVoltar — layout.css
   App shell, Governance shell, public + auth layouts
   ============================================================ */

.app { min-height: 100vh; background: var(--bg); background-image: var(--grad-app); }

/* ---------------- Brand ---------------- */
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 46px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--primary), var(--primary-strong));
  box-shadow: var(--shadow-glow);
}
.brand-mark svg { width: 18px; height: 18px; color: var(--primary-ink); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.03em; }
.brand-name b { font-weight: 700; }
.brand-saas {
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 5px; margin-left: 2px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-line);
}

/* ---------------- App header (professional) ---------------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  height: 60px; padding: 0 22px;
  background: color-mix(in oklch, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-nav { display: flex; align-items: center; gap: 2px; }
.app-nav a {
  position: relative; height: 60px; display: inline-flex; align-items: center;
  padding: 0 14px; font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  transition: color .15s ease;
}
.app-nav a:hover { color: var(--text-soft); }
.app-nav a.active { color: var(--text); font-weight: 600; }
.app-nav a.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2.5px;
  background: var(--primary); border-radius: 3px 3px 0 0; box-shadow: 0 0 10px var(--primary);
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }

.bell { position: relative; }
.bell .dot {
  position: absolute; top: 4px; right: 4px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 99px; background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}

.user-chip {
  min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-2); transition: border-color .15s ease, background .15s ease;
}
.user-chip:hover { border-color: var(--border-strong); }
.user-chip .u-name { font-size: 12.5px; font-weight: 600; line-height: 1.15; }
.user-chip .u-sub { font-size: 11px; color: var(--text-muted); line-height: 1.15; }
.user-chip svg { width: 15px; height: 15px; color: var(--text-muted); }

.env-select {
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12.5px; font-weight: 500; color: var(--text-soft);
}
.env-select .label { color: var(--text-muted); }
.env-select select { min-height: 46px; background: none; border: none; color: var(--text); font-weight: 600; cursor: pointer; appearance: none; padding-right: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a99ad' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right center; }
.clock { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.clock svg { width: 15px; height: 15px; color: var(--text-muted); }

/* ---------------- App content area ---------------- */
.app-main { max-width: 1500px; margin: 0 auto; padding: 26px clamp(18px, 2.4vw, 34px) 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head .sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.page-head-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------- Floating page actions ---------------- */
.page-fab-root {
  position: fixed;
  right: max(16px, calc((100vw - 430px) / 2 + 16px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 86;
  display: none;
  align-items: flex-end;
  pointer-events: none;
}
.page-fab-root[hidden] { display: none !important; }
body.modal-open .page-fab-root { display: none !important; }
.page-fab-toggle {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  box-shadow: 0 14px 34px color-mix(in oklch, var(--primary) 34%, transparent);
  pointer-events: auto;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.page-fab-toggle:active { transform: translateY(1px) scale(.98); }
.page-fab-toggle svg { width: 26px; height: 26px; }
.page-fab-root.open .page-fab-toggle {
  background: var(--text);
  box-shadow: var(--shadow-lg);
}
.page-fab-root.open .page-fab-toggle svg { transform: rotate(45deg); }
.page-fab-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(312px, calc(100vw - 28px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in oklch, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}
.page-fab-title {
  padding: 4px 6px 9px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.page-fab-menu {
  display: grid;
  gap: 8px;
}
.page-fab-menu > *,
.page-fab-menu > * > .btn,
.page-fab-menu .btn,
.page-fab-menu select {
  width: 100%;
}
.page-fab-menu .btn,
.page-fab-menu button,
.page-fab-menu a {
  min-height: 48px;
  justify-content: flex-start;
}
.page-fab-menu select {
  min-height: 48px;
  border-radius: var(--radius-sm);
}

/* ---------------- Governance shell ---------------- */
.gov { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: var(--bg); }
.gov-sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--bg-soft); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.gov-sidebar .side-brand { padding: 17px 18px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; }
.gov-nav { padding: 14px 12px; flex: 1; }
.gov-nav .nav-group { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); padding: 14px 10px 7px; }
.gov-nav .nav-group:first-child { padding-top: 4px; }
.gov-nav a {
  min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 8.5px 10px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--text-muted); transition: all .14s ease; margin-bottom: 1px;
}
.gov-nav a svg { width: 16px; height: 16px; flex: none; }
.gov-nav a:hover { background: var(--surface-2); color: var(--text-soft); }
.gov-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary-line); }
.gov-nav a .nav-count { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: var(--danger-soft); color: var(--danger); }

.gov-side-foot { padding: 14px 18px; border-top: 1px solid var(--border-soft); }
.svc-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-soft); }
.svc-status .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); position: relative; }
.svc-status .pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--success); animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.7); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
.svc-status .ver { font-size: 11px; color: var(--text-faint); margin-top: 8px; }

.gov-body { display: flex; flex-direction: column; min-width: 0; }
.gov-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 24px;
  background: color-mix(in oklch, var(--surface) 86%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.gov-header .gov-title { font-size: 14px; font-weight: 600; }
.gov-main { padding: 24px clamp(18px, 2.4vw, 34px); max-width: 1320px; width: 100%; }

/* ---------------- Grids ---------------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 1.5fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 1.6fr; }

/* ---------------- Mobile nav ---------------- */
.menu-toggle { display: none; }
.mobile-bar { display: none; }

/* ---------------- Public layout ---------------- */
.public { background: var(--bg); background-image: var(--grad-app); min-height: 100vh; }
.public-header {
  position: sticky; top: 0; z-index: 50; height: 64px; padding: 0 28px;
  display: flex; align-items: center; gap: 28px;
  background: color-mix(in oklch, var(--bg) 80%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.public-header .pub-nav { display: flex; gap: 4px; margin-left: 10px; }
.public-header .pub-nav a { min-width: 46px; min-height: 46px; display: inline-flex; align-items: center; padding: 8px 13px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; color: var(--text-muted); transition: all .14s; }
.public-header .pub-nav a:hover { color: var(--text); background: var(--surface-2); }
.public-wrap { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
.public-footer { border-top: 1px solid var(--border-soft); margin-top: 80px; padding: 40px 28px; }
.public-footer a { min-height: 46px; display: inline-flex; align-items: center; }
.auth-panel a,
.public-footer a {
  min-width: 46px;
}

.notif-panel {
  position: absolute;
  right: 52px;
  top: calc(100% + 8px);
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 84px));
  overflow: hidden;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 190;
}
.notif-panel[hidden] { display: none; }
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.notif-head strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.2;
}
.notif-head span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.notif-list {
  display: flex;
  flex-direction: column;
  max-height: 390px;
  overflow-y: auto;
  padding: 6px;
}
.notif-item {
  display: grid;
  grid-template-columns: 34px 1fr 16px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.notif-item:hover { background: var(--surface-2); }
.notif-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--st-soft, var(--surface-2));
  border: 1px solid var(--st-line, var(--border));
  color: var(--st, var(--text-muted));
}
.notif-ico svg { width: 17px; height: 17px; }
.notif-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-copy strong {
  font-size: 12.8px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-copy small {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-item > svg {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
}
.notif-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}
.notif-foot {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border-soft);
}
.notif-foot a {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.notif-foot a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ---------------- Auth layout ---------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
  position: relative; overflow: hidden; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 500px at 20% 10%, rgba(34,199,247,.18), transparent 60%),
    radial-gradient(600px 500px at 90% 90%, rgba(14,165,233,.14), transparent 55%),
    var(--bg-soft);
  border-right: 1px solid var(--border);
}
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 23px; }
.auth-card .sub { font-size: 13.5px; color: var(--text-muted); margin-top: 6px; margin-bottom: 26px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 22px; }
.auth-foot a,
.auth-form .field a,
.auth-form .checkbox a {
  min-width: 46px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
}
.auth-foot a { color: var(--primary); font-weight: 600; justify-content: center; }

/* feature bullets on auth aside */
.auth-points { display: flex; flex-direction: column; gap: 16px; margin-top: 28px; }
.auth-point { display: flex; gap: 13px; align-items: flex-start; }
.auth-point .ap-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-soft); border: 1px solid var(--primary-line); color: var(--primary); display: grid; place-items: center; flex: none; }
.auth-point .ap-ico svg { width: 17px; height: 17px; }
.auth-point h4 { font-size: 13.5px; }
.auth-point p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------------- Helpers ---------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex-1 { flex: 1; }
.stack-16 > * + * { margin-top: 16px; }
.stack-20 > * + * { margin-top: 20px; }

/* Prevent nested panels, flex rows and grid children from forcing horizontal scroll. */
.app,
.gov,
.app-main,
.gov-main,
.gov-body,
.app-header,
.gov-header,
.header-right,
.page-head,
.page-head > *,
.page-head-actions,
.page-head-actions > *,
.panel,
.card,
.metric,
.table-wrap,
.row,
.row-between,
.grid > *,
.flex-1 {
  min-width: 0;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (min-width: 1600px) {
  .app-main { max-width: 1680px; }
  .gov-main { max-width: 1480px; }
}
@media (max-width: 1024px) {
  .gov { grid-template-columns: 1fr; }
  .gov-sidebar {
    position: fixed; left: 0; top: 0; z-index: 90; width: 264px;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .gov-sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: grid; }
  .scrim { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  /* App shell: collapse the 8-item nav to the hamburger at the SAME width the hamburger appears,
     otherwise both show together between 861–1024px and overflow the header. */
  .app-nav { display: none; }
  .user-chip .u-meta { display: none; }
}
@media (max-width: 860px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .app-header { gap: 14px; padding: 0 16px; }
  .public-wrap { padding: 0 22px; }
}
@media (max-width: 760px) {
  body.has-page-fab .app-main,
  body.has-page-fab .gov-main { padding-bottom: 112px; }
  body[data-shell="app"] .page-head-actions[data-floating-active="true"],
  body[data-shell="gov"] .page-head-actions[data-floating-active="true"],
  body[data-shell="app"] [data-floating-actions][data-floating-active="true"],
  body[data-shell="gov"] [data-floating-actions][data-floating-active="true"] {
    display: none;
  }
  body[data-shell="app"] .page-fab-root,
  body[data-shell="gov"] .page-fab-root {
    display: flex;
  }
  .page-fab-root {
    left: max(14px, calc((100vw - 430px) / 2 + 14px));
    right: max(14px, calc((100vw - 430px) / 2 + 14px));
    bottom: calc(82px + env(safe-area-inset-bottom));
    justify-content: center;
    align-items: flex-end;
    z-index: 76;
  }
  .page-fab-toggle {
    display: none;
  }
  .page-fab-panel {
    position: static;
    width: min(320px, calc(100vw - 28px));
    max-height: min(52dvh, 420px);
    overflow: auto;
  }
}
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }   /* 2×2 metric cards read better than a single tall stack */
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-main { padding: 16px 14px 84px; }
  .gov-main { padding: 16px 14px 84px; }
  body.has-page-fab .app-main,
  body.has-page-fab .gov-main { padding-bottom: 112px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 21px; }
  .page-head .sub { font-size: 13px; }
  .page-head-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-head-actions > * { flex: 1 1 140px; }     /* buttons, dropdown wrappers, segmented all stretch */
  .page-head-actions .btn { width: 100%; }
  .page-head-actions .segmented { display: flex; }
  .page-head-actions .segmented button { flex: 1; }
  body[data-shell="app"] .page-head-actions[data-floating-active="true"],
  body[data-shell="gov"] .page-head-actions[data-floating-active="true"],
  body[data-shell="app"] [data-floating-actions][data-floating-active="true"],
  body[data-shell="gov"] [data-floating-actions][data-floating-active="true"] {
    display: none;
  }
  body[data-shell="app"] .page-fab-root,
  body[data-shell="gov"] .page-fab-root {
    display: flex;
  }
  .app-header { height: 56px; gap: 10px; padding: 0 12px; }
  .header-right { gap: 4px; }
  .notif-panel {
    right: 0;
    top: calc(100% + 6px);
    width: calc(100vw - 24px);
  }
  .gov-header { height: 56px; padding: 0 14px; gap: 10px; }
  .gov-header .env-select, .gov-header .clock { display: none; }   /* keep admin header uncluttered on phones */
  .brand-name { font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .user-chip {
    min-width: 46px;
    width: 46px;
    min-height: 46px;
    justify-content: center;
    padding: 4px;
    background: transparent;
  }
  .user-chip > svg { display: none; }
  .mobile-bar {
    display: grid; position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    grid-template-columns: 1fr 1fr 74px 1fr 1fr;
    align-items: end;
    background: color-mix(in oklch, var(--surface) 94%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    justify-items: center;
  }
  .mobile-bar a,
  .mobile-bar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    padding: 7px 4px;
    border-radius: var(--radius-sm);
    min-width: 54px;
    min-height: 46px;
  }
  .mobile-bar a {
    font-size: 10px;
  }
  .mobile-bar a.active { color: var(--primary); }
  .mobile-bar a svg { width: 21px; height: 21px; }
  .mobile-bar .mobile-action-fab {
    width: 62px;
    height: 62px;
    min-width: 62px;
    min-height: 62px;
    aspect-ratio: 1 / 1;
    margin-top: -26px;
    border: 0;
    border-radius: 999px;
    color: white;
    background: var(--primary);
    box-shadow: 0 12px 30px color-mix(in oklch, var(--primary) 34%, transparent);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, opacity .16s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-bar .mobile-action-fab svg {
    width: 30px;
    height: 30px;
    color: currentColor;
    stroke: currentColor;
  }
  .mobile-bar .mobile-action-fab:active {
    transform: translateY(1px) scale(.98);
    box-shadow: 0 8px 22px color-mix(in oklch, var(--primary) 28%, transparent);
    outline: none;
  }
  .mobile-bar .mobile-action-fab:focus {
    outline: none;
  }
  .mobile-bar .mobile-action-fab:focus-visible {
    outline: none;
    box-shadow:
      0 0 0 4px color-mix(in oklch, var(--bg) 86%, transparent),
      0 0 0 7px color-mix(in oklch, var(--primary) 42%, transparent),
      0 12px 30px color-mix(in oklch, var(--primary) 34%, transparent);
  }
  .mobile-bar .mobile-action-fab.is-disabled {
    opacity: .45;
    box-shadow: none;
  }
  .public-header { padding: 0 16px; gap: 12px; }
  .public-header .pub-nav { display: none; }
  .public-wrap { padding: 0 16px; }
  .public-header .header-right { min-width: 0; }
  .public-header .header-right .btn { padding-inline: 12px; }
  /* roomier tap targets on phones */
  .ico-btn { width: 46px; height: 46px; }
  .ico-btn.btn-sm { width: 46px; height: 46px; }
  .btn-sm { min-height: 46px; }
  /* modals hug the screen */
  .modal-overlay { padding: 14px; align-items: flex-end; }
  .modal { max-width: 100%; }
  .modal-foot {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .modal-foot .btn {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding-inline: 12px;
  }
}
@media (max-width: 400px) {
  .grid-4 { grid-template-columns: 1fr; }
  .brand-saas { display: none; }
  .public-header .header-right .btn-ghost { display: inline-flex; }
  .public-header .header-right .btn-primary {
    display: none;
  }
}

@media (display-mode: standalone) {
  html {
    background: var(--bg-soft);
  }
  body {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100dvh;
    background: var(--bg);
  }
  .app,
  .public,
  .auth,
  .gov {
    min-height: 100dvh;
  }
  .grid-3,
  .grid-2,
  .grid-2-1,
  .grid-1-2 {
    grid-template-columns: 1fr !important;
  }
  .grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }
  .app-header,
  .gov-header {
    height: 56px;
    gap: 10px;
    padding: 0 12px;
  }
  .app-nav {
    display: none;
  }
  .menu-toggle {
    display: grid;
  }
  .user-chip .u-meta,
  .gov-header .env-select,
  .gov-header .clock {
    display: none;
  }
  .header-right {
    gap: 4px;
  }
  .app-main,
  .gov-main {
    padding: 16px 14px 84px;
  }
  .gov {
    grid-template-columns: 1fr;
  }
  .gov-sidebar {
    position: fixed;
    left: max(0px, calc((100vw - 430px) / 2));
    top: 0;
    z-index: 90;
    width: min(264px, 82vw);
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .gov-sidebar.open {
    transform: none;
  }
  .mobile-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 50%;
    right: auto;
    z-index: 70;
    width: min(430px, 100vw);
    transform: translateX(-50%);
    background: color-mix(in oklch, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 56px;
    min-height: 46px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 10px;
  }
  .mobile-bar a.active {
    color: var(--primary);
  }
  .mobile-bar a svg {
    width: 21px;
    height: 21px;
  }
  .public-header {
    height: 58px;
    padding: 0 14px;
    gap: 10px;
  }
  .public-header .pub-nav {
    display: none;
  }
  .public-header .header-right {
    min-width: 0;
  }
  .public-header .header-right .btn {
    padding-inline: 11px;
  }
  .public-header .header-right .btn-ghost {
    display: inline-flex;
  }
  .public-header .header-right .btn-primary {
    display: none;
  }
  .public-wrap {
    padding: 0 16px;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-aside {
    display: none;
  }
  .auth-main {
    padding: 28px 18px;
  }
  .notif-panel {
    right: 0;
    top: calc(100% + 6px);
    width: min(406px, calc(100vw - 24px));
  }
  .toast-stack {
    left: 50%;
    right: auto;
    bottom: calc(74px + env(safe-area-inset-bottom));
    width: min(406px, calc(100vw - 24px));
    transform: translateX(-50%);
  }
  body.has-page-fab .toast-stack {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }
  .toast {
    width: 100%;
    max-width: none;
  }
}

html.is-mobile-pwa {
  background: var(--bg-soft);
}
html.is-mobile-pwa body {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
}
html.is-mobile-pwa .app,
html.is-mobile-pwa .public,
html.is-mobile-pwa .auth,
html.is-mobile-pwa .gov {
  min-height: 100dvh;
}
html.is-mobile-pwa .grid-3,
html.is-mobile-pwa .grid-2,
html.is-mobile-pwa .grid-2-1,
html.is-mobile-pwa .grid-1-2 {
  grid-template-columns: 1fr !important;
}
html.is-mobile-pwa .grid-4 {
  grid-template-columns: 1fr 1fr !important;
}
html.is-mobile-pwa .app-header,
html.is-mobile-pwa .gov-header {
  height: 56px;
  gap: 10px;
  padding: 0 12px;
}
html.is-mobile-pwa .app-nav,
html.is-mobile-pwa .public-header .pub-nav,
html.is-mobile-pwa .user-chip .u-meta,
html.is-mobile-pwa .user-chip > svg,
html.is-mobile-pwa .gov-header .env-select,
html.is-mobile-pwa .gov-header .clock,
html.is-mobile-pwa .auth-aside {
  display: none;
}
html.is-mobile-pwa .public-header .header-right .btn-primary {
  display: none;
}
html.is-mobile-pwa .public-header .header-right .btn-ghost {
  display: inline-flex;
}
html.is-mobile-pwa .menu-toggle {
  display: grid;
}
html.is-mobile-pwa .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
html.is-mobile-pwa .user-chip {
  min-width: 46px;
  width: 46px;
  min-height: 46px;
  justify-content: center;
  padding: 4px;
  background: transparent;
}
html.is-mobile-pwa .app-main,
html.is-mobile-pwa .gov-main {
  padding: 16px 14px 84px;
}
html.is-mobile-pwa .gov,
html.is-mobile-pwa .auth {
  grid-template-columns: 1fr;
}
html.is-mobile-pwa .public-header {
  height: 58px;
  padding: 0 14px;
  gap: 10px;
}
html.is-mobile-pwa .public-wrap {
  padding: 0 16px;
}
html.is-mobile-pwa .auth-main {
  padding: 28px 18px;
}
html.is-mobile-pwa .mobile-bar {
  display: grid;
  position: fixed;
  bottom: 0;
  left: 50%;
  right: auto;
  z-index: 70;
  width: min(430px, 100vw);
  transform: translateX(-50%);
  grid-template-columns: 1fr 1fr 74px 1fr 1fr;
  align-items: end;
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  justify-items: center;
}
html.is-mobile-pwa .mobile-bar a,
html.is-mobile-pwa .mobile-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 54px;
  min-height: 46px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
html.is-mobile-pwa .mobile-bar a {
  font-size: 10px;
}
html.is-mobile-pwa .mobile-bar a.active {
  color: var(--primary);
}
html.is-mobile-pwa .mobile-bar a svg {
  width: 21px;
  height: 21px;
}
html.is-mobile-pwa .mobile-bar .mobile-action-fab {
  width: 62px;
  height: 62px;
  min-width: 62px;
  min-height: 62px;
  aspect-ratio: 1 / 1;
  margin-top: -26px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--primary);
  box-shadow: 0 12px 30px color-mix(in oklch, var(--primary) 34%, transparent);
  -webkit-tap-highlight-color: transparent;
}
html.is-mobile-pwa .mobile-bar .mobile-action-fab:active {
  box-shadow: 0 8px 22px color-mix(in oklch, var(--primary) 28%, transparent);
  outline: none;
}
html.is-mobile-pwa .mobile-bar .mobile-action-fab:focus {
  outline: none;
}
html.is-mobile-pwa .mobile-bar .mobile-action-fab:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px color-mix(in oklch, var(--bg) 86%, transparent),
    0 0 0 7px color-mix(in oklch, var(--primary) 42%, transparent),
    0 12px 30px color-mix(in oklch, var(--primary) 34%, transparent);
}
html.is-mobile-pwa .mobile-bar .mobile-action-fab svg {
  width: 30px;
  height: 30px;
  color: currentColor;
  stroke: currentColor;
}

/* Mobile slide-out for app nav */
.app-drawer { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
.app-drawer .panel-side {
  position: absolute; top: 0; left: 0; bottom: 0; width: 270px; padding: 18px;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.app-drawer.open { pointer-events: auto; }
.app-drawer.open .panel-side { transform: none; box-shadow: var(--shadow-lg); }
.app-drawer .drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; }
.app-drawer.open .drawer-scrim { opacity: 1; }
.app-drawer .panel-side a { min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--text-soft); }
.app-drawer .panel-side a svg { width: 18px; height: 18px; }
.app-drawer .panel-side a.active { background: var(--primary-soft); color: var(--primary); }

@media (display-mode: standalone) {
  .app-drawer {
    left: 50%;
    right: auto;
    width: min(430px, 100vw);
    transform: translateX(-50%);
  }
  .app-drawer .panel-side {
    width: min(270px, 82vw);
  }
}

html.is-mobile-pwa .app-drawer {
  left: 50%;
  right: auto;
  width: min(430px, 100vw);
  transform: translateX(-50%);
}
html.is-mobile-pwa .app-drawer .panel-side {
  width: min(270px, 82vw);
}
