:root {
  color-scheme: light;
  --brand: #2f6fed;
  --brand-dark: #1f4fc4;
  --brand-light: #eef3ff;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2430;
  --muted: #6b7686;
  --danger: #d64545;
  --danger-light: #fdeaea;
  --success: #1a9b5c;
  --success-light: #e8f8ef;
  --warn: #d98a1e;
  --warn-light: #fff4e2;
  --warn-dark: #8a5a10;
  --purple: #7c3aed;
  --purple-light: #f3ebff;
  --logo-blue: #1e71b5;
  --logo-purple: #582c91;
  --logo-gradient: linear-gradient(135deg, var(--logo-blue), var(--logo-purple));
  --shadow-sm: 0 1px 2px rgba(28, 36, 48, 0.05);
  --shadow-md: 0 4px 14px rgba(28, 36, 48, 0.07);
  --surface-hover: #f3f5f9;
  --table-hover: #fafbfd;
  --group-muted: #a7afba;
  --btn-secondary-bg: #eef1f6;
  --btn-secondary-bg-hover: #e3e8f0;
  --badge-neutral-bg: #eee;
  --overlay: rgba(20, 24, 32, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #5c93f5;
    --brand-dark: #9dbdfb;
    --brand-light: rgba(92, 147, 245, 0.16);
    --bg: #11141b;
    --card: #1a1e28;
    --border: #2c313d;
    --text: #e7eaf0;
    --muted: #97a0b0;
    --danger: #f0807f;
    --danger-light: rgba(240, 128, 127, 0.16);
    --success: #4fd499;
    --success-light: rgba(79, 212, 153, 0.16);
    --warn: #f0ad4e;
    --warn-light: rgba(240, 173, 78, 0.16);
    --warn-dark: #f0ad4e;
    --purple: #ab8ffa;
    --purple-light: rgba(171, 143, 250, 0.18);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --surface-hover: #232833;
    --table-hover: #1f2430;
    --group-muted: #6b7180;
    --btn-secondary-bg: #232833;
    --btn-secondary-bg-hover: #2c313d;
    --badge-neutral-bg: #2a2f3a;
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #5c93f5;
  --brand-dark: #9dbdfb;
  --brand-light: rgba(92, 147, 245, 0.16);
  --bg: #11141b;
  --card: #1a1e28;
  --border: #2c313d;
  --text: #e7eaf0;
  --muted: #97a0b0;
  --danger: #f0807f;
  --danger-light: rgba(240, 128, 127, 0.16);
  --success: #4fd499;
  --success-light: rgba(79, 212, 153, 0.16);
  --warn: #f0ad4e;
  --warn-light: rgba(240, 173, 78, 0.16);
  --warn-dark: #f0ad4e;
  --purple: #ab8ffa;
  --purple-light: rgba(171, 143, 250, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --surface-hover: #232833;
  --table-hover: #1f2430;
  --group-muted: #6b7180;
  --btn-secondary-bg: #232833;
  --btn-secondary-bg-hover: #2c313d;
  --badge-neutral-bg: #2a2f3a;
  --overlay: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Bengali", system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -4px; }
.icon-lg { width: 24px; height: 24px; vertical-align: -6px; }

/* ---------- Notification banners ---------- */
.notif-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 24px; font-size: 13px; font-weight: 500;
}
.notif-bar.warning { background: var(--warn-light); color: var(--warn-dark); }
.notif-bar.info { background: var(--brand-light); color: var(--brand-dark); }
.notif-bar .icon { width: 16px; height: 16px; flex-shrink: 0; }
.notif-bar .notif-msg { flex: 1; }
.notif-bar a.notif-action {
  background: rgba(0,0,0,0.08); padding: 3px 10px; border-radius: 6px; font-weight: 600; font-size: 12px;
  color: inherit; white-space: nowrap;
}
.notif-bar a.notif-action:hover { background: rgba(0,0,0,0.14); text-decoration: none; }

/* ---------- Top bar ---------- */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  /* Higher than any in-page sticky header (e.g. .chat-thread-head, z-index:10)
     so the notification dropdown — nested inside .navbar's own stacking
     context — can never render behind page content that happens to share
     the old z-index:10. Stays below transient overlays that must cover
     everything including the navbar (.chat-reaction-picker: 500, .modal: 1000). */
  z-index: 45;
  transition: background-color .2s ease, border-color .2s ease;
}
.navbar .brand { display: flex; align-items: center; line-height: 0; }
.navbar .brand:hover { text-decoration: none; }
.navbar .brand img { display: block; }

.navbar-right { display: flex; align-items: center; gap: 12px; }

/* One shared pill instead of three individually-bordered circles — groups
   the theme/language/notification controls into a single visual unit. */
.navbar-utility-group {
  display: flex; align-items: center; gap: 2px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.navbar-utility-group .theme-toggle {
  border: none; background: transparent; width: 32px; height: 32px;
}
.navbar-utility-group .theme-toggle:hover { background: var(--surface-hover); }

.navbar-divider { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }

.user-menu-wrap { position: relative; }
.user-menu-toggle {
  display: flex; align-items: center; gap: 10px; padding: 5px 8px 5px 12px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 10px; text-decoration: none; transition: background-color .15s;
}
.user-menu-toggle:hover { background: var(--surface-hover); }
.user-menu-chevron { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.user-meta { text-align: right; line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.avatar-photo { object-fit: cover; }

.user-dropdown {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 40;
  min-width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden; padding: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .user-dropdown { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4); }
}
:root[data-theme="dark"] .user-dropdown { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4); }
.user-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text); text-decoration: none;
  transition: background-color .12s ease;
}
.user-dropdown-item:hover { background: var(--surface-hover); text-decoration: none; }
.user-dropdown-item .icon { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.user-dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger); }
.user-dropdown-item.danger:hover .icon { color: var(--danger); }

