/* ══════════════════════════════════════════════════════
   LEGAL FOX · TEAM OS
   Design language: "Chambers" — enterprise legal operations
   Hairline structure · monospace data · serif authority
   ══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── TOKENS · LIGHT (default) ── */
:root {
  --sidebar-w: 232px;
  --topbar-h:  52px;
  --r:    6px;
  --r-sm: 4px;

  /* Type */
  --font-ui:      'Instrument Sans', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Surfaces — warm neutral, print-like */
  --canvas: #f5f5f3;
  --paper:  #ffffff;
  --raise:  #fafaf9;
  --sunken: #eeeeeb;

  /* Structure */
  --line:        #e3e3df;
  --line-strong: #cfcfc9;

  /* Ink */
  --ink:   #14161a;
  --ink-2: #565b63;
  --ink-3: #868b93;
  --ink-4: #b4b8be;

  /* Action — chromatically neutral, saturation reserved for status */
  --action:       #1a1d23;
  --action-hover: #33383f;
  --on-action:    #ffffff;

  /* Interactive / selected */
  --link:    #2f5d8a;
  --link-bg: #edf3f9;

  /* Status — the only saturated colors in the system */
  --ok:     #0f7048;  --ok-bg:   #e8f3ed;
  --warn:   #9c6410;  --warn-bg: #faf0e0;
  --crit:   #ab2a20;  --crit-bg: #fbecea;
  --info:   #2f5d8a;  --info-bg: #edf3f9;

  /* Sidebar */
  --rail:      #fbfbfa;
  --rail-line: #e6e6e2;

  --ring: 0 0 0 3px rgba(47,93,138,.14);
}

/* ── TOKENS · DARK ── */
[data-theme="dark"] {
  --canvas: #101114;
  --paper:  #17191d;
  --raise:  #1d1f24;
  --sunken: #0b0c0e;

  --line:        #292c32;
  --line-strong: #3b3f47;

  --ink:   #e7e7e4;
  --ink-2: #9ba0a8;
  --ink-3: #6c717a;
  --ink-4: #464b53;

  --action:       #e7e7e4;
  --action-hover: #ffffff;
  --on-action:    #14161a;

  --link:    #85aad4;
  --link-bg: #1a222d;

  --ok:     #46a87a;  --ok-bg:   #13241c;
  --warn:   #c9963f;  --warn-bg: #262013;
  --crit:   #d96b60;  --crit-bg: #291815;
  --info:   #85aad4;  --info-bg: #1a222d;

  --rail:      #131519;
  --rail-line: #24272c;

  --ring: 0 0 0 3px rgba(133,170,212,.16);
}

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

html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--canvas);
  color: var(--ink);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 99px;
  border: 3px solid var(--canvas);
}

/* Numeric data anywhere reads as tabular */
.mono, .num, td .mono {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

/* ══════════════════════════
   TOPBAR
   ══════════════════════════ */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 900;
  height: var(--topbar-h);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: stretch;
}
.topbar-brand {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex; align-items: center; gap: 9px;
  padding: 0 18px;
  border-right: 1px solid var(--line);
}
.brand-mark {
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: var(--action); color: var(--on-action);
  display: grid; place-items: center;
  font-size: .7rem; flex-shrink: 0;
}
.brand-word {
  font-family: var(--font-display);
  font-size: 1.12rem; letter-spacing: .005em;
  color: var(--ink); line-height: 1;
}
.topbar-main {
  flex: 1; display: flex; align-items: center;
  padding: 0 16px 0 18px; gap: 10px; min-width: 0;
}
/* Breadcrumb / context strip */
.topbar-context {
  font-size: .76rem; color: var(--ink-3);
  letter-spacing: .04em; text-transform: uppercase; font-weight: 600;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.tbar-btn {
  height: 30px; min-width: 30px; padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--ink-2); font-size: .82rem; cursor: pointer;
  font-family: var(--font-ui);
}
.tbar-btn:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.tbar-btn.badged { position: relative; }
.tbar-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 99px; background: var(--crit); color: #fff;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  display: grid; place-items: center;
  border: 1.5px solid var(--paper);
}

