/* Jalia design system — global brand + dynamic tenant theme */
:root {
  /* Global brand (requirements) */
  --brand-navy: #102A43;
  --brand-gold: #C89B3C;
  --brand-bg: #FAF8F3;
  --brand-text: #1F2933;
  --brand-muted: #52606D;
  --brand-success: #16805B;
  --brand-warning: #D99020;
  --brand-danger: #C43D4D;

  /* Tenant theme (overridden at runtime) */
  --primary: #A61B29;
  --secondary: #176B52;
  --accent: #C9A44D;
  --bg: #FFF9F6;
  --surface: #FFFFFF;
  --text: #1F2933;
  --muted: #52606D;
  --line: rgba(31, 41, 51, 0.12);
  --shadow: 0 14px 40px rgba(16, 42, 67, 0.08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
  --display: "IBM Plex Sans Arabic", "Noto Kufi Arabic", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 380px at 100% -5%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
    radial-gradient(700px 360px at -10% 110%, color-mix(in srgb, var(--secondary) 16%, transparent), transparent 50%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.65;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 2px; }

.app-shell { min-height: 100vh; padding-bottom: calc(5.6rem + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: .55rem;
  padding: .8rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, white);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--brand-navy);
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: .45rem; text-decoration: none;
}
.brand em { font-style: normal; color: var(--primary); }
.brand-logo {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex: 0 0 auto;
  border: 1.5px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--surface);
}
.brand-text {
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-actions {
  display: flex; gap: .3rem; align-items: center; flex-wrap: nowrap;
  justify-content: flex-end; flex: 0 0 auto; max-width: 38%;
}

.lang-switch, .icon-btn, .tenant-switch {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: .4rem .75rem;
  cursor: pointer;
  min-height: 40px;
}
.tenant-switch {
  max-width: min(220px, 52vw);
  font-weight: 600; color: var(--primary);
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}

.container { width: min(980px, calc(100% - 1.4rem)); margin: 0 auto; padding: 1.1rem 0 2rem; }

.hero {
  position: relative; overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  padding: 1.7rem 1.25rem;
  color: #fff;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 82%, #000), color-mix(in srgb, var(--secondary) 70%, #102A43));
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.hero-logo {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; margin-bottom: .85rem;
  border: 2.5px solid color-mix(in srgb, var(--accent) 70%, white);
  background: #fff; box-shadow: 0 8px 22px rgba(0,0,0,.2);
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  line-height: 1.25; margin: 0 0 .5rem; max-width: 16ch;
}
.hero p { margin: 0; opacity: .95; max-width: 40ch; }
.hero .eyebrow { color: var(--accent); font-weight: 700; margin-bottom: .45rem; display: inline-block; }

.grid { display: grid; gap: .8rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  /* block: <a class="card"> contains h3/p — inline anchors fragment the box in RTL */
  display: block;
  width: 100%;
  max-width: 100%;
  background: color-mix(in srgb, var(--surface) 92%, white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset;
  overflow: hidden;
}
.card h3 { font-family: var(--display); margin: 0 0 .35rem; font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: .94rem; }
.card.interactive { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card.featured {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 42%),
    color-mix(in srgb, var(--surface) 92%, white);
}

.section-title { font-family: var(--display); font-size: 1.15rem; margin: 1.25rem 0 .65rem; color: var(--brand-navy); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .55rem; }
@media (max-width: 640px) { .quick-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.quick-link {
  display: flex; flex-direction: column; gap: .25rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: .85rem .8rem; min-height: 88px; font-weight: 700; color: var(--brand-navy);
}
.quick-link span { color: var(--muted); font-weight: 500; font-size: .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 999px; padding: .78rem 1.15rem; min-height: 46px;
  background: var(--primary); color: #fff; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line)); }
.btn.navy { background: var(--brand-navy); }
.btn.success { background: var(--brand-success); }
.btn.danger { background: var(--brand-danger); }
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px dashed color-mix(in srgb, var(--primary) 40%, var(--line));
}
.topbar .btn.ghost,
.hero .btn.ghost,
.cover-actions .btn.ghost {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
}
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: .85rem; }
.field label { display: block; font-weight: 700; margin-bottom: .3rem; font-size: .9rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: .85rem .95rem; min-height: 48px; outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.hint { color: var(--muted); font-size: .84rem; margin-top: .28rem; }
.phone-row { display: grid; grid-template-columns: 110px 1fr; gap: .5rem; }

.city-picker { position: relative; }
.city-picker-list {
  list-style: none; margin: .35rem 0 0; padding: .35rem;
  max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.city-picker-list[hidden] { display: none !important; }
.city-picker-list li {
  padding: .65rem .8rem; border-radius: 10px; cursor: pointer;
}
.city-picker-list li:hover,
.city-picker-list li[aria-selected="true"] {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}
.city-picker-list li.muted { cursor: default; opacity: .75; }
.city-picker-list li.muted:hover { background: transparent; }

.table tr.row-focus td {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.badge {
  display: inline-flex; align-items: center; gap: .28rem;
  background: color-mix(in srgb, var(--brand-success) 12%, white);
  color: var(--brand-success); border: 1px solid color-mix(in srgb, var(--brand-success) 28%, white);
  border-radius: 999px; padding: .18rem .55rem; font-size: .76rem; font-weight: 700;
}
.badge i {
  width: .85rem; height: .85rem; border-radius: 50%; background: var(--brand-success); color: #fff;
  display: inline-grid; place-items: center; font-style: normal; font-size: .6rem;
}
.badge.pending { background: color-mix(in srgb, var(--brand-warning) 14%, white); color: #8a5a10; border-color: color-mix(in srgb, var(--brand-warning) 35%, white); }
.badge.danger { background: color-mix(in srgb, var(--brand-danger) 12%, white); color: var(--brand-danger); border-color: color-mix(in srgb, var(--brand-danger) 28%, white); }
.badge.success { background: color-mix(in srgb, var(--brand-success) 12%, white); color: var(--brand-success); border-color: color-mix(in srgb, var(--brand-success) 28%, white); }
.badge.navy { background: color-mix(in srgb, var(--brand-navy) 10%, white); color: var(--brand-navy); border-color: color-mix(in srgb, var(--brand-navy) 22%, white); }
.badge.urgent { background: color-mix(in srgb, var(--brand-danger) 18%, white); color: var(--brand-danger); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stat-tile {
  background: color-mix(in srgb, var(--surface) 92%, white);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  padding: .85rem .9rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.stat-tile strong { font-size: 1.35rem; color: var(--brand-navy); line-height: 1.2; }
.stat-tile span { font-size: .82rem; color: var(--muted); }

.toolbar-row {
  display: flex; gap: .55rem; flex-wrap: wrap; align-items: center;
  margin: .4rem 0 1rem;
}
.toolbar-row input[type="search"],
.toolbar-row select {
  flex: 1 1 12rem;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: .7rem .85rem;
}
.table tr.row-you td {
  background: color-mix(in srgb, var(--accent) 10%, white);
}

.content-kind-nav {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin: .4rem 0 1rem;
}
.content-kind-nav a {
  padding: .4rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .85rem;
  color: var(--muted);
}
.content-kind-nav a.active {
  background: color-mix(in srgb, var(--primary) 12%, white);
  color: var(--brand-navy);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  font-weight: 600;
}
.pager {
  display: flex; align-items: center; justify-content: center; gap: .65rem;
  flex-wrap: wrap; margin: .75rem 0 1rem;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .1rem;
  background: color-mix(in srgb, var(--brand-navy) 96%, black);
  color: #fff;
  padding: .45rem .3rem calc(.45rem + var(--safe-bottom));
  border-top: 0;
  box-shadow: 0 -8px 24px rgba(16, 42, 67, 0.18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.tabbar a {
  text-align: center; font-size: .68rem; opacity: .72; padding: .4rem .1rem .15rem;
  display: flex; flex-direction: column; gap: .1rem; align-items: center;
  border: 0; background: transparent; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { opacity: 1; color: var(--accent); }
.tabbar .ico { font-size: 1.1rem; line-height: 1; }

/* Marquee / ticker */
.ticker {
  overflow: hidden;
  background: color-mix(in srgb, var(--brand-navy) 92%, black);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  height: 2.05rem;
  display: flex; align-items: center;
}
.ticker-track {
  display: flex; gap: 3rem; white-space: nowrap;
  width: max-content;
  will-change: transform;
}
.ticker-track span { padding: 0 1rem; font-size: .86rem; font-weight: 600; letter-spacing: .01em; }
/* Faster ticker: previous 23.8s → +40% speed */
.ticker-rtl .ticker-track { animation: ticker-ltr 14.28s linear infinite; }
.ticker-ltr .ticker-track { animation: ticker-rtl 14.28s linear infinite; }
@keyframes ticker-ltr {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}
@keyframes ticker-rtl {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.report-btn {
  margin-top: .45rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: .25rem .7rem;
  font-size: .75rem;
  cursor: pointer;
}
.report-btn:hover { color: var(--brand-danger); border-color: color-mix(in srgb, var(--brand-danger) 35%, var(--line)); }
.share-btn {
  margin-top: .45rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: .25rem .7rem;
  font-size: .75rem;
  cursor: pointer;
}
.share-btn:hover { color: var(--brand-navy); border-color: color-mix(in srgb, var(--brand-navy) 35%, var(--line)); }
.content-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-top: .45rem; }
.publish-date { margin-top: .35rem; }

.book-viewer {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  display: grid;
  place-items: center;
  color: #fff;
}
.book-viewer img, .book-viewer canvas {
  max-width: 100%; max-height: 70vh; object-fit: contain;
  background: #1a1a1a;
}
.book-nav {
  display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; margin-top: .75rem;
}
.book-page-label { font-weight: 700; color: var(--muted); }

.admin-nav {
  display: flex; gap: .35rem; flex-wrap: wrap; margin: .4rem 0 1rem;
}
.admin-nav a {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: .35rem .75rem; font-size: .82rem; font-weight: 600;
}
.admin-nav a.active { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card {
  width: min(460px, 100%);
  background: color-mix(in srgb, var(--surface) 94%, white);
  border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
  padding: 1.35rem 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.auth-card h1 { font-family: var(--display); font-size: 1.55rem; margin: 0 0 .35rem; color: var(--brand-navy); }

.stack { display: flex; flex-direction: column; gap: .65rem; }
.help-timeline { display: flex; flex-direction: column; gap: .55rem; margin: .5rem 0; }
.help-timeline-item {
  border: 1px solid var(--line); border-radius: 12px; padding: .65rem .75rem; background: var(--surface);
}
.help-timeline-item.internal { border-style: dashed; opacity: .92; }
.help-timeline-item.member_reply { border-inline-start: 3px solid var(--secondary); }
.help-timeline-item.staff_reply { border-inline-start: 3px solid var(--brand-navy); }
.help-timeline-item.status_change { border-inline-start: 3px solid var(--primary); }
.help-timeline-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; font-size: .85rem; }
.attendee-panel { margin: .5rem 0; }
.guest-gate {
  margin-top: .85rem; padding-top: .85rem; border-top: 1px dashed var(--line);
}
.guest-banner {
  background: color-mix(in srgb, var(--secondary) 12%, var(--surface));
  border: 1px solid var(--line); border-radius: 12px; padding: .65rem .75rem;
}
.guest-teaser p { position: relative; }
.row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: start; padding: .65rem .35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.empty, .state {
  text-align: center; color: var(--muted); padding: 1.8rem 1rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.skeleton { background: linear-gradient(90deg, #eee, #f7f7f7, #eee); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; min-height: 72px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.toast {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--brand-navy); color: #fff; padding: .7rem 1rem; border-radius: 999px;
  z-index: 60; font-size: .9rem; display: none; max-width: min(92vw, 420px); text-align: center;
}
.toast.show { display: block; }

.cover-thumb {
  width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  background-position: center top;
  background-size: cover;
  margin-bottom: .65rem;
}

body.lightbox-open { overflow: hidden; }
.mag-lightbox {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(8, 10, 12, .94);
  display: flex; flex-direction: column;
  padding: max(.65rem, env(safe-area-inset-top)) .75rem max(.75rem, env(safe-area-inset-bottom));
  gap: .55rem;
}
.mag-lightbox-close {
  align-self: flex-end;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(0,0,0,.45); color: #fff;
  border-radius: 999px; padding: .45rem .9rem;
  font-size: .95rem; font-weight: 700; cursor: pointer; z-index: 2;
}
.mag-lightbox-stage {
  margin: 0; flex: 1; width: 100%; min-height: 0;
  display: grid; place-items: center;
}
.mag-lightbox-stage img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 8px;
}
.mag-lightbox-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; width: 100%;
}
.mag-lightbox-caption {
  color: rgba(255,255,255,.85); font-size: .9rem; font-weight: 700;
  text-align: center; flex: 1;
}
.mag-lightbox-nav {
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12); color: #fff;
  border-radius: 999px; padding: .65rem 1.05rem;
  font-weight: 700; cursor: pointer; min-width: 5.5rem;
}
.mag-lightbox-nav:disabled {
  opacity: .35; cursor: not-allowed;
}
.book-viewer img.mag-page-tap {
  cursor: zoom-in;
}
.list-meta { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .5rem; font-size: .8rem; color: var(--muted); }
.list-meta span {
  display: inline-flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 70%, white);
  border: 1px solid var(--line);
  border-radius: 999px; padding: .18rem .55rem; max-width: 100%;
}
.meta-date {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.admin-nav { display: flex; gap: .4rem; overflow: auto; padding-bottom: .35rem; margin-bottom: .75rem; }
.admin-nav a {
  white-space: nowrap; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: .42rem .8rem; font-size: .84rem;
}
.admin-nav a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.alert-banner {
  border-radius: 16px; padding: .9rem 1rem; margin-bottom: .85rem;
  border: 1px solid var(--line); background: var(--surface);
}
.alert-banner.important { border-color: color-mix(in srgb, var(--brand-warning) 45%, var(--line)); background: color-mix(in srgb, var(--brand-warning) 10%, white); }
.alert-banner.urgent, .alert-banner.emergency { border-color: color-mix(in srgb, var(--brand-danger) 45%, var(--line)); background: color-mix(in srgb, var(--brand-danger) 10%, white); }

.chip-row { display: flex; gap: .4rem; overflow: auto; padding-bottom: .2rem; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: .35rem .75rem; white-space: nowrap; font-size: .84rem; cursor: pointer;
}
.chip.active { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }

.membership-card {
  border-radius: 20px; padding: 1.2rem; color: #fff;
  background: linear-gradient(145deg, var(--brand-navy), color-mix(in srgb, var(--primary) 70%, #102A43));
  box-shadow: var(--shadow);
}
.membership-card .qr-slot {
  width: 72px; height: 72px; border-radius: 10px; background: rgba(255,255,255,.15);
  display: grid; place-items: center; font-size: .72rem; opacity: .85;
}

.demo-banner {
  margin: .85rem auto 0; width: min(980px, calc(100% - 1.4rem));
  background: color-mix(in srgb, var(--brand-gold) 18%, white);
  border: 1px solid color-mix(in srgb, var(--brand-gold) 40%, white);
  border-radius: 14px; padding: .75rem .95rem; color: #6b5318; font-weight: 600;
}

.color-swatch { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); display: inline-block; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

[data-theme-preview] {
  border-radius: 16px; padding: 1rem; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}

.preview-banner {
  margin: .75rem auto 0;
  width: min(980px, calc(100% - 1.4rem));
  background: color-mix(in srgb, var(--brand-warning) 14%, white);
  border: 1px solid color-mix(in srgb, var(--brand-warning) 35%, white);
  border-radius: 14px;
  padding: .7rem .95rem;
  color: #8a5a10;
  font-weight: 600;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.status-filter-nav { margin: .35rem 0 1rem; }

.staff-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .22rem .55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .72rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  min-height: 28px;
  background: color-mix(in srgb, var(--brand-navy) 10%, white);
  color: var(--brand-navy);
  border: 1px solid color-mix(in srgb, var(--brand-navy) 28%, white);
}
.staff-switch.to-app {
  background: color-mix(in srgb, var(--brand-success) 12%, white);
  color: var(--brand-success);
  border-color: color-mix(in srgb, var(--brand-success) 30%, white);
}

.powered-by {
  margin: 1.6rem 0 5.5rem;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .02em;
  opacity: .75;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.switch-track {
  width: 3rem;
  height: 1.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 35%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  position: relative;
  transition: background .2s ease, border-color .2s ease;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: transform .2s ease;
}
.switch input:checked + .switch-track {
  background: color-mix(in srgb, var(--brand-success) 75%, var(--primary));
  border-color: transparent;
}
.switch input:checked + .switch-track::after {
  transform: translateX(1.25rem);
}
html[dir="rtl"] .switch input:checked + .switch-track::after {
  transform: translateX(-1.25rem);
}
.switch input:disabled + .switch-track {
  opacity: .55;
}

.staff-msg-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 5rem;
}
@media (max-width: 800px) {
  .staff-msg-layout { grid-template-columns: 1fr; }
}
.staff-msg-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: min(70vh, 640px);
  overflow: auto;
  padding: .65rem;
}
.staff-conv {
  display: grid;
  gap: .2rem;
  text-align: start;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--surface) 88%, var(--primary));
  border-radius: 12px;
  padding: .7rem .8rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.staff-conv:hover { border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.staff-conv.active {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}
.staff-conv .muted { font-size: .82rem; }
.staff-conv .badge { justify-self: start; }
.staff-msg-thread {
  display: flex;
  flex-direction: column;
  min-height: min(70vh, 640px);
  padding: 0;
  overflow: hidden;
}
.staff-msg-head {
  padding: 1rem 1.1rem .7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.staff-msg-head h2 { margin: 0; font-size: 1.15rem; }
.staff-msg-bubbles {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  background: color-mix(in srgb, var(--bg, #f6f4f1) 70%, var(--surface));
}
.staff-bubble {
  max-width: min(92%, 420px);
  padding: .7rem .85rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
}
.staff-bubble.mine {
  align-self: flex-end;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 28%, transparent);
}
.staff-bubble.theirs { align-self: flex-start; }
.staff-bubble p { margin: .35rem 0 0; white-space: pre-wrap; word-break: break-word; }
.staff-bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .78rem;
  opacity: .8;
}
.staff-msg-compose {
  display: grid;
  gap: .65rem;
  padding: .85rem 1rem 1rem;
  border-top: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.staff-msg-compose textarea {
  width: 100%;
  resize: vertical;
  min-height: 4.5rem;
}
.staff-voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
}
.staff-voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.staff-voice-actions .btn {
  min-height: 2.2rem;
  padding: .35rem .75rem;
}
.staff-voice {
  display: grid;
  gap: .4rem;
  margin-top: .35rem;
}
.staff-voice-label { font-size: .86rem; font-weight: 600; }
.staff-voice audio {
  width: 100%;
  max-width: 280px;
  height: 36px;
}