.menu-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer;
}
.menu-toggle:hover { background: var(--surface-hover); }
.sidebar-overlay { display: none; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; flex-shrink: 0;
  transition: background-color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { background: var(--surface-hover); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.login-wrap .theme-toggle { position: fixed; top: 18px; right: 20px; box-shadow: var(--shadow-sm); z-index: 5; }

.lang-toggle { font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.lang-toggle:hover { text-decoration: none; }
.login-wrap .lang-toggle { position: fixed; top: 18px; right: 64px; box-shadow: var(--shadow-sm); z-index: 5; }

/* ---------- Header notification bell ---------- */
.notif-bell-wrap { position: relative; }
.notif-bell-badge {
  position: absolute; top: -2px; right: -2px;
  font-size: 9.5px; min-width: 15px; height: 15px;
  border: 2px solid var(--card); box-sizing: content-box;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 40;
  width: 360px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notif-dropdown { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4); }
}
:root[data-theme="dark"] .notif-dropdown { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.4); }
/* Small pointer triangle connecting the panel back to the bell, so it reads as "attached" rather than a stray floating box. */
.notif-dropdown::before {
  content: ''; position: absolute; top: -7px; right: 12px;
  width: 14px; height: 14px; background: var(--card);
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg); border-radius: 3px 0 0 0;
}
.notif-dropdown-head {
  padding: 14px 18px; font-weight: 700; font-size: 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-hover);
  position: relative;
}
.notif-dropdown-body { max-height: 420px; overflow-y: auto; }
.notif-dropdown-empty { padding: 28px 16px; color: var(--muted); font-size: 13px; text-align: center; margin: 0; }
.notif-section-title {
  padding: 12px 18px 6px; font-size: 10.5px; text-transform: uppercase;
  color: var(--brand); letter-spacing: .07em; font-weight: 800;
}
.notif-section-title-divider { border-top: 1px solid var(--border); margin-top: 4px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 18px; font-size: 12.8px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--border);
  transition: background-color .12s ease;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); text-decoration: none; }
.notif-item-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--brand-light);
}
.notif-item-icon .icon { width: 15px; height: 15px; color: var(--brand); }
.notif-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-item-msg {
  line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-item-time { color: var(--muted); font-size: 10.5px; }
@media (max-width: 560px) {
  .notif-dropdown { position: fixed; top: 60px; right: 8px; left: 8px; width: auto; }
  .notif-dropdown::before { display: none; }
}

/* ---------- Compact icon action buttons (list-row actions) ---------- */
.action-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  cursor: pointer; text-decoration: none; flex-shrink: 0;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }
.icon-btn .icon { width: 16px; height: 16px; vertical-align: middle; }
.icon-btn:disabled { opacity: .65; cursor: not-allowed; }

/* ---------- Inline loading spinner (button busy state) ---------- */
.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: middle;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toggle switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; width: 38px; height: 21px; border-radius: 999px;
  background: var(--border); flex-shrink: 0; transition: background-color .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Client list row ---------- */
.client-name-cell { display: flex; align-items: center; gap: 10px; }
.client-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--logo-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