/* Theme switch — segmented, no glow */
.theme-seg {
  display: inline-flex; padding: 2px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--sunken);
}
.theme-seg button {
  width: 26px; height: 22px; border: 0; border-radius: 3px;
  background: transparent; color: var(--ink-3);
  font-size: .72rem; cursor: pointer; display: grid; place-items: center;
  transition: background .12s, color .12s;
}
.theme-seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
[data-theme="dark"] .theme-seg button.on { box-shadow: none; border: 1px solid var(--line-strong); }

.topbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.topbar-id { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.id-avatar {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--sunken); border: 1px solid var(--line);
  color: var(--ink-2);
  display: grid; place-items: center;
  font-size: .68rem; font-weight: 600; letter-spacing: .02em;
}
.id-name { font-size: .78rem; font-weight: 600; line-height: 1.25; color: var(--ink); }
.id-role {
  font-family: var(--font-mono); font-size: .62rem;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em;
}

/* ══════════════════════════
   RAIL (sidebar)
   ══════════════════════════ */
.app-shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--rail);
  border-right: 1px solid var(--rail-line);
  padding: 10px 8px 12px;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto; z-index: 800;
}
.side-label {
  font-family: var(--font-mono);
  font-size: .6rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-4);
  padding: 14px 10px 5px;
}
.sidebar a {
  display: flex; align-items: center; gap: 9px;
  height: 31px; padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: .82rem; font-weight: 500;
  white-space: nowrap;
}
.sidebar a i { font-size: .92rem; width: 16px; text-align: center; color: var(--ink-3); }
.sidebar a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.sidebar a:hover i { color: var(--ink-2); }
.sidebar a.active {
  background: var(--paper);
  color: var(--ink); font-weight: 600;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
[data-theme="dark"] .sidebar a.active { box-shadow: none; }
.sidebar a.active i { color: var(--ink); }
.sidebar-count {
  margin-left: auto;
  font-family: var(--font-mono); font-size: .66rem;
  color: var(--ink-3);
}
.sidebar-sep { height: 1px; background: var(--rail-line); margin: 9px 10px; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--rail-line); padding-top: 8px; }

/* ══════════════════════════
   CONTENT
   ══════════════════════════ */
.content-wrap {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 26px 30px 48px;
  max-width: 1420px;
}

/* ── Page masthead ── */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.85rem; font-weight: 400;
  line-height: 1.1; letter-spacing: -.005em;
  color: var(--ink);
}
.page-sub {
  font-size: .8rem; color: var(--ink-3);
  margin-top: 5px;
}
.page-sub .mono { color: var(--ink-2); }

/* ── Eyebrow ── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: .63rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ══════════════════════════
   PANELS
   ══════════════════════════ */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--raise);
}
.card-header strong {
  font-size: .82rem; font-weight: 600; letter-spacing: -.005em;
  color: var(--ink);
}
.card-p { padding: 18px; }

/* ══════════════════════════
   STAT STRIP — no gradients, hairline dividers
   ══════════════════════════ */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.stat {
  padding: 15px 18px;
  border-right: 1px solid var(--line);
  position: relative;
}
.stat:last-child { border-right: 0; }
.stat-label {
  font-family: var(--font-mono);
  font-size: .63rem; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 6px;
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 1.75rem; font-weight: 500;
  line-height: 1.15; margin-top: 8px;
  color: var(--ink); font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.stat-meta {
  font-size: .72rem; color: var(--ink-3); margin-top: 3px;
}
.stat.is-crit .stat-val { color: var(--crit); }
.stat.is-warn .stat-val { color: var(--warn); }
.stat.is-ok   .stat-val { color: var(--ok); }
/* Status rule at the top of an alerting stat */
.stat.is-crit::before, .stat.is-warn::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat.is-crit::before { background: var(--crit); }
.stat.is-warn::before { background: var(--warn); }

/* ══════════════════════════
   TABLES — the workhorse
   ══════════════════════════ */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 8px 14px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: .63rem; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
  background: var(--raise);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: .82rem;
  color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--raise); }

