/* AIGU OS — internal operating system theme (dark, AIGU brand) */
:root {
  color-scheme: dark;
  --bg: #081418; --bg-2: #0b1c21; --bg-3: #0e2329; --bg-4: #12303a;
  --line: rgba(166,222,230,.12); --line-2: rgba(166,222,230,.2);
  --text: #eef6f7; --muted: #a9c3c9; --faint: #5d7a82;
  --accent: #57d6f2; --accent-2: #2bc8d6; --accent-soft: rgba(87,214,242,.12);
  --accent-ink: #06232b;
  --brand-2: #7fe6d2; --muted-2: #7f9aa1;
  --gold: #f6c453; --amber: #f6c453;
  --green: #7fe6b0; --red: #ff9e9e;
  --chart-area: #57d6f2;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Noto Sans Display", "Inter", system-ui, -apple-system, sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  /* 100vh on iOS Safari excludes the collapsing browser toolbar, so the
     page is TALLER than the visible area and the composer (last flex child)
     gets pushed below the toolbar chrome and hides behind it. dvh tracks the
     real visible height; the vh line stays as a fallback for old engines. */
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; height: var(--app-h, 100dvh);
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; font-family: var(--font-display); }
button { font-family: inherit; }
::selection { background: rgba(87,214,242,.30); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid transparent; border-radius: 11px; cursor: pointer;
  padding: .55rem .95rem; font-size: .92rem; font-weight: 550; color: var(--text);
  background: var(--bg-3); transition: background .12s, transform .05s, border-color .12s;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-sm { padding: .38rem .7rem; font-size: .84rem; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; transition: all .12s; position: relative;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.ci { font-size: 1.05rem; line-height: 1; }
.field { display: block; margin-bottom: .7rem; }
.field > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; font-weight: 550; letter-spacing: .02em; }
.field input, .field select {
  width: 100%; padding: .55rem .7rem; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); font-size: .93rem; outline: none;
  transition: border-color .12s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
input[type="search"] {
  width: 100%; padding: .5rem .7rem; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); font-size: .9rem; outline: none;
}
input[type="search"]:focus { border-color: var(--accent); }
.form-actions { display: flex; align-items: center; gap: .6rem; margin-top: .4rem; }
.form-error { background: rgba(255,158,158,.10); border: 1px solid rgba(255,158,158,.4); color: #ffc9c9;
  border-radius: 10px; padding: .5rem .7rem; font-size: .85rem; margin: .5rem 0; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; margin-bottom: .9rem; }
.card h3, .card h4 { margin-bottom: .5rem; font-size: .95rem; }

/* ================================================================ OS chrome */
/* ---------- topbar ---------- */
.os-topbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: .7rem;
  height: 58px; padding: 0 1rem; background: var(--bg-2);
  border-bottom: 1px solid var(--line); position: relative; z-index: 75;
}
.tb-menu { display: none; }
.tb-brand { display: flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; flex: none; }
.tb-logo {
  display: block; width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: #f8f5ed url("/static/img/aigu-logo.svg") center / 76% 76% no-repeat;
  border: 1px solid rgba(168,127,53,.35);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  transition: transform .16s ease, box-shadow .16s ease;
}
.tb-brand:hover .tb-logo { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(168,127,53,.28); }
.tb-word { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; letter-spacing: -.015em; }
.tb-word em { font-style: normal; font-weight: 500; letter-spacing: .06em; color: var(--muted); font-size: .82em; }

.tb-search { position: relative; flex: 1; max-width: 540px; margin-left: .4rem; }
.tb-search .tb-search-ico { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; display: flex; }
.tb-search input {
  width: 100%; padding: .52rem 1rem .52rem 2.35rem; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
  font-size: .88rem; outline: none; transition: border-color .12s, box-shadow .12s;
}
.tb-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tb-drop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 80;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; }
.tb-drop-title { padding: .55rem .95rem .15rem; font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }
.tb-drop-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .95rem; cursor: pointer; }
.tb-drop-item:hover { background: var(--bg-4); }
.tb-drop-item .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: .72rem; }
.tb-drop-item .dt-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-drop-item .dt-sub { font-size: .72rem; color: var(--muted); }
.tb-drop-item .dt-ava { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tb-drop-empty { padding: .7rem .95rem; font-size: .82rem; color: var(--muted); }

.tb-actions { display: flex; align-items: center; gap: .3rem; margin-left: auto; }
/* theme switch — same footprint as the bell / group-call icons */
#btn-theme { color: var(--muted); }
#btn-theme:hover { color: var(--text); }
#btn-theme svg { display: block; }

/* floating theme switch on the standalone pages (login, join, 404/500, group call) */
.theme-fab {
  position: fixed; top: 14px; right: 14px; z-index: 210;
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--muted);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transition: color .14s, background .14s, border-color .14s, transform .12s;
}
.theme-fab:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.theme-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-fab svg { display: block; }
.tb-bell { position: relative; display: flex; }
.bell-badge { position: absolute; top: 1px; right: 0; background: var(--red); color: var(--accent-ink);
  font-size: .58rem; font-weight: 700; min-width: 15px; height: 15px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 3px; }