/* ---------- AI provider settings cards ---------- */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; align-items: stretch; }
.provider-card {
  position: relative; margin-bottom: 0; overflow: hidden;
  display: flex; flex-direction: column;
  border-top-color: transparent; padding-top: 22px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .2s ease;
}
.provider-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent, var(--brand));
}
.provider-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.provider-card.anthropic { --accent: var(--purple); }
.provider-card.openai { --accent: var(--success); }
.provider-card.gemini { --accent: var(--brand); }
.provider-card form { display: flex; flex-direction: column; flex: 1; }
.provider-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.provider-avatar {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent, var(--brand)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
  box-shadow: 0 3px 10px -3px var(--accent, var(--brand));
}
.provider-head h3 { margin: 0; font-size: 15.5px; line-height: 1.3; }
.provider-head .badge { margin-left: auto; flex-shrink: 0; }
.provider-help { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.key-status {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600;
  padding: 9px 12px; border-radius: 9px; margin-bottom: 18px; min-width: 0;
}
.key-status .icon { width: 15px; height: 15px; flex-shrink: 0; }
.key-status.set { background: var(--success-light); color: var(--success); }
.key-status.unset { background: var(--danger-light); color: var(--danger); }
.key-status-text { flex-shrink: 0; }
.key-status code {
  flex: 1; background: transparent; border: 1px solid currentColor; opacity: .85;
  padding: 2px 7px; border-radius: 5px; font-size: 11.5px; font-family: 'Courier New', monospace;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.provider-card .form-group:last-of-type { margin-bottom: 0; }
.provider-card .switch { margin: 4px 0 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.provider-card .btn { width: 100%; justify-content: center; margin-top: auto; }

/* ---------- Layout / sidebar ---------- */
.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 59px); }
.sidebar {
  width: 232px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  position: sticky;
  top: 59px;
  height: calc(100vh - 59px);
  overflow-y: auto;
  flex-shrink: 0;
  transition: background-color .2s ease, border-color .2s ease;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}
.sidebar a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--logo-gradient); color: #fff; font-weight: 700; }
.sidebar a span:first-of-type { flex: 1; }
.nav-badge {
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.sidebar .group-title {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; border: none; background: transparent; cursor: pointer;
  padding: 16px 12px 6px; font-size: 10.5px; text-transform: uppercase;
  color: var(--group-muted); letter-spacing: .07em; font-weight: 700;
  font-family: inherit;
}
.sidebar .group-title:hover { color: var(--text); }
.nav-group-chevron { width: 13px; height: 13px; flex-shrink: 0; transition: transform .15s ease; }
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-body { display: none; }

.content { flex: 1; padding: 26px 32px; max-width: 1120px; }

/* Opt-in for pages whose cards are wide data tables (many columns, stat
   grids) — the default 1120px cap exists for readable line-length on
   prose/form pages, but it starves a table with 6-8 columns for room on
   any screen wider than a laptop. Set $wideContent = true before including
   header.php to use this instead. */
.content.content-wide { max-width: 1600px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: background-color .2s ease, border-color .2s ease;
}

h1.page-title { font-size: 21px; margin: 0 0 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; }
h1.page-title .icon-lg { color: var(--brand); }

/* ---------- Stat cards (dashboard / summaries) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; border-top: 3px solid var(--accent, var(--brand));
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }
.stat-card .stat-label .icon { width: 14px; height: 14px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: var(--text); margin-top: 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.late { background: var(--danger-light); color: var(--danger); }
.badge.ontime { background: var(--success-light); color: var(--success); }
.badge.overtime { background: var(--warn-light); color: var(--warn); }
.badge.absent { background: var(--badge-neutral-bg); color: var(--muted); }
.badge.info { background: var(--brand-light); color: var(--brand-dark); }
.badge.purple { background: var(--purple-light); color: var(--purple); }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
/* Audit log "changes" column: caps a long before/after JSON dump to a
   readable column width and force-wraps it (JSON has few natural break
   points) instead of stretching the row or overflowing. */
.audit-changes-cell { max-width: 340px; overflow-wrap: anywhere; word-break: break-word; }
table.data th { color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; }
table.data tbody tr:hover { background: var(--table-hover); }
table.data td input[type=text],
table.data td input[type=number] {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit;
  background: var(--card); color: var(--text); transition: border-color .15s, background-color .2s ease;
}
table.data td input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
table.data td .payment-input {
  width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text); font-size: 13px; font-family: inherit;
}
table.data td .payment-input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}

/* Two-column form layout (client/reason pairs, etc.) that collapses to one
   column on mobile — see the `.rtable` responsive-table pattern below for
   the same treatment applied to data tables instead of forms. */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

/* ---------- Settings page: labeled groups + a day-of-week pill picker ---------- */
.settings-section { padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--border); }
.settings-section:first-child { padding-top: 0; margin-top: 0; border-top: none; }
.settings-section h4 {
  display: flex; align-items: center; gap: 8px; margin: 0 0 14px;
  font-size: 13.5px; font-weight: 700; color: var(--text);
}
.settings-section h4 .icon { width: 16px; height: 16px; color: var(--brand); }
.settings-section + .btn { margin-top: 20px; }

/* ---------- Invoice form: totals summary + action row ---------- */
.invoice-total-box {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  margin-top: 16px; padding: 14px 18px; border-radius: 10px; background: var(--brand-light);
}
.invoice-total-box .label { font-size: 13px; font-weight: 700; color: var(--brand-dark); }
.invoice-total-box .value { font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

.day-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.day-toggle { position: relative; cursor: pointer; }
.day-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.day-toggle span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 600;
  transition: background-color .15s, border-color .15s, color .15s;
}
.day-toggle:hover span { border-color: var(--muted); }
.day-toggle input:checked + span { background: var(--logo-gradient); color: #fff; border-color: transparent; }
.day-toggle input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Bulk-action callout (a single prominent admin action, set
   apart from ordinary filter controls — e.g. "generate for everyone") ---------- */
.callout-action {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--brand-light); margin-bottom: 18px;
}
.callout-action-text { display: flex; align-items: center; gap: 14px; }
.callout-action-text .icon-lg { color: var(--brand); flex-shrink: 0; }
.callout-action-title { font-weight: 700; font-size: 14.5px; }
.callout-action-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Chart.js canvas wrapper — fixed CSS height instead of a canvas
   height attribute, so the chart (rendered with maintainAspectRatio:false)
   resizes fluidly with its container instead of needing horizontal scroll. */
