/* ==========================================================================
   BeeSync — mobile-first design system
   Deep navy canvas, honey accent. Every offset uses logical properties so the
   whole interface mirrors correctly when <html dir="rtl"> is set for Persian.
   Breakpoints: base = phone, 700px = large phone/tablet, 1000px = desktop.
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */
:root {
  /* surfaces */
  --bg: #070d1e;
  --bg-grad-1: rgba(245, 166, 35, .10);
  --bg-grad-2: rgba(64, 120, 220, .10);
  --surface: #0e1730;
  --surface-2: #141f3d;
  --surface-3: #1b2950;
  --input-bg: #091329;

  /* ink */
  --ink: #f6f8fd;
  --ink-2: #c6d0e6;
  --ink-3: #8b9ab8;
  --ink-4: #64738f;

  /* lines */
  --line: #21304f;
  --line-2: #2c3e64;
  --hairline: rgba(255, 255, 255, .07);

  /* brand + semantics */
  --honey: #f5a623;
  --honey-2: #ffc44d;
  --honey-soft: rgba(245, 166, 35, .14);
  --honey-line: rgba(245, 166, 35, .32);
  --on-honey: #21160a;
  --mint: #3ddc97;
  --mint-soft: rgba(61, 220, 151, .14);
  --coral: #ff7a6b;
  --coral-soft: rgba(255, 122, 107, .14);
  --sky: #5c9dff;
  --sky-soft: rgba(92, 157, 255, .14);
  --violet: #b98cff;
  --violet-soft: rgba(185, 140, 255, .14);

  /* radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r: 16px;
  --r-lg: 22px;
  --r-full: 999px;

  /* type — never smaller than 12px for real content */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 25px;
  --fs-3xl: 31px;

  /* space */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;

  /* elevation */
  --sh-1: 0 2px 8px rgba(2, 6, 20, .30);
  --sh-2: 0 10px 30px rgba(2, 6, 20, .40);
  --sh-3: 0 -14px 44px rgba(2, 6, 20, .55);

  /* chrome */
  --header-h: 58px;
  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap: 44px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* --- 2. Reset & base ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -6%, var(--bg-grad-1), transparent 26rem),
    radial-gradient(circle at 96% 68%, var(--bg-grad-2), transparent 24rem),
    var(--bg);
  color: var(--ink);
  color-scheme: dark;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Noto Sans Arabic", Vazirmatn, Tahoma, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
html[lang="fa"] body { line-height: 1.75; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: var(--honey-2); text-decoration: none; }
img, svg, video, audio { display: block; max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--honey-2); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: fixed; z-index: 999; inset-block-start: var(--s2); inset-inline-start: var(--s2);
  padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg); transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.muted { color: var(--ink-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- 3. Boot screen & Telegram gate ------------------------------------- */
.boot-screen, .access-gate {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center; align-content: center; gap: var(--s4);
  padding: max(var(--s6), var(--safe-top)) var(--s5) max(var(--s6), var(--safe-bottom));
  background: radial-gradient(circle at 50% 16%, rgba(245, 166, 35, .16), transparent 18rem), var(--bg);
}
.boot-screen { transition: opacity .22s var(--ease); }
body:not(.booting) .boot-screen { opacity: 0; pointer-events: none; }

.boot-mark, .gate-mark {
  width: 76px; height: 76px; border-radius: 24px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--surface);
  box-shadow: var(--sh-2), 0 0 0 5px rgba(245, 166, 35, .07);
}
.boot-mark { animation: breathe 2.2s ease-in-out infinite; }
.boot-mark img, .gate-mark img { width: 100%; height: 100%; object-fit: cover; }
@keyframes breathe { 50% { transform: translateY(-4px); } }

.boot-copy { display: grid; gap: 2px; text-align: center; }
.boot-copy strong { font-size: var(--fs-xl); }
.boot-copy span { color: var(--ink-3); font-size: var(--fs-sm); }

.gate-card {
  width: min(100%, 420px); padding: var(--s7) var(--s5) var(--s5);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-2); text-align: center;
}
.gate-mark { margin: 0 auto var(--s5); }
.gate-kicker {
  display: block; color: var(--honey-2);
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .12em;
}
.gate-card h1 { margin: var(--s3) 0 var(--s2); font-size: var(--fs-2xl); }
.gate-card > p { color: var(--ink-2); font-size: var(--fs-sm); }
.gate-steps { display: grid; gap: var(--s2); margin: var(--s5) 0 var(--s4); text-align: start; }
.gate-steps span {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--tap); padding: 10px var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-sm);
}
.gate-steps b {
  flex: 0 0 24px; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: var(--r-xs);
  background: var(--honey); color: var(--on-honey); font-size: var(--fs-xs);
}
.gate-seal {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  color: var(--ink-3); font-size: var(--fs-xs);
}
.gate-seal i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 0 4px var(--mint-soft);
}

/* --- 4. App shell ------------------------------------------------------- */
.app {
  display: flex; flex-direction: column; min-height: 100dvh;
  opacity: 1; transition: opacity .18s var(--ease);
}
.app[aria-hidden="true"] { opacity: 0; pointer-events: none; }

.topbar {
  position: sticky; inset-block-start: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--s2);
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--s4) 0;
  border-block-end: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
}
.topbar-lead { display: flex; align-items: center; gap: var(--s3); min-width: 0; flex: 1; }
.topbar-mark {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--hairline); background: var(--surface);
}
.topbar-mark img { width: 100%; height: 100%; object-fit: cover; }
.topbar-title { min-width: 0; display: grid; }
.topbar-title b {
  overflow: hidden; font-size: var(--fs-lg); font-weight: 700;
  white-space: nowrap; text-overflow: ellipsis;
}
.topbar-title small {
  overflow: hidden; color: var(--ink-3); font-size: var(--fs-xs);
  white-space: nowrap; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: var(--s2); }

.iconbtn {
  position: relative; flex: 0 0 auto;
  display: grid; place-items: center;
  width: var(--tap); height: var(--tap);
  border-radius: var(--r-sm); color: var(--ink-2);
  transition: background .15s var(--ease), transform .1s var(--ease);
}
.iconbtn:active { transform: scale(.93); }
.iconbtn:hover { background: var(--surface-2); }
.iconbtn svg { width: 21px; height: 21px; }
.iconbtn.solid { border: 1px solid var(--line); background: var(--surface); }
.iconbtn.danger { color: var(--coral); }
.iconbtn.danger:hover { background: var(--coral-soft); }

.bell-badge {
  position: absolute; inset-block-start: 4px; inset-inline-end: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border: 2px solid var(--bg); border-radius: var(--r-full);
  background: var(--coral); color: #fff; font-size: 10px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
/* 34px amber disc, 44px hit area — the disc is drawn behind the initial so the
   button itself can stay a full touch target. */
.avatar-btn {
  position: relative; isolation: isolate;
  flex: 0 0 var(--tap); width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  color: var(--on-honey); font-size: var(--fs-sm); font-weight: 800;
}
.avatar-btn::before {
  content: ""; position: absolute; z-index: -1;
  width: 34px; height: 34px; border-radius: var(--r-full); background: var(--honey);
}

/* content */
.view {
  flex: 1; min-width: 0;
  padding: var(--s4) var(--s4) calc(var(--nav-h) + var(--safe-bottom) + 84px);
  animation: viewIn .22s var(--ease) both;
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* bottom navigation */
.bottomnav {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 45;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-block-end: var(--safe-bottom);
  border-block-start: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(1.3);
}
.tab {
  display: grid; justify-items: center; align-content: center; gap: 3px;
  min-height: var(--nav-h); padding: var(--s2) 2px;
  color: var(--ink-4); font-size: 10px; font-weight: 700;
  transition: color .15s var(--ease);
}
.tab svg { width: 22px; height: 22px; }
.tab span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tab.active { color: var(--honey-2); }
.tab.active .tab-ico { background: var(--honey-soft); }
.tab-ico {
  display: grid; place-items: center;
  width: 42px; height: 28px; border-radius: var(--r-full);
  transition: background .18s var(--ease);
}
.tab:active .tab-ico { transform: scale(.9); }

/* floating create button */
.fab {
  position: fixed; z-index: 46;
  inset-inline-end: var(--s4);
  inset-block-end: calc(var(--nav-h) + var(--safe-bottom) + var(--s4));
  display: flex; align-items: center; gap: var(--s2);
  height: 52px; padding-inline: 18px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--honey-2), var(--honey));
  color: var(--on-honey); font-size: var(--fs-sm); font-weight: 800;
  box-shadow: 0 10px 26px rgba(245, 166, 35, .34);
  transition: transform .12s var(--ease);
}
.fab:active { transform: scale(.94); }
.fab svg { width: 20px; height: 20px; }