.bell-drop { left: auto; right: -6px; width: 320px; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .22rem .55rem .22rem .25rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-3); margin-left: .3rem; }
.chip-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#55d4e8,#2bc8d6);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff; }
.chip-meta { display: flex; flex-direction: column; line-height: 1.2; }
.chip-name { font-size: .8rem; font-weight: 650; }
.chip-role { font-size: .64rem; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- rail: aigu.vn navigation language ---------- */
/* aigu.vn keeps its nav on one line at 14.5px in --muted, with a thin underline
   accent for the current page and a soft teal pill for active controls. The rail
   below reuses exactly that vocabulary, stacked vertically. */
.os-rail {
  width: 248px; flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: .85rem .7rem 1rem; gap: 1.05rem;
  scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent;
}

/* brand block — the gold AIGU monogram on its cream tile, wordmark to the right */
.rail-head {
  display: flex; align-items: center; gap: .4rem; width: 100%;
  padding: .1rem .25rem .85rem .45rem; margin-bottom: .1rem;
  border-bottom: 1px solid var(--line);
}
.rail-brand {
  display: flex; align-items: center; gap: .65rem; flex: 1; min-width: 0;
  padding: 0; background: transparent; border: 0; cursor: pointer; text-align: left;
}
/* drawer-only close affordance, mirrors aigu.vn's .mobile-close */
.rail-close {
  display: none; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: var(--muted);
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.rail-close:hover { background: rgba(255,255,255,.08); color: var(--text); border-color: var(--line-2); }
.rail-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rail-mark {
  display: block; width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: #f8f5ed url("/static/img/aigu-logo.svg") center / 76% 76% no-repeat;
  border: 1px solid rgba(168,127,53,.35);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  transition: transform .16s ease, box-shadow .16s ease;
}
.rail-brand:hover .rail-mark { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(168,127,53,.3); }
.rail-brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.rail-word { font-family: var(--font-display); font-size: 1.24rem; font-weight: 800;
  letter-spacing: -.02em; color: var(--text); white-space: nowrap; }
.rail-tagline { font-size: .62rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2, var(--faint)); margin-top: .16rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rail-sec { display: flex; flex-direction: column; gap: .1rem; }
.rail-sec-title {
  font-size: .63rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  color: var(--faint); padding: 0 .6rem; margin-bottom: .35rem;
}

.rail-item {
  position: relative; display: flex; align-items: center; gap: .5rem;
  padding: .48rem .6rem; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 14.5px; font-weight: 500; line-height: 1.3;
  text-align: left; text-decoration: none; cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.rail-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.rail-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rail-item.active {
  color: var(--brand-2, #7fe6d2); background: rgba(87,214,242,.16);
  font-weight: 600;
}
.rail-item.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 2px; height: 16px; border-radius: 2px; background: var(--brand-2, #7fe6d2);
}
.ri-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-ext { margin-left: auto; font-size: .78rem; color: var(--faint); transition: color .18s ease; }
.rail-item:hover .ri-ext { color: var(--muted); }

.rail-foot {
  margin-top: auto; padding: .8rem .6rem .2rem; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .72rem; color: var(--faint); line-height: 1.5;
}
.rail-foot-link { display: inline-flex; align-items: center; gap: .3rem; align-self: flex-start;
  color: var(--muted); font-weight: 600; text-decoration: none; transition: color .18s ease; }
.rail-foot-link span { font-size: .72rem; color: var(--faint); }
.rail-foot-link:hover { color: var(--accent); }
.rail-foot-link:hover span { color: var(--accent); }
.rail-foot-note { color: var(--faint); font-size: .68rem; }

/* ---------- main / views ---------- */
#app-shell { flex: 1; display: flex; min-height: 0; }
.os-main { flex: 1; display: flex; min-width: 0; min-height: 0; background: var(--bg); }
.os-view { flex: 1; display: flex; min-width: 0; min-height: 0; flex-direction: column; }
#view-messenger { flex-direction: row; }

/* ---------- messenger sidebar ---------- */
.sidebar {
  width: 320px; min-width: 260px; max-width: 380px; display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--line);
}
.tabs { display: flex; gap: .25rem; padding: .8rem .7rem .6rem; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: .42rem 0; border: none; background: transparent; color: var(--muted);
  font-size: .83rem; font-weight: 600; border-radius: 9px; cursor: pointer; transition: all .12s;
}
.tab:hover { color: var(--text); background: var(--bg-3); }
.tab.active { background: var(--bg-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.panel { flex: 1; overflow-y: auto; padding: .6rem .6rem 1rem; display: flex; flex-direction: column; }
.panel-actions { padding: .3rem .3rem .6rem; }
.action-row { display: flex; gap: .4rem; margin-top: .5rem; }
.action-row .btn { flex: 1; justify-content: center; display: flex; gap: .35rem; }

/* ---------- chat list ---------- */
.chat-list, .people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: flex; gap: .65rem; align-items: center; padding: .55rem .55rem; border-radius: 12px;
  cursor: pointer; transition: background .1s; position: relative;
}
.chat-item:hover { background: var(--bg-3); }
.chat-item.active { background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.avatar {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: #fff; position: relative;
  background: var(--bg-4); user-select: none;
}
.avatar-lg { width: 52px; height: 52px; font-size: 1.3rem; border-radius: 15px; }
.avatar .online-dot {
  position: absolute; bottom: -2px; right: -2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--green); border: 2.5px solid var(--bg-2);
}
.chat-item-text { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; }
.chat-item-name { font-weight: 600; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: .72rem; color: var(--faint); flex-shrink: 0; }
.chat-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-top: 2px; }
.chat-item-preview { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .68rem; font-weight: 700;
  min-width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}
.badge.urgent { background: var(--red); color: var(--accent-ink); }

/* ---------- main / chat view ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.empty-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 2rem; gap: .4rem; }
.empty-emoji { font-size: 2.6rem; opacity: .9; }
.empty-main h2 { color: var(--text); font-size: 1.3rem; }
.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: .8rem; padding: .65rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--bg-2); flex: 0 0 auto;
}
.chat-id { display: flex; align-items: center; gap: .65rem; flex: 1; min-width: 0; }
.chat-id .avatar { width: 38px; height: 38px; font-size: .95rem; }
.chat-id h2 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; gap: .3rem; }
.head-actions .icon-btn:hover { background: var(--bg-4); }
#btn-back { display: none; }

.messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 1.1rem 1.2rem .6rem; display: flex; flex-direction: column; gap: .35rem;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, rgba(87,214,242,.05), transparent 45%);
}
.day-sep { display: flex; align-items: center; gap: .8rem; margin: .7rem 0 .4rem; color: var(--faint); font-size: .75rem; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: flex; gap: .55rem; max-width: 78%; animation: msgin .16s ease-out; }
@keyframes msgin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: .8rem; margin-top: 2px; }
.msg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-head { display: flex; gap: .5rem; align-items: baseline; }
.msg-sender { font-size: .75rem; font-weight: 650; color: var(--muted); }
.msg-time { font-size: .68rem; color: var(--faint); }
.bubble {
  padding: .5rem .75rem; border-radius: 14px; font-size: .94rem; line-height: 1.45;
  background: var(--bg-3); border: 1px solid var(--line); white-space: pre-wrap;
  word-break: break-word; overflow-wrap: anywhere;
}
.mine .bubble { background: var(--accent-soft); border-color: rgba(87,214,242,.38); border-top-right-radius: 5px; }
.msg:not(.mine) .bubble { border-top-left-radius: 5px; }
.bubble.streaming::after { content: "▍"; animation: blink 1s infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: .2; } }
.sys-line { align-self: center; text-align: center; font-size: .76rem; color: var(--faint);
  background: rgba(255,255,255,.03); border-radius: 999px; padding: .25rem .9rem; margin: .3rem 0; max-width: 90%;
  white-space: pre-wrap; word-break: break-word; }
.file-chip {
  display: flex; align-items: center; gap: .6rem; min-width: 240px; max-width: 340px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem;
  cursor: pointer; transition: border-color .12s, background .12s; text-decoration: none; color: var(--text);
}
.mine .file-chip { background: var(--accent-soft); border-color: rgba(87,214,242,.38); }
.file-chip:hover { border-color: var(--accent); }
.file-chip .fi { font-size: 1.5rem; }
.file-chip .ft { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.file-chip .fname { display: block; max-width: 100%; font-weight: 600; font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .fmeta { display: block; max-width: 100%; font-size: .74rem; color: var(--muted); }

.typing { flex: 0 0 auto; padding: 0 1.4rem .3rem; font-size: .78rem; color: var(--muted); height: 1.15rem; }
.typing-dots { letter-spacing: 2px; }
.composer {
  display: flex; align-items: flex-end; gap: .5rem; padding: .7rem 1rem .9rem;
  border-top: 1px solid var(--line); background: var(--bg-2);
  flex: 0 0 auto; padding-bottom: calc(.9rem + env(safe-area-inset-bottom, 0px));
}
.composer-attach { display: flex; gap: .2rem; flex: 0 0 auto; }
.composer #btn-send { flex: 0 0 auto; }
#msg-input {
  flex: 1 1 auto; min-width: 0; resize: none; max-height: 120px; min-height: 40px; padding: .6rem .8rem;
  border-radius: 11px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
  font-size: .94rem; font-family: inherit; outline: none; line-height: 1.4;
}
#msg-input:focus { border-color: var(--accent); }

/* ---------- info panel ---------- */
.info-panel {
  width: 300px; flex-shrink: 0; border-left: 1px solid var(--line); background: var(--bg-2);
  overflow-y: auto; padding: .9rem;
}
.info-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.info-members { display: flex; flex-direction: column; gap: .15rem; margin-bottom: 1rem; }
.info-member { display: flex; align-items: center; gap: .6rem; padding: .3rem .2rem; }
.info-member .avatar { width: 32px; height: 32px; font-size: .8rem; border-radius: 9px; }
.info-member .nm { font-size: .9rem; font-weight: 550; }
.info-member .st { font-size: .74rem; color: var(--muted); }
.me-row { display: flex; align-items: center; gap: .8rem; }
.me-name { font-weight: 650; font-size: .95rem; }
.topic-code {
  display: block; background: var(--bg); border: 1px dashed var(--line-2); border-radius: 9px;
  padding: .45rem .6rem; font-size: .8rem; color: var(--accent-2); cursor: pointer; margin: .4rem 0;
  word-break: break-all;
}

/* ---------- call overlay ---------- */
#call-overlay {
  position: fixed; inset: 0; background: #040d11; z-index: 100;
  display: flex; flex-direction: column;
}
.call-top { display: flex; align-items: center; gap: .9rem; padding: .9rem 1.4rem;
  border-bottom: 1px solid var(--line); }
.call-status { width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); font-size: 0; overflow: hidden; flex: none; }
.call-title { font-weight: 650; }
.call-timer { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.call-grid { flex: 1; display: grid; gap: 10px; padding: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-content: center; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  position: relative; display: flex; flex-direction: column; }
.tile video { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  background: #000; display: block; } /* deterministic 16:9: a muted/2x2 track
  must never stretch the grid row (it used to turn tiles square and shove
  them into the floating control island) */
.tile .tile-label { position: absolute; left: 10px; bottom: 8px; background: rgba(0,0,0,.55);
  border-radius: 7px; padding: 2px 9px; font-size: .75rem; }
.tile .tile-avatar { flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .5rem; min-height: 160px; }
.tile .tile-avatar .avatar { width: 64px; height: 64px; font-size: 1.6rem; border-radius: 18px; }
.tile.muted-mic .tile-label::after { content: " 🎤̶"; }
.call-controls { display: flex; align-items: center; justify-content: center; gap: .9rem;
  padding: 1rem 1rem 1.4rem; }
.cc { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--text); cursor: pointer; font-size: 1.35rem;
  display: flex; align-items: center; justify-content: center; transition: all .12s; }
.cc:hover { background: var(--bg-4); transform: scale(1.05); }
.cc.off { background: var(--bg); color: var(--faint); }
.cc-end { background: var(--red); border-color: var(--red); color: var(--accent-ink); }
.cc-end:hover { background: #ffb4b4; }

/* ---------- incoming call banner ---------- */
.incoming { position: fixed; right: 18px; bottom: 18px; z-index: 90; }
.incoming-card {
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 16px; padding: 1rem;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: .9rem; min-width: 330px;
  animation: slideup .18s ease-out;
}
@keyframes slideup { from { transform: translateY(12px); opacity: 0; } }
.incoming-avatar { flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem; color: var(--accent-ink);
  background: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,255,255,.10); }
.incoming-text { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.incoming-text #inc-title { font-weight: 600; font-size: .95rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.incoming-text .small { font-size: .8rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.incoming-actions { display: flex; flex-direction: column; gap: .4rem; margin-left: .4rem; }

/* ---------- sector hub ---------- */
#view-sector { overflow: hidden; }
.hub-wrap { flex: 1; overflow-y: auto; }
.hub { max-width: 1000px; margin: 0 auto; padding: 2.2rem 2.4rem 3rem;
  display: flex; flex-direction: column; gap: 1.5rem; }
.hub-hero { display: flex; gap: 1.6rem; align-items: flex-start; }
.hub-icon {
  width: 92px; height: 92px; border-radius: 26px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 2.6rem; background: var(--bg-3); border: 1px solid var(--line-2);
  box-shadow: inset 0 0 34px rgba(87,214,242,.08), 0 12px 30px rgba(0,0,0,.3);
}
.hub-kicker { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  color: var(--accent); }
.hub h1 { font-family: var(--font-display); font-size: 2.05rem; font-weight: 700;
  margin: .25rem 0 .15rem; letter-spacing: .005em; line-height: 1.15; }
.hub-tagline { font-size: 1.04rem; color: var(--text); opacity: .92; margin: 0 0 .7rem; }
.hub-desc { color: var(--muted); line-height: 1.65; max-width: 64ch; font-size: .94rem; margin: 0; }
.hub-cols { display: grid; grid-template-columns: 1.55fr 1fr; gap: 1.3rem; align-items: start; }
.hub-panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.35rem; }
.hub-panel h3 { font-size: .78rem; margin-bottom: .95rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--faint); font-weight: 700; }
.hub-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.hub-facts li { display: flex; gap: .65rem; align-items: flex-start; font-size: .88rem;
  color: var(--muted); line-height: 1.55; }
.hub-facts .fk { color: var(--accent); flex-shrink: 0; margin-top: .1rem; display: flex; }
.hub-facts b { color: var(--text); font-weight: 650; display: block; margin-bottom: 1px; }
.hub-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.hub-chip { background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  font-size: .78rem; font-weight: 600; padding: .34rem .72rem; border-radius: 999px; }
.hub-chip.gold { border-color: rgba(246,196,83,.35); color: var(--gold); background: rgba(246,196,83,.07); }
.hub-status { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: 13px;
  background: rgba(127,230,176,.07); border: 1px solid rgba(127,230,176,.25); margin-bottom: .9rem; }
.hub-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); flex-shrink: 0; }
.hub-status .st-txt { font-size: .85rem; font-weight: 650; }
.hub-status .st-sub { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.hub-ctas { display: flex; flex-direction: column; gap: .55rem; }
.hub-link { display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  text-decoration: none; color: var(--text); background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 13px; padding: .75rem .95rem; transition: border-color .12s, background .12s; }
.hub-link:hover { border-color: var(--accent); background: var(--bg-4); }
.hub-link > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.hub-link .hl-name { font-weight: 650; font-size: .9rem; }
.hub-link .hl-sub { font-size: .73rem; color: var(--muted); margin-top: 1px; }
.hub-link .hl-arr { color: var(--accent); font-size: 1.1rem; flex-shrink: 0; }
.hub-actions { display: flex; gap: .7rem; flex-wrap: wrap; }
.hub-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.15rem;
  border-radius: 13px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text);
  font-size: .9rem; font-weight: 650; cursor: pointer; text-decoration: none; transition: all .12s; }