.chart-wrap { position: relative; height: 300px; }
@media (max-width: 860px) {
  .chart-wrap { height: 230px; }
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=date],
.form-group input[type=time],
.form-group input[type=number],
.form-group textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--text); transition: border-color .15s, background-color .2s ease;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
.form-group textarea { min-height: 100px; }

/* Every <select> site-wide (form fields, inline table selects, filter bars)
   gets the same themed look instead of the raw OS control. */
select {
  padding: 8px 30px 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  background-color: var(--card);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 15px;
  transition: border-color .15s, background-color .2s ease;
}
select:hover { border-color: var(--muted); }
select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
select::-ms-expand { display: none; }
.form-group select { width: 100%; }
table.data select { padding: 5px 26px 5px 8px; font-size: 12.5px; border-radius: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--logo-gradient);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { filter: brightness(0.92); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--btn-secondary-bg); color: var(--text); box-shadow: none; }
.btn.secondary:hover { background: var(--btn-secondary-bg-hover); }
.btn.danger { background: var(--danger); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--success-light); color: var(--success); }
.alert.error { background: var(--danger-light); color: var(--danger); }

.todo-item-row { display: flex; gap: 8px; margin-bottom: 8px; }
.todo-item-row input { flex: 1; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, var(--brand-light), var(--bg) 60%);
}
.login-wrap .card {
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  text-align: center;
  border-radius: 16px;
  padding: 40px 36px;
}
.login-wrap .logo { display: block; height: 72px; margin: 0 auto 24px; max-width: 100%; }
.login-wrap .subtitle { color: var(--muted); font-size: 14px; margin: -12px 0 24px; }
.login-wrap .form-group { text-align: left; }
.login-wrap .form-group label { font-size: 13px; color: var(--text); }
.login-wrap .card .btn { padding: 11px 18px; font-size: 15px; margin-top: 6px; justify-content: center; }
.password-field { position: relative; }
.password-field input { padding-right: 42px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: none; background: none; border-radius: 6px;
  color: var(--muted); cursor: pointer;
}
.password-toggle:hover { background: var(--surface-hover); color: var(--text); }
.password-toggle .icon { width: 17px; height: 17px; }

.rich-content p { margin: 0 0 8px; }
.rich-content ol, .rich-content ul { margin: 0 0 8px; padding-left: 24px; }
.rich-content blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }

/* ---------- Notice board ---------- */
.notice-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.notice-item:last-child { border-bottom: none; padding-bottom: 0; }
.notice-item:first-child { padding-top: 0; }
.notice-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notice-item-head h4 { margin: 0; font-size: 14.5px; }
.notice-item-meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }

/* Quill only sizes .ql-editor to its content by default — without this the
   outer box (set via inline min-height on #editor) is taller than the
   actual clickable/editable area, so clicks below the first line do nothing. */
#editor.ql-container .ql-editor { min-height: 220px; }

/* Quill's snow theme ships hardcoded light colors — retint for dark mode
   so the toolbar/editor don't stay a bright white box on a dark page. */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border) !important; }
.ql-toolbar.ql-snow { background: var(--btn-secondary-bg); border-radius: 10px 10px 0 0; }
.ql-container.ql-snow { border-radius: 0 0 10px 10px; }
.ql-container.ql-snow .ql-editor { background: var(--card); color: var(--text); }

