/* ============================================================
   MAREEB - Premium Glassmorphism UI
   Brand blue derived from the MAREEB logo mark.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Brand */
  --brand-1: #2563eb;
  --brand-2: #3b82f6;
  --brand-3: #60a5fa;
  --brand-soft: #93c5fd;
  --grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 45%, #60a5fa 100%);

  --radius: 18px;
  --radius-sm: 12px;
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --shadow: 0 20px 45px rgba(2, 8, 23, .25);
}

/* -------- DARK THEME (default) -------- */
[data-theme="dark"] {
  --bg-0: #070b16;
  --bg-1: #0b1220;
  --bg-grad-a: color-mix(in srgb, var(--brand-1) 22%, transparent);
  --bg-grad-b: color-mix(in srgb, var(--brand-3) 16%, transparent);
  --text: #e8edf7;
  --text-dim: #94a3b8;
  --glass: rgba(255, 255, 255, .06);
  --sidebar-bg: var(--glass);
  --heading: var(--text);
  --timer: var(--heading);
  --link: #5b9dff;
  --btn-shadow: 0 8px 22px color-mix(in srgb, var(--brand-1) 28%, transparent);
  --btn-shadow-hover: 0 12px 28px color-mix(in srgb, var(--brand-1) 40%, transparent);
  --ok:#22c55e; --warn:#f59e0b; --bad:#ef4444;
  --glass-2: rgba(255, 255, 255, .04);
  --glass-strong: rgba(255, 255, 255, .10);
  --border: rgba(255, 255, 255, .12);
  --border-soft: rgba(255, 255, 255, .07);
  --input-bg: rgba(255, 255, 255, .05);
  --shadow: 0 20px 45px rgba(0, 0, 0, .45);
}

/* -------- LIGHT THEME -------- */
[data-theme="light"] {
  --bg-0: #eef2fb;
  --bg-1: #f7f9ff;
  --bg-grad-a: color-mix(in srgb, var(--brand-1) 14%, transparent);
  --bg-grad-b: color-mix(in srgb, var(--brand-3) 20%, transparent);
  --text: #0f1e3a;
  --text-dim: #5b6b86;
  --glass: rgba(255, 255, 255, .55);
  --glass-2: rgba(255, 255, 255, .40);
  --glass-strong: rgba(255, 255, 255, .78);
  --border: rgba(15, 30, 58, .12);
  --border-soft: rgba(15, 30, 58, .07);
  --input-bg: rgba(255, 255, 255, .70);
  --shadow: 0 18px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 12% -8%, var(--bg-grad-a), transparent 60%),
    radial-gradient(900px 600px at 108% 12%, var(--bg-grad-b), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .3s ease;
  position: relative;
  overflow-x: hidden;
}
/* floating colour orbs that sit behind the frosted glass */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .55;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 460px; height: 460px;
  background: radial-gradient(circle, var(--brand-2), transparent 70%);
  top: -120px; left: -80px;
  animation: float1 18s ease-in-out infinite;
}
body::after {
  width: 520px; height: 520px;
  background: radial-gradient(circle, var(--brand-3), transparent 70%);
  bottom: -160px; right: -100px;
  animation: float2 22s ease-in-out infinite;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(60px,40px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-50px,-40px)} }
.shell { position: relative; z-index: 1; }

h1, h2, h3, h4, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }

