/* ==========================================================================
   shell.css — app chrome
   Side navigation, action pre-loader, onboarding, QR, notifications and the
   language switcher. Loaded after app.css.
   ========================================================================== */

/* ------------------------------------------------------------- Content well */

.app-main,
.admin-main {
  flex: 1;
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  padding: 2rem var(--app-gutter) 4rem;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.3s, border-color 0.3s, transform 0.3s var(--ease);
}

.icon-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  transform: translateY(-2px);
}

/* ---------------------------------------------------------- Side navigation */

.shell {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 1.25rem 0.9rem 1rem;
  background: rgba(8, 11, 18, 0.86);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.side-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.35rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.side-nav-close {
  display: none;
}

.side-nav-links {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 1rem;
  overflow-y: auto;
}

.side-nav-links a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
  transition: color 0.3s var(--ease), background 0.3s var(--ease), transform 0.35s var(--ease);
}

.side-nav-links a .icon {
  flex: 0 0 auto;
  opacity: 0.75;
  transition: opacity 0.3s;
}

.side-nav-links a:hover {
  color: var(--text);
  background: rgba(92, 225, 255, 0.06);
  transform: translateX(2px);
}

.side-nav-links a:hover .icon,
.side-nav-links a.is-active .icon {
  opacity: 1;
}

.side-nav-links a.is-active {
  color: var(--cyan);
  background: rgba(92, 225, 255, 0.1);
}

/* Marker on the rail edge */
.side-nav-links a.is-active::before {
  content: "";
  position: absolute;
  left: -0.9rem;
  top: 50%;
  width: 3px;
  height: 1.5rem;
  border-radius: 0 3px 3px 0;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  transform: translateY(-50%);
}

.nav-signout {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.nav-signout:hover {
  color: var(--down);
  background: rgba(255, 107, 122, 0.06);
}

.nav-badge {
  margin-left: auto;
  min-width: 1.3rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--copper);
  color: #1a0d03;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  text-align: center;
}

.side-nav-foot {
  padding: 0.9rem 0.8rem 0;
  border-top: 1px solid var(--line);
}

.side-nav-name { margin: 0; font-size: 0.84rem; }
.side-nav-meta { margin: 0.1rem 0 0; color: var(--muted); font-family: var(--mono); font-size: 0.68rem; }
.side-nav-cash {
  margin: 0.4rem 0 0;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shell-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.6rem;
  padding: 0.5rem var(--app-gutter);
  background: rgba(5, 6, 10, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.shell-menu,
.shell-bar-brand { display: none; }

.shell-bar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.shell-bell { position: relative; }

.nav-badge-dot {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  margin: 0;
  min-width: 1.05rem;
  padding: 0 0.25rem;
  font-size: 0.6rem;
  line-height: 1.05rem;
}

.shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  border: 0;
  background: rgba(3, 5, 9, 0.7);
  backdrop-filter: blur(3px);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.shell-backdrop.is-on { opacity: 1; }

.icon-btn .icon { display: block; }

@media (max-width: 1024px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .side-nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(18rem, 84vw);
    transform: translateX(-105%);
    box-shadow: 30px 0 80px -40px rgba(0, 0, 0, 0.9);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .side-nav.is-open { transform: none; }
  .side-nav-close,
  .shell-menu { display: inline-grid; }
  .shell-bar-brand { display: flex; }
}

/* --------------------------------------------------------- Action preloader */

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 10, 0.88);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}

.page-loader.is-on {
  opacity: 1;
  visibility: visible;
}

/* Card holding the staged messages */
.page-loader-card {
  width: min(22rem, calc(100vw - 2.5rem));
  padding: 2rem 2rem 1.6rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.92), rgba(8, 11, 18, 0.94));
  border: 1px solid rgba(92, 225, 255, 0.22);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 30px 70px -25px rgba(0, 0, 0, 0.9),
    0 0 70px -30px rgba(92, 225, 255, 0.65);
}

/* Ring with the action glyph at its centre */
.page-loader-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  margin: 0 auto 1.2rem;
  border: 1px solid rgba(92, 225, 255, 0.2);
  border-radius: 50%;
  background: rgba(92, 225, 255, 0.08);
  color: var(--cyan);
}