/* ---------- Small inline hint under a form field ---------- */
.tip-box {
  display: flex; align-items: flex-start; gap: 8px; margin: 14px 0;
  padding: 10px 12px; border-radius: 8px; background: var(--brand-light);
  color: var(--brand-dark); font-size: 12.5px; line-height: 1.5;
}
.tip-box .icon { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.ql-editor.ql-blank::before { color: var(--muted) !important; }
.ql-snow .ql-stroke { stroke: var(--muted); }
.ql-snow .ql-fill { fill: var(--muted); }
.ql-snow .ql-picker { color: var(--muted); }
.ql-snow .ql-picker-options { background: var(--card); border-color: var(--border) !important; }

/* ======================================================================
   Responsive — tablet & phone
   ====================================================================== */
@media (max-width: 860px) {
  .menu-toggle { display: flex; }

  .user-meta { display: none; }

  .layout { position: relative; }
  .sidebar {
    position: fixed;
    top: 59px;
    left: 0;
    height: calc(100vh - 59px);
    width: 250px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 30;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 59px 0 0 0;
    background: var(--overlay);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  .content { padding: 18px 16px; max-width: 100%; }
  .card { padding: 16px; }

  h1.page-title { font-size: 18px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .provider-grid { grid-template-columns: 1fr; }

  form[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }

  table.data { display: block; overflow-x: auto; white-space: nowrap; }

  /* Opt-in: a `table.data.rtable` becomes a stack of labeled cards instead
     of a horizontally-scrolling table — for list tables where the row has
     too many small facts (and actions) to skim sideways on a phone. Each
     <td> needs a data-label attribute; the header row is visually hidden
     rather than removed, so it's still announced to screen readers. */
  /* table/tbody must drop out of table-layout entirely (not just tr/td) —
     otherwise the table's auto column-width algorithm still shrink-to-fits
     the now-block tr against its content instead of the full table width,
     leaving a stray gap on the right of every card. */
  table.rtable { display: block; overflow-x: visible; white-space: normal; }
  table.rtable tbody { display: block; }
  table.rtable thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  /* Each row-card gets its own surface tone (not the same --card the
     surrounding .card container already uses) — otherwise the only thing
     separating one invoice from the next is a faint 1px border and they
     read as one continuous block. */
  table.rtable tbody tr {
    display: block; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px; margin-bottom: 16px; background: var(--surface-hover);
    box-shadow: var(--shadow-sm);
  }
  table.rtable tbody tr:last-child { margin-bottom: 0; }
  table.rtable tbody tr:hover { background: var(--surface-hover); }
  table.rtable td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 9px 0; border-bottom: 1px solid var(--border); text-align: right;
  }
  table.rtable td:last-child { border-bottom: none; }
  table.rtable td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--muted);
  }
  table.rtable td.rtable-actions { justify-content: flex-start; }
  table.rtable td.rtable-actions::before { display: none; }

  /* The audit log's "changes" column holds full before/after JSON dumps —
     much longer than a normal label:value pair. rtable's default side-by-side
     flex row (label left, value right, both nowrap-shrinking) assumes a short
     value, so a long unbroken JSON string just overflows past the card edge
     instead of wrapping. Stack the label above a full-width wrapped block
     for this one column instead. */
  table.rtable td.audit-changes-cell {
    flex-direction: column; align-items: flex-start; text-align: left; gap: 6px;
    max-width: 100%;
  }

  /* admin/clients.php's editable service-rows table: on a wide screen the
     description/rate/remove-button columns sit side by side fine, but the
     rate column's fixed 160px width leaves too little room for the
     description input on a phone — it was rendering readable text as
     truncated ("Social Medi..."). Stack each row into its own compact
     card instead: description input full-width on its own line, rate +
     remove button sharing the line below. */
  table.service-rows-table, table.service-rows-table tbody, table.service-rows-table tr { display: block; }
  table.service-rows-table thead { display: none; }
  table.service-rows-table tr {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    border: 1px solid var(--border); border-radius: 8px; padding: 10px;
    margin-bottom: 10px; background: var(--surface-hover);
  }
  table.service-rows-table td { display: block; border: none; padding: 0; }
  table.service-rows-table td:first-child { flex: 1 1 100%; }
  table.service-rows-table td:nth-child(2) { flex: 1 1 auto; }
  table.service-rows-table td:last-child { flex: 0 0 auto; }

  .login-wrap .card { padding: 28px 22px; }

  /* One pane at a time: conversation list, or the open thread — matches
     the standard mobile chat-app pattern (WhatsApp/Slack/Messenger). */
  .chat-layout { height: calc(100vh - 150px); border-radius: 0; }
  .chat-sidebar { width: 100%; display: flex; }
  .chat-thread { display: none; }
  .chat-layout.has-conversation .chat-sidebar { display: none; }
  .chat-layout.has-conversation .chat-thread { display: flex; }
  .chat-back-link { display: inline-flex; }
  .chat-bubble-col { max-width: 85%; }
  /* No hover on touch — the reply/react icons must stay visible, not
     appear only on a hover event that never fires. */
  .chat-bubble-actions { opacity: 1; }
}

@media (max-width: 460px) {
  .stat-grid { grid-template-columns: 1fr; }
  .navbar { padding: 10px 14px; }
  .navbar .brand img { height: 24px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
}

/* ---------- Chat ---------- */
.chat-layout {
  display: flex; height: calc(100vh - 170px); min-height: 460px;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--card); box-shadow: var(--shadow-md);
}
/* A notice banner (todo/report reminder, pending-leave count, etc.) sits
   above .layout and pushes everything down by its own height, which the
   170px estimate above doesn't know about — without this, the composer
   ends up pushed below the fold whenever a banner is showing. :has() lets
   this stay a pure-CSS fix instead of measuring layout in JS. */
body:has(.notif-bar) .chat-layout { height: calc(100vh - 218px); }
.chat-sidebar { width: 300px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; background: var(--card); }
.chat-sidebar-head { padding: 14px; border-bottom: 1px solid var(--border); }
.chat-sidebar-head .btn { border-radius: 10px; font-weight: 700; }

.chat-new-panel {
  padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px;
  background: var(--surface-hover); animation: slide-reply .15s ease-out;
}
.chat-new-tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.chat-new-tab {
  flex: 1; padding: 6px 8px; border: none; background: transparent; border-radius: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s;
}
.chat-new-tab.active { background: var(--brand); color: #fff; }
.chat-inline-form { display: flex; flex-direction: column; gap: 8px; }
.chat-inline-form select, .chat-inline-form input[type=text] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); font-size: 13px; font-family: inherit;
}
.chat-inline-form select:focus, .chat-inline-form input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
.chat-inline-form button[type=submit] {
  align-self: flex-start; padding: 7px 16px; font-size: 12.5px;
}