/* --- 5. Primitives ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: 700; text-align: center;
  transition: transform .1s var(--ease), background .15s var(--ease), opacity .15s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--honey-2), var(--honey)); color: var(--on-honey); box-shadow: 0 6px 18px rgba(245, 166, 35, .22); }
.btn-ghost { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-danger { border-color: rgba(255, 122, 107, .35); background: var(--coral-soft); color: var(--coral); }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-xs); }
.btn-lg { min-height: 52px; font-size: var(--fs-md); }
.btn-block { width: 100%; }

.card {
  padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--sh-1);
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.chip.honey { background: var(--honey-soft); color: var(--honey-2); }
.chip.mint, .chip.approved { background: var(--mint-soft); color: var(--mint); }
.chip.coral, .chip.denied { background: var(--coral-soft); color: var(--coral); }
.chip.sky { background: var(--sky-soft); color: var(--sky); }
.chip.pending { background: var(--honey-soft); color: var(--honey-2); }

.prio { padding: 3px 9px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; }
.prio.low { background: var(--surface-3); color: var(--ink-3); }
.prio.medium { background: var(--sky-soft); color: var(--sky); }
.prio.high { background: var(--honey-soft); color: var(--honey-2); }
.prio.urgent { background: var(--coral-soft); color: var(--coral); }

.avatar {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 800; text-transform: uppercase;
}
.avatar.honey { background: var(--honey-soft); color: var(--honey-2); }

/* section headers */
.sec-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3);
  margin-block: var(--s6) var(--s3);
}
.sec-head:first-child { margin-block-start: 0; }
.sec-head-copy { display: grid; gap: 1px; min-width: 0; }
.kicker { color: var(--honey-2); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.sec-head h3 { font-size: var(--fs-lg); }
.link-action {
  flex: 0 0 auto; min-height: 36px; padding-inline: var(--s2);
  color: var(--ink-3); font-size: var(--fs-xs); font-weight: 700;
}
.link-action:hover { color: var(--honey-2); }

/* page hero */
.hero {
  position: relative; overflow: hidden;
  padding: var(--s5) var(--s4);
  margin-block-end: var(--s5);
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(135deg, var(--surface-2), var(--surface) 70%);
}
.hero::after {
  content: ""; position: absolute;
  inset-block-start: -60px; inset-inline-end: -50px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, var(--honey-soft), transparent 70%);
}
.hero > * { position: relative; }
.hero h2 { margin-block: var(--s2) var(--s1); font-size: var(--fs-2xl); }
.hero p { color: var(--ink-3); font-size: var(--fs-sm); max-width: 48ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-block-start: var(--s4); }
.hero-actions .btn { flex: 1 1 auto; }

/* segmented control */
.segmented {
  display: flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg);
}
.segmented button {
  flex: 1; min-height: 38px; padding-inline: var(--s2);
  border-radius: 9px; color: var(--ink-3);
  font-size: var(--fs-xs); font-weight: 700;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button.active { background: var(--surface-3); color: var(--honey-2); }

/* scrolling filter chips */
.chiprow {
  display: flex; gap: var(--s2); overflow-x: auto;
  margin-inline: calc(var(--s4) * -1); padding-inline: var(--s4);
  padding-block-end: var(--s1);
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chiprow::-webkit-scrollbar { display: none; }
.chiprow button {
  flex: 0 0 auto; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); color: var(--ink-3);
  font-size: var(--fs-xs); font-weight: 700;
}
.chiprow button.active {
  border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2);
}
.chiprow button i {
  padding: 1px 6px; border-radius: var(--r-full);
  background: rgba(255, 255, 255, .08); font-style: normal;
  font-size: 11px; font-variant-numeric: tabular-nums;
}

/* form fields */
.field { display: grid; gap: 6px; margin-block-end: var(--s4); }
.field > label { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700; }
.field .hint { color: var(--ink-4); font-size: var(--fs-xs); }
input[type="text"], input[type="number"], input[type="date"], input[type="search"],
input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 12px var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink);
  font-size: var(--fs-md); /* 15px+ stops iOS zoom-on-focus */
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  border-color: var(--honey-line); background: var(--surface-2); outline: none;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
select {
  appearance: none;
  padding-inline-end: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-size: 6px 6px, 6px 6px;
  background-position: right 18px center, right 12px center;
  background-repeat: no-repeat;
}
html[dir="rtl"] select { background-position: left 18px center, left 12px center; }
/* The default file control is an unstyled grey OS button — give it the same
   language as the rest of the form. */
input[type="file"] {
  padding: 8px; font-size: var(--fs-sm); color: var(--ink-3); cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-inline-end: var(--s3); padding: 9px var(--s3);
  border: 1px solid var(--line-2); border-radius: var(--r-xs);
  background: var(--surface-3); color: var(--ink);
  font: inherit; font-weight: 700; font-size: var(--fs-xs); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

/* colour picker */
.colorpicks { display: flex; gap: var(--s2); flex-wrap: wrap; }
.colorpick {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 2px solid transparent; background: var(--pick);
  transition: transform .12s var(--ease);
}
.colorpick.active { border-color: var(--ink); transform: scale(1.06); }

/* lists */
.list { display: grid; gap: var(--s2); }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 64px; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); text-align: start;
}
.list-row:active { background: var(--surface-2); }
.list-copy { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list-copy b { overflow: hidden; font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.list-copy small { overflow: hidden; color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; }
.chev { flex: 0 0 18px; display: grid; place-items: center; color: var(--ink-4); }
.chev svg { width: 18px; height: 18px; }
html[dir="rtl"] .chev svg { transform: scaleX(-1); }

/* empty & loading states */
.empty {
  display: grid; justify-items: center; gap: var(--s2);
  padding: var(--s7) var(--s4);
  border: 1px dashed var(--line); border-radius: var(--r);
  text-align: center;
}
.empty-ico {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-block-end: var(--s2);
  border-radius: var(--r); background: var(--honey-soft); color: var(--honey-2);
}
.empty-ico svg { width: 26px; height: 26px; }
.empty b { font-size: var(--fs-md); }
.empty p { max-width: 34ch; color: var(--ink-3); font-size: var(--fs-sm); }
.empty .btn { margin-block-start: var(--s3); }
.empty.compact { padding: var(--s5) var(--s4); }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 45%, var(--surface) 65%);
  background-size: 250% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -250% 0; } }
.sk-line { height: 14px; }
.sk-block { height: 96px; }

.loading {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s6); color: var(--ink-3); font-size: var(--fs-sm);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--honey);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  display: grid; justify-items: center; gap: var(--s3);
  padding: var(--s6) var(--s4); text-align: center;
  border: 1px solid rgba(255, 122, 107, .3); border-radius: var(--r);
  background: var(--coral-soft);
}
.error-box p { color: var(--ink-2); font-size: var(--fs-sm); }