.page-loader-spin {
  position: absolute;
  inset: -1px;
  border: 2px solid transparent;
  border-top-color: var(--cyan);
  border-right-color: rgba(92, 225, 255, 0.35);
  border-radius: 50%;
  animation: loaderSpin 0.85s linear infinite;
}

.page-loader-icon { display: grid; place-items: center; }
.page-loader-icon .icon { display: block; }

.page-loader-text {
  min-height: 1.3em;
  margin: 0 0 1.1rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}

.page-loader-text.is-fading {
  opacity: 0;
  transform: translateY(5px);
}

.page-loader-bar {
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(92, 225, 255, 0.12);
}

.page-loader-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--copper));
  box-shadow: 0 0 12px rgba(92, 225, 255, 0.7);
  transition: width 0.42s var(--ease);
}

.page-loader-count {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  min-height: 1em;
}

@keyframes loaderSpin { to { transform: rotate(360deg); } }
@keyframes loaderPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Inline button spinner */
.button.is-busy {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.button.is-busy::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.05rem;
  height: 1.05rem;
  margin: -0.525rem 0 0 -0.525rem;
  border: 2px solid rgba(4, 16, 24, 0.35);
  border-top-color: #041018;
  border-radius: 50%;
  animation: loaderSpin 0.7s linear infinite;
}

.button-outline.is-busy::before,
.button-ghost.is-busy::before {
  border-color: rgba(92, 225, 255, 0.3);
  border-top-color: var(--cyan);
}

/* ------------------------------------------------------------- Onboarding */

.onboard {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.onboard li {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 11, 18, 0.55);
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease);
}

.onboard li:hover { transform: translateX(3px); }
.onboard li.is-done { border-color: rgba(93, 255, 177, 0.3); }
.onboard li.is-next { border-color: rgba(92, 225, 255, 0.4); background: rgba(92, 225, 255, 0.05); }

.onboard-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.is-done .onboard-mark { border-color: var(--up); color: var(--up); }
.is-next .onboard-mark { border-color: var(--cyan); color: var(--cyan); }

.onboard-copy { flex: 1; min-width: 0; }
.onboard-copy strong { display: block; font-size: 0.94rem; }
.onboard-copy span { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.82rem; }
.onboard-copy .done-note { color: var(--up); }

/* ------------------------------------------------------------- Deposit QR */

.qr-block {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 11, 18, 0.6);
}

.qr-frame {
  flex: 0 0 auto;
  padding: 0.6rem;
  border-radius: 0.6rem;
  background: #fff;
  line-height: 0;
  box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.2), 0 18px 40px -22px rgba(92, 225, 255, 0.6);
}

.qr-frame svg {
  display: block;
  width: 9.5rem;
  height: 9.5rem;
}

.qr-note { min-width: 0; }
.qr-note p { margin: 0 0 0.45rem; font-size: 0.86rem; }
.qr-note .muted { font-size: 0.8rem; }

@media (max-width: 620px) {
  .qr-block { flex-direction: column; align-items: flex-start; }
  .qr-frame svg { width: 11rem; height: 11rem; }
}

/* ---------------------------------------------------------- Notifications */

.notice-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notice-list { gap: 0.4rem; }

.notice {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(12, 16, 24, 0.7);
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.notice:hover { border-color: rgba(92, 225, 255, 0.28); }
.notice.is-unread { background: rgba(92, 225, 255, 0.05); }

.notice-body { flex: 1; min-width: 0; }

/* Title and message share a line until the width runs out. */
.notice-body strong {
  font-size: 0.88rem;
  font-weight: 600;
  margin-right: 0.4rem;
}

.notice-body p {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.notice-body .notice-link {
  display: inline-block;
  margin-left: 0.5rem;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-decoration: none;
  white-space: nowrap;
}

.notice-body .notice-link:hover { text-decoration: underline; }

.notice-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
}

.notice-dot {
  flex: 0 0 auto;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--cyan);
  transform: translateY(-0.1rem);
}

@media (max-width: 620px) {
  .notice { flex-wrap: wrap; }
  .notice-time { width: 100%; margin-top: 0.15rem; }
}

/* ------------------------------------------------------- Language switcher */

.lang-switch { position: relative; }

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s;
}