/* Custom user picker (replaces a native <select> for the "সরাসরি মেসেজ" tab)
   — a native select's open dropdown list can't be themed, so it looked
   like a plain light popup against this app's dark UI. This is styled
   identically to .chat-member-check rows for a consistent look. */
.chat-user-select { position: relative; }
.chat-user-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--muted); font-size: 13px; font-family: inherit;
  cursor: pointer; text-align: left; transition: border-color .15s;
}
.chat-user-select-trigger:hover { border-color: var(--brand); }
.chat-user-select-trigger.has-value { color: var(--text); }
.chat-user-select-trigger .icon { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); transition: transform .15s; }
.chat-user-select.open .chat-user-select-trigger { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.chat-user-select.open .chat-user-select-trigger .icon { transform: rotate(180deg); }

.chat-user-select-menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 220px; overflow-y: auto; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); animation: slide-reply .12s ease-out;
}
.chat-user-select-option {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border: none; background: transparent; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text); text-align: left; font-family: inherit;
}
.chat-user-select-option:hover { background: var(--surface-hover); }
.chat-user-select-option.selected { background: var(--brand-light); color: var(--brand-dark); }
.chat-member-picker { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px; background: var(--card); }
.chat-member-check {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: background-color .12s;
}
.chat-member-check:hover { background: var(--surface-hover); }
.chat-member-check input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--brand); cursor: pointer; }
.chat-member-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--logo-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700;
}
.chat-member-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.chat-conv-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 2px;
  text-decoration: none; color: var(--text); border-radius: 10px; border-left: 3px solid transparent;
  transition: background-color .12s;
}
.chat-conv-item:hover { background: var(--surface-hover); text-decoration: none; }
.chat-conv-item.active { background: var(--brand-light); border-left-color: var(--brand); }
.chat-conv-item.active .chat-conv-name { color: var(--brand-dark); }
.chat-conv-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--logo-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.chat-conv-avatar .icon { width: 18px; height: 18px; }
.chat-conv-body { min-width: 0; flex: 1; }
.chat-conv-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.chat-conv-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.chat-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); position: relative; }
.chat-thread-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--card); z-index: 10; }
.chat-thread-head-info { flex: 1; min-width: 0; }
.chat-thread-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-back-link { display: none; color: var(--muted); flex-shrink: 0; }
.chat-back-link .icon { width: 20px; height: 20px; }
.chat-thread-title { font-weight: 700; font-size: 14.5px; }
.chat-thread-sub { font-size: 12px; color: var(--muted); }

.chat-edit-group-panel {
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-hover);
  display: flex; flex-direction: column; gap: 14px; z-index: 10;
}
.chat-edit-group-panel .chat-inline-form { max-width: 320px; }
.chat-thread-actions form { display: contents; }