/* toast */
.toast {
  position: fixed; z-index: 300;
  inset-inline: var(--s4);
  inset-block-end: calc(var(--nav-h) + var(--safe-bottom) + var(--s4));
  display: flex; align-items: center; gap: var(--s3);
  padding: 13px var(--s4);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface-3); box-shadow: var(--sh-2);
  font-size: var(--fs-sm); font-weight: 600;
  opacity: 0; transform: translateY(16px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast i {
  flex: 0 0 22px; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-style: normal; font-size: 13px; font-weight: 900;
}
.toast[data-tone="success"] i { background: var(--mint-soft); color: var(--mint); }
.toast[data-tone="error"] i { background: var(--coral-soft); color: var(--coral); }
.toast[data-tone="warn"] i { background: var(--honey-soft); color: var(--honey-2); }

/* --- 6. Sheets (mobile) / dialogs (desktop) ----------------------------- */
.sheet-host {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.sheet-host.open { pointer-events: auto; }
.sheet-bg {
  position: absolute; inset: 0;
  background: rgba(3, 7, 20, .66); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s var(--ease);
}
.sheet-host.open .sheet-bg { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-height: 92dvh;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-block-end: 0;
  border-start-start-radius: var(--r-lg); border-start-end-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-3);
  transform: translateY(100%); transition: transform .28s var(--ease);
  overscroll-behavior: contain;
}
.sheet-host.open .sheet { transform: none; }
.sheet-grip {
  flex: 0 0 auto; padding: var(--s3) 0 var(--s1); display: grid; justify-items: center;
  cursor: grab; touch-action: none;
}
.sheet-grip span { width: 38px; height: 4px; border-radius: var(--r-full); background: var(--line-2); }
.sheet-head {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s2) var(--s4) var(--s3);
}
.sheet-head-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sheet-head h3 { font-size: var(--fs-lg); }
.sheet-head p { color: var(--ink-3); font-size: var(--fs-sm); }
.sheet-sym {
  flex: 0 0 42px; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: var(--r-sm);
  background: var(--honey-soft); color: var(--honey-2);
}
.sheet-sym svg { width: 22px; height: 22px; }
.sheet-body {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--s4) var(--s4);
  -webkit-overflow-scrolling: touch;
}
.sheet-foot {
  flex: 0 0 auto; display: flex; gap: var(--s2);
  padding: var(--s3) var(--s4) calc(var(--s4) + var(--safe-bottom));
  border-block-start: 1px solid var(--hairline);
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; min-height: 50px; }

/* confirm dialog */
.confirm-text { color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-line; }

/* --- 7. Home ------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
/* Each stat is a control that opens the screen behind the number. */
.stat {
  position: relative; overflow: hidden;
  display: grid; align-content: start; gap: 2px;
  width: 100%; min-height: 118px; padding: var(--s4) var(--s4) 34px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); text-align: start;
  transition: border-color .15s var(--ease), transform .12s var(--ease), background .15s var(--ease);
}
.stat:hover { border-color: color-mix(in srgb, var(--tone), var(--line) 55%); background: var(--surface-2); }
.stat:active { transform: scale(.98); }
.stat:focus-visible { outline: 2px solid var(--tone); outline-offset: 2px; }
.stat::before {
  content: ""; position: absolute;
  inset-block-start: -50px; inset-inline-end: -40px;
  width: 118px; height: 118px; border-radius: 50%;
  background: color-mix(in srgb, var(--tone), transparent 88%);
}
.stat-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.stat-ico {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--tone), transparent 86%);
  color: var(--tone);
}
.stat-ico svg { width: 18px; height: 18px; }
.stat strong { position: relative; margin-block-start: var(--s2); font-size: var(--fs-2xl); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label {
  position: relative; display: flex; align-items: center; gap: 4px;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700;
}
.stat-label .chev { flex-basis: 14px; color: var(--ink-4); }
.stat-label .chev svg { width: 14px; height: 14px; }
.stat:hover .stat-label .chev { color: var(--tone); }
.stat-note { position: relative; color: var(--ink-4); font-size: var(--fs-xs); }
.spark { position: absolute; inset-inline: 0; inset-block-end: 0; width: 100%; height: 40px; color: var(--tone); }
.spark polygon { fill: currentColor; opacity: .14; }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
.stat.honey { --tone: var(--honey); }
.stat.sky { --tone: var(--sky); }
.stat.coral { --tone: var(--coral); }
.stat.mint { --tone: var(--mint); }

.panel {
  padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s3); margin-block-end: var(--s3);
}
.panel-head h3 { font-size: var(--fs-lg); }

.legend { display: flex; gap: var(--s3); color: var(--ink-3); font-size: var(--fs-xs); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--honey); }
.legend .urgent i { background: var(--coral); }

.flow-summary { display: flex; gap: var(--s5); margin-block-end: var(--s2); color: var(--ink-3); font-size: var(--fs-xs); }
.flow-summary b { color: var(--ink); font-size: var(--fs-lg); margin-inline-end: 4px; }
.flow-chart svg { width: 100%; height: 150px; }
.flow-grid line { stroke: var(--line); stroke-width: 1; }
.flow-area { fill: rgba(245, 166, 35, .09); }
.flow-line { fill: none; stroke: var(--honey); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.flow-line.urgent { stroke: var(--coral); stroke-width: 2; stroke-dasharray: 7 7; }
.flow-dot { fill: var(--surface); stroke: var(--honey-2); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.flow-axis {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px;
  color: var(--ink-4); font-size: 10px; text-align: center;
}

.goal-ring {
  --goal: 0;
  width: 148px; aspect-ratio: 1; margin: var(--s3) auto;
  display: grid; place-items: center; border-radius: 50%;
  background: conic-gradient(var(--mint) calc(var(--goal) * 1%), var(--surface-3) 0);
  transform: rotate(-90deg);
}
.goal-ring::before {
  content: ""; grid-area: 1 / 1; width: 76%; aspect-ratio: 1;
  border-radius: 50%; background: var(--surface);
}
.goal-ring > div { grid-area: 1 / 1; z-index: 1; display: grid; text-align: center; transform: rotate(90deg); }
.goal-ring strong { font-size: var(--fs-2xl); line-height: 1.15; }
.goal-ring span { color: var(--ink-3); font-size: var(--fs-xs); }
.goal-split { display: grid; grid-template-columns: 1fr 1fr; border-block-start: 1px solid var(--hairline); margin: var(--s3) calc(var(--s4) * -1) calc(var(--s4) * -1); }
.goal-split span { padding: var(--s3); text-align: center; color: var(--ink-3); font-size: var(--fs-xs); }
.goal-split span + span { border-inline-start: 1px solid var(--hairline); }
.goal-split b { display: block; color: var(--ink); font-size: var(--fs-lg); }

.project-row {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 68px; padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); text-align: start;
}
.project-row::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 12px;
  width: 3px; border-radius: var(--r-full); background: var(--accent);
}
.project-row:active { background: var(--surface-2); }
.dept-ico {
  flex: 0 0 38px; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent), transparent 84%);
  color: var(--accent); font-size: var(--fs-md); font-weight: 800; text-transform: uppercase;
}

.focus-row {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 60px; padding: var(--s3) 0;
  border-block-end: 1px solid var(--hairline);
  color: var(--ink); text-align: start;
}
.focus-row:last-child { border-block-end: 0; }
.dot {
  flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--sky); box-shadow: 0 0 0 4px var(--sky-soft);
}
.dot.done { background: var(--mint); box-shadow: 0 0 0 4px var(--mint-soft); }
.dot.blocked { background: var(--coral); box-shadow: 0 0 0 4px var(--coral-soft); }
.dot.review { background: var(--violet); box-shadow: 0 0 0 4px var(--violet-soft); }
.dot.ideas { background: var(--honey); box-shadow: 0 0 0 4px var(--honey-soft); }

/* --- 8. Projects & board ------------------------------------------------ */
.project-card {
  position: relative; overflow: hidden;
  padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.project-card::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
  background: var(--accent);
}
.project-card-top { display: flex; align-items: center; gap: var(--s3); margin-block-end: var(--s3); }
.project-card-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.project-card-copy b { overflow: hidden; font-size: var(--fs-md); white-space: nowrap; text-overflow: ellipsis; }
.project-card-copy small { overflow: hidden; color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; }
.project-card-actions { display: flex; gap: var(--s2); }
.project-card-actions .btn { flex: 1; }