/* ---------- Glass primitives ---------- */
.glass {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* subtle top highlight for a frosted-glass edge */
.glass::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255,255,255,.35), rgba(255,255,255,0) 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; opacity: .5;
}
.glass-2 {
  background: var(--glass-2);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

/* ---------- SVG icons ---------- */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.nav-link .icon { width: 19px; height: 19px; }
.btn .icon { width: 17px; height: 17px; }
.stat .ico .icon { width: 22px; height: 22px; }
.icon-btn .icon { width: 19px; height: 19px; }

/* ============================================================
   AUTH (login / forgot / reset)
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 410px;
  padding: 40px 34px;
}
.auth-logo {
  display: flex; justify-content: center; margin-bottom: 6px;
}
.auth-logo .badge {
  background: transparent;
  border-radius: 16px;
  padding: 6px 8px;
  border: none;
  box-shadow: none;
}
.auth-logo img { height: 48px; max-width: 190px; object-fit: contain; display: block; }
.auth-card h1 { text-align: center; font-size: 1.35rem; margin: 18px 0 4px; }
.auth-card .sub { text-align: center; color: var(--text-dim); font-size: .88rem; margin-bottom: 26px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .92rem;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 26%, transparent);
}
textarea.input { resize: vertical; min-height: 90px; }
.input::placeholder { color: var(--text-dim); opacity: .8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-weight: 600; font-size: .92rem;
  cursor: pointer; transition: transform .12s, box-shadow .2s, opacity .2s;
  color: #fff; background: var(--grad);
  box-shadow: var(--btn-shadow);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--btn-shadow-hover); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--glass-strong); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.ghost:hover { box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.btn.danger { background: linear-gradient(135deg,#ef4444,#f97316); box-shadow: 0 10px 24px rgba(239,68,68,.3); }
.btn.success { background: linear-gradient(135deg,#16a34a,#22c55e); box-shadow: 0 10px 24px rgba(34,197,94,.3); }
.btn.sm { padding: 8px 14px; font-size: .82rem; }
.btn.warn { background: linear-gradient(135deg,#d97706,#f59e0b); }

.link { color: var(--link); font-weight: 500; }
.link:hover { text-decoration: underline; }
.text-center { text-align: center; }
.mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; }

/* Flash messages */
.flash { padding: 11px 15px; border-radius: var(--radius-sm); font-size: .86rem; margin-bottom: 16px; border: 1px solid transparent; }
.flash.error   { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.4); color: #fecaca; }
.flash.success { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.4); color: #bbf7d0; }
.flash.info    { background: rgba(59,130,246,.14); border-color: rgba(59,130,246,.4); color: #bfdbfe; }
[data-theme="light"] .flash.error   { color:#991b1b; }
[data-theme="light"] .flash.success { color:#166534; }
[data-theme="light"] .flash.info    { color:#1e40af; }

/* ============================================================
   APP SHELL (sidebar + topbar + content)
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 258px; flex-shrink: 0;
  padding: 20px 16px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid var(--border);
  transition: transform .3s ease;
  z-index: 50;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.sidebar .brand .logo-badge { background:transparent; border-radius:12px; padding:2px 0; border:none; }
.sidebar .brand .logo-badge img { height: 26px; display:block; }

.nav-group { margin-top: 14px; }
.nav-group .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-dim); padding: 0 10px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: .9rem;
  margin-bottom: 3px; transition: background .18s, color .18s;
}
.nav-link .ico { width: 20px; text-align: center; font-size: 1rem; }
.nav-link:hover { background: var(--glass-strong); color: var(--text); }
.nav-link.active { background: var(--grad); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--brand-1) 30%, transparent); }
.nav-link .pill { margin-left: auto; background: #ef4444; color:#fff; font-size:.68rem; padding: 1px 7px; border-radius: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 26px;
  position: sticky; top: 0; z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 1.15rem; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative;
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--glass-strong); border: 1px solid var(--border);
  color: var(--text); font-size: 1.05rem; transition: transform .12s;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; min-width: 16px; height:16px; padding:0 4px; border-radius: 10px; background:#ef4444; color:#fff; font-size:.62rem; display:grid; place-items:center; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-family: var(--font-display); font-weight: 600; font-size: .85rem;
  color: #fff; background: var(--grad); flex-shrink: 0;
}
.avatar img { width:100%; height:100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 1.6rem; }

.user-chip { display:flex; align-items:center; gap:10px; cursor:pointer; padding:5px 8px; border-radius:12px; }
.user-chip:hover { background: var(--glass-strong); }
.user-chip .meta small { display:block; color: var(--text-dim); font-size:.72rem; }
.user-chip .meta span { font-weight:600; font-size:.85rem; }

.content { padding: 26px; flex: 1; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 230px; padding: 8px; z-index: 60; display: none;
}
.dropdown-menu.open { display: block; animation: pop .15s ease; }
@keyframes pop { from { opacity:0; transform: translateY(-6px);} to {opacity:1; transform:none;} }
.dropdown-menu a, .dropdown-menu button {
  display:flex; align-items:center; gap:10px; width:100%;
  padding: 9px 11px; border-radius: 10px; font-size:.87rem;
  color: var(--text); background:none; border:none; cursor:pointer; text-align:left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--glass-strong); }
.notif-item { padding:10px 11px; border-radius:10px; }
.notif-item:hover { background: var(--glass-strong); }
.notif-item small { color: var(--text-dim); font-size:.72rem; }
.notif-item.unread { border-left: 3px solid var(--brand-2); }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.card { padding: 22px; }
.card h3 { font-size: 1rem; margin-bottom: 14px; }
.card .head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 16px; }

.stat { padding: 20px; display:flex; flex-direction:column; gap: 6px; }
.stat .ico { width: 46px; height:46px; border-radius: 13px; display:grid; place-items:center; font-size:1.25rem; color:#fff; background: var(--grad); margin-bottom: 6px; }
.stat .num { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; }
.stat .lbl { color: var(--text-dim); font-size: .82rem; }

/* Check-in widget */
.checkin-box { text-align:center; padding: 26px; }
.timer { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; letter-spacing: .02em; margin: 6px 0 4px; color: var(--timer); }
.timer.live { color: var(--timer); }
.checkin-status { color: var(--text-dim); font-size:.85rem; margin-bottom: 18px; }
.pulse { display:inline-block; width:9px; height:9px; border-radius:50%; background:#22c55e; margin-right:6px; box-shadow:0 0 0 0 rgba(34,197,94,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(34,197,94,.55);} 70%{box-shadow:0 0 0 10px rgba(34,197,94,0);} 100%{box-shadow:0 0 0 0 rgba(34,197,94,0);} }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; }
table.tbl thead th { color: var(--text-dim); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
table.tbl tbody tr { border-bottom: 1px solid var(--border-soft); }
table.tbl tbody tr:hover { background: var(--glass-strong); }
table.tbl td .avatar { width: 32px; height: 32px; font-size: .72rem; }

.badge {
  display: inline-flex; align-items:center; gap:5px;
  padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 600;
}
.badge.b-blue   { background: rgba(59,130,246,.16); color:#93c5fd; }
.badge.b-green  { background: color-mix(in srgb,var(--ok) 18%,transparent); color: var(--ok); }
.badge.b-amber  { background: color-mix(in srgb,var(--warn) 18%,transparent); color: var(--warn); }
.badge.b-red    { background: color-mix(in srgb,var(--bad) 20%,transparent); color: var(--bad); }
.badge.b-gray   { background: rgba(148,163,184,.16);color:#cbd5e1; }
[data-theme="light"] .badge.b-blue{color:#1d4ed8;} [data-theme="light"] .badge.b-green{color:#15803d;}
[data-theme="light"] .badge.b-amber{color:#b45309;} [data-theme="light"] .badge.b-red{color:#b91c1c;}
[data-theme="light"] .badge.b-gray{color:#475569;}

/* Chip row for recipient selection */
.chips { display:flex; flex-wrap:wrap; gap:8px; }
.chk {
  display:flex; align-items:center; gap:8px; padding:8px 12px;
  border-radius: 30px; border:1px solid var(--border); background: var(--input-bg);
  cursor:pointer; font-size:.82rem; user-select:none;
}
.chk input { accent-color: var(--brand-2); }

/* Modal */
.modal-back { position: fixed; inset:0; background: rgba(2,8,23,.6); backdrop-filter: blur(4px); display:none; place-items:center; z-index:100; padding:20px; }
.modal-back.open { display:grid; }
.modal { width:100%; max-width: 560px; max-height: 90vh; overflow-y:auto; padding: 26px; }
.modal .head { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; }
.modal .close { cursor:pointer; font-size:1.3rem; color: var(--text-dim); background:none; border:none; }

.row { display:flex; gap:14px; flex-wrap:wrap; }
.row > * { flex: 1; min-width: 140px; }
.muted { color: var(--text-dim); }
.mb-0{margin-bottom:0;} .mb-2{margin-bottom:14px;} .mb-3{margin-bottom:22px;}
.flex { display:flex; align-items:center; gap:10px; }
.between { justify-content: space-between; }
.wrap-gap { display:flex; gap:10px; flex-wrap:wrap; }

/* Theme toggle switch */
.theme-toggle { display:flex; align-items:center; gap:8px; }

.hamburger { display:none; }
.backdrop { display:none; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) { .g-4 { grid-template-columns: repeat(2,1fr);} .g-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 760px) {
  .sidebar { position: fixed; left:0; top:0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display:block; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:45; }
  .hamburger { display:grid; }
  .g-2,.g-3,.g-4 { grid-template-columns: 1fr; }
  .row > * { min-width: 100%; }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; }
  .user-chip .meta { display:none; }
  .timer { font-size: 2.1rem; }
}

/* ============================================================
   PREMIUM ADD-ONS  (toasts, spinner, message thread, live update)
   ============================================================ */

/* Toasts */
#toastWrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 340px; padding: 13px 16px;
  border-radius: 14px; color: var(--text); font-size: .88rem;
  display: flex; align-items: center; gap: 10px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1);
}
.toast.out { animation: toastOut .3s forwards; }
.toast .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.toast.success .bar { background: #22c55e; }
.toast.error .bar { background: #ef4444; }
.toast.info .bar { background: var(--brand-2); }
.toast .icon { color: var(--brand-3); }
@keyframes toastIn { from { opacity:0; transform: translateX(30px);} to {opacity:1; transform:none;} }
@keyframes toastOut { to { opacity:0; transform: translateX(30px);} }

/* Spinner + busy state */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand-2); animation: spin .7s linear infinite; display:inline-block; }
@keyframes spin { to { transform: rotate(360deg);} }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading .icon, .btn.loading .btn-label { visibility: hidden; }
.btn.loading::after { content:""; position:absolute; width:16px; height:16px; border-radius:50%; border:2px solid rgba(255,255,255,.5); border-top-color:#fff; animation: spin .7s linear infinite; }
.btn { position: relative; }

/* Content fade when a fragment reloads */
/* #pageContent used to carry `animation: fadeUp .35s ease` unconditionally.
   Two problems: it faded every navigation in from opacity 0, and because the
   app-enter class swaps the animation-name, REMOVING that class switched the
   property back to fadeUp — which restarts an animation from its first frame.
   The result was two fades per navigation, i.e. content appearing, vanishing and
   appearing again. The directional slide in app-shell.css covers mobile now, and
   it never touches opacity. Keyframes kept in case a page opts in explicitly. */
#pageContent { animation: none; }
/* Content is NEVER dimmed or blanked while loading. Any opacity change here
   reads as the page flashing — which is exactly what it did, and on a real
   server (300-800ms responses) it happened on every single navigation no matter
   what delay was tuned in. Loading feedback is the top bar below instead. */
#pageContent.updating { opacity: 1; }

/* thin top progress bar — the only loading affordance */
#navProgress {
  position: fixed; top: 0; left: 0; height: 2.5px; width: 0;
  z-index: 9999; pointer-events: none;
  background: linear-gradient(90deg, var(--brand-1, #3B7BF7), var(--brand-2, #14B8A6));
  box-shadow: 0 0 8px rgba(59,123,247,.55);
  transition: width .18s ease, opacity .25s ease;
  opacity: 0;
}
#navProgress.on  { opacity: 1; }
#navProgress.done { width: 100% !important; opacity: 0; }
@keyframes fadeUp { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* Notification dot pulse */
.icon-btn .dot { animation: dotPop .3s ease; }
@keyframes dotPop { from { transform: scale(0);} to { transform: scale(1);} }

/* ---------- Message thread ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; margin: 10px 0 18px; }
.bubble { max-width: 78%; padding: 12px 15px; border-radius: 16px; position: relative; }
.bubble .who { font-size: .76rem; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.bubble .txt { font-size: .9rem; line-height: 1.55; white-space: pre-wrap; }
.bubble.them { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--border-soft); border-bottom-left-radius: 5px; }
.bubble.me { align-self: flex-end; background: var(--grad); color:#fff; border: none; border-bottom-right-radius: 5px; }
.bubble .time { font-size: .68rem; color: var(--text-dim); margin-top: 5px; text-align: right; }

/* message list rows */
.msg-row { display:flex; align-items:center; gap:12px; padding:13px 14px; border-radius: 14px; cursor:pointer; border:1px solid transparent; transition: background .15s, border-color .15s; }
.msg-row:hover { background: var(--glass-strong); border-color: var(--border-soft); }
.msg-row.unread { border-left: 3px solid var(--brand-2); }
.msg-row .who { font-weight:600; font-size:.9rem; }
.msg-row .subj { color: var(--text-dim); font-size:.83rem; }
.msg-row .when { margin-left:auto; color: var(--text-dim); font-size:.75rem; white-space:nowrap; }

/* tab pills */
.seg { display:inline-flex; gap:4px; padding:4px; border-radius: 14px; background: var(--glass-2); border:1px solid var(--border-soft); }
.seg a { padding:8px 14px; border-radius: 10px; font-size:.85rem; font-weight:600; color: var(--text-dim); display:flex; align-items:center; gap:7px; }
.seg a.active { background: var(--grad); color:#fff; box-shadow: 0 6px 16px color-mix(in srgb,var(--brand-1) 30%,transparent); }

/* empty state */
.empty { text-align:center; padding: 40px 20px; color: var(--text-dim); }
.empty .icon { width: 40px; height: 40px; opacity: .5; margin-bottom: 10px; }

/* ============================================================
   FALLBACK: browsers without backdrop-filter get solid panels
   (modern Chrome/Edge/Safari/Firefox show the full glass blur)
   ============================================================ */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  [data-theme="dark"] .glass,
  [data-theme="dark"] .sidebar,
  [data-theme="dark"] .topbar,
  [data-theme="dark"] .dropdown-menu,
  [data-theme="dark"] .modal,
  [data-theme="dark"] .toast { background: #101a33; }
  [data-theme="dark"] .glass-2 { background: #16223f; }

  [data-theme="light"] .glass,
  [data-theme="light"] .sidebar,
  [data-theme="light"] .topbar,
  [data-theme="light"] .dropdown-menu,
  [data-theme="light"] .modal,
  [data-theme="light"] .toast { background: #ffffff; }
  [data-theme="light"] .glass-2 { background: #eef3ff; }
}

/* ============================================================
   CHAT UI
   ============================================================ */
.chat-wrap { display:flex; height: calc(100vh - 150px); min-height: 460px; overflow:hidden; padding:0; }
.chat-list { width: 320px; flex-shrink:0; border-right:1px solid var(--border); display:flex; flex-direction:column; }
.chat-list-head { display:flex; gap:8px; padding:14px; border-bottom:1px solid var(--border-soft); align-items:center; }
.chat-search { flex:1; display:flex; align-items:center; gap:8px; padding:8px 12px; border-radius:12px; background:var(--input-bg); border:1px solid var(--border); color:var(--text-dim); }
.chat-search input { flex:1; background:none; border:none; outline:none; color:var(--text); font-size:.86rem; }
#convItems { overflow-y:auto; flex:1; }
.conv-item { display:flex; gap:12px; padding:12px 14px; cursor:pointer; border-bottom:1px solid var(--border-soft); align-items:center; }
.conv-item:hover { background:var(--glass-strong); }
.conv-item.active { background:var(--glass-strong); }
.conv-meta { flex:1; min-width:0; }
.conv-top { display:flex; justify-content:space-between; gap:8px; }
.conv-name { font-weight:600; font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-time { color:var(--text-dim); font-size:.72rem; white-space:nowrap; }
.conv-bottom { display:flex; justify-content:space-between; gap:8px; margin-top:2px; }
.conv-last { color:var(--text-dim); font-size:.82rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-unread { background:var(--brand-2); color:#fff; font-size:.68rem; min-width:18px; height:18px; border-radius:9px; display:grid; place-items:center; padding:0 5px; }

.chat-pane { flex:1; display:flex; flex-direction:column; min-width:0; }
.chat-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; color:var(--text-dim); }
.chat-empty .icon { opacity:.4; }
.chat-active { flex:1; display:flex; flex-direction:column; min-height:0; }
.chat-head { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); }
.chat-back { display:none; }
.chat-peer-name { font-weight:600; font-size:.95rem; }
.chat-peer-status { font-size:.75rem; color:var(--text-dim); }
.chat-peer-status.is-online { color:#22c55e; }
.chat-msgs { flex:1; overflow-y:auto; padding:18px; display:flex; flex-direction:column; gap:6px; }
.chat-daysep { text-align:center; font-size:.72rem; color:var(--text-dim); margin:10px 0; }
.cmsg { display:flex; }
.cmsg.me { justify-content:flex-end; }
.cbubble { max-width:72%; padding:9px 13px 6px; border-radius:14px; font-size:.9rem; line-height:1.45; position:relative; word-wrap:break-word; }
.cmsg.them .cbubble { background:var(--glass-2); border:1px solid var(--border-soft); border-bottom-left-radius:5px; }
.cmsg.me .cbubble { background:var(--grad); color:#fff; border:none; border-bottom-right-radius:5px; }
.cmeta { display:block; text-align:right; font-size:.62rem; color:var(--text-dim); margin-top:3px; }
.ticks { margin-left:3px; letter-spacing:-2px; }
.ticks.seen { color:#38bdf8; }
.chat-typing { padding:4px 20px 0; display:flex; gap:4px; align-items:center; height:20px; }
.tdot { width:7px; height:7px; border-radius:50%; background:var(--text-dim); animation:tbounce 1.2s infinite; }
.tdot:nth-child(2){ animation-delay:.2s; } .tdot:nth-child(3){ animation-delay:.4s; }
@keyframes tbounce { 0%,60%,100%{ transform:translateY(0); opacity:.4;} 30%{ transform:translateY(-5px); opacity:1;} }
.chat-input { display:flex; gap:10px; padding:14px 16px; border-top:1px solid var(--border); }
.chat-input input { flex:1; padding:11px 15px; border-radius:22px; border:1px solid var(--border); background:var(--input-bg); color:var(--text); outline:none; font-size:.9rem; }
.chat-input input:focus { border-color:var(--brand-2); }
.chat-input .btn { border-radius:50%; width:44px; height:44px; padding:0; }
.online-dot { position:absolute; width:11px; height:11px; border-radius:50%; background:#22c55e; border:2px solid var(--bg-1); right:-1px; bottom:-1px; }
.offline-dot { position:absolute; width:11px; height:11px; border-radius:50%; background:#f59e0b; border:2px solid var(--bg-1); right:-1px; bottom:-1px; }
.chat-peer-status { display:flex; align-items:center; gap:6px; }
.pres-dot { width:9px; height:9px; border-radius:50%; background:#f59e0b; display:inline-block; flex:0 0 auto; }
.pres-dot.online { background:#22c55e; }
.avatar { position:relative; }
.pick-item { display:flex; gap:12px; align-items:center; padding:10px 12px; border-radius:12px; cursor:pointer; }
.pick-item:hover { background:var(--glass-strong); }

@media (max-width:760px){
  .chat-wrap { height: calc(100vh - 120px); }
  .chat-list { width:100%; }
  .chat-pane { display:none; }
  #chatApp.chat-open .chat-list { display:none; }
  #chatApp.chat-open .chat-pane { display:flex; }
  .chat-back { display:grid; }
}

/* ---------- Global search ---------- */
.global-search { position:relative; display:flex; align-items:center; gap:8px; padding:8px 14px; border-radius:12px;
  background:var(--input-bg); border:1px solid var(--border); color:var(--text-dim); min-width:220px; max-width:360px; flex:1; margin:0 8px; }
.global-search input { flex:1; background:none; border:none; outline:none; color:var(--text); font-size:.86rem; }
#globalResults { position:absolute; top:calc(100% + 8px); left:0; right:0; min-width:280px; padding:8px; display:none; max-height:420px; overflow:auto; }
#globalResults.open { display:block; animation:pop .15s ease; }
.gs-group { font-size:.68rem; text-transform:uppercase; letter-spacing:.08em; color:var(--text-dim); padding:8px 10px 4px; }
.gs-item { display:flex; flex-direction:column; padding:9px 11px; border-radius:10px; }
.gs-item:hover { background:var(--glass-strong); }
.gs-name { font-size:.88rem; font-weight:600; }
.gs-sub { font-size:.76rem; color:var(--text-dim); }
.gs-empty { padding:12px; color:var(--text-dim); font-size:.85rem; }
@media (max-width:760px){ .global-search { display:none; } }

/* ---------- Payroll rows + payslip lines ---------- */
.pay-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-radius:14px;
  border:1px solid var(--border-soft); background:var(--glass-2); margin-bottom:10px; cursor:pointer; transition:transform .12s, border-color .15s; }
.pay-row:hover { transform:translateY(-1px); border-color:var(--brand-2); }
.pay-ico { width:40px; height:40px; border-radius:12px; display:grid; place-items:center; color:#fff; background:var(--grad); }
.ps-line { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border-soft); font-size:.9rem; }
.ps-line:last-child { border-bottom:none; }

/* ---------- Progress bar (targets/KPI) ---------- */
.pbar { height:8px; border-radius:6px; background:var(--glass-2); overflow:hidden; border:1px solid var(--border-soft); }
.pbar span { display:block; height:100%; background:var(--grad); border-radius:6px; transition:width .4s ease; }

/* ---------- Rich text editor ---------- */
.rte-wrap { border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--input-bg); }
.rte-toolbar { display:flex; gap:2px; padding:6px; border-bottom:1px solid var(--border-soft); flex-wrap:wrap; align-items:center; }
.rte-toolbar button { background:none; border:1px solid transparent; color:var(--text-dim); border-radius:8px; min-width:30px; height:30px; padding:0 6px; cursor:pointer; font-size:.85rem; line-height:1; }
.rte-toolbar button:hover { background:var(--glass-strong); color:var(--text); }
.rte-format { height:30px; border-radius:8px; background:var(--input-bg); border:1px solid var(--border); color:var(--text); font-size:.8rem; padding:0 6px; cursor:pointer; }
.rte-sep { width:1px; height:20px; background:var(--border); margin:0 3px; }
.rte-color { display:inline-flex; align-items:center; gap:2px; position:relative; height:30px; padding:0 4px; border-radius:8px; cursor:pointer; }
.rte-color:hover { background:var(--glass-strong); }
.rte-color span { font-weight:700; font-size:.9rem; }
.rte-color input { width:18px; height:18px; border:none; background:none; cursor:pointer; padding:0; }
.rte { min-height:110px; max-height:340px; overflow:auto; padding:10px 12px; color:var(--text); outline:none; font-size:.9rem; line-height:1.6; }
.rte a { color:var(--brand-2); }
.rte h2 { font-size:1.35rem; margin:.4em 0 .2em; }
.rte h3 { font-size:1.15rem; margin:.4em 0 .2em; }
.rte h4 { font-size:1rem; margin:.4em 0 .2em; }
.rte blockquote { border-left:3px solid var(--brand-2); margin:.4em 0; padding:.2em 0 .2em 12px; color:var(--text-dim); }
.rte ul,.rte ol { padding-left:22px; }

/* ---------- Tasks ---------- */
.task-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-radius:14px;
  border:1px solid var(--border-soft); background:var(--glass-2); margin-bottom:10px; cursor:pointer; transition:transform .12s,border-color .15s; }
.task-row:hover { transform:translateY(-1px); border-color:var(--brand-2); }
.task-desc { font-size:.92rem; line-height:1.6; color:var(--text); }
.task-desc h3,.task-desc h4 { margin:.4em 0 .2em; }
.task-desc a { color:var(--brand-2); }
.task-thread { display:flex; flex-direction:column; gap:10px; }
.tc { padding:11px 13px; border-radius:12px; background:var(--glass-2); border:1px solid var(--border-soft); }
.tc.submit { border-left:3px solid #3b82f6; }
.tc.approve { border-left:3px solid #22c55e; }
.tc.reject { border-left:3px solid #f87171; }
.tc.system { background:transparent; border-style:dashed; font-size:.82rem; }
.tc-head { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.tc-body { font-size:.9rem; line-height:1.55; }
.tc-file { font-size:.8rem; display:inline-flex; gap:4px; align-items:center; margin-top:6px; }

/* ---------- Tasks list cards (richer) ---------- */
.task-card { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:14px 16px; border-radius:16px;
  border:1px solid var(--border-soft); background:var(--glass-2); margin-bottom:12px; cursor:pointer; transition:transform .12s, border-color .15s, box-shadow .15s; }
.task-card:hover { transform:translateY(-2px); border-color:var(--brand-2); box-shadow:0 8px 24px rgba(0,0,0,.18); }
.task-card-main { display:flex; align-items:center; gap:14px; min-width:0; flex:1; }
.task-avatar { width:42px; height:42px; flex:0 0 auto; border-radius:12px; display:grid; place-items:center; font-weight:700; font-size:.85rem; color:#fff; background:var(--grad); }
.task-card-title { font-weight:600; font-size:.98rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.task-badges { display:flex; gap:6px; flex-wrap:wrap; margin:4px 0 3px; }
.task-card-side { display:flex; flex-direction:column; align-items:flex-end; gap:6px; flex-shrink:0; }
.task-card-side small { display:inline-flex; align-items:center; gap:4px; font-size:.76rem; }
.task-due-over { color:#f87171; font-weight:600; display:inline-flex; align-items:center; gap:4px; font-size:.76rem; }
@media (max-width:600px){ .task-card-title { white-space:normal; } }

/* reload icon button spin */
.icon-btn.spin svg { animation:mareebspin .6s linear infinite; }
@keyframes mareebspin { to { transform:rotate(360deg); } }

/* ---------- Daily attendance snapshot cards ---------- */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; }
.stat-card { display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:14px; border:1px solid var(--border-soft); }
.stat-card .s-ico { width:40px; height:40px; border-radius:11px; display:grid; place-items:center; background:var(--glass-strong); color:var(--brand-2); flex:0 0 auto; }
.stat-card .s-ico.online { color:#22c55e; } .stat-card .s-ico.ok { color:#22c55e; }
.stat-card .s-ico.warn { color:#f59e0b; } .stat-card .s-ico.bad { color:#f87171; }
.stat-card .s-num { font-size:1.5rem; font-weight:700; line-height:1; }
.stat-card .s-lbl { font-size:.78rem; color:var(--text-dim); margin-top:3px; }

/* ---------- Advance payouts (dashboard) ---------- */
.ap-sub { font-size:.8rem; font-weight:700; color:var(--text-dim); text-transform:uppercase; letter-spacing:.04em; margin-bottom:10px; display:flex; align-items:center; gap:8px; }
.ap-item { display:flex; align-items:center; gap:12px; padding:12px; border-radius:14px; border:1px solid var(--border-soft); background:var(--glass-2); margin-bottom:10px; }
.ap-ava { width:38px; height:38px; flex:0 0 auto; border-radius:11px; display:grid; place-items:center; font-weight:700; font-size:.8rem; color:#fff; background:var(--grad); }
.ap-info { min-width:0; flex:1; }
.ap-name { font-weight:600; font-size:.92rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ap-meta { font-size:.75rem; color:var(--text-dim); }
.ap-amt { font-weight:700; font-size:.95rem; flex-shrink:0; }
.ap-empty { display:flex; align-items:center; gap:8px; color:var(--text-dim); font-size:.85rem; padding:16px 12px; border:1px dashed var(--border-soft); border-radius:14px; }
.ap-item .pbar { height:5px; }

/* ---------- Premium header badges + notification dropdown ---------- */
.icon-btn { position:relative; }
.icon-btn .dot {
  position:absolute; top:-5px; right:-5px; min-width:18px; height:18px; padding:0 5px;
  border-radius:9px; background:linear-gradient(135deg,#ef4444,#f97316); color:#fff;
  font-size:.68rem; font-weight:700; display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 8px rgba(239,68,68,.5); border:2px solid var(--header-bg,#0b1220); line-height:1;
  animation:badgePop .25s ease; }
@keyframes badgePop { 0%{transform:scale(.4);opacity:0} 100%{transform:scale(1);opacity:1} }
.nav-link .pill {
  margin-left:auto; min-width:20px; height:20px; padding:0 6px; border-radius:10px;
  background:linear-gradient(135deg,#ef4444,#f97316); color:#fff; font-size:.7rem; font-weight:700;
  display:inline-flex; align-items:center; justify-content:center; box-shadow:0 2px 6px rgba(239,68,68,.4); }
.nav-link.active .pill { background:rgba(255,255,255,.25); box-shadow:none; }
.dropdown-menu#notifMenu { padding:0; overflow:hidden; border-radius:16px; }
.notif-head { display:flex; align-items:center; justify-content:space-between; padding:13px 16px; border-bottom:1px solid var(--border-soft); font-weight:700; font-size:.92rem; position:sticky; top:0; background:var(--glass-strong); backdrop-filter:blur(12px); }
#notifList { max-height:380px; overflow:auto; }
.notif-item { padding:12px 16px; border-bottom:1px solid var(--border-soft); transition:background .12s; text-decoration:none; color:var(--text); }
.notif-item:hover { background:var(--glass-2); }
.notif-item.unread { background:linear-gradient(90deg,rgba(59,130,246,.10),transparent); border-left:3px solid var(--brand-2); }
.notif-item small { color:var(--text-dim); font-size:.72rem; }

/* heading token */
.card h1,.card h2,.card h3,.card h4,.head h3,.display{color:var(--heading);}

/* Rich-text code formatting */
.rte code, .prose code, .ab code, .agent-log code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.88em; background:color-mix(in srgb,var(--brand-1) 14%,transparent); border:1px solid var(--border-soft); border-radius:5px; padding:1px 6px; }
.rte pre, .prose pre, .ab pre, .agent-log pre { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.86em; background:var(--bg-0); border:1px solid var(--border); border-radius:10px; padding:12px 14px; overflow-x:auto; line-height:1.5; margin:8px 0; white-space:pre-wrap; }
.rte pre code, .prose pre code, .ab pre code, .agent-log pre code { background:none; border:0; padding:0; }

/* Page header — consistent spacing across every page (fixes cramped/stuck layouts) */
.page-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap; margin:0 0 24px; }
.page-head > div:first-child { min-width:0; }
.page-title { font-size:1.55rem; font-weight:700; line-height:1.2; margin:0; letter-spacing:-.01em; }
.page-head .muted { margin-top:3px; font-size:.9rem; }
@media (max-width:600px){ .page-title{ font-size:1.3rem; } }

/* Themeable link colour for content anchors (not buttons/nav/tabs) */
.rte a, .task-desc a, .prose a, .flash a, .empty a, .card a.link, a.link { color: var(--link); }
.rte a:hover, .task-desc a:hover, .prose a:hover, .flash a:hover { text-decoration: underline; }

/* ── Notification panel: solid background + strong blur so nothing shows through ── */
.dropdown-menu#notifMenu{
  background: var(--surface, #141824) !important;
  backdrop-filter: blur(26px) saturate(140%); -webkit-backdrop-filter: blur(26px) saturate(140%);
  border:1px solid var(--border-soft, rgba(255,255,255,.12));
  box-shadow:0 24px 70px -12px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.03);
}
[data-theme="dark"] .dropdown-menu#notifMenu{ background:#131826 !important; }
[data-theme="light"] .dropdown-menu#notifMenu{ background:#ffffff !important; }
#notifList{ max-height:60vh; overflow:auto; }
#notifList .notif-item{ display:block; padding:12px 16px; border-bottom:1px solid var(--border-soft, rgba(255,255,255,.07)); border-radius:0; line-height:1.35; }
#notifList .notif-item:last-child{ border-bottom:0; }
#notifList .notif-item + .notif-item{ margin-top:0; }
#notifList .notif-item .n-title{ font-weight:600; font-size:.86rem; margin-bottom:2px; }
#notifList .notif-item small{ display:block; margin-top:3px; opacity:.8; }
#notifList .notif-item.unread{ background:linear-gradient(90deg,rgba(59,130,246,.14),transparent); border-left:3px solid var(--brand-2,#3b82f6); }

/* mention dropdown always on top */
.mareeb-mention-box{ z-index:2147483000 !important; }

/* AI Insights + AI-rendered rich text: keep bullets/headings tidy inside the card */
#aiInsBody{ overflow-wrap:break-word; }
#aiInsBody p{ margin:0 0 9px; } #aiInsBody p:last-child{ margin-bottom:0; }
#aiInsBody ul,#aiInsBody ol{ margin:8px 0; padding-left:20px; }
#aiInsBody li{ margin:5px 0; padding-left:3px; line-height:1.55; }
#aiInsBody h3,#aiInsBody h4,#aiInsBody h5{ margin:14px 0 6px; font-weight:700; line-height:1.3; }
#aiInsBody h3{ font-size:1.02rem; } #aiInsBody h4{ font-size:.95rem; } #aiInsBody h5{ font-size:.9rem; }
#aiInsBody h3:first-child,#aiInsBody h4:first-child{ margin-top:0; }
#aiInsBody strong{ font-weight:700; }