/* SLA spine — signature element: a status rule on the row's leading edge */
.data-table tbody tr td:first-child {
  border-left: 3px solid transparent;
  padding-left: 13px;
}
tr.sla-ok   td:first-child { border-left-color: var(--ok); }
tr.sla-warn td:first-child { border-left-color: var(--warn); }
tr.sla-crit td:first-child { border-left-color: var(--crit); }
tr.sla-none td:first-child { border-left-color: var(--line-strong); }

.cell-primary { font-weight: 600; color: var(--ink); font-size: .84rem; }
.cell-primary:hover { text-decoration: underline; text-underline-offset: 2px; }
.cell-ref {
  font-family: var(--font-mono); font-size: .68rem;
  color: var(--ink-3); letter-spacing: .01em; margin-top: 2px;
}

/* Countdown cell */
.countdown { font-family: var(--font-mono); font-size: .78rem; font-variant-numeric: tabular-nums; font-weight: 500; }
.countdown.ok   { color: var(--ok); }
.countdown.warn { color: var(--warn); }
.countdown.crit { color: var(--crit); }
.sla-track { height: 2px; background: var(--sunken); border-radius: 99px; margin-top: 5px; width: 78px; }
.sla-fill  { height: 2px; border-radius: 99px; }
.sla-fill.ok   { background: var(--ok); }
.sla-fill.warn { background: var(--warn); }
.sla-fill.crit { background: var(--crit); }

/* ══════════════════════════
   TAGS (status) — squared, print-like
   ══════════════════════════ */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: .65rem; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag-crit { background: var(--crit-bg); color: var(--crit); border-color: var(--crit); }
.tag-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.tag-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok); }
.tag-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.tag-mute { background: var(--sunken);  color: var(--ink-2); border-color: var(--line-strong); }
/* Priority uses a leading square, not a fill */
.tag-p::before {
  content: ''; width: 6px; height: 6px; border-radius: 1px; background: currentColor;
}

/* ══════════════════════════
   BUTTONS — ink-filled, no glow
   ══════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: .8rem; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-primary:hover { background: var(--action-hover); }
.btn-ghost {
  background: var(--paper); color: var(--ink-2);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--sunken); color: var(--ink); }
.btn-danger { background: var(--crit-bg); color: var(--crit); border-color: var(--crit); }
.btn-danger:hover { background: var(--crit); color: #fff; }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: var(--ok); color: #fff; }
.btn-sm { height: 26px; padding: 0 9px; font-size: .74rem; }
.btn-icon { width: 32px; padding: 0; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* Filter segment */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  overflow: hidden; background: var(--paper);
}
.seg a {
  padding: 0 12px; height: 28px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .76rem; font-weight: 500; color: var(--ink-2);
  border-right: 1px solid var(--line);
}
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.seg a.on { background: var(--action); color: var(--on-action); font-weight: 600; }
.seg .count { font-family: var(--font-mono); font-size: .66rem; opacity: .75; }

/* ══════════════════════════
   FORMS
   ══════════════════════════ */
.form-control, .form-select {
  width: 100%;
  height: 34px; padding: 0 11px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-ui); font-size: .82rem;
  outline: none;
}
textarea.form-control { height: auto; padding: 9px 11px; min-height: 84px; resize: vertical; line-height: 1.55; }
select.form-select[multiple] { height: auto; padding: 6px; }
.form-control:hover, .form-select:hover { border-color: var(--ink-4); }
.form-control:focus, .form-select:focus { border-color: var(--link); box-shadow: var(--ring); }
.form-control::placeholder { color: var(--ink-4); }
.form-select option { background: var(--paper); color: var(--ink); }
.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: .64rem; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.form-hint { font-size: .72rem; color: var(--ink-3); margin-top: 5px; }
.field { margin-bottom: 15px; }