.lang-trigger:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.lang-trigger img {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  object-fit: cover;
}

.lang-trigger .chev { font-size: 0.6rem; }

.lang-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 60;
  min-width: 11rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: rgba(10, 14, 22, 0.98);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
}

.lang-menu[hidden] { display: none; }

.lang-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s;
}

.lang-menu button:hover { background: rgba(92, 225, 255, 0.08); }
.lang-menu button.is-active { color: var(--cyan); }

.lang-menu img {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  object-fit: cover;
}

/* The GTranslate float widget is driven by our own switcher, never shown.
   Its #gt_float_wrapper carries inline position:fixed, so it escapes an
   offscreen parent and has to be hidden by id. #google_translate_element2 is
   the engine mount and must stay in the document for translation to work. */
.gtranslate_wrapper {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#gt_float_wrapper,
.gt_float_switcher {
  display: none !important;
}

/* Google's banner pushes <body> down; undo it. */
body { top: 0 !important; }
.skiptranslate iframe { display: none !important; }

html[data-motion="reduced"] .page-loader-ring,
html[data-motion="reduced"] .page-loader-text,
html[data-motion="reduced"] .button.is-busy::before {
  animation: none;
}

/* ==========================================================================
   Select controls
   The native chevron sits hard against the right edge of a full-width select
   and reads as detached. Replace it with an inset one drawn to match the
   inline SVG icon set.
   ========================================================================== */

.field select,
select.control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a96a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
  background-size: 0.85rem;
  padding-right: 2.6rem;
  cursor: pointer;
}

.field select:focus {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235ce1ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Firefox keeps a focus ring inside the control */
.field select:-moz-focusring {
  color: transparent;
  text-shadow: 0 0 0 var(--text);
}

.field select option {
  background: #0a0f18;
  color: var(--text);
}

/* ==========================================================================
   Toasts
   Flash messages are rendered inline by PHP, then lifted into this stack by
   toast.js. With JavaScript off they simply stay inline and readable.
   ========================================================================== */

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 210;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(24rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(12, 16, 24, 0.97);
  box-shadow: 0 24px 60px -26px rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 0.4s var(--ease), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

.toast.is-out {
  opacity: 0;
  transform: translateX(120%);
}

.toast-success { border-color: rgba(93, 255, 177, 0.3); }
.toast-error   { border-color: rgba(255, 107, 122, 0.32); }
.toast-warning { border-color: rgba(232, 160, 106, 0.32); }
.toast-info    { border-color: rgba(92, 225, 255, 0.3); }

.toast-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}

.toast-success .toast-icon { background: rgba(93, 255, 177, 0.16); color: var(--up); }
.toast-error   .toast-icon { background: rgba(255, 107, 122, 0.16); color: var(--down); }
.toast-warning .toast-icon { background: rgba(232, 160, 106, 0.18); color: var(--copper); }
.toast-info    .toast-icon { background: rgba(92, 225, 255, 0.16); color: var(--cyan); }

.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.toast-close {
  flex: 0 0 auto;
  padding: 0 0.15rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.25s;
}

.toast-close:hover { color: var(--text); }

/* Countdown bar showing how long is left before auto-dismiss */
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  background: currentColor;
  opacity: 0.35;
}

.toast { position: relative; overflow: hidden; }
.toast-success .toast-timer { color: var(--up); }
.toast-error   .toast-timer { color: var(--down); }
.toast-warning .toast-timer { color: var(--copper); }
.toast-info    .toast-timer { color: var(--cyan); }

@media (max-width: 620px) {
  .toast-stack {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
  }

  .toast,
  .toast.is-out { transform: translateY(140%); }
  .toast.is-in { transform: none; }
}

html[data-motion="reduced"] .toast { transition: opacity 0.2s linear; transform: none; }
html[data-motion="reduced"] .toast.is-out { transform: none; }
html[data-motion="reduced"] .toast-timer { display: none; }

.lang-code {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.lang-trigger .chev { transition: transform 0.3s var(--ease); }
.lang-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }
.lang-trigger[aria-expanded="true"] { border-color: var(--cyan); color: var(--cyan); }

.nav-badge-alert {
  background: var(--down);
  color: #1a0308;
}