.board-hero {
  position: relative; overflow: hidden;
  padding: var(--s4);
  margin-block-end: var(--s4);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 74%);
  border-radius: var(--r);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 88%), var(--surface) 62%);
}
.board-hero h2 { margin-block: var(--s2) 2px; font-size: var(--fs-xl); }
.board-hero p { color: var(--ink-3); font-size: var(--fs-sm); }
.crumb { display: flex; align-items: center; gap: var(--s2); color: var(--ink-3); font-size: var(--fs-xs); }
.crumb .iconbtn { width: 34px; height: 34px; }
.crumb .iconbtn svg { width: 18px; height: 18px; }
html[dir="rtl"] .crumb .iconbtn svg { transform: scaleX(-1); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-block-end: var(--s4); }
.metric {
  display: grid; gap: 2px; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.metric span { color: var(--ink-3); font-size: 11px; }
.metric strong { font-size: var(--fs-xl); line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric small { color: var(--ink-4); font-size: 11px; }
.metric.mint strong { color: var(--mint); }
.metric.coral strong { color: var(--coral); }

.board-toolbar {
  display: flex; align-items: center; gap: var(--s2);
  margin-block-end: var(--s3);
}
.board-toolbar .segmented { flex: 1; }

/* Kanban — phone: one column at a time, chosen by the chip row above.
   Desktop: the classic multi-column board with native drag & drop.       */
.kanban { display: grid; gap: var(--s2); }
.kancol { display: grid; gap: var(--s2); align-content: start; }
.kancol-head { display: none; }

.task {
  position: relative;
  display: grid; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); text-align: start; width: 100%;
}
.task:active { background: var(--surface-2); }
.task.pending { border-color: var(--honey-line); }
.task-top { display: flex; align-items: flex-start; gap: var(--s2); }
.task-title { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: 600; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-3); font-size: 11px;
}
.tag svg { width: 12px; height: 12px; }
.tag.overdue { background: var(--coral-soft); color: var(--coral); }
.pend-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px var(--s2); border-radius: var(--r-xs);
  background: var(--honey-soft); color: var(--honey-2); font-size: 11px; font-weight: 700;
}
.pend-badge svg { width: 13px; height: 13px; }
.task-grip { display: none; }

.tasklist { display: grid; gap: var(--s2); }
.tasklist-row {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 60px; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); text-align: start;
}

/* task detail */
.detail-owner { display: flex; align-items: center; gap: var(--s2); }
.approve-bar {
  display: grid; gap: var(--s2);
  padding: var(--s3); margin-block-end: var(--s4);
  border: 1px solid var(--honey-line); border-radius: var(--r-sm);
  background: var(--honey-soft);
  color: var(--honey-2); font-size: var(--fs-sm); font-weight: 700;
}
.approve-bar .btnrow { display: flex; gap: var(--s2); }
.approve-bar .btn { flex: 1; }
.movechips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.movechip {
  min-height: 40px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 700;
}
.movechip.active { border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2); }
.tklog { display: grid; gap: var(--s2); max-height: 220px; overflow-y: auto; }
.act {
  padding: var(--s2) var(--s3);
  border-inline-start: 2px solid var(--line-2); border-radius: var(--r-xs);
  background: var(--input-bg); color: var(--ink-2); font-size: var(--fs-xs);
}
.act time { display: block; color: var(--ink-4); font-size: 11px; }
.proof-prev { display: grid; gap: var(--s2); }
.proof-prev img, .proof-prev video { width: 100%; border-radius: var(--r-sm); }

/* --- 9. Feed — a group chat, not a list of cards ------------------------ */
.chat { display: flex; flex-direction: column; gap: 2px; padding-block: var(--s2); }

.chat-day {
  align-self: center; margin-block: var(--s3) var(--s2);
  padding: 4px 12px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-3);
  font-size: var(--fs-xs); font-weight: 700;
}

.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; }
.msg.run-start { margin-block-start: var(--s2); }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 11px; font-weight: 800; text-transform: uppercase;
}
.msg-avatar.ghost { visibility: hidden; }

.bubble {
  position: relative; min-width: 0;
  padding: 7px 11px 5px;
  border-radius: var(--r);
  background: var(--surface-2);
  text-align: start; color: var(--ink);
}
/* Own messages need to be readable as "mine" at a glance. */
.msg.mine .bubble { background: #2f4372; }
/* Square off the corner nearest the avatar on the last bubble of a run —
   the same shape language Telegram uses for a message tail. */
.msg.run-end .bubble { border-end-start-radius: 6px; }
.msg.mine.run-end .bubble { border-end-start-radius: var(--r); border-end-end-radius: 6px; }
.bubble-author {
  display: block; margin-block-end: 2px;
  color: var(--honey-2); font-size: var(--fs-xs); font-weight: 800;
}
.msg.mine .bubble-author { color: var(--sky); }
.bubble-text {
  font-size: var(--fs-sm); line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
  /* User text can be Persian or English regardless of the interface language.
     plaintext resolves each paragraph's direction from its own first strong
     character, so punctuation lands on the correct side either way. */
  unicode-bidi: plaintext; text-align: start;
}
/* The meta floats into the last text line, so short messages stay compact. */
.bubble-meta {
  float: inline-end; margin-inline-start: var(--s2); margin-block-start: 4px;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink-4); font-size: 11px; white-space: nowrap;
}
.bubble-meta svg { width: 12px; height: 12px; color: var(--honey-2); }
.bubble.unread { box-shadow: inset 2px 0 0 var(--sky); }
html[dir="rtl"] .bubble.unread { box-shadow: inset -2px 0 0 var(--sky); }

.chat-empty { align-self: center; margin-block: var(--s7); text-align: center; }

/* composer pinned above the bottom navigation */
.composer {
  position: sticky; z-index: 30;
  inset-block-end: calc(var(--nav-h) + var(--safe-bottom));
  display: flex; align-items: flex-end; gap: var(--s2);
  padding: var(--s2) 0;
  margin-block-start: var(--s2);
  background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}
.composer textarea {
  unicode-bidi: plaintext; text-align: start;
  flex: 1; min-height: var(--tap); max-height: 140px;
  padding: 11px var(--s4); border-radius: var(--r-lg);
  background: var(--surface-2); resize: none; line-height: 1.4;
}
.composer-send {
  flex: 0 0 var(--tap); width: var(--tap); height: var(--tap);
  display: grid; place-items: center; border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--honey-2), var(--honey));
  color: var(--on-honey);
  box-shadow: 0 6px 16px rgba(245, 166, 35, .26);
  transition: transform .12s var(--ease), opacity .15s var(--ease);
}
.composer-send:disabled { opacity: .45; box-shadow: none; }
.composer-send:active { transform: scale(.92); }
.composer-send svg { width: 20px; height: 20px; }
html[dir="rtl"] .composer-send svg { transform: scaleX(-1); }
.composer-note {
  padding: var(--s3); margin-block-start: var(--s2);
  border: 1px dashed var(--line); border-radius: var(--r-sm);
  color: var(--ink-3); font-size: var(--fs-sm); text-align: center;
}
/* The feed has a composer instead of a floating button, and behaves like a
   chat: the column fills the viewport so a short conversation still sits just
   above the composer rather than floating in the middle of an empty screen. */
body[data-tab="feed"] .view {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--header-h) - var(--safe-top));
  padding-block-end: calc(var(--nav-h) + var(--safe-bottom) + var(--s3));
}
body[data-tab="feed"] #feedBody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
body[data-tab="feed"] .chat { flex: 1; justify-content: flex-end; }

.post {
  display: grid; gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.post-text {
  color: var(--ink-2); font-size: var(--fs-sm);
  white-space: pre-wrap; overflow-wrap: anywhere;
  unicode-bidi: plaintext; text-align: start;
}

.idea { display: flex; align-items: flex-start; gap: var(--s3); }
.vote-btn {
  flex: 0 0 54px; display: grid; justify-items: center; align-content: center; gap: 1px;
  width: 54px; min-height: 58px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink-3);
}
.vote-btn.voted { border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2); }
.vote-btn b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.vote-btn svg { width: 15px; height: 15px; }
.idea-body { flex: 1; min-width: 0; display: grid; gap: var(--s2); }

/* --- 10. Files: the explorer window ------------------------------------ */
.explorer {
  display: grid; grid-template-columns: minmax(0, 1fr);
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--sh-1);
}
.explorer-side { display: none; }
.explorer-main { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; min-width: 0; }