/* ══════════════════════════
   FLASH
   ══════════════════════════ */
.flash {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 13px; margin-bottom: 16px;
  border-radius: var(--r-sm);
  border: 1px solid; border-left-width: 3px;
  font-size: .82rem;
}
.flash-success { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok); }
.flash-danger  { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); }
.flash-info    { background: var(--info-bg); border-color: var(--info); color: var(--info); }

/* ══════════════════════════
   IDENTITY
   ══════════════════════════ */
.person { display: inline-flex; align-items: center; gap: 8px; }
.mono-avatar {
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: var(--sunken); border: 1px solid var(--line);
  color: var(--ink-2);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: .62rem; font-weight: 600;
  flex-shrink: 0; text-transform: uppercase;
}
.mono-avatar.lg { width: 34px; height: 34px; font-size: .74rem; }
.live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }
.presence { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--ok); font-weight: 500; }

/* ══════════════════════════
   CHAT
   ══════════════════════════ */
/* The chat page fills the viewport exactly, so the compose bar is always on screen */
.content-chat {
  height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column;
  overflow: hidden;
  padding-bottom: 22px;
}
.content-chat .page-header { flex-shrink: 0; margin-bottom: 16px; padding-bottom: 12px; }
.content-chat .chat-shell  { flex: 1; min-height: 0; height: auto; }

.chat-shell {
  display: grid; grid-template-columns: 268px 1fr;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--paper);
}
.chat-list-pane {
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--raise);
}
.chat-list-head { flex-shrink: 0; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.chat-search { position: relative; }
.chat-search input { height: 30px; padding-left: 30px; font-size: .78rem; background: var(--paper); }
.chat-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-size: .78rem; }
.chat-list-items { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  color: var(--ink);
}
.chat-item:hover { background: var(--sunken); text-decoration: none; }
.chat-item.active { background: var(--paper); border-left-color: var(--action); }
.chat-item-name { font-size: .8rem; font-weight: 600; }
.chat-item-kind {
  font-family: var(--font-mono); font-size: .62rem;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; margin-top: 1px;
}
.chat-main-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.chat-topbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.chat-topbar-name { font-size: .84rem; font-weight: 600; }
.chat-topbar-meta { font-family: var(--font-mono); font-size: .63rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }

.messages-area {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px 18px 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.msg-bubble-wrap { display: flex; align-items: flex-end; gap: 7px; max-width: 68%; }
.msg-bubble-wrap.me { margin-left: auto; flex-direction: row-reverse; }
.msg-bubble {
  position: relative;
  padding: 8px 11px;
  border-radius: var(--r);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: .82rem; line-height: 1.5;
  word-break: break-word;
}
.msg-bubble-wrap.me .msg-bubble { background: var(--link-bg); border-color: var(--link); }
[data-theme="dark"] .msg-bubble-wrap.me .msg-bubble { border-color: var(--line-strong); }
.msg-bubble.deleted-msg {
  background: transparent; border-style: dashed; border-color: var(--line-strong);
  color: var(--ink-3); font-style: italic;
}
.msg-sender {
  font-family: var(--font-mono); font-size: .62rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 3px;
}
.msg-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  font-family: var(--font-mono); font-size: .62rem;
  color: var(--ink-4); margin-top: 4px;
}
.msg-ctx-btn {
  display: none; position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 3px;
  background: var(--sunken); border: 1px solid var(--line);
  color: var(--ink-3); cursor: pointer;
  align-items: center; justify-content: center; font-size: .58rem;
}
.msg-bubble:hover .msg-ctx-btn { display: flex; }
.ctx-menu {
  position: absolute; top: 24px; right: 0; z-index: 60;
  min-width: 178px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  overflow: hidden;
}
[data-theme="dark"] .ctx-menu { box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; font-size: .78rem; color: var(--ink); cursor: pointer;
}
.ctx-item:hover { background: var(--sunken); }
.ctx-item.danger { color: var(--crit); }
.ctx-item i { width: 13px; text-align: center; font-size: .8rem; }
.ctx-sep { height: 1px; background: var(--line); }