.hub-btn:hover { border-color: var(--accent); background: var(--bg-4); }
.hub-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.hub-btn.primary:hover { background: var(--accent-2); }
.hub-btn.ghost { background: transparent; color: var(--muted); }
.hub-btn.ghost:hover { color: var(--text); }
.hub-btn:disabled { opacity: .6; cursor: default; }

/* ---------- files view ---------- */
.files-wrap { flex: 1; overflow-y: auto; }
.files-head { max-width: 1000px; margin: 0 auto; padding: 2rem 2.4rem 0; }
.files-head h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; }
.files-head p { color: var(--muted); font-size: .9rem; margin: .3rem 0 0; }
.files-list { max-width: 1000px; margin: 0 auto; padding: 1.2rem 2.4rem 2.5rem;
  display: flex; flex-direction: column; gap: .5rem; }
.file-row { display: flex; align-items: center; gap: .9rem; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px; padding: .75rem 1rem; cursor: pointer;
  transition: border-color .12s, background .12s; }
.file-row:hover { border-color: var(--accent); background: var(--bg-3); }
.file-row .fr-ico { font-size: 1.4rem; width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--bg-3); border-radius: 12px; flex-shrink: 0; }
.file-row .fr-main { flex: 1; min-width: 0; }
.file-row .fr-name { font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.file-row .fr-sub { font-size: .75rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .fr-meta { text-align: right; flex-shrink: 0; }
.file-row .fr-size { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-row .fr-when { font-size: .7rem; color: var(--faint); }
.files-empty { max-width: 1000px; margin: 0 auto; padding: 4rem 2rem; text-align: center; color: var(--muted); }
.files-empty .empty-emoji { margin-bottom: .6rem; }

/* ---------- files view: shared space (visible to everyone) ---------- */
.files-head { display: flex; flex-direction: column; }
.files-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.shared-panel { max-width: 1000px; margin: 1.1rem auto 0; padding: 1rem 2.4rem 1.1rem;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--bg-2);
  transition: border-color .15s ease, background .15s ease; }
.shared-panel.dragging { border-color: var(--accent); background: var(--accent-soft); }
.shared-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  margin-bottom: .7rem; flex-wrap: wrap; }
.shared-head .files-actions { margin: 0 0 0 auto; }
.shared-pill { font-size: .78rem; font-weight: 650; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(87,214,242,.3);
  padding: .3rem .7rem; border-radius: 999px; white-space: nowrap; }
.shared-hint { font-size: .72rem; color: var(--faint); }
.shared-list { margin: 0; padding: 0; max-width: none; }
.shared-list .files-empty { padding: 1.6rem 1rem; }
.files-sec-title { max-width: 1000px; margin: 0 auto; padding: 1.7rem 2.4rem .5rem;
  font-size: .63rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .11em; color: var(--faint); }

/* ---------- full-width system views (admin / settings) ---------- */
.view-panel { flex: 1; overflow-y: auto; padding: 2rem 2.4rem 2.6rem; min-height: 0; }
.vp-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; }
.vp-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; }
.vp-sub { color: var(--muted); font-size: .88rem; margin: .2rem 0 1.3rem; }