/* data-tone replaces the colour class on cells that now carry data-label */
[data-tone="is-up"] { color: var(--up); }
[data-tone="is-down"] { color: var(--down); }

/* ==========================================================================
   Responsive tables
   Below 760px a .stack table becomes one card per row, each cell labelled
   from its data-label, so nothing needs sideways scrolling.
   ========================================================================== */

@media (max-width: 760px) {
  .table-wrap.stack {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .stack table.data {
    display: block;
    min-width: 0;
  }

  .stack table.data thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .stack table.data tbody,
  .stack table.data tr,
  .stack table.data td {
    display: block;
    width: auto;
  }

  .stack table.data tr {
    margin-bottom: 0.6rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(12, 16, 24, 0.72);
  }

  .stack table.data tr:hover { background: rgba(12, 16, 24, 0.72); }

  .stack table.data td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.32rem 0;
    border: 0;
    text-align: right;
  }

  .stack table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: left;
  }

  /* First cell is the row's heading: full width, no label, bolder. */
  .stack table.data td:first-child {
    display: block;
    padding: 0 0 0.55rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 1rem;
  }

  .stack table.data td:first-child::before { content: none; }

  /* Trailing action cell (empty label) needs no key column. */
  .stack table.data td[data-label=""] {
    justify-content: flex-end;
    padding-top: 0.6rem;
  }

  .stack table.data td[data-label=""]::before { content: none; }

  .stack table.data td .muted { text-align: left; }
}

/* ==========================================================================
   Mobile footer navigation
   ========================================================================== */

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  display: none;
  background: rgba(6, 8, 13, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-inner {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}

.mobile-nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.25rem 0.55rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.25s var(--ease);
}

.mobile-nav a .icon { opacity: 0.8; }
.mobile-nav a:hover { color: var(--text); }

.mobile-nav a.is-active {
  color: var(--cyan);
}

.mobile-nav a.is-active .icon { opacity: 1; }

/* Active marker along the top edge */
.mobile-nav a.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.mobile-nav .nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 50%;
  margin-right: -1.15rem;
  min-width: 1rem;
  padding: 0 0.22rem;
  font-size: 0.58rem;
  line-height: 1rem;
}

@media (max-width: 760px) {
  .mobile-nav { display: block; }

  /* Keep the last row of content clear of the bar. */
  .app-main,
  .admin-main { padding-bottom: 6rem; }

  .toast-stack { bottom: 5rem; }
}

/* --------------------------------------- Raised primary action in the bar */

.mobile-nav-inner { align-items: end; }

.mobile-nav-action {
  position: relative;
  overflow: visible;
}

.mobile-nav-action .fab {
  display: grid;
  place-items: center;
  width: 3.1rem;
  height: 3.1rem;
  /* Lifts clear of the bar; .mobile-nav must not clip. */
  margin: -1.55rem 0 0.1rem;
  border-radius: 1.05rem;
  background: var(--cyan);
  color: #041018;
  box-shadow:
    0 0 0 5px rgba(6, 8, 13, 0.94),
    0 12px 26px -8px rgba(92, 225, 255, 0.85);
  transition: transform 0.3s var(--ease-back, cubic-bezier(0.34, 1.56, 0.64, 1)),
    box-shadow 0.3s var(--ease);
}

.mobile-nav-action .fab .icon { stroke-width: 2.4; }

.mobile-nav-action:active .fab {
  transform: scale(0.92);
}

.mobile-nav-action.is-active {
  color: var(--cyan);
}

.mobile-nav-action.is-active .fab {
  box-shadow:
    0 0 0 5px rgba(6, 8, 13, 0.94),
    0 0 0 7px rgba(92, 225, 255, 0.35),
    0 12px 26px -8px rgba(92, 225, 255, 0.9);
}

/* The lift replaces the top marker the flat tabs use. */
.mobile-nav-action.is-active::before { content: none; }

.mobile-nav-action .nav-badge {
  top: -1.2rem;
  margin-right: -1.5rem;
}

html[data-motion="reduced"] .mobile-nav-action .fab { transition: none; }