.explorer-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3); border-block-end: 1px solid var(--hairline);
  background: var(--surface-2);
}
.explorer-bar > .iconbtn svg { width: 18px; height: 18px; }
html[dir="rtl"] .explorer-bar > [data-back] svg { transform: scaleX(-1); }
.crumbs {
  flex: 1 1 160px; min-width: 0; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 14px), transparent);
}
.crumbs::-webkit-scrollbar { display: none; }
.crumb-item {
  flex: 0 0 auto; min-height: 36px; padding: 0 var(--s2); border-radius: var(--r-xs);
  color: var(--ink-3); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; max-width: 34ch;
  overflow: hidden; text-overflow: ellipsis; unicode-bidi: plaintext;
}
@media (hover: hover) { .crumb-item:hover { background: var(--surface-3); color: var(--ink); } }
.crumb-item[aria-current] { color: var(--ink); font-weight: 700; background: none; }
.project-crumb { display: inline-flex; align-items: center; gap: 6px; }
.project-crumb > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.project-crumb .chev { flex: 0 0 14px; display: grid; place-items: center; }
.project-crumb .chev svg, html[dir="rtl"] .project-crumb .chev svg { width: 14px; height: 14px; transform: rotate(90deg); }
.crumb-sep { flex: 0 0 14px; color: var(--ink-4); }
.crumb-sep svg { width: 14px; height: 14px; }
html[dir="rtl"] .crumb-sep svg { transform: scaleX(-1); }
.explorer-tools { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s2); margin-inline-start: auto; }
@media (max-width: 699px) {
  .explorer-tools { flex: 1 1 100%; margin-inline-start: 0; }
  .explorer-tools .view-switch { order: 9; margin-inline-start: auto; }
  .explorer-tools .compact-sm { width: 44px; min-width: 44px; padding: 0; justify-content: center; }
  .explorer-tools .compact-sm span { display: none; }
  .explorer-tools .lbl-long { display: none; }
}
.explorer-tools .btn { white-space: nowrap; }
.explorer-tools .view-switch { flex: 0 0 96px; }
@media (min-width: 700px) { .explorer-tools .lbl-short { display: none; } }
.view-switch {
  display: grid; grid-template-columns: repeat(2, 40px); justify-content: center;
  flex: 0 0 96px; inline-size: 96px; min-inline-size: 96px;
  gap: 2px; padding: 4px; overflow: visible;
}
.view-switch button {
  display: grid; place-items: center;
  inline-size: 40px; min-inline-size: 40px; min-height: 38px; padding: 0;
}
.view-switch svg { width: 17px; height: 17px; }

.explorer-cols { display: none; }

.explorer-body { position: relative; padding: var(--s2); }
.explorer-body.is-empty { padding: var(--s3); }
.explorer-body .empty { border: 0; background: none; padding-block: var(--s6); }

/* entries */
.entry {
  --i: 0;
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: var(--s3);
  width: 100%; min-height: 56px; padding: 6px var(--s2); border-radius: var(--r-sm);
  color: var(--ink); text-align: start;
  animation: entry-in .32s var(--ease) both; animation-delay: calc(var(--i) * 16ms);
}
.entry.file { grid-template-columns: minmax(0, 1fr) auto; padding: 0; gap: 0; }
.entry-main {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: var(--s3);
  min-width: 0; min-height: 56px; padding: 6px var(--s2); border-radius: var(--r-sm);
  color: var(--ink); text-align: start;
}
@media (hover: hover) { .entry.folder:hover, .entry-main:hover { background: var(--surface-2); } }
.entry.folder:active, .entry-main:active { background: var(--surface-3); }
.entry.folder:focus-visible, .entry-main:focus-visible, .entry-dl:focus-visible { outline: 2px solid var(--honey); outline-offset: -2px; }
.entry + .entry { border-block-start: 1px solid var(--hairline); }
.entry-glyph {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-3); color: var(--ink-3);
}
.entry-glyph svg { width: 21px; height: 21px; }
.entry-glyph.folder { background: var(--honey-soft); color: var(--honey-2); }
.entry-glyph.image { background: var(--sky-soft); color: var(--sky); }
.entry-glyph.video { background: var(--violet-soft); color: var(--violet); }
.entry-glyph.audio { background: var(--mint-soft); color: var(--mint); }
.entry-glyph.pdf { background: var(--coral-soft); color: var(--coral); }
.entry-name { min-width: 0; display: grid; gap: 2px; }
.entry-name b { overflow: hidden; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; text-overflow: ellipsis; unicode-bidi: plaintext; }
.entry-name small { overflow: hidden; color: var(--ink-4); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.entry-col { display: none; }
.entry-dl { width: 44px; height: 44px; margin-inline-end: 2px; }
.entry-dl svg { width: 18px; height: 18px; }
.entry .chev { margin-inline-end: 4px; }
@keyframes entry-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* icon view */
.explorer-body.mode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--s1); padding: var(--s3); }
.explorer-body.mode-grid.is-empty { display: block; }
.explorer-body.mode-grid .entry, .explorer-body.mode-grid .entry-main {
  grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; align-content: start;
  gap: var(--s2); min-height: 0; padding: var(--s3) var(--s2) var(--s2); border: 0;
}
.explorer-body.mode-grid .entry.file { position: relative; padding: 0; }
.explorer-body.mode-grid .entry-name small { display: none; }
.explorer-body.mode-grid .entry-glyph { width: 56px; height: 56px; border-radius: 16px; }
.explorer-body.mode-grid .entry-glyph svg { width: 30px; height: 30px; }
.explorer-body.mode-grid .entry-name { justify-items: center; width: 100%; text-align: center; }
.explorer-body.mode-grid .entry-name b {
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; word-break: break-word;
}
.explorer-body.mode-grid .entry-name small { white-space: normal; text-align: center; }
.explorer-body.mode-grid .chev { display: none; }
.explorer-body.mode-grid .entry-dl { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; width: 36px; height: 36px; }
.explorer-body.mode-grid .entry + .entry { border: 0; }

/* drag-and-drop onto a folder (pointer devices) */
.drop-veil {
  position: absolute; inset: var(--s2); display: none; place-items: center;
  border: 2px dashed var(--honey-line); border-radius: var(--r-sm);
  background: rgba(7, 13, 30, .82); color: var(--honey-2); font-weight: 700; font-size: var(--fs-sm);
  pointer-events: none;
}
.drop-veil span { display: inline-flex; align-items: center; gap: var(--s2); }
.drop-veil svg { width: 20px; height: 20px; }
.explorer-body.dragging .drop-veil { display: grid; }

.explorer-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding: var(--s2) var(--s3); border-block-start: 1px solid var(--hairline);
  background: var(--surface-2); color: var(--ink-3); font-size: var(--fs-xs); font-variant-numeric: tabular-nums;
}
.explorer-status > span:first-child { white-space: nowrap; }
.explorer-status .status-hint { flex: 1 1 100%; order: 3; color: var(--ink-4); }
.explorer-status .chip { margin-inline-start: auto; }

/* file details sheet */
.file-facts { display: grid; gap: 0; margin: 0 0 var(--s3); }
.file-facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s3); padding: var(--s2) 0; border-block-end: 1px solid var(--hairline); font-size: var(--fs-sm); }
.file-facts dt { color: var(--ink-3); }
.file-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; unicode-bidi: plaintext; }
.file-audio { width: 100%; height: 40px; margin-block: var(--s2) var(--s3); }
.btn-ghost.danger { color: var(--coral); border-color: rgba(255, 122, 107, .35); }
.btn-ghost.danger:hover { background: var(--coral-soft); }
.menu-action.danger { color: var(--coral); }
.menu-action.danger > span { background: var(--coral-soft); color: var(--coral); }