/* ---------- toast ---------- */
.toast-host { position: fixed; top: 70px; right: 16px; z-index: 200; display: flex;
  flex-direction: column; gap: .5rem; pointer-events: none; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: 11px; padding: .65rem .95rem; font-size: .88rem; box-shadow: var(--shadow);
  max-width: 360px; animation: toastin .18s ease-out; pointer-events: auto; cursor: pointer;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
@keyframes toastin { from { transform: translateX(14px); opacity: 0; } }
.toast.out { opacity: 0; transform: translateX(14px); transition: all .25s; }
.toast-title { font-weight: 650; font-size: .85rem; }
.toast-text { font-size: .8rem; color: var(--muted); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(3,10,13,.7); z-index: 150;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-card { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 1.5rem; width: min(460px, 92vw); max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-card h3 { margin-bottom: .8rem; }
.gm-members { max-height: 260px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: 11px;
  padding: .4rem; display: flex; flex-direction: column; gap: .1rem; margin-bottom: .8rem; }
.gm-member { display: flex; align-items: center; gap: .55rem; padding: .32rem .45rem; border-radius: 8px; cursor: pointer; }
.gm-member:hover { background: var(--bg-3); }
.gm-member .avatar { width: 28px; height: 28px; font-size: .72rem; border-radius: 8px; }
.gm-member input { accent-color: var(--accent); }

/* ---------- admin ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.admin-head h3 { font-size: 1.02rem; }
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.admin-user { background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; padding: .7rem .8rem; }
.admin-user.disabled { opacity: .55; }
.admin-top { display: flex; align-items: center; gap: .55rem; }
.admin-top .avatar { width: 30px; height: 30px; font-size: .75rem; border-radius: 9px; }
.admin-name { font-weight: 650; font-size: .9rem; }
.role-pill { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px; background: var(--bg-4); color: var(--muted); margin-left: auto; }
.role-pill.admin { background: rgba(246,196,83,.13); color: var(--gold); }
.admin-actions { display: flex; gap: .3rem; margin-top: .5rem; flex-wrap: wrap; }
.mini-btn { font-size: .72rem; padding: .28rem .55rem; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--muted); cursor: pointer; }
.mini-btn:hover { background: var(--bg-4); color: var(--text); }
.mini-btn.danger:hover { border-color: var(--red); color: #ffc9c9; }

/* ---------- login / empty pages ---------- */
.login-page, .empty-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.4rem;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(87,214,242,.12), transparent 60%), var(--bg);
  overflow: auto;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 22px; padding: 2rem; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-logo-img { width: 64px; height: 64px; margin: 0 auto .9rem; display: block;
  border-radius: 16px; box-shadow: 0 10px 26px rgba(0,0,0,.4); }
.login-brand h1 { font-size: 1.5rem; }
.login-sub { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; line-height: 1.5; }
.login-foot { text-align: center; color: var(--faint); font-size: .78rem; margin-top: 1.2rem; line-height: 1.6; }
.login-gc-link { display: block; text-align: center; margin-top: .9rem; font-size: .8rem; color: var(--faint); text-decoration: none; transition: color .15s; }
.login-gc-link:hover { color: var(--accent); text-decoration: underline; }
.empty-card { text-align: center; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.pw-change { margin-top: .5rem; }
.pw-change h2 { margin-bottom: .4rem; font-size: 1.1rem; }

/* ---------- dashboard (command center) ---------- */
.dash-wrap { flex: 1; overflow-y: auto; min-height: 0; padding: 1.8rem 2.2rem 2.4rem; }
.dash-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.4rem;
  flex-wrap: wrap; margin-bottom: 1.35rem;
}
.dash-kicker {
  font-size: .7rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: .4rem;
}
.dash-title { font-family: var(--font-display); font-size: 1.72rem; font-weight: 700; letter-spacing: -.01em; }
.dash-sub { color: var(--muted); font-size: .88rem; margin: .38rem 0 0; max-width: 62ch; line-height: 1.55; }
.dash-tools { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.dash-range {
  display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 11px;
}
.dr-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: .8rem; font-weight: 650; letter-spacing: .04em; padding: .38rem .72rem;
  border-radius: 8px; transition: background .12s, color .12s;
}
.dr-btn:hover { color: var(--text); background: var(--bg-3); }
.dr-btn.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(87,214,242,.35); }
.dash-updated { font-size: .76rem; color: var(--faint); min-width: 96px; }

/* KPI tiles */
.kpi-grid {
  display: grid; gap: .85rem; margin-bottom: .95rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.kpi {
  position: relative; overflow: hidden; background: linear-gradient(160deg, var(--bg-3), var(--bg-2) 62%);
  border: 1px solid var(--line); border-radius: 15px; padding: .95rem 1.05rem 1rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 72%); opacity: .55;
}
.kpi-top { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.kpi-label {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-delta {
  font-size: .72rem; font-weight: 700; padding: .12rem .42rem; border-radius: 99px;
  border: 1px solid transparent; white-space: nowrap;
}
.kpi-delta.up { color: #8ff0c0; background: rgba(127,230,176,.12); border-color: rgba(127,230,176,.3); }
.kpi-delta.down { color: #ffc0c0; background: rgba(255,158,158,.12); border-color: rgba(255,158,158,.3); }
.kpi-delta.flat { color: var(--muted); background: var(--bg-3); border-color: var(--line-2); }
.kpi-value {
  font-family: var(--font-display); font-size: 1.72rem; font-weight: 700; line-height: 1.1;
  letter-spacing: -.02em; display: inline-flex; align-items: baseline; gap: .3rem;
  font-variant-numeric: tabular-nums;
}
.kpi-unit { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-hint { font-size: .72rem; color: var(--faint); line-height: 1.4; }

/* columns */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr); gap: .95rem; margin-bottom: .95rem; }
.dash-col { display: flex; flex-direction: column; gap: .95rem; min-width: 0; }
.dash-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.05rem 1.15rem 1.15rem; min-width: 0;
}
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; }
.dc-title { font-family: var(--font-display); font-size: .98rem; font-weight: 650; }
.dc-sub { color: var(--faint); font-size: .78rem; margin-top: .18rem; }
.dc-badge {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(87,214,242,.28);
  padding: .2rem .5rem; border-radius: 99px; white-space: nowrap;
}
.chart-hold { width: 100%; display: flex; align-items: center; }
.chart-hold > .dash-empty { width: 100%; }
.chart-svg { display: block; max-width: 100%; overflow: visible; }
.chart-svg .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--faint); font-size: 10px; font-family: var(--font); }
.chart-svg .area { fill: url(#dashGrad); }
.chart-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .avg { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-dasharray: 4 4; opacity: .9; }
.chart-svg .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart-svg .peak-dot { fill: var(--gold); stroke: var(--bg-2); stroke-width: 2; }
.chart-legend { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-top: .7rem; }
.cl-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; color: var(--muted); }
.cl-swatch { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.cl-swatch.area { background: linear-gradient(90deg, rgba(87,214,242,.7), rgba(87,214,242,.12)); }
.cl-swatch.line { background: var(--gold); }
.chart-stats { display: flex; gap: 1.4rem; flex-wrap: wrap; margin-top: .55rem; }
.cs-item { font-size: .74rem; color: var(--faint); }
.cs-item b { color: var(--text); font-weight: 650; font-size: .86rem; font-variant-numeric: tabular-nums; }

@media (max-width: 1150px) {
  /* 3 tiles, then the last two share the second row — no empty cell */
  .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi-grid > .kpi { grid-column: span 2; }
  .kpi-grid > .kpi:nth-child(4), .kpi-grid > .kpi:nth-child(5) { grid-column: span 3; }
}

/* revenue bars */
.bar-rows { display: flex; flex-direction: column; gap: .62rem; }
.bar-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 92px; align-items: center; gap: .7rem; }
.bar-label { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: 9px; border-radius: 99px; background: var(--bg-4); overflow: hidden; }
.bar-fill {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  min-width: 4px; transition: width .35s ease-out;
}
.bar-rows > .bar-row:nth-child(2) .bar-fill { background: linear-gradient(90deg, #3ec9d6, #7ee3f5); opacity: .92; }
.bar-row:nth-child(3) .bar-fill { background: linear-gradient(90deg, #2f9fc4, #59cfe8); opacity: .86; }
.bar-row:nth-child(4) .bar-fill { background: linear-gradient(90deg, var(--gold), #f8d98d); opacity: .9; }
.bar-row:nth-child(5) .bar-fill { background: linear-gradient(90deg, #7fb6c4, #a6d7e2); opacity: .8; }
.bar-row:nth-child(6) .bar-fill { background: linear-gradient(90deg, #5d8a94, #8ab5bf); opacity: .75; }
.bar-val { font-size: .8rem; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val em { color: var(--faint); font-style: normal; font-weight: 500; font-size: .72rem; margin-left: .3rem; }

/* live grid */
.live-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.live-item {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 11px;
  padding: .55rem .7rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0;
}
.li-val {
  font-family: var(--font-display); font-size: 1.16rem; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.li-lab { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.live-item.hl { background: linear-gradient(150deg, rgba(87,214,242,.14), rgba(87,214,242,.03)); border-color: rgba(87,214,242,.28); }
.live-item.hl .li-val { color: var(--accent); }

/* sector rows */
.sec-rows { display: flex; flex-direction: column; }
.sec-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto 10px; align-items: center;
  gap: .6rem; padding: .56rem .1rem; border-bottom: 1px solid var(--line);
}
.sec-row:last-child { border-bottom: 0; }
.sr-ico {
  width: 28px; height: 28px; border-radius: 9px; display: inline-flex; align-items: center;
  justify-content: center; background: var(--bg-3); border: 1px solid var(--line); font-size: .86rem;
}
.sr-name {
  display: block; font-size: .84rem; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sr-sub { display: block; font-size: .7rem; color: var(--faint); margin-top: .05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-num { display: flex; flex-direction: column; align-items: flex-end; gap: .05rem; text-align: right; }
.sr-num b { font-size: .84rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.sr-num span { font-size: .68rem; color: var(--faint); }
.sr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sr-dot.growing { background: var(--green); box-shadow: 0 0 0 3px rgba(127,230,176,.14); }
.sr-dot.steady { background: var(--gold); box-shadow: 0 0 0 3px rgba(246,196,83,.14); }
.sr-dot.slowing { background: var(--red); box-shadow: 0 0 0 3px rgba(255,158,158,.14); }

/* finance */
.fin-locked { display: flex; align-items: center; gap: .9rem; color: var(--muted); font-size: .86rem; }
.fin-locked .fl-ico {
  width: 34px; height: 34px; border-radius: 10px; background: var(--bg-3);
  border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center;
}
.fin-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .95rem; }
.fin-kpi { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: .62rem .75rem; }
.fin-kpi .fk-lab { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 650; }
.fin-kpi .fk-val { font-family: var(--font-display); font-size: 1.14rem; font-weight: 700; margin-top: .16rem; font-variant-numeric: tabular-nums; }
.fin-kpi.pos .fk-val { color: var(--green); }
.fin-kpi.neg .fk-val { color: var(--red); }
.fin-scroll { overflow-x: auto; }
.fin-table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 560px; }
.fin-table th {
  text-align: right; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; padding: .4rem .55rem; border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.fin-table th:first-child, .fin-table td:first-child { text-align: left; }
.fin-table td { text-align: right; padding: .5rem .55rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-table tr:last-child td { border-bottom: 0; }
.fin-table td.mono { color: var(--muted); }
.fin-table td.net { font-weight: 650; }
.fin-table td .mb-wrap { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; }
.fin-table td .mb-track { width: 62px; height: 6px; border-radius: 99px; background: var(--bg-4); overflow: hidden; }
.fin-table td .mb-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.fin-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.1rem; margin-top: .2rem; }
.fin-h { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 700; margin: 0 0 .5rem; }

/* community panel */
.comm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .6rem; }
.comm-item { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .75rem; }
.comm-item .ci-val { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.comm-item .ci-lab { font-size: .7rem; color: var(--faint); margin-top: .1rem; }
.comm-acts { display: flex; flex-direction: column; gap: .1rem; }
.comm-act { display: flex; align-items: center; gap: .55rem; padding: .38rem 0; border-bottom: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.comm-act:last-child { border-bottom: 0; }
.comm-act .ca-ico { font-size: .82rem; }
.comm-act .ca-when { margin-left: auto; color: var(--faint); font-size: .7rem; white-space: nowrap; }
.comm-links { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .85rem; }

/* footer */
.dash-foot {
  margin-top: 1rem; padding: .75rem .2rem 0; border-top: 1px solid var(--line);
  display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: .72rem; color: var(--faint); line-height: 1.5;
}
.dash-foot b { color: var(--muted); font-weight: 600; }
.dash-empty { color: var(--faint); font-size: .84rem; padding: 1.2rem 0; text-align: center; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* ---------- small screens: call UI ---------- */
@media (max-width: 640px), (max-height: 480px) {
  .call-top { padding: .55rem .9rem; gap: .6rem; }
  .call-title { font-size: .95rem; }
  #cc-endall { margin-right: 0; padding: .35rem .6rem; font-size: .78rem; }
  .call-grid { padding: 10px; gap: 8px; align-content: center;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); overflow-y: auto; }
  .tile { min-height: 0; }
  .tile video { aspect-ratio: 16/9; height: auto; }
  .tile .tile-avatar { min-height: 0; }
  .tile .tile-label { font-size: .7rem; padding: 2px 8px; }

  /* two people: remote full-bleed, local as a corner PiP (FaceTime-style) */
  .call-grid.duo { display: block; position: relative; overflow: visible; }
  .call-grid.duo .tile { position: absolute; inset: 0; width: auto; height: auto;
    border: 0; border-radius: 0; }
  .call-grid.duo .tile video { width: 100%; height: 100%; aspect-ratio: auto; }
  .call-grid.duo .tile.me { inset: auto; right: 10px; bottom: 10px; width: 38%;
    max-width: 240px; height: auto; aspect-ratio: 16/9; border: 1px solid var(--line-2); border-radius: 12px;
    box-shadow: 0 10px 28px rgba(0,0,0,.55); z-index: 5; }
  .call-grid.duo .tile.me video { height: 100%; }
  .call-grid.duo .tile.me .tile-avatar { gap: .3rem; }
  .call-grid.duo .tile.me .tile-avatar .avatar { width: 44px; height: 44px;
    font-size: 1.1rem; border-radius: 12px; }
  .call-grid.duo .tile.me .tile-avatar .muted { display: none; }

  .call-controls { padding: .8rem .9rem calc(.8rem + env(safe-area-inset-bottom, 0px)); gap: .75rem; }
  .cc { width: 50px; height: 50px; font-size: 1.25rem; }

  /* incoming-call banner spans the bottom of the screen */
  .incoming { left: 0; right: 0; bottom: 0;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .incoming-card { min-width: 0; padding: .8rem .9rem; flex-wrap: wrap; gap: .6rem; }
  .incoming-actions { flex-direction: row; margin-left: auto; }
  .incoming-actions .btn { padding: .45rem .9rem; font-size: .88rem; }
}

/* ---------- responsive: phone / small tablet (rail becomes a drawer) ---------- */
@media (max-width: 920px) {
  .os-topbar { padding: 0 .7rem; height: 54px; gap: .5rem; }
  .tb-menu { display: inline-flex; }
  .tb-word { display: none; }
  .tb-search { margin-left: 0; }
  .tb-logo { width: 30px; height: 30px; }
  .rail-close { display: inline-flex; }
  .chip-meta { display: none; }
  .user-chip { padding: .2rem; margin-left: .1rem; }
  .tb-actions { gap: .1rem; }

  .os-rail {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 85;
    transform: translateX(-103%); transition: transform .2s ease-out;
    box-shadow: 0 0 40px rgba(0,0,0,.55);
  }
  body.rail-open .os-rail { transform: none; }
  #rail-scrim { display: none; position: fixed; inset: 0; background: rgba(3,10,13,.62); z-index: 84; }
  body.rail-open #rail-scrim { display: block; }

  #view-messenger .sidebar { position: fixed; inset: 0; width: 100%; max-width: none; z-index: 60; }
  #view-messenger .main { display: none; }
  body.chat-open #view-messenger .sidebar { display: none; }
  body.chat-open #view-messenger .main { display: flex; }
  #btn-back { display: inline-flex; }
  .msg { max-width: 92%; }
  .info-panel { position: fixed; inset: 0; width: 100%; z-index: 70; }

  .composer { padding: .5rem .6rem calc(.55rem + env(safe-area-inset-bottom, 0px)); gap: .35rem; }
  .composer-attach .icon-btn { width: 30px; }
  .composer #btn-send { padding: .5rem .75rem; font-size: .88rem; }

  .hub { padding: 1.4rem 1.1rem 2rem; gap: 1.1rem; }
  .hub-cols { grid-template-columns: 1fr; }
  .hub-hero { gap: 1rem; }
  .hub-icon { width: 64px; height: 64px; font-size: 1.9rem; border-radius: 18px; }
  .hub h1 { font-size: 1.55rem; }
  .hub-tagline { font-size: .95rem; }
  .files-head, .files-list { padding-left: 1.1rem; padding-right: 1.1rem; }
  .files-head { padding-top: 1.4rem; }
  .shared-panel { padding: .8rem 1.1rem .9rem; }
  .shared-head { gap: .55rem; }
  .shared-head .files-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .shared-hint { display: none; }
  .files-sec-title { padding-left: 1.1rem; padding-right: 1.1rem; padding-top: 1.3rem; }
  .files-actions { justify-content: flex-start; }
  .view-panel { padding: 1.4rem 1.1rem 2rem; }
  .toast-host { top: 62px; left: .7rem; right: .7rem; }

  /* dashboard */
  .dash-wrap { padding: 1.25rem .9rem 2rem; }
  .dash-head { gap: .8rem; margin-bottom: 1rem; }
  .dash-title { font-size: 1.4rem; }
  .dash-sub { font-size: .82rem; }
  .dash-tools { width: 100%; gap: .45rem; }
  .dash-updated { margin-left: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .8rem .8rem .85rem; }
  .kpi-value { font-size: 1.3rem; }
  .kpi-hint { display: none; }
  .dash-cols { grid-template-columns: minmax(0, 1fr); gap: .7rem; }
  .dash-card { padding: .9rem .85rem 1rem; border-radius: 14px; }
  .chart-legend { gap: .8rem; }
  .cl-item { font-size: .7rem; }
  .kpi-label { font-size: .66rem; letter-spacing: .04em; }
  .fin-table { min-width: 0; font-size: .78rem; }
  .fin-table th, .fin-table td { padding: .42rem .3rem; }
  .fin-table .col-cogs, .fin-table .col-opex, .fin-table .col-margin { display: none; }
  .bar-row { grid-template-columns: 92px minmax(0, 1fr) 84px; gap: .5rem; }
  .bar-label, .bar-val { font-size: .74rem; }
  .fin-cols { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
  .live-grid { gap: .45rem; }
  .li-val { font-size: 1rem; }
  .sec-row { grid-template-columns: 26px minmax(0, 1fr) auto 8px; gap: .5rem; }
  .sr-name { font-size: .8rem; }
  .dash-foot { gap: .5rem; flex-direction: column; }

  .toast { max-width: none; }
}

.tile video.mirror { transform: scaleX(-1); }

/* ---------- display names (name + @handle) ---------- */
.admin-handle {
  font-size: .72rem; color: var(--faint); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 14ch;
  margin-right: auto; padding-left: .1rem;
}
.admin-name { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; margin-right: .25rem; }
.admin-top .role-pill { margin-left: 0; flex: none; }
.admin-top { min-width: 0; }
.chat-item-name, .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#set-name { width: 100%; max-width: 340px; }
.cu-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 920px) { .cu-row { grid-template-columns: 1fr; gap: 0; } }