/* ==========================================================================
   Reveal offsets on small screens
   [data-reveal="left"|"right"] slide in horizontally. On a phone the panel is
   already full width, so a 32px offset pushes it past the viewport and creates
   a horizontal scrollbar until the reveal fires. Slide vertically instead.
   ========================================================================== */

@media (max-width: 760px) {
  [data-reveal="left"],
  [data-reveal="right"] {
    transform: translateY(18px);
  }
}

/* Safety net: nothing should ever scroll the page sideways. `clip` (not
   `hidden`) so position: sticky keeps working. */
html {
  overflow-x: clip;
}

/* ==========================================================================
   Impersonation banner + danger zone
   ========================================================================== */

.impersonation-bar {
  position: sticky;
  top: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem var(--app-gutter);
  background: linear-gradient(90deg, rgba(232, 160, 106, 0.22), rgba(232, 160, 106, 0.1));
  border-bottom: 1px solid rgba(232, 160, 106, 0.4);
  color: #ffe4cd;
  font-size: 0.84rem;
}

.impersonation-bar strong { color: #fff; }
.impersonation-bar form { margin-left: auto; }

.impersonation-bar .button {
  padding: 0.4rem 0.85rem;
  font-size: 0.76rem;
  border-color: rgba(255, 228, 205, 0.45);
  color: #ffe4cd;
}

.impersonation-bar .button:hover {
  border-color: #ffe4cd;
  background: rgba(255, 228, 205, 0.1);
}

.impersonation-dot {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 0 rgba(232, 160, 106, 0.6);
  animation: impersonatePulse 2.2s ease-out infinite;
}

@keyframes impersonatePulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 160, 106, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(232, 160, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 160, 106, 0); }
}

/* The sticky bar sits above the shell, so the rail starts below it. */
.impersonation-bar ~ .shell .side-nav { height: auto; min-height: calc(100vh - 2.6rem); }

.danger-zone {
  border-color: rgba(255, 107, 122, 0.28);
}

.danger-zone .panel-head h2 { color: var(--down); }

.danger-zone code {
  padding: 0.1rem 0.35rem;
  border-radius: 0.3rem;
  background: rgba(255, 107, 122, 0.12);
  color: var(--down);
  font-family: var(--mono);
  font-size: 0.8rem;
}

@media (max-width: 620px) {
  .impersonation-bar { flex-wrap: wrap; }
  .impersonation-bar form { margin-left: 0; width: 100%; }
  .impersonation-bar .button { width: 100%; justify-content: center; }
}

html[data-motion="reduced"] .impersonation-dot { animation: none; }

/* ==========================================================================
   Confirmation modal
   ========================================================================== */

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
}

.modal-host[hidden] { display: none; }
body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.72);
  backdrop-filter: blur(5px);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.25s var(--ease);
}

.modal-host.is-open .modal-backdrop { opacity: 1; }

.modal-card {
  position: relative;
  width: min(28rem, 100%);
  padding: 1.5rem;
  background: rgba(12, 16, 24, 0.98);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.28s var(--ease), transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-host.is-open .modal-card {
  opacity: 1;
  transform: none;
}

.modal-card.is-danger { border-color: rgba(255, 107, 122, 0.35); }

.modal-title {
  margin: 0 0 0.55rem;
  font-size: 1.35rem;
  line-height: 1.2;
}

.modal-card.is-danger .modal-title { color: var(--down); }

.modal-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
  /* Keeps the blank line in "…?\n\nThis cannot be undone." */
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.modal-message[hidden] { display: none; }

.modal-field {
  margin-top: 1rem;
}

.modal-field[hidden] { display: none; }

.modal-field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.modal-input {
  width: 100%;
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  background: #080b12;
  color: var(--text);
  font-family: var(--mono);
}

.modal-input:focus {
  border-color: rgba(92, 225, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(92, 225, 255, 0.1);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.modal-actions .button { padding: 0.7rem 1.3rem; }

@media (max-width: 480px) {
  .modal-host { place-items: end center; padding: 0; }
  .modal-card {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top));
    padding: 1.25rem max(1rem, env(safe-area-inset-right))
      max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    overflow-y: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; justify-content: center; }
}

html[data-motion="reduced"] .modal-backdrop,
html[data-motion="reduced"] .modal-card { transition: none; }
html[data-motion="reduced"] .modal-card { transform: none; }