/* the explorer's own scrollbar, tinted from the palette */
.explorer-body, .explorer-side { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.explorer-body::-webkit-scrollbar, .explorer-side::-webkit-scrollbar { width: 8px; }
.explorer-body::-webkit-scrollbar-thumb, .explorer-side::-webkit-scrollbar-thumb { border-radius: 8px; background: var(--line-2); }

@media (min-width: 700px) {
  .explorer-cols {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) 130px 96px 120px 48px; align-items: center; gap: var(--s3);
    padding: 6px var(--s4); border-block-end: 1px solid var(--hairline);
    color: var(--ink-4); font-size: 11px; font-weight: 700; letter-spacing: .02em;
  }
  .explorer-cols .entry-glyph { display: block; width: 40px; height: 0; }
  .explorer-cols .entry-col { display: block; }
  .explorer-body.mode-list .entry { grid-template-columns: 40px minmax(0, 1fr) 130px 96px 120px 48px; min-height: 50px; padding-inline: var(--s2); }
  .explorer-body.mode-list .entry.file { grid-template-columns: minmax(0, 1fr) 48px; }
  .explorer-body.mode-list .entry-main { grid-template-columns: 40px minmax(0, 1fr) 130px 96px 120px; min-height: 50px; }
  .explorer-body.mode-list .entry-name small { display: none; }
  .explorer-body.mode-list .entry-col { display: block; overflow: hidden; color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
  .explorer-body.mode-list .entry .chev { justify-self: center; }
  .explorer-body.mode-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
  .explorer-status .status-hint { flex: 0 1 auto; order: 0; }
}

@media (min-width: 1000px) {
  .explorer { grid-template-columns: 220px minmax(0, 1fr); min-height: 560px; max-height: calc(100dvh - 140px); }
  .explorer-side {
    display: flex; flex-direction: column; gap: 1px; overflow-y: auto;
    padding: var(--s3) var(--s2); border-inline-end: 1px solid var(--hairline); background: var(--surface-2);
  }
  .tree-item {
    display: flex; align-items: center; gap: var(--s2);
    min-height: 34px; padding: 0 var(--s2); padding-inline-start: calc(var(--s2) + var(--depth, 0) * 14px);
    border-radius: var(--r-xs); color: var(--ink-2); font-size: var(--fs-sm); text-align: start;
  }
  .tree-item svg { flex: 0 0 16px; width: 16px; height: 16px; color: var(--honey-2); }
  .tree-item span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; unicode-bidi: plaintext; }
  .tree-item.root { margin-block-end: var(--s2); font-weight: 700; color: var(--ink); }
  .tree-item.root svg { color: var(--ink-3); }
  .tree-item:hover { background: var(--surface-3); }
  .tree-item.active { background: var(--honey-soft); color: var(--ink); }
  .explorer-body { overflow-y: auto; }
}

.perm-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) 0; border-block-end: 1px solid var(--hairline);
}
.perm-row:last-child { border-block-end: 0; }
.perm-who { flex: 1; min-width: 0; display: grid; gap: 1px; }
.perm-who b { overflow: hidden; font-size: var(--fs-sm); white-space: nowrap; text-overflow: ellipsis; }
.perm-who small { color: var(--ink-4); font-size: var(--fs-xs); }
.perm-row { flex-wrap: wrap; }
.perm-row .choice { display: contents; }
.perm-row .choice-btn { width: auto; min-width: 132px; min-height: 40px; padding-block: 8px; font-size: var(--fs-xs); }
.perm-row .choice-menu { flex: 1 0 100%; margin-block: var(--s1) var(--s2); }

/* Choice: the app's dropdown (see choiceField in core.js) */
.choice { min-width: 0; }
.choice-btn {
  display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 48px;
  padding: 12px var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink); font-size: var(--fs-md); text-align: start;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.choice-btn .choice-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-btn .chev svg, html[dir="rtl"] .choice-btn .chev svg { transform: rotate(90deg); transition: transform .15s var(--ease); }
.choice.open .choice-btn { border-color: var(--honey-line); background: var(--surface-2); }
.choice.open .choice-btn .chev svg, html[dir="rtl"] .choice.open .choice-btn .chev svg { transform: rotate(-90deg); }
.choice-btn:disabled { opacity: .55; cursor: default; }
.choice-btn:focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }
.choice-menu {
  display: grid; gap: 2px; margin-block-start: var(--s2); padding: var(--s1);
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  max-height: 44vh; overflow-y: auto; overscroll-behavior: contain;
}
.choice-menu [role="option"] {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-xs);
  background: transparent; color: var(--ink); font-size: var(--fs-sm); text-align: start;
}
.choice-menu [role="option"]:hover { background: var(--surface-3); }
.choice-menu [role="option"][aria-selected="true"] { background: var(--honey-soft); color: var(--honey-2); font-weight: 700; }
.choice-menu [role="option"][aria-selected="true"]::after { content: "✓"; font-size: 13px; }

.upload-tabs { display: flex; gap: var(--s2); margin-block-end: var(--s4); }
.upload-tabs button {
  flex: 1; min-height: 42px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--input-bg);
  color: var(--ink-3); font-size: var(--fs-sm); font-weight: 700;
}
.upload-tabs button.active { border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2); }

.voice-box {
  display: grid; gap: var(--s3); padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); text-align: center;
}
.voice-status { display: flex; align-items: center; justify-content: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 700; }
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-4); }
.voice-status[data-phase="recording"] .voice-dot { background: var(--coral); animation: pulse 1s ease-in-out infinite; }
.voice-status[data-phase="recorded"] .voice-dot { background: var(--mint); }
@keyframes pulse { 50% { opacity: .3; } }
.voice-clock { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.voice-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }
.voice-preview { width: 100%; }

.upload-progress { height: 4px; overflow: hidden; border-radius: var(--r-full); background: var(--surface-3); }
.upload-progress span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--honey); animation: indeterminate 1.1s ease-in-out infinite; }
@keyframes indeterminate { 0% { margin-inline-start: -40%; } 100% { margin-inline-start: 100%; } }
/* A multi-file batch reports real progress, so the sweep stops and the bar fills. */
.upload-progress.determinate span { width: 100%; animation: none; transform: scaleX(0); transform-origin: 0 50%; transition: transform .25s ease; }
[dir="rtl"] .upload-progress.determinate span { transform-origin: 100% 50%; }
/* The real input is kept in the tree but off-screen so the label activates
   it natively; JS never has to call click() on it. */
.pick-bar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.pick-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pick-bar .btn { cursor: pointer; }
.pick-count { font-size: var(--fs-sm); color: var(--ink-3); }
.pick-list { list-style: none; margin: calc(var(--s2) * -1) 0 var(--s3); padding: 0; display: grid; gap: 2px; }
.pick-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: 6px var(--s2); border-radius: var(--r-xs); background: var(--surface-3);
  font-size: var(--fs-xs); color: var(--ink-2);
}
.pick-list li b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; unicode-bidi: plaintext; }
.pick-list li small { flex: none; color: var(--ink-3); margin-inline-start: auto; }
.pick-list li .iconbtn { flex: none; width: 36px; height: 36px; min-height: 36px; margin: -6px -4px; }

/* --- 11. Finance & operations ------------------------------------------- */
.fin-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.fin-metric {
  display: grid; gap: 2px; padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.fin-metric span { color: var(--ink-3); font-size: var(--fs-xs); }
.fin-metric strong { font-size: var(--fs-xl); line-height: 1.15; color: var(--tone, var(--ink)); font-variant-numeric: tabular-nums; }
.fin-metric small { color: var(--ink-4); font-size: 11px; }
.fin-metric.honey { --tone: var(--honey-2); }
.fin-metric.sky { --tone: var(--sky); }
.fin-metric.coral { --tone: var(--coral); }
.fin-metric.mint { --tone: var(--mint); }

.gauge { display: grid; gap: var(--s2); }
.gauge-top { display: flex; align-items: baseline; justify-content: space-between; color: var(--ink-3); font-size: var(--fs-xs); }
.gauge-top b { color: var(--ink); font-size: var(--fs-lg); }
.gauge-track { height: 8px; overflow: hidden; border-radius: var(--r-full); background: var(--surface-3); }
.gauge-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--honey), var(--honey-2)); }
html[dir="rtl"] .gauge-track i { background: linear-gradient(270deg, var(--honey), var(--honey-2)); }