.chat-compose-area {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.chat-compose-area textarea {
  flex: 1; min-height: 34px; max-height: 120px; resize: none;
  padding: 8px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--paper);
  color: var(--ink); font-family: var(--font-ui); font-size: .82rem;
  line-height: 1.5; outline: none;
}
.chat-compose-area textarea:focus { border-color: var(--link); box-shadow: var(--ring); }
.compose-attach-btn, .compose-send-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  font-size: .85rem;
}
.compose-attach-btn { background: var(--paper); border: 1px solid var(--line-strong); color: var(--ink-2); }
.compose-attach-btn:hover { background: var(--sunken); color: var(--ink); }
.compose-send-btn { background: var(--action); border: 0; color: var(--on-action); }
.compose-send-btn:hover { background: var(--action-hover); }

.date-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.date-divider span {
  font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}

/* ══════════════════════════
   MODAL
   ══════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(20,22,26,.42);
  align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px;
  overflow-y: auto;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.62); }
.modal-overlay.active { display: flex; }
.modal-box {
  width: 100%; max-width: 460px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  animation: mIn .14s ease-out;
}
[data-theme="dark"] .modal-box { box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.modal-box.modal-lg { max-width: 620px; }
@keyframes mIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 400; color: var(--ink); }
.modal-close {
  width: 26px; height: 26px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 1.1rem; line-height: 1; display: grid; place-items: center;
}
.modal-close:hover { background: var(--sunken); color: var(--ink); }
.modal-body-inner { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line); background: var(--raise);
}

/* ══════════════════════════
   DEPARTMENT / LIST TILES
   ══════════════════════════ */
.tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.tile:hover { border-color: var(--line-strong); }
.tile-name { font-size: .88rem; font-weight: 600; color: var(--ink); }
.tile-meta { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-3); }
.tile-rule { height: 2px; width: 26px; background: var(--action); margin-bottom: 11px; }

/* ══════════════════════════
   NOTIFICATIONS
   ══════════════════════════ */
.notif-item {
  display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  color: var(--ink);
}
.notif-item:hover { background: var(--raise); text-decoration: none; }
.notif-item.unread { border-left-color: var(--link); background: var(--link-bg); }
.notif-title { font-size: .83rem; font-weight: 600; }
.notif-body { font-size: .79rem; color: var(--ink-2); margin-top: 2px; }
.notif-time { font-family: var(--font-mono); font-size: .65rem; color: var(--ink-3); margin-top: 4px; }

/* ══════════════════════════
   EMPTY STATE
   ══════════════════════════ */
.empty-state { padding: 54px 20px; text-align: center; }
.empty-state i { font-size: 1.5rem; color: var(--ink-4); display: block; margin-bottom: 10px; }
.empty-state .es-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink-2); }
.empty-state p { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }

/* ══════════════════════════
   UTILITIES
   ══════════════════════════ */
