@font-face { font-family: Vazirmatn; src: url(/admin/fonts/Vazirmatn-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/admin/fonts/Vazirmatn-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --primary: #00696b; --primary-weak: #e0f0f0; --bg: #f4f6fb; --surface: #fff; --text: #172033; --muted: #5d6a7e;
  --border: #e4e9f2; --danger: #c62828; --danger-weak: #fde8e8; --warn: #b26a00; --ok: #2e7d32; --info: #1565c0;
  --radius: 16px; --shadow: 0 1px 2px rgba(23, 32, 51, .04), 0 6px 20px rgba(23, 32, 51, .05);
}
@media (prefers-color-scheme: dark) {
  :root { --primary: #4cd9db; --primary-weak: #1f3535; --bg: #0e1218; --surface: #171d26; --text: #e6ecf5; --muted: #9aa7ba;
    --border: #273040; --danger: #ff8a80; --danger-weak: #3a2222; --warn: #ffb74d; --ok: #81c784; --info: #90caf9; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Vazirmatn, Tahoma, sans-serif; font-size: 15px; line-height: 1.8; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 48px 16px; }

/* layout */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--primary); font-size: 18px; margin-left: 8px; }
.spacer { flex: 1; }
.tabs { display: none; gap: 4px; padding: 8px 16px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 20px; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: var(--primary-weak); color: var(--primary); font-weight: 700; }
main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 64px; }
h2 { font-size: 20px; margin: 4px 0 16px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; }
.stat.danger b { color: var(--danger); } .stat.warn b { color: var(--warn); } .stat.ok b { color: var(--ok); } .stat.info b { color: var(--info); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

/* controls */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 20px; cursor: pointer; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #fff; } }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
input:not([type]), input[type=text], input[type=password], input[type=tel], input[type=search], input[type=date], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 2px; }
.form-error { background: var(--danger-weak); color: var(--danger); padding: 8px 12px; border-radius: 10px; margin-top: 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 700; background: var(--bg); position: sticky; top: 0; }
tr:hover td { background: color-mix(in srgb, var(--primary-weak) 40%, transparent); }
.chip { display: inline-block; padding: 1px 10px; border-radius: 12px; font-size: 12px; background: var(--primary-weak); color: var(--primary); white-space: nowrap; }
.chip.danger { background: var(--danger-weak); color: var(--danger); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.muted { background: var(--bg); color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; }

/* modal & toast */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 20; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 20px; padding: 20px; width: min(560px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; flex-direction: row-reverse; }
.toast { position: fixed; bottom: 24px; right: 50%; transform: translateX(50%); background: #263232; color: #fff; padding: 10px 20px; border-radius: 22px; z-index: 30; box-shadow: 0 4px 16px rgba(0,0,0,.3); }

/* login */
.login { max-width: 400px; margin: 10vh auto; }
.login h1 { color: var(--primary); text-align: center; margin: 0 0 4px; }
.seg { display: flex; background: var(--bg); border-radius: 22px; padding: 4px; margin: 16px 0; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 12px; border-radius: 18px; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--primary); font-weight: 700; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.list-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.list-item:hover { background: var(--bg); }
.list-item.active { border-color: var(--primary); background: var(--primary-weak); }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 150px); min-height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
/* Phones: one panel at a time — the list, or the open conversation with a back button. */
.chat-back { display: none; }
@media (max-width: 800px) {
  .chat { grid-template-columns: 1fr; border-radius: 0; border-left: 0; border-right: 0; }
  .chat-list { border-left: 0; }
  .chat.has-open .chat-list { display: none; }
  .chat:not(.has-open) .chat-main { display: none; }
  .chat-back { display: inline-block; }
  .chat-head { padding: 8px 10px; gap: 6px; }
  .chat-head .avatar { width: 34px; height: 34px; }
  .chat-head-actions { gap: 4px; }
  .chat-head .btn.icon { padding: 6px 8px; min-width: 36px; }
  #ws-status:empty { display: none; }
  .msgs { padding: 8px 10px; }
  .bubble { max-width: 85%; }
  .img-wrap img { max-width: 100%; }
  .file { max-width: 100%; }
  .voice audio { max-width: 100%; }
  .composer { padding: 8px; gap: 6px; }
  main:has(.chat) { padding: 0 0 0; }
  main:has(.chat) > .chat { margin: 0; }
}
/* Compact header on phones. */
@media (max-width: 600px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .muted { display: none; }
  #org-select { min-width: 0 !important; flex: 1; }
  .tabs { padding: 6px 8px; }
  .tabs button { padding: 6px 10px; }
}
/* Browser-notification banner. */
.notif-banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--primary-weak); color: var(--text); padding: 8px 16px; border-bottom: 1px solid var(--border); }
.notif-banner span { flex: 1; min-width: 200px; }
.chat-list { border-left: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conv { display: flex; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; align-items: center; }
.conv:hover { background: var(--bg); } .conv.active { background: var(--primary-weak); }
.conv-body { flex: 1; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { font-size: 12px; }
.badge { background: var(--primary); color: #fff; border-radius: 12px; padding: 0 8px; font-size: 12px; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.typing { color: var(--primary); }
.msgs { flex: 1; overflow-y: auto; padding: 12px 16px; background: var(--bg); }
.day { text-align: center; margin: 10px 0; } .day span { background: var(--surface); border-radius: 12px; padding: 2px 12px; font-size: 12px; color: var(--muted); }
.msg { display: flex; margin: 4px 0; }
.msg.mine { justify-content: flex-start; }  /* own messages on the right (Persian messenger convention) */
.msg.theirs { justify-content: flex-end; }
.bubble { max-width: min(560px, 75%); padding: 7px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); position: relative; }
.mine .bubble { background: var(--primary-weak); border-color: transparent; }
.sender { font-size: 12px; color: var(--primary); font-weight: 700; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { font-size: 11px; color: var(--muted); text-align: left; margin-top: 2px; }
.tick.read { color: var(--info); } .tick.failed { color: var(--danger); }
.reply-quote { border-right: 3px solid var(--primary); background: color-mix(in srgb, var(--surface) 60%, transparent); padding: 2px 8px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.actions { display: none; gap: 4px; margin-top: 4px; }
.bubble:hover .actions, .bubble:focus-within .actions { display: flex; }
.actions button { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0 4px; }
.img-wrap img { max-width: 280px; max-height: 260px; border-radius: 10px; cursor: zoom-in; display: block; }
.file { display: flex; gap: 6px; align-items: center; max-width: 360px; }
.voice audio { max-width: 260px; }
.reply-bar { display: flex; gap: 8px; align-items: center; padding: 6px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--border); }
.composer textarea { resize: none; min-height: 40px; }
.attach { cursor: pointer; }
.pick-list { max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px; margin-top: 6px; }
.pick { display: block; padding: 4px 0; margin: 0; color: var(--text); font-size: 14px; }
.seg label { margin: 0; text-align: center; color: var(--text); font-size: 14px; }
.chat-list .seg { margin: 0 0 8px; flex-wrap: wrap; } .chat-list .seg button { font-size: 13px; padding: 2px 6px; flex: 1 0 auto; }

/* ---------- member pages ---------- */
.stat.link, tr.link, .list-item[data-route] { cursor: pointer; }
.stat.link:hover { border-color: var(--primary); }
.list-item.active[data-notif] { border-color: transparent; background: var(--primary-weak); }
details summary { cursor: pointer; }
.modal table th { position: static; }

/* Touch screens have no hover: tapping a message shows its actions. */
.bubble.show-actions .actions { display: flex; flex-wrap: wrap; }
@media (max-width: 600px) {
  .notif-banner { padding: 6px 10px; gap: 6px; font-size: 13px; }
  .notif-banner span { min-width: 100%; }
}

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; margin-bottom: 4px; }
.powered { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.install-hint { margin-top: 14px; background: var(--primary-weak); border-radius: 10px; padding: 8px 12px; font-size: 13px; }

/* ---------- phone: bottom navigation, safe areas (iPhone notch / home bar) ---------- */
body { padding-top: env(safe-area-inset-top); }
.bottom-nav { display: none; }
@media (max-width: 600px) {
  .tabs { display: none; }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 0; font-size: 11px; color: var(--muted); cursor: pointer; }
  .bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav button.active { color: var(--primary); }
  .bottom-nav button.active svg { background: var(--primary-weak); border-radius: 14px; padding: 2px 12px; width: 48px; box-sizing: content-box; height: 22px; }
  main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* iOS zooms into smaller inputs */
  .more-list .list-item { display: block; width: 100%; text-align: right; border: 0; background: transparent; font-size: 16px; padding: 12px; }
}
@media (max-width: 600px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stat { padding: 10px; } .stat b { font-size: 22px; } }

/* ---------- voice messages & calls ---------- */
.rec-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--border); background: var(--danger-weak); }
.rec-dot, .call-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); display: inline-block; animation: tfpulse 1s infinite; }
.call-dot { background: var(--ok); }
@keyframes tfpulse { 50% { opacity: .3; } }
#call-root { position: fixed; z-index: 40; inset: auto 12px calc(12px + env(safe-area-inset-bottom)) 12px; display: flex; justify-content: center; pointer-events: none; }
#call-root > * { pointer-events: auto; }
.call-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; min-width: 260px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.call-card.ringing { border-color: var(--primary); }
.call-avatar { font-size: 32px; }
.call-bar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--primary); border-radius: 16px; padding: 8px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 760px; width: 100%; }
@media (max-width: 600px) { #call-root { bottom: calc(80px + env(safe-area-inset-bottom)); } .call-bar { flex-wrap: wrap; } }

/* ---------- chat search ---------- */
.search-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 4px; border-top: 1px solid var(--border); }
.search-hit mark { background: var(--warn-weak, #fff3c4); color: inherit; border-radius: 3px; padding: 0 1px; }
.msg.flash .bubble { outline: 3px solid var(--primary); outline-offset: 2px; transition: outline-color 1s; }

/* ---------- video calls ---------- */
.call-panel { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 980px; }
.call-stage { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); background: #0b0f10; border-radius: 16px; padding: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,.35); max-height: 34vh; overflow: auto; }
.call-stage.big { max-height: 68vh; }
.call-tile { position: relative; border-radius: 12px; overflow: hidden; background: #1b2122; aspect-ratio: 16 / 9; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.call-tile.screen { grid-column: 1 / -1; aspect-ratio: auto; }
.call-tile.screen video { object-fit: contain; max-height: 60vh; }
.call-stage:not(.big) .call-tile.screen video { max-height: 28vh; }
.call-tile.local video { transform: scaleX(-1); } /* mirror my own camera like a selfie */
.call-tile-name { position: absolute; inset: auto 8px 6px auto; color: #fff; font-size: 12px; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 8px; }
@media (max-width: 600px) { .call-stage { grid-template-columns: 1fr 1fr; } .call-stage.big { max-height: 55vh; } }

/* Chat header: one row on any width — the title shrinks (…), the icon buttons never wrap. */
.chat-head-title { min-width: 0; overflow: hidden; }
.chat-head-title > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.chat-head .btn { white-space: nowrap; flex-shrink: 0; }
.chat-head .btn.icon { font-size: 16px; line-height: 1; }
.call-stage[hidden] { display: none; }
/* Phones: the call bar shows icons only (labels stay as tooltips), name/time on the first line. */
@media (max-width: 600px) {
  .call-bar .lbl { display: none; }
  .call-bar { flex-wrap: wrap; justify-content: space-around; row-gap: 10px; }
  .call-bar > .grow { flex: 1 1 0; min-width: 0; }
  .call-break { flex-basis: 100%; height: 0; } /* name and time on row 1, all buttons on row 2 */
  .call-bar .btn { padding: 8px 14px; font-size: 18px; min-height: 0; flex: 0 0 auto; }
}
.call-break { display: none; }
@media (max-width: 600px) { .call-break { display: block; } }

/* ---------- live location ---------- */
.loc-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 12px; align-items: start; }
.loc-map { height: 68vh; min-height: 360px; border-radius: 14px; border: 1px solid var(--border); overflow: hidden; z-index: 0; }
.loc-list { max-height: 68vh; overflow: auto; }
.loc-row { cursor: pointer; } .loc-row.off { cursor: default; opacity: .65; }
.loc-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--ok); }
.loc-dot.off { background: var(--danger); } .loc-warn { color: var(--danger); }
.loc-dot.stale { background: var(--warn); } .loc-dot.none { background: var(--border); }
.loc-pin { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.loc-pin { font-size: 14px; }
.loc-pin.stale { background: #8a9494; }
@media (max-width: 800px) { .loc-wrap { grid-template-columns: 1fr; } .loc-map { height: 50vh; } .loc-list { max-height: none; } }

/* ---------- pinned messages and seen status ---------- */
.pin-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pin-bar .pin-body { flex: 1; min-width: 0; text-align: start; background: none; border: 0; padding: 2px 6px; border-inline-start: 3px solid var(--primary); display: flex; flex-direction: column; cursor: pointer; font: inherit; color: inherit; }
.tick-btn { background: none; border: 0; padding: 0 2px; cursor: pointer; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.tick.read, .receipt-read { color: #1e88e5; }
.seen-count { font-size: 11px; opacity: .75; }
.receipt-delivered, .receipt-sent { color: var(--muted, #7a8585); }

/* reactions, mentions, message → task */
.rxs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rx { border: 1px solid var(--border); background: var(--surface); color: inherit; border-radius: 999px; padding: 0 8px; font: inherit; font-size: 13px; cursor: pointer; line-height: 22px; }
.rx.mine { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.rx-pick { display: inline-flex; gap: 2px; margin-inline-end: 6px; }
.actions .rx-pick button { font-size: 16px; padding: 0 2px; }
.mention { color: var(--primary); font-weight: 600; }
.mention.me { background: color-mix(in srgb, var(--primary) 18%, transparent); border-radius: 4px; padding: 0 2px; }
.msg.mentioned .bubble { box-shadow: inset 3px 0 0 var(--primary); }
.task-chip { display: block; margin-top: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--primary); border-radius: 8px; padding: 2px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.mention-box { border-top: 1px solid var(--border); background: var(--surface); max-height: 180px; overflow: auto; }
.mention-box button { display: block; width: 100%; text-align: start; border: 0; background: none; color: inherit; font: inherit; padding: 8px 14px; cursor: pointer; }
.mention-box button:hover, .mention-box button:first-child { background: color-mix(in srgb, var(--primary) 10%, transparent); }

/* kanban board, checklist */
.kb { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-height: 160px; }
.kb-col.over { outline: 2px dashed var(--primary); }
.kb-head { padding: 4px 6px 8px; }
.kb-cards { display: flex; flex-direction: column; gap: 5px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.6; }
.kb-card.dragging { opacity: .5; }
.kb-card .kb-move { width: auto; font-size: 12px; padding: 2px 6px; margin-top: 2px; }
@media (max-width: 760px) { .kb { grid-template-columns: repeat(4, 62vw); scroll-snap-type: x mandatory; } .kb-col { scroll-snap-align: start; } }

/* calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { text-align: center; font-size: 12px; color: var(--muted, #6b7a76); padding: 4px 0; }
.cal-cell { min-height: 92px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--surface); overflow: hidden; }
.cal-cell.off { background: transparent; border-color: transparent; }
.cal-task.ghost { opacity: .65; border-style: dashed; }
.cal-cell.rest, .cal-col.rest { background: color-mix(in srgb, var(--muted, #6b7a76) 12%, var(--surface)); }
.cal-cell.hol, .cal-col.hol { background: color-mix(in srgb, #c62828 10%, var(--surface)); border-color: color-mix(in srgb, #c62828 35%, var(--border)); }
.cal-hol { font-size: 10px; color: #c62828; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.cal-key.hol { background: color-mix(in srgb, #c62828 35%, var(--surface)); }
.cal-key.rest { background: color-mix(in srgb, var(--muted, #6b7a76) 35%, var(--surface)); }
.cal-cell.today, .cal-col.today { outline: 2px solid var(--primary); }
.cal-num { font-size: 12px; font-weight: 700; cursor: pointer; }
.cal-task { font-size: 11px; border-radius: 5px; padding: 1px 5px; margin-top: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--primary) 14%, transparent); }
.cal-task.danger { background: color-mix(in srgb, #c0392b 18%, transparent); }
.cal-task.ok { background: color-mix(in srgb, #2e9e5b 20%, transparent); text-decoration: line-through; opacity: .8; }
.cal-task.warn { background: color-mix(in srgb, #d4a017 22%, transparent); }
.cal-task.muted { background: color-mix(in srgb, var(--border) 60%, transparent); }
.cal-task.wide { white-space: normal; font-size: 13px; padding: 4px 8px; margin-top: 6px; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 6px; overflow-x: auto; }
.cal-col { border: 1px solid var(--border); border-radius: 8px; padding: 6px; min-height: 160px; background: var(--surface); }
.cal-more { cursor: pointer; }
@media (max-width: 760px) { .cal-cell { min-height: 64px; } .cal-task { font-size: 10px; } }


/* =====================================================================
   Layout: right-hand sidebar, top bar, dashboard (desktop and tablet),
   and the phone / iPhone-PWA layout (bottom bar, safe areas, 16px inputs).
   ===================================================================== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side { width: 252px; flex: none; position: sticky; top: 0; align-self: flex-start; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--surface);
  border-inline-end: 1px solid var(--border); padding: 18px 12px 24px; padding-inline-start: max(12px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 4px; }
.side-brand { padding: 4px 10px 16px; }
.side-brand .brand { font-size: 21px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group + .side-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.side-title { font-size: 12px; color: var(--muted); padding: 4px 14px; letter-spacing: .02em; }
.side-nav button { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 0; border-radius: 12px; background: transparent;
  color: var(--muted); cursor: pointer; text-align: start; font-size: 14.5px; min-height: 44px; }
.side-nav button svg, .icon-btn svg, .hero svg, .quick-item svg, .stat-ico svg, .feed-ico svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-nav button:hover { background: var(--bg); color: var(--text); }
.side-nav button.active { background: var(--primary-weak); color: var(--primary); font-weight: 700; }
.side-nav button.active::before { content: ''; position: absolute; inset-block: 8px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--primary); }
.side-nav button:focus-visible, .icon-btn:focus-visible, .quick-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.topbar-brand { display: none; }
.org-select { width: auto; min-width: 200px; border-radius: 12px; background: var(--surface); }
.icon-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.user-meta b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-meta small { color: var(--muted); font-size: 12px; }
.tabs button { min-height: 40px; }

/* dashboard */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 28px 30px; min-height: 190px; color: #fff; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 220' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' fill-opacity='.14' d='M0 220V150L170 70l120 70 160-100 170 120 140-80 190 90 250-70v140z'/%3E%3Cpath fill='%23ffffff' fill-opacity='.2' d='M0 220v-60l220 20 200-60 210 70 200-40 370 70v-0z'/%3E%3C/svg%3E") bottom / 100% 60% no-repeat,
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 78%, #0b1230), color-mix(in srgb, var(--primary) 52%, #7c6cff)); }
.hero-text { position: relative; max-width: 560px; }
.hero-date { font-size: 13px; opacity: .92; margin-bottom: 4px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.4; }
.hero p { margin: 0; opacity: .95; font-size: 15px; }
.hero-actions { position: relative; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 18px; font-weight: 700; }
.hero .btn svg { width: 18px; height: 18px; }
.btn.light { background: #fff; color: color-mix(in srgb, var(--primary) 85%, #000); border-color: #fff; }
.btn.light:hover { border-color: #fff; filter: brightness(.96); }
.btn.glass { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .45); backdrop-filter: blur(4px); }
.btn.glass:hover { border-color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 16px 0; }
.stat-card { --ink: #2563eb; display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; background: color-mix(in srgb, var(--ink) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent); }
.stat-card.green, .quick-item.green { --ink: #16a34a; }
.stat-card.red, .quick-item.red { --ink: #dc2626; }
.stat-card.purple, .quick-item.purple, .feed-ico.purple { --ink: #7c3aed; }
.stat-card.orange, .quick-item.orange { --ink: #ea580c; }
.quick-item.blue, .feed-ico.blue { --ink: #2563eb; }
@media (prefers-color-scheme: dark) { .stat-card { background: color-mix(in srgb, var(--ink) 20%, var(--surface)); } .stat-card.red, .quick-item.red { --ink: #ff6b6b; } .stat-card.blue, .stat-card:not(.green):not(.red):not(.purple):not(.orange) { --ink: #6ea8ff; } .stat-card.purple, .quick-item.purple, .feed-ico.purple { --ink: #b197fc; } .stat-card.green { --ink: #4ade80; } .stat-card.orange { --ink: #fb923c; } }
.stat-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 16%, var(--surface)); color: var(--ink); flex: none; }
.stat-ico svg { width: 22px; height: 22px; }
.stat-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.5; }
.stat-body b { font-size: 28px; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-body span { font-size: 13px; color: var(--text); opacity: .85; }
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 17px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed-av { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.feed-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.feed-ico { --ink: #2563eb; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 14%, var(--surface)); color: var(--ink); flex: none; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-item { --ink: #2563eb; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 0; background: color-mix(in srgb, var(--ink) 10%, var(--surface)); color: var(--text); cursor: pointer; text-align: start; min-height: 56px; font-size: 14px; }
.quick-item .stat-ico { width: 36px; height: 36px; }
.quick-item .stat-ico svg { width: 18px; height: 18px; }
.quick-item:hover { filter: brightness(.97); }

/* tablet: the sidebar shrinks to icons */
@media (max-width: 1100px) {
  .side { width: 76px; padding-inline: 10px; align-items: center; }
  .side-brand { padding-inline: 0; }
  .side-brand .brand { font-size: 0; gap: 0; }
  .side-brand .brand-logo { width: 38px; height: 38px; }
  .side-nav button span, .side-title { display: none; }
  .side-nav button { justify-content: center; padding: 10px 0; }
  .side-group + .side-group { margin-top: 6px; }
  .dash-cols { grid-template-columns: 1fr; }
  main { padding: 20px 18px 56px; }
}
/* small tablet / large phone landscape: no sidebar, a scrolling tab strip instead */
@media (max-width: 899px) {
  .side { display: none; }
  .tabs { display: flex; }
  .topbar-brand { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .tabs button { border-radius: 999px; }
}
/* phones, including the iPhone home-screen app: bottom bar, safe areas, big targets */
@media (max-width: 600px) {
  .user-meta { display: none; }
  .user-chip { padding: 0; }
  .topbar { gap: 8px; padding: 8px 12px; }
  .org-select { min-width: 0; flex: 1; }
  .topbar .spacer { display: none; }
  main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .hero { padding: 20px 18px; min-height: 160px; border-radius: 20px; }
  .hero h1 { font-size: 22px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; }
  .stat-body b { font-size: 24px; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 14px; border-radius: 16px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
}
/* phones: the bottom bar stays above the iPhone home indicator */
.bottom-nav { padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
.bottom-nav button { min-height: 52px; }
@media (hover: none) { .side-nav button:hover { background: transparent; } .side-nav button.active:hover { background: var(--primary-weak); } .quick-item:hover { filter: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* fixes after the first look */
main { width: 100%; }
.stat-card.link, .feed li.link { cursor: pointer; }
.stat-card.link:hover { filter: brightness(.98); box-shadow: var(--shadow); }
.feed li.link:hover { background: color-mix(in srgb, var(--primary-weak) 45%, transparent); }
.icon-btn { position: relative; }
.icon-btn[data-count]::after { content: attr(data-count); position: absolute; top: -6px; inset-inline-start: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.hero .btn span { color: inherit; }
@media (max-width: 600px) { .tabs { display: none; } }

/* dark mode: brand colours are tuned for light surfaces, so text/tints derived from them are re-mixed here */
:root { --primary-ink: var(--primary); }
@media (prefers-color-scheme: dark) {
  :root { --primary-ink: color-mix(in srgb, var(--primary) 50%, #fff); --primary-weak: color-mix(in srgb, var(--primary) 24%, var(--surface)) !important; }
}
a, .brand, .chip, .side-nav button.active, .tabs button.active, .seg button.active, .user-avatar, .feed-av, .sender, .mention, .typing, .actions button, .task-chip { color: var(--primary-ink); }
.chip.danger { color: var(--danger); } .chip.warn { color: var(--warn); } .chip.ok { color: var(--ok); } .chip.muted { color: var(--muted); }
.btn.primary, .badge, .avatar { color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #fff; } .side { scrollbar-color: var(--border) transparent; } }
.side { scrollbar-width: thin; }

/* small iPhones (SE / XS / mini): nothing may push the page sideways */
.shell-main { overflow-x: clip; }
.seg { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; }
.table-wrap, .card { max-width: 100%; }
.hero .btn span { white-space: nowrap; }
@media (max-width: 400px) {
  .hero { padding: 18px 16px; }
  .hero h1 { font-size: 20px; }
  .hero-actions .btn { flex: 1 1 100%; }
  .stat-card { padding: 12px; }
  .stat-body b { font-size: 22px; }
  .stat-body span { font-size: 12px; }
  .org-select { font-size: 14px; padding-inline: 8px; }
  .icon-btn { width: 40px; height: 40px; }
  main { padding-inline: 10px; }
}

/* dashboard widgets */
.dash-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 14px; }
.dash-row > .card { margin-bottom: 0; }
.seg.small { margin: 0; padding: 3px; }
.seg.small button { padding: 3px 12px; font-size: 13px; min-height: 30px; }
.ch-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.ch-legend i, .ring-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; }
.ch-svg { width: 100%; height: auto; display: block; direction: ltr; }
.ch-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.ch-x, .ch-y { fill: var(--muted); font-size: 11px; font-family: inherit; }
.ch-x { text-anchor: middle; } .ch-y { text-anchor: end; }
.ch-line { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.ch-created { --c: #2563eb; } .ch-completed { --c: #16a34a; } .ch-overdue { --c: #dc2626; }
.ch-line.ch-created, .ch-line.ch-completed, .ch-line.ch-overdue { stroke: var(--c); }
.ch-legend .ch-created, .ch-legend .ch-completed, .ch-legend .ch-overdue { background: var(--c); }
.ch-dot { fill: var(--surface); stroke: var(--c); stroke-width: 2; }
.ch-area { fill: color-mix(in srgb, #16a34a 14%, transparent); }
@media (prefers-color-scheme: dark) { .ch-created { --c: #6ea8ff; } .ch-completed { --c: #4ade80; } .ch-overdue { --c: #ff6b6b; } }
.ring-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.ring-svg { width: 150px; height: 150px; flex: none; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: color-mix(in srgb, var(--muted) 20%, transparent); stroke-width: 14; }
.ring-seg { fill: none; stroke-width: 14; }
.ring-pct { transform: rotate(90deg); transform-origin: 70px 70px; text-anchor: middle; fill: var(--text); font-size: 26px; font-weight: 700; font-family: inherit; }
.ring-done { --c: #16a34a; } .ring-doing { --c: #2563eb; } .ring-todo { --c: #94a3b8; } .ring-late { --c: #dc2626; }
.ring-seg.ring-done, .ring-seg.ring-doing, .ring-seg.ring-todo, .ring-seg.ring-late { stroke: var(--c); }
.ring-legend i.ring-done, .ring-legend i.ring-doing, .ring-legend i.ring-todo, .ring-legend i.ring-late { background: var(--c); }
.ring-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 150px; }
.ring-legend li { display: flex; align-items: center; gap: 4px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ring-legend li span { flex: 1; } .ring-legend li:last-child { border-bottom: 0; } .ring-total { font-weight: 700; }
.mc-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mc-bar .icon-btn { width: 32px; height: 32px; font-size: 18px; border-radius: 10px; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mc-head { font-size: 12px; color: var(--muted); padding: 2px 0; }
.mc-day { position: relative; border: 0; background: transparent; color: var(--text); border-radius: 10px; min-height: 36px; font-size: 13px; cursor: pointer; padding: 0; }
.mc-day:hover { background: var(--bg); }
.mc-day.today { background: var(--primary); color: #fff; font-weight: 700; }
.mc-day.hol { color: var(--danger); } .mc-day.rest { color: var(--muted); }
.mc-day i { position: absolute; bottom: 4px; inset-inline: 0; margin: 0 auto; width: 5px; height: 5px; border-radius: 50%; background: #2563eb; }
.mc-day i.late { background: #dc2626; } .mc-day.today i { background: #fff; }
.mini-title { margin: 14px 0 4px; font-size: 14px; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.tl li:last-child { border-bottom: 0; } .tl li:hover { background: color-mix(in srgb, var(--primary-weak) 45%, transparent); }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: #2563eb; flex: none; } .tl-dot.late { background: #dc2626; } .tl-dot.done { background: #16a34a; }
.tl-body { flex: 1; min-width: 0; overflow-wrap: anywhere; } .tl-done { text-decoration: line-through; opacity: .7; }
@media (max-width: 1100px) { .dash-row { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .dash-row { gap: 10px; margin-bottom: 10px; } .ring-svg { width: 130px; height: 130px; } .mc-day { min-height: 34px; } }
@media (prefers-reduced-motion: no-preference) { .ring-seg { transition: stroke-dasharray .4s ease; } }

@media (max-width: 480px) { .ch-x, .ch-y { font-size: 11px; } .ch-line { stroke-width: 2.4; } }

/* ---------- sign-in screens: brand panel next to the form ---------- */
.auth { display: grid; grid-template-columns: minmax(400px, 560px) minmax(0, 1fr); grid-template-areas: "main hero"; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.auth-main { grid-area: main; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px max(24px, env(safe-area-inset-right)) 32px max(24px, env(safe-area-inset-left)); gap: 16px; }
.auth-main .login { width: min(440px, 100%); max-width: none; margin: 0; padding: 28px; border-radius: 22px; box-shadow: var(--shadow), 0 20px 50px rgba(23, 32, 51, .08); }
.auth-main .login h1 { font-size: 24px; margin: 0 0 4px; color: var(--text); }
.auth-main .login h3 { font-size: 20px; margin: 0 0 8px; }
.auth-main .login .btn.primary { min-height: 46px; font-size: 16px; font-weight: 700; }
.auth-main .login .seg { margin: 14px 0 6px; }
.auth-hero { grid-area: hero; position: relative; overflow: hidden; color: #fff; padding: 48px 52px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 400' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' fill-opacity='.12' d='M0 400V260L160 150l130 90 170-130 190 150 150-100 200 120 200-90v250z'/%3E%3Cpath fill='%23ffffff' fill-opacity='.18' d='M0 400v-80l240 30 200-90 230 90 210-60 320 90v20z'/%3E%3C/svg%3E") bottom / 100% 45% no-repeat,
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, .22), transparent 38%),
    linear-gradient(150deg, color-mix(in srgb, var(--primary) 80%, #0b1230), color-mix(in srgb, var(--primary) 50%, #7c6cff)); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 700; position: relative; }
.auth-logo { width: 46px; height: 46px; border-radius: 13px; object-fit: cover; background: #fff; }
.auth-copy { position: relative; max-width: 460px; }
.auth-copy h2 { font-size: 34px; line-height: 1.5; margin: 0 0 10px; }
.auth-copy p { margin: 0 0 22px; opacity: .95; font-size: 16px; }
.auth-copy ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-copy li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.auth-copy svg { width: 22px; height: 22px; flex: none; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .95; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; color: var(--primary-ink); }
.auth-mobile-brand .auth-logo { width: 40px; height: 40px; }
@media (max-width: 1000px) { .auth-hero { padding: 36px 32px; } .auth-copy h2 { font-size: 28px; } }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-main { justify-content: flex-start; padding-top: calc(36px + env(safe-area-inset-top)); }
}
@media (max-width: 400px) { .auth-main { padding-inline: 12px; } .auth-main .login { padding: 20px 16px; border-radius: 18px; } }

/* ---------- stories ---------- */
.st-bar { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.st-bar::-webkit-scrollbar { display: none; }
.st-bar:empty { display: none; }
.st-item { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer; width: 76px; padding: 0; color: var(--text); }
.st-ring { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; padding: 3px; background: conic-gradient(from 200deg, var(--primary), #7c6cff, #f59e0b, var(--primary)); }
.st-ring.seen { background: var(--border); }
.st-ring.add { background: transparent; border: 2px dashed var(--primary); padding: 3px; }
.st-av { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--primary-weak); color: var(--primary-ink); font-weight: 700; font-size: 22px; border: 3px solid var(--surface); overflow: hidden; }
.st-av img { width: 100%; height: 100%; object-fit: cover; }
.st-plus { font-size: 30px; font-weight: 400; border: 0; }
.st-ring.small { width: 40px; height: 40px; padding: 2px; } .st-ring.small .st-av { font-size: 16px; border-width: 2px; }
.st-name { font-size: 12px; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 12px; }
.st-viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.st-stage { position: relative; width: min(100vw, 440px, calc((100dvh - 24px) * 9 / 16)); aspect-ratio: 9 / 16; max-height: 100dvh; background: var(--bg, #0f766e); border-radius: 18px; overflow: hidden; color: #fff; display: flex; flex-direction: column; }
.st-progress { position: absolute; inset: 10px 10px auto; display: flex; gap: 4px; z-index: 3; direction: ltr; }
.st-progress i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.st-progress b { display: block; height: 100%; background: #fff; }
.st-head { position: absolute; inset: 22px 10px auto; display: flex; align-items: center; gap: 10px; z-index: 3; }
.st-who { display: flex; flex-direction: column; line-height: 1.4; } .st-who small { opacity: .85; font-size: 12px; }
.st-btn { border: 0; background: rgba(0, 0, 0, .35); color: #fff; min-width: 40px; height: 40px; border-radius: 20px; padding: 0 12px; cursor: pointer; font-size: 15px; }
.st-body { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; background: var(--bg, #0f766e); }
.st-img { width: 100%; height: 100%; object-fit: contain; background: #000; position: absolute; inset: 0; }
.st-text { font-size: 28px; line-height: 1.7; font-weight: 700; text-align: center; padding: 70px 26px; overflow-wrap: anywhere; position: relative; }
.st-caption { position: absolute; inset: auto 0 0; padding: 40px 18px 22px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.st-zone { position: absolute; top: 70px; bottom: 0; width: 50%; border: 0; background: transparent; cursor: pointer; z-index: 2; }
.st-prev { right: 0; } .st-next { left: 0; }
.st-viewers { list-style: none; margin: 0; padding: 0; } .st-viewers li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.st-preview { margin-top: 8px; } .st-preview img { max-width: 100%; max-height: 240px; border-radius: 12px; display: block; }
.st-colors { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.st-color { width: 34px; height: 34px; border-radius: 50%; margin: 0; position: relative; cursor: pointer; display: block; }
.st-color input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.st-color span { position: absolute; inset: -3px; border-radius: 50%; border: 3px solid transparent; }
.st-color input:checked + span { border-color: var(--text); }
.st-color input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.st-sample { border-radius: 16px; min-height: 120px; display: grid; place-items: center; color: #fff; font-weight: 700; padding: 16px; text-align: center; overflow-wrap: anywhere; }
@media (max-width: 600px) { .st-stage { border-radius: 0; width: 100vw; height: 100dvh; aspect-ratio: auto; } .st-item { width: 68px; } .st-ring { width: 62px; height: 62px; } }
@media (prefers-reduced-motion: reduce) { .st-progress b { transition: none; } }

.st-video { background: #000; }
.st-zone.with-reply { bottom: 64px; }
.st-reply { position: absolute; inset: auto 10px 10px; z-index: 4; display: flex; gap: 8px; }
.st-reply input { flex: 1; border: 1px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .35); color: #fff; border-radius: 22px; padding: 10px 16px; font-size: 16px; }
.st-reply input::placeholder { color: rgba(255, 255, 255, .8); }
.st-send { border: 0; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #111; font-size: 18px; cursor: pointer; flex: none; }

.tick-seal { width: 1.05em; height: 1.05em; vertical-align: -.16em; margin-inline-start: .3em; flex: none; }
.tick-seal.business { color: #1d9bf0; }
.tick-seal.platform { color: #f5b301; }

.stat-card.add-card { background: var(--surface-2, var(--bg)); border: 1.5px dashed var(--border, #cbd5d5); color: var(--primary); cursor: pointer; font: inherit; text-align: inherit; }
.stat-card.add-card .stat-body b { font-size: 26px; }

.as-level { display: inline-block; width: 120px; height: 8px; background: var(--border, #dde3e3); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-inline-start: 10px; }
.as-level i { display: block; height: 100%; width: 0; background: #d33; transition: width .1s linear; }

#as-fab { position: fixed; z-index: 60; width: 58px; height: 58px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4); cursor: grab; touch-action: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6d4aff, #3b2bd9); box-shadow: 0 8px 22px rgba(80,50,220,.45); transition: left .2s, top .2s; animation: as-glow 2.4s ease-in-out infinite; }
#as-fab svg { width: 28px; height: 28px; }
#as-fab.drag { cursor: grabbing; transition: none; opacity: .88; animation: none; }
@keyframes as-glow { 50% { box-shadow: 0 8px 30px rgba(109,74,255,.7); } }
#as-fab-panel { position: fixed; z-index: 61; width: 260px; background: var(--surface, #fff); border-radius: 22px; padding: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.25); display: grid; gap: 8px; }
.as-fab-head { display: flex; align-items: center; gap: 8px; color: #6d4aff; }
.as-fab-head svg { width: 22px; height: 22px; }
.as-fab-head b { flex: 1; font-size: 14px; }
.as-fab-head button { border: 0; background: none; cursor: pointer; color: var(--muted, #777); font-size: 16px; }
.as-fab-q { border: 0; border-radius: 14px; padding: 12px; background: var(--surface-2, #eef1f1); font: inherit; text-align: start; cursor: pointer; }
.as-fab-q.open { background: rgba(109,74,255,.12); color: #6d4aff; font-weight: 700; }

/* ---- payslip (فیش حقوقی) ---- */
.ps-layout { display: grid; grid-template-columns: 210px 1fr; gap: 14px; align-items: start; }
.ps-periods { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.ps-periods h4 { margin: 0 0 8px; }
.ps-periods button { display: block; width: 100%; text-align: right; background: transparent; border: 0; border-radius: 10px; padding: 10px 12px; margin-bottom: 4px; cursor: pointer; color: var(--text); font: inherit; }
.ps-periods button.active { background: var(--primary); color: #fff; font-weight: 700; }
.ps-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; border-radius: var(--radius); margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #000)); }
.ps-name { font-size: 20px; font-weight: 700; }
.ps-sub { opacity: .85; margin-top: 4px; }
.ps-badge { background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 5px 14px; font-size: 13px; white-space: nowrap; }
.ps-badge.ok { background: #e6f4ea; color: #1b5e20; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.ps-card h4 { margin: 0 0 10px; }
.ps-line { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ps-pos { color: var(--ok); }
.ps-neg { color: var(--danger); }
.ps-net { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--primary-weak); font-weight: 700; font-size: 16px; }
.ps-table { width: 100%; border-collapse: collapse; }
.ps-table th { font-size: 12px; color: var(--muted); text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--border); font-weight: 600; }
.ps-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.ps-table .amt { text-align: left; white-space: nowrap; }
.ps-total td { font-weight: 700; padding: 10px 8px; }
.ps-total.pos td { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.ps-total.neg td { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.ps-row { display: flex; gap: 6px; margin-bottom: 6px; }
.ps-row .ps-t { flex: 1; min-width: 0; }
.ps-row .ps-a { width: 150px; }
.ps-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ps-tools select { flex: 1; min-width: 180px; }
.ps-tools input { width: 70px; }
.ps-totals { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px; margin-top: 8px; border-radius: 10px; background: var(--primary-weak); }
@media (max-width: 800px) {
  .ps-layout { grid-template-columns: 1fr; }
  .ps-periods { display: flex; gap: 6px; overflow-x: auto; }
  .ps-periods h4 { display: none; }
  .ps-periods button { width: auto; white-space: nowrap; margin: 0; }
  .ps-grid { grid-template-columns: 1fr; }
  .ps-row .ps-a { width: 110px; }
}

/* ---- org chart (چارت سازمانی) ---- */
.oc-node { margin-top: 8px; }
.oc-children { margin-inline-start: 22px; padding-inline-start: 14px; border-inline-start: 2px solid var(--border); }
.oc-card { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); max-width: 760px; }
.oc-card.vacant { border-style: dashed; background: transparent; }
.oc-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.oc-card.vacant .oc-avatar { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.oc-info { flex: 1; min-width: 0; }
.oc-name { font-weight: 700; }
.oc-title { color: var(--muted); }
.oc-toggle { width: 22px; flex: none; background: transparent; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0; }
.oc-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.oc-unit { padding: 12px 14px; margin-bottom: 8px; }
@media (max-width: 800px) { .oc-card { flex-wrap: wrap; } .oc-children { margin-inline-start: 8px; padding-inline-start: 8px; } }

.oc-card[draggable=true] { cursor: grab; }
.oc-card.drop, .oc-root-drop.drop { outline: 2px dashed var(--primary); background: var(--primary-weak); }
.oc-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.oc-avatar[data-user] { cursor: grab; }
.oc-root-drop { border: 1px dashed var(--border); border-radius: 10px; padding: 6px; text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ---- payslip editor: stepper beside a live preview ---- */
.pe-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pe-preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; position: sticky; top: 0; max-height: 78vh; overflow: auto; }
.pe-steps { display: flex; gap: 6px; margin-bottom: 12px; }
.pe-steps button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border: 0; border-radius: 999px; background: var(--bg); color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.pe-steps button i { width: 22px; height: 22px; border-radius: 50%; background: var(--border); color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 12px; }
.pe-steps button.active { background: var(--primary); color: #fff; font-weight: 700; }
.pe-steps button.active i { background: #fff; color: var(--primary); }
.pe-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.pe-tiles div { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.pe-tiles span, .pe-tiles small { color: var(--muted); font-size: 12px; }
.pe-h { margin: 12px 0 6px; }
.pe-h.pos { color: var(--ok); } .pe-h.neg { color: var(--danger); }
.pe-nav { margin-top: 12px; }
.pe-switch { display: flex; align-items: center; gap: 8px; margin-top: 10px; cursor: pointer; }
.pe-switch input { display: none; }
.pe-switch span { width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; flex: none; transition: background .15s; }
.pe-switch span::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.pe-switch input:checked + span { background: var(--primary); }
.pe-switch input:checked + span::after { inset-inline-start: 20px; }
.pv { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.pv .lh { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 3px solid var(--pv); margin-bottom: 10px; }
.pv .lh-logo { width: 48px; height: 48px; border-radius: 10px; background: var(--pv); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; overflow: hidden; flex: none; }
.pv .lh-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pv .lh-id { flex: 1; } .pv .lh-name { font-weight: 700; font-size: 16px; color: var(--pv); } .pv .lh-org { color: var(--muted); font-size: 12px; }
.pv .lh-meta { font-size: 12px; color: var(--muted); text-align: left; line-height: 1.6; }
.pv-who { display: flex; justify-content: space-between; margin-bottom: 6px; }
.pv-hero { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--pv); color: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.pv-hero-id { display: flex; flex-direction: column; } .pv-hero-id span { opacity: .85; font-size: 13px; }
.pv-hero-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; opacity: .9; }
.pv-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.pv-tiles div { background: var(--bg); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; font-size: 12px; }
.pv-tiles span { color: var(--muted); }
.pv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv-col { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pv-col h5 { margin: 0; padding: 8px 10px; font-size: 13px; }
.pv-col.pos h5 { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pv-col.neg h5 { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.pv-col .ps-table td, .pv-col .ps-table th { font-size: 12px; padding: 6px 8px; }
.pv-net { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--pv); color: #fff; font-size: 16px; }
.pv-net.classic { background: var(--primary-weak); color: var(--text); }
.pv-foot { margin-top: 8px; color: var(--muted); font-size: 11px; }
@media (max-width: 900px) { .pe-grid { grid-template-columns: 1fr; } .pe-preview { position: static; max-height: none; } .pv-cols { grid-template-columns: 1fr; } }

.modal.wide:has(.pe-grid) { width: min(1180px, 100%); }
.modal-body:has(.pe-grid) { max-height: 74vh; overflow: auto; }

/* ---- org chart as a diagram ---- */
.og-wrap { position: relative; }
.og-canvas { background-color: #f7f8fa; background-image: radial-gradient(#cfd4dc 1px, transparent 1px); background-size: 16px 16px; border: 1px solid var(--border); border-radius: 16px; overflow: auto; padding: 30px 24px 50px; min-height: 440px; }
.og-stage { transform-origin: top center; width: max-content; margin: 0 auto; }
.og-node { display: flex; flex-direction: column; align-items: center; }
.og-down { width: 2px; height: 26px; background: #2b2f3a; }
.og-row { display: flex; justify-content: center; gap: 30px; padding-top: 26px; position: relative; }
.og-roots { padding-top: 0; }
.og-col { position: relative; display: flex; flex-direction: column; align-items: stretch; width: 232px; }
.og-row:not(.og-roots) > .og-col::before { content: ''; position: absolute; top: -26px; inset-inline-start: 50%; height: 26px; border-inline-start: 2px solid #2b2f3a; }
.og-row:not(.og-roots) > .og-col::after { content: ''; position: absolute; top: -26px; inset-inline: -15px; border-top: 2px solid #2b2f3a; }
.og-row:not(.og-roots) > .og-col:first-child::after { inset-inline-start: 50%; }
.og-row:not(.og-roots) > .og-col:last-child::after { inset-inline-end: 50%; }
.og-row:not(.og-roots) > .og-col:only-child::after { display: none; }
.og-pill { background: var(--uc); color: #fff; border-radius: 8px; text-align: center; padding: 7px 10px; font-weight: 700; font-size: 13px; margin-bottom: 14px; position: relative; }
.og-pill::after { content: ''; position: absolute; bottom: -14px; inset-inline-start: 50%; height: 14px; border-inline-start: 2px solid #2b2f3a; }
.og-card { display: flex; align-items: center; gap: 10px; width: 100%; background: #fff; border: 1px solid #e4e6ec; border-radius: 12px; padding: 9px 11px; box-shadow: 0 1px 4px rgba(16, 24, 40, .08); cursor: pointer; }
.og-card[draggable=true] { cursor: grab; }
.og-card.vacant { border-style: dashed; background: transparent; box-shadow: none; }
.og-card.drop { outline: 2px dashed var(--primary); background: var(--primary-weak); }
.og-av { width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, var(--uc, var(--primary)) 18%, #fff); color: var(--uc, var(--primary)); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; overflow: hidden; }
.og-av img { width: 100%; height: 100%; object-fit: cover; }
.og-card.vacant .og-av { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.og-tx { min-width: 0; display: flex; flex-direction: column; } .og-tx b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .og-tx small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.og-stack { position: relative; margin-top: 14px; padding-inline-start: 28px; display: flex; flex-direction: column; gap: 12px; }
.og-stack::before { content: ''; position: absolute; inset-inline-start: 12px; top: -14px; bottom: 24px; border-inline-start: 2px solid #9aa1ad; }
.og-item { position: relative; display: flex; flex-direction: column; }
.og-item::before { content: ''; position: absolute; inset-inline-start: -16px; top: 28px; width: 16px; border-top: 2px solid #9aa1ad; }
.og-item > .og-stack { margin-top: 12px; }
.og-zoom { position: absolute; bottom: 14px; inset-inline-end: 14px; display: flex; flex-direction: column; gap: 6px; }
.og-zoom button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #12141c; color: #fff; font-size: 18px; cursor: pointer; }

.og-node > .og-card { width: 232px; }