.fin-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center;
  gap: var(--s3); padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.fin-ico {
  flex: 0 0 38px; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--honey-soft); color: var(--honey-2);
}
.fin-ico.budget { background: var(--sky-soft); color: var(--sky); }
.fin-ico svg { width: 19px; height: 19px; }
.fin-copy { min-width: 0; display: grid; gap: 1px; }
.fin-copy b {
  font-size: var(--fs-sm); overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.fin-copy small { overflow: hidden; color: var(--ink-4); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; }
.fin-amount { text-align: end; font-size: var(--fs-md); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-amount small { display: block; color: var(--ink-4); font-size: 10px; font-weight: 600; }
.fin-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.fin-foot > .fin-status, .fin-foot > a.btn { flex: 0 0 auto; }
.fin-foot .decide { display: flex; flex: 1 1 180px; gap: var(--s2); }
.fin-foot .decide .btn { flex: 1; }
.fin-status { padding: 4px 10px; border-radius: var(--r-full); font-size: 11px; font-weight: 700; }
.fin-status.pending { background: var(--honey-soft); color: var(--honey-2); }
.fin-status.approved { background: var(--mint-soft); color: var(--mint); }
.fin-status.denied { background: var(--coral-soft); color: var(--coral); }

.info-box {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); margin-block-end: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.info-box > div { flex: 1; min-width: 0; display: grid; gap: 1px; }
.info-box b { font-size: var(--fs-sm); }
.info-box small { color: var(--ink-3); font-size: var(--fs-xs); }
.info-ico {
  flex: 0 0 36px; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--honey-soft); color: var(--honey-2);
}
.info-ico svg { width: 18px; height: 18px; }

.routine {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.routine.done { opacity: .62; }
.routine.done .routine-copy b { text-decoration: line-through; }
/* 30px checkbox, 44px hit area — the box is a pseudo-element so the button
   itself stays a full touch target. */
.routine-check {
  position: relative; isolation: isolate;
  flex: 0 0 var(--tap); width: var(--tap); height: var(--tap);
  display: grid; place-items: center; color: transparent;
}
.routine-check::before {
  content: ""; position: absolute; z-index: -1;
  width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--line-2);
}
.routine.done .routine-check { color: var(--on-honey); }
.routine.done .routine-check::before { border-color: var(--mint); background: var(--mint); }
.routine-check svg { width: 16px; height: 16px; }
.routine-copy { flex: 1; min-width: 0; display: grid; gap: 1px; }
.routine-copy b { font-size: var(--fs-sm); }
.routine-copy small { color: var(--ink-4); font-size: var(--fs-xs); }

.request-item {
  display: grid; gap: var(--s2); padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.request-top { display: flex; align-items: center; gap: var(--s2); }
.request-top .chip { flex: 0 0 auto; }
.request-text {
  color: var(--ink-2); font-size: var(--fs-sm);
  white-space: pre-wrap; overflow-wrap: anywhere;
  unicode-bidi: plaintext; text-align: start;
}

.meeting {
  display: grid; gap: var(--s2); padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.meeting-head { display: flex; align-items: center; gap: var(--s3); }
.meet-note {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  background: var(--input-bg); font-size: var(--fs-sm);
}
.meet-note span { flex: 1; min-width: 0; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.type-card {
  display: grid; justify-items: start; gap: 2px;
  min-height: 100px; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink); text-align: start;
}
.type-card > span {
  display: grid; place-items: center;
  width: 34px; height: 34px; margin-block-end: var(--s1);
  border-radius: 11px; background: var(--honey-soft); color: var(--honey-2);
}
.type-card svg { width: 18px; height: 18px; }
.type-card b { font-size: var(--fs-sm); }
.type-card small { color: var(--ink-3); font-size: var(--fs-xs); }

/* --- 12. Organizations -------------------------------------------------- */
.company-card {
  display: grid; gap: var(--s3); padding: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.company-card.current { border-color: var(--honey-line); }
.company-top { display: flex; align-items: center; gap: var(--s3); }
.company-copy { flex: 1; min-width: 0; display: grid; gap: 1px; }
.company-copy h3 { overflow: hidden; font-size: var(--fs-md); white-space: nowrap; text-overflow: ellipsis; }
.company-copy small { color: var(--ink-4); font-size: var(--fs-xs); }
.company-stats { display: flex; flex-wrap: wrap; gap: var(--s3); color: var(--ink-3); font-size: var(--fs-xs); }
.company-stats b { color: var(--ink); }
.company-cmd {
  display: block; padding: var(--s2) var(--s3);
  border: 1px dashed var(--line-2); border-radius: var(--r-xs);
  background: var(--input-bg); color: var(--honey-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs);
  direction: ltr; text-align: start;
}
.company-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

/* Invite sheet */
.invite-rules { margin: var(--s2) 0 var(--s4); padding-inline-start: 18px; display: grid; gap: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.invite-result { display: grid; gap: var(--s2); padding-block-start: var(--s2); border-block-start: 1px solid var(--line); }
.invite-link {
  width: 100%; padding: var(--s2) var(--s3); resize: none;
  border: 1px dashed var(--line-2); border-radius: var(--r-xs);
  background: var(--input-bg); color: var(--honey-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); line-height: 1.5;
  direction: ltr; text-align: start; word-break: break-all;
}
.invite-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.company-actions .btn { min-height: 40px; }

/* --- 13. Bell, menu, search --------------------------------------------- */
.bell-item {
  display: grid; gap: var(--s2); padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg);
}
.bell-top { display: flex; align-items: flex-start; gap: var(--s3); }
.bell-ico {
  flex: 0 0 34px; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--sky-soft); color: var(--sky);
}
.bell-ico.approve { background: var(--honey-soft); color: var(--honey-2); }
.bell-ico svg { width: 17px; height: 17px; }
.bell-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bell-copy b { font-size: var(--fs-sm); font-weight: 600; }
.bell-copy small { color: var(--ink-4); font-size: var(--fs-xs); }
.bell-actions { display: flex; gap: var(--s2); }
.bell-actions .btn { flex: 1; }

.menu-profile {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3); margin-block-end: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg);
}
.menu-profile .avatar { width: 44px; height: 44px; font-size: var(--fs-lg); }
.menu-profile > div { flex: 1; min-width: 0; display: grid; gap: 1px; }
.menu-profile b { overflow: hidden; font-size: var(--fs-md); white-space: nowrap; text-overflow: ellipsis; }
.menu-profile small { overflow: hidden; color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; }

.menu-group { display: block; margin-block: var(--s4) var(--s2); color: var(--ink-4); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.menu-tile {
  display: grid; justify-items: start; gap: 2px;
  min-height: 92px; padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink); text-align: start;
}
.menu-tile.active { border-color: var(--honey-line); background: var(--honey-soft); }
.menu-tile > span {
  display: grid; place-items: center;
  width: 34px; height: 34px; margin-block-end: var(--s1);
  border-radius: 11px; background: var(--surface-3); color: var(--honey-2);
}
.menu-tile.active > span { background: rgba(255, 255, 255, .1); }
.menu-tile svg { width: 18px; height: 18px; }
.menu-tile b { font-size: var(--fs-sm); }
.menu-tile small { overflow: hidden; color: var(--ink-3); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }

.menu-actions { display: grid; gap: var(--s2); }
.menu-action {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 52px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg); color: var(--ink); text-align: start;
}
.menu-action > span {
  flex: 0 0 32px; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--honey-soft); color: var(--honey-2);
}
.menu-action svg { width: 17px; height: 17px; }
.menu-action b { flex: 1; font-size: var(--fs-sm); }

.lang-switch { display: flex; gap: var(--s2); }
.lang-switch button {
  flex: 1; min-height: 46px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--input-bg);
  color: var(--ink-3); font-size: var(--fs-sm); font-weight: 700;
}
.lang-switch button.active { border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2); }

.search-field {
  display: flex; align-items: center; gap: var(--s2);
  padding-inline: var(--s3); margin-block-end: var(--s3);
  border: 1px solid var(--honey-line); border-radius: var(--r-sm);
  background: var(--input-bg);
}
.search-field svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--honey-2); }
.search-field input { border: 0; background: transparent; padding-inline: 0; }
.search-field input:focus { background: transparent; }
.search-group { display: block; margin-block: var(--s3) var(--s2); color: var(--ink-4); font-size: 11px; font-weight: 800; letter-spacing: .08em; }