.d-flex{display:flex}.align-center{align-items:center}.justify-between{justify-content:space-between}
.flex-wrap{flex-wrap:wrap}.flex-1{flex:1}.mt-auto{margin-top:auto}.w-100{width:100%}
.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}
.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.5rem}
.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}
.text-muted{color:var(--ink-3)!important}.text-sub{color:var(--ink-2)!important}
.text-ok{color:var(--ok)!important}.text-crit{color:var(--crit)!important}.text-warn{color:var(--warn)!important}
.text-center{text-align:center}.text-right{text-align:right}
.text-truncate{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.fs-sm{font-size:.79rem}.fs-xs{font-size:.72rem}
.fw-600{font-weight:600}
.min-w-0{min-width:0}
.d-md-block{display:none}
@media(min-width:768px){.d-md-block{display:block}}
.grid-2{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}
.divider{height:1px;background:var(--line);margin:16px 0}

/* ══════════════════════════
   RESPONSIVE
   ══════════════════════════ */
@media (max-width: 1100px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 54px; }
  .sidebar a span, .side-label, .sidebar-count { display: none; }
  .sidebar a { justify-content: center; padding: 0; }
  .brand-word { display: none; }
  .topbar-brand { width: var(--sidebar-w); justify-content: center; padding: 0; }
  .topbar-context { display: none; }
  .chat-shell { grid-template-columns: 1fr; }
  .chat-list-pane { display: none; }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .content-wrap { margin-left: 0; width: 100%; padding: 16px 14px 84px; }
  .sidebar {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 56px;
    flex-direction: row; justify-content: space-around;
    border-right: 0; border-top: 1px solid var(--rail-line); padding: 6px;
  }
  .sidebar-sep, .sidebar-bottom { display: none; }
  .sidebar a { height: 40px; width: 44px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: 1.5rem; }
  .topbar-id .id-name, .topbar-id .id-role { display: none; }
  .msg-bubble-wrap { max-width: 86%; }
}

/* ═══════════════════════════
   CALLS IN MESSAGES
   ═══════════════════════════ */
.call-btn-group { display: flex; gap: 6px; }
.chat-call-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--paper); border: 1px solid var(--line-strong);
  color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; font-size: .85rem;
  transition: background .14s, color .14s, border-color .14s;
}
.chat-call-btn:hover { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chat-call-btn:disabled { opacity: .5; cursor: default; }

/* Live-call banner above the thread */
.call-banner {
  flex-shrink: 0;
  display: none; align-items: center; gap: 11px;
  padding: 10px 14px;
  background: var(--ok-bg);
  border-bottom: 1px solid var(--ok);
}
.call-banner.show { display: flex; }
.call-banner-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--ok);
  flex-shrink: 0; animation: callPulse 1.6s ease-in-out infinite;
}
@keyframes callPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }
.call-banner-text { flex: 1; min-width: 0; font-size: .82rem; color: var(--ok); font-weight: 600; }
.call-banner-sub { font-family: var(--font-mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; font-weight: 500; }

/* Call event card inside the thread */
.call-event {
  display: flex; align-items: center; gap: 10px;
  align-self: center;
  max-width: 82%;
  margin: 6px 0;
  padding: 8px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
}
.call-event.live { border-color: var(--ok); background: var(--ok-bg); }
.call-event-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sunken); color: var(--ink-2);
  display: grid; place-items: center; font-size: .78rem; flex-shrink: 0;
}
.call-event.live .call-event-icon { background: var(--ok); color: #fff; }
.call-event-text { display: flex; flex-direction: column; min-width: 0; }
.call-event-title { font-size: .78rem; font-weight: 500; color: var(--ink-2); }
.call-event.live .call-event-title { color: var(--ok); font-weight: 600; }
.call-event-time { font-family: var(--font-mono); font-size: .62rem; color: var(--ink-4); }

/* Meeting page: return-to-thread bar */
.meeting-backbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  font-size: .82rem;
}


/* Chat on small screens: leave room for the bottom navigation bar */
@media (max-width: 640px) {
  .content-chat {
    height: calc(100vh - var(--topbar-h) - 56px);
    padding: 12px 12px 12px;
  }
  .content-chat .page-header { margin-bottom: 12px; padding-bottom: 10px; }
}

/* A deleted message, as an administrator sees it */
.msg-bubble.deleted-admin {
  background: var(--warn-bg);
  border-color: var(--warn);
  border-style: dashed;
}
.deleted-reveal-tag {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: .6rem; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--warn);
  margin-bottom: 5px;
}
.deleted-reveal-meta {
  font-family: var(--font-mono); font-size: .6rem;
  color: var(--warn); opacity: .8; margin-top: 5px;
}