.chat-messages { flex: 1; overflow-y: auto; padding: 22px 18px 18px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.chat-bubble-row { display: flex; align-items: center; position: relative; width: 100%; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble-row.theirs { justify-content: flex-start; }

.chat-bubble-col { max-width: 70%; display: flex; flex-direction: column; position: relative; }
.chat-bubble-row.mine .chat-bubble-col { align-items: flex-end; }
.chat-bubble-row.theirs .chat-bubble-col { align-items: flex-start; }

.ai-chat-box { max-height: 480px; overflow-y: auto; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; padding: 4px 4px 4px 0; }
.ai-chat-box .chat-bubble-row { align-items: flex-start; }
.ai-chat-box .chat-bubble-row.theirs .chat-bubble { background: var(--bg); border: 1px solid var(--border); box-shadow: none; }

.chat-bubble { padding: 10px 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-sm); position: relative; }
.chat-bubble-row.mine .chat-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-row.theirs .chat-bubble { border-bottom-left-radius: 4px; }
.chat-bubble-sender { font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.chat-bubble-row.mine .chat-bubble-sender { color: rgba(255,255,255,.85); }
.chat-bubble-text { font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.chat-bubble-time { font-size: 10.5px; opacity: .7; margin-top: 4px; text-align: right; }
.chat-bubble audio { max-width: 230px; height: 34px; display: block; margin-top: 2px; }

.chat-reply-quote {
  border-left: 3px solid currentColor; opacity: .88; padding: 4px 10px; margin-bottom: 6px;
  border-radius: 6px; background: rgba(127,127,127,.12); font-size: 12px; line-height: 1.4;
  cursor: pointer; transition: opacity .15s, background-color .15s;
}
.chat-reply-quote:hover { opacity: 1; background: rgba(127,127,127,.22); }
.chat-reply-quote strong { display: block; font-size: 11px; font-weight: 700; margin-bottom: 1px; }

@keyframes message-highlight {
  0% { filter: brightness(1.25); transform: scale(1.03); }
  40% { filter: brightness(1.25); transform: scale(1.03); }
  100% { filter: brightness(1); transform: scale(1); }
}
.chat-bubble-row.highlighted .chat-bubble {
  animation: message-highlight 1.2s ease-out;
  box-shadow: 0 0 0 3px var(--brand);
}

/* Messenger style side action buttons */
.chat-bubble-actions {
  display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s ease;
  padding: 0 6px; flex-shrink: 0;
}
.chat-bubble-row:hover .chat-bubble-actions, .chat-bubble-actions:focus-within { opacity: 1; }
.chat-bubble-action {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  transition: all .15s ease; box-shadow: var(--shadow-sm);
}
.chat-bubble-action:hover { background: var(--surface-hover); color: var(--text); transform: scale(1.15); }
.chat-bubble-action .icon { width: 13px; height: 13px; }

.chat-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; width: 100%; }
.chat-bubble-row.mine .chat-reactions { justify-content: flex-end; }
.chat-bubble-row.theirs .chat-reactions { justify-content: flex-start; }
.chat-reaction-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 12px; cursor: pointer; transition: transform .12s, background-color .12s, border-color .12s;
  box-shadow: var(--shadow-sm);
}
.chat-reaction-pill.mine { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.chat-reaction-pill:hover { transform: scale(1.08); }

/* Messenger-style Floating Reaction Popover positioned over thread */
.chat-reaction-picker {
  position: absolute; z-index: 500;
  display: flex; align-items: center; gap: 4px; padding: 6px 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  animation: messenger-pop .18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  white-space: nowrap;
}

.chat-bubble-row.mine .chat-reaction-picker { right: 0; transform-origin: right bottom; }
.chat-bubble-row.theirs .chat-reaction-picker { left: 0; transform-origin: left bottom; }

@keyframes messenger-pop {
  from { opacity: 0; transform: scale(0.6) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.chat-reaction-picker button {
  width: 34px; height: 34px; border: none; background: transparent; border-radius: 50%;
  font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .15s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color .15s ease;
}
.chat-reaction-picker button:hover {
  background: var(--surface-hover);
  transform: scale(1.35) translateY(-4px);
}

.chat-edited-badge { font-size: 10px; opacity: .75; font-style: italic; margin-left: 4px; }
.chat-bubble-action.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

.chat-reply-preview, .chat-edit-preview {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--border); font-size: 12.5px;
  animation: slide-reply .15s ease-out;
}
.chat-reply-preview { background: var(--brand-light); color: var(--brand-dark); }
.chat-edit-preview { background: rgba(59, 130, 246, 0.12); color: var(--brand); }
@keyframes slide-reply {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-reply-preview-text, .chat-edit-preview-text { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.chat-reply-preview-text .icon, .chat-edit-preview-text .icon { width: 13px; height: 13px; flex-shrink: 0; }
.chat-reply-preview-text span, .chat-edit-preview-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.chat-empty .icon { width: 54px; height: 54px; opacity: .3; margin-bottom: 4px; }
.chat-empty p { margin: 0; max-width: 260px; line-height: 1.6; }
.chat-empty .btn { margin-top: 6px; }
.chat-empty-thread { margin: auto; text-align: center; padding: 30px 15px; color: var(--text); }

.chat-composer-wrap { position: relative; border-top: 1px solid var(--border); background: var(--card); }
#chatComposer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
#chatComposer.sending { opacity: .6; pointer-events: none; }
#chatComposer input[type=text] {
  flex: 1; padding: 10px 16px; border: 1px solid var(--border); border-radius: 22px;
  background: var(--surface-hover); color: var(--text); font-size: 13.5px; font-family: inherit;
}
#chatComposer input[type=text]:focus {
  outline: none; border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 3px var(--brand-light);
}
.chat-mic-btn, .chat-send-btn, .chat-attach-btn { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }
.chat-send-btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.chat-send-btn:hover { background: var(--brand-dark); color: #fff; }
.chat-mic-btn.recording { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.chat-attach-btn { color: var(--muted); background: var(--surface-hover); }
.chat-attach-btn:hover { color: var(--text); background: var(--border); }

/* Media previews in message bubbles */
.chat-media-wrap { margin-bottom: 4px; overflow: hidden; border-radius: 12px; }
.chat-img-preview {
  max-width: 320px; max-height: 280px; width: auto; height: auto;
  border-radius: 12px; object-fit: cover; display: block; cursor: pointer;
  transition: transform .2s ease, filter .2s ease;
}
.chat-img-preview:hover { transform: scale(1.02); filter: brightness(1.05); }
.chat-video-preview {
  max-width: 340px; max-height: 260px; width: 100%; border-radius: 12px;
  background: #000; display: block; outline: none;
}
.chat-media-caption { margin-top: 6px; font-size: 13px; }

/* Media preview bar above composer before sending */
.chat-media-preview-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--surface-hover); border-top: 1px solid var(--border);
  animation: slide-reply .15s ease-out;
}
.chat-media-preview-thumb {
  width: 44px; height: 44px; border-radius: 8px; background: var(--card);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 1px solid var(--border); font-size: 20px;
}
.chat-media-preview-thumb img, .chat-media-preview-thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-media-preview-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-media-preview-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-media-preview-size { font-size: 11px; color: var(--muted); }

.chat-recording-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(239, 68, 68, 0.08); border-top: 1px solid rgba(239, 68, 68, 0.25);
}
.chat-recording-left { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--danger); }
.chat-recording-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex-shrink: 0; }
.chat-recording-label { font-size: 13px; }
.chat-recording-timer { font-family: monospace; font-size: 13.5px; font-weight: 700; background: rgba(239, 68, 68, 0.15); padding: 2px 8px; border-radius: 6px; }