.picker-list {
  max-height: 240px; overflow-y: auto;
  display: grid; gap: var(--s2);
  padding: var(--s2); margin-block-end: var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--input-bg);
}
.files-project-list { max-height: min(52dvh, 420px); margin-block-end: 0; }
.picker-item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: 52px; padding: var(--s2) var(--s3);
  border: 1px solid transparent; border-radius: var(--r-xs);
  color: var(--ink); text-align: start;
}
.picker-item.active { border-color: var(--honey-line); background: var(--honey-soft); }
.picker-item .cb {
  flex: 0 0 22px; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 7px;
  border: 2px solid var(--line-2); color: var(--honey-2);
}
.picker-item.active .cb { border-color: var(--honey-2); }
.picker-item .cb svg { width: 14px; height: 14px; }
.picker-copy { flex: 1; min-width: 0; display: grid; gap: 1px; }
.picker-copy b { overflow: hidden; font-size: var(--fs-sm); white-space: nowrap; text-overflow: ellipsis; }
.picker-copy small { overflow: hidden; color: var(--ink-4); font-size: var(--fs-xs); white-space: nowrap; text-overflow: ellipsis; }

/* --- 14. Large phones / tablets ----------------------------------------- */
@media (min-width: 700px) {
  .view { padding-inline: var(--s6); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .fin-metrics { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .type-grid { grid-template-columns: repeat(4, 1fr); }
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
  .company-actions { grid-template-columns: repeat(3, 1fr); }
  .sheet {
    width: min(560px, 100%); max-height: 88dvh; margin-block-end: var(--s5);
    border-radius: var(--r-lg); border-block-end: 1px solid var(--line);
  }
  .sheet-host { align-items: center; padding: var(--s4); }
  .sheet-foot { padding-block-end: var(--s4); }
  .toast { inset-inline: auto var(--s5); min-width: 320px; }
}

/* --- 15. Desktop -------------------------------------------------------- */
@media (min-width: 1000px) {
  :root { --nav-h: 0px; }

  .app {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-areas: "side head" "side main";
    grid-template-rows: auto 1fr;
    max-width: 1500px; margin-inline: auto;
  }
  .topbar {
    grid-area: head;
    min-height: 68px; padding-inline: var(--s6);
  }
  .topbar-mark, .topbar .avatar-btn { display: none; }
  .view { grid-area: main; padding: var(--s6) var(--s6) var(--s8); }

  .bottomnav {
    grid-area: side; position: sticky; inset-block-start: 0; inset-inline: auto;
    align-self: start; height: 100dvh;
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--s5) var(--s3);
    border-block-start: 0; border-inline-end: 1px solid var(--hairline);
    background: none; backdrop-filter: none;
  }
  .bottomnav::before {
    content: ""; display: block; height: 46px; margin-block-end: var(--s5);
    background: url("/static/brand/beesync-logo.jpg") center / 34px 34px no-repeat;
    border-radius: 11px;
  }
  html[dir="rtl"] .bottomnav::before { background-position: right center; }
  html[dir="ltr"] .bottomnav::before { background-position: left center; }
  .tab {
    grid-auto-flow: column; justify-items: start; justify-content: start;
    gap: var(--s3); min-height: 46px; padding-inline: var(--s3);
    border-radius: var(--r-sm); font-size: var(--fs-sm);
  }
  .tab .tab-ico { width: 24px; height: 24px; background: none !important; }
  .tab.active { background: var(--honey-soft); }
  .tab:hover:not(.active) { background: var(--surface-2); }

  .fab { inset-block-end: var(--s6); inset-inline-end: var(--s6); }

  .grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: var(--s4); }
  .stat { min-height: 138px; }
  .flow-chart svg { height: 200px; }
  .goal-ring { width: 180px; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .company-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 200px)); }

  /* real multi-column Kanban with drag & drop */
  .kanban.multi {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr);
    gap: var(--s3); overflow-x: auto; padding-block-end: var(--s3);
    align-items: start;
  }
  .kanban.multi .kancol {
    padding: var(--s3); border: 1px solid var(--line);
    border-radius: var(--r); background: color-mix(in srgb, var(--surface) 60%, transparent);
    min-height: 140px;
  }
  .kanban.multi .kancol-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s2); padding-block-end: var(--s2);
    color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700;
  }
  .kanban.multi .kancol-head i {
    padding: 1px 8px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--ink-3);
    font-style: normal; font-size: 11px;
  }
  .kanban.multi .kancol.drop-hover { border-color: var(--honey-line); background: var(--honey-soft); }
  .kanban.multi .task { cursor: grab; }
  .kanban.multi .task.dragging { opacity: .4; }
  .kanban.multi .task-grip {
    display: grid; place-items: center; width: 26px; height: 26px;
    color: var(--ink-4); cursor: grab;
  }
  .kanban.multi .task-grip svg { width: 15px; height: 15px; }
  .col-chips { display: none; }
}

/* --- 16. Print-safe / misc ---------------------------------------------- */
/* Column utilities. The base case is the phone: one column, always spaced.
   The media queries below only add columns — never the gap, or the panels
   weld together on small screens. */
.grid-2, .project-grid, .company-grid { display: grid; gap: var(--s3); align-items: start; }

.access-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin-block: var(--s4); }
.access-tabs .btn { min-width: 0; white-space: normal; text-align: center; justify-content: center; }
.access-tabs .btn.active { border-color: var(--honey-line); background: var(--honey-soft); color: var(--honey-2); }
.access-help { margin: 0 0 var(--s3); color: var(--ink-3); font-size: var(--fs-sm); line-height: 1.6; }
.access-role-group { margin-block: var(--s4); }
.access-role-group h4 { margin: 0 0 var(--s3); color: var(--ink-2); font-size: var(--fs-sm); }
.access-list { display: grid; gap: var(--s3); }
.access-card { display: grid; gap: var(--s3); min-width: 0; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.access-card.disabled { opacity: .55; }
.access-card p { margin: 0; font-size: var(--fs-sm); }
.access-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.access-role-pill { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r-xs); padding: 4px; }
.access-role-pill small { color: var(--ink-4); font-size: var(--fs-xs); }
.access-pill-remove { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-xs); color: var(--ink-3); background: transparent; cursor: pointer; }
.access-pill-remove:hover, .access-pill-remove:focus-visible { color: var(--danger); background: var(--input-bg); }
.access-pill-remove svg { width: 16px; height: 16px; }
.access-key { min-width: 0; color: var(--ink-4); font-size: var(--fs-xs); }
.access-key summary { cursor: pointer; }
.access-key code { display: block; margin-top: var(--s2); overflow-wrap: anywhere; }
.access-picker-head, .access-reach { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.access-picker-head small { color: var(--ink-4); }
.access-permission-picker { max-height: 50vh; overflow: auto; }
.access-effective-list { display: grid; gap: var(--s2); }
@media (min-width: 700px) { .access-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } .access-tabs { display: flex; } }

.stack { display: grid; gap: var(--s3); }
.stack-sm { display: grid; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.mb0 { margin-block-end: 0; }
.mt3 { margin-block-start: var(--s3); }

/* --- 17. Diagnostics ------------------------------------------------------
   A readable crash log for phones, where no developer console exists. */
.diag-device { display: grid; gap: 2px; margin-block-end: var(--s2); }
.diag-device > div {
  display: flex; gap: var(--s3); align-items: baseline;
  padding: 6px var(--s3);
  border-radius: var(--r-xs); background: var(--input-bg);
}
.diag-device span { flex: 0 0 84px; color: var(--ink-4); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.diag-device b { flex: 1; min-width: 0; font-size: var(--fs-xs); font-weight: 600; overflow-wrap: anywhere; }

.diag-list { display: grid; gap: var(--s2); }
.diag-row {
  display: grid; gap: 2px; padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  background: var(--input-bg);
}
/* Severity reads from a status dot, the same cue the rest of the app uses. */
.diag-row time {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-4); font-size: 11px; font-variant-numeric: tabular-nums;
}
.diag-row time::before {
  content: ""; flex: 0 0 6px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--ink-4);
}
.diag-row.error time::before { background: var(--coral); }
.diag-row.info time::before { background: var(--sky); }
.diag-row b { font-size: var(--fs-xs); font-weight: 700; overflow-wrap: anywhere; }
.diag-row span { color: var(--ink-3); font-size: 11px; overflow-wrap: anywhere; }

/* Shown only when the clipboard API is unavailable, so the report can still
   be selected and copied by hand. */
.diag-text {
  margin-block-start: var(--s3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; direction: ltr; text-align: start;
}