.chat-recording-actions { display: flex; align-items: center; gap: 8px; }
.btn-record-cancel {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 18px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 12.5px;
  font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.btn-record-cancel:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-light); }
.btn-record-cancel .icon { width: 14px; height: 14px; }

.btn-record-send {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 18px;
  border: none; background: var(--brand); color: #fff; font-size: 12.5px;
  font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.2); transition: all .15s ease;
}
.btn-record-send:hover { background: var(--brand-dark); transform: scale(1.04); }
.btn-record-send .icon { width: 14px; height: 14px; }

/* ---------- Generic centered modal (delete-message confirm, etc.) ----------
   Fixed + flex-centered instead of anchored/positioned near a trigger button
   — no getBoundingClientRect() math, so it can never end up unstyled/
   mispositioned depending on which element it was opened from. */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal-card {
  position: relative; width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: messenger-pop .16s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header h3 .icon { width: 17px; height: 17px; color: var(--danger); }
.modal-body { padding: 16px 18px; }
.modal-body p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.modal-footer { padding: 12px 18px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Guide page (guide.php) ----------
   Role-badge colors are local custom properties on .guide-page so they don't
   leak into the rest of the site; --role-admin reuses --brand directly so it
   stays correct across the theme toggle without a separate override. */
.guide-page {
  --role-member: #6b7280;
  --role-team_lead: #0e9488;
  --role-hr: #b8781f;
  --role-accounts: #2e8b57;
  --role-admin: var(--brand);
  --role-super: #b23368;
}
:root:not([data-theme="light"]) .guide-page {
  --role-member: #a9b0c2;
  --role-team_lead: #3fc7b8;
  --role-hr: #e0a34c;
  --role-accounts: #52c285;
  --role-super: #e37aa4;
}
:root[data-theme="dark"] .guide-page {
  --role-member: #a9b0c2;
  --role-team_lead: #3fc7b8;
  --role-hr: #e0a34c;
  --role-accounts: #52c285;
  --role-super: #e37aa4;
}

.guide-hero { background: var(--brand-light); border-color: var(--border); }
.guide-hero p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.7; max-width: 68ch; }
.guide-hero p:last-of-type { margin-bottom: 0; }
.guide-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.guide-legend a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.guide-legend a:hover { border-color: var(--rc, var(--brand)); transform: translateY(-1px); text-decoration: none; }
.guide-legend .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rc, var(--brand)); flex: none; }

.guide-facts { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.guide-facts div { font-size: 12.5px; color: var(--muted); }
.guide-facts b { display: block; font-size: 15px; color: var(--text); font-weight: 800; margin-top: 2px; }

.guide-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.guide-flow-step { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.guide-flow-step .n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 800; margin-bottom: 10px;
}
.guide-flow-step h4 { margin: 0 0 6px; font-size: 14.5px; font-weight: 700; }
.guide-flow-step p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.guide-flow-step .tag {
  display: inline-block; margin-top: 10px; font-size: 11px; font-weight: 700;
  color: var(--brand-dark); background: var(--brand-light); padding: 3px 8px; border-radius: 999px;
}

.guide-howto { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guide-howto li { display: flex; gap: 12px; align-items: flex-start; }
.guide-howto .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-light); color: var(--brand-dark);
  font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.guide-howto p { margin: 0; font-size: 14px; }
.guide-howto p.sub { margin-top: 3px; font-size: 12.5px; color: var(--muted); }

.guide-role-card { border-left: 4px solid var(--rc); }
.guide-role-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.guide-role-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.guide-role-slug { font-family: 'Courier New', monospace; font-size: 12px; color: var(--rc); font-weight: 700; }
.guide-role-for { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); max-width: 70ch; }
.guide-role-inherit {
  margin-top: 12px; font-size: 12.5px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface-hover); border: 1px solid var(--border);
}
.guide-role-inherit b { color: var(--rc); }
.guide-role-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 26px; margin-top: 16px; }
.guide-role-group h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800;
  color: var(--muted); margin: 0 0 9px;
}
.guide-role-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.guide-role-group li { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.guide-role-group li .icon { width: 15px; height: 15px; margin-top: 2px; flex: none; color: var(--rc); }
.guide-role-group li .note { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

table.guide-matrix td.yes { color: var(--success); font-weight: 800; text-align: center; }
table.guide-matrix td.no { color: var(--muted); text-align: center; }
table.guide-matrix th.feat, table.guide-matrix td.feat { text-align: left; }
.guide-matrix-foot { margin-top: 10px; font-size: 12px; color: var(--muted); }

@media (max-width: 700px) {
  .guide-role-card { border-left: none; border-top: 4px solid var(--rc); }
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }
