/* ═══════════════════════════════════════════════════════════════
   MSCON DESIGN – Operations Platform
   Bold professional UI with switchable colour themes
   ═══════════════════════════════════════════════════════════════ */

/* ── Colour Themes ────────────────────────────────────────────── */

/* Theme 1: Teal & Navy (default) — popular with engineers */
:root,
[data-theme="teal"] {
  --sidebar-bg:   #0d1b2a;
  --sidebar-hi:   #1a3045;
  --sidebar-txt:  #c8d9e8;
  --sidebar-act:  #ffffff;
  --primary:      #00b4a0;
  --primary-dk:   #007f70;
  --accent:       #2563eb;
  --ink:          #0f1923;
  --muted:        #5e7486;
  --line:         #d8e4ed;
  --surface:      #f0f4f8;
  --panel:        #ffffff;
  --danger:       #c0392b;
  --warn:         #d97706;
  --good:         #059669;
  --badge-pend:   #fff3cd;
  --badge-pend-t: #856404;
}

/* Theme 2: Indigo & Gold — architect / premium feel */
[data-theme="indigo"] {
  --sidebar-bg:   #1a1040;
  --sidebar-hi:   #2d1f6e;
  --sidebar-txt:  #c5bff0;
  --sidebar-act:  #ffd700;
  --primary:      #6c47ff;
  --primary-dk:   #4f2ee8;
  --accent:       #f59e0b;
  --ink:          #1a1040;
  --muted:        #64748b;
  --line:         #e2e8f0;
  --surface:      #f5f3ff;
  --panel:        #ffffff;
  --danger:       #dc2626;
  --warn:         #d97706;
  --good:         #059669;
  --badge-pend:   #fff7ed;
  --badge-pend-t: #92400e;
}

/* Theme 3: Slate & Ember — dark-mode-adjacent, popular with devs */
[data-theme="slate"] {
  --sidebar-bg:   #1e293b;
  --sidebar-hi:   #334155;
  --sidebar-txt:  #94a3b8;
  --sidebar-act:  #fb923c;
  --primary:      #f97316;
  --primary-dk:   #ea580c;
  --accent:       #38bdf8;
  --ink:          #1e293b;
  --muted:        #64748b;
  --line:         #e2e8f0;
  --surface:      #f1f5f9;
  --panel:        #ffffff;
  --danger:       #ef4444;
  --warn:         #f59e0b;
  --good:         #22c55e;
  --badge-pend:   #fef9c3;
  --badge-pend-t: #854d0e;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Login Screen ─────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #0a2540 100%);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 32px;
  display: grid;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

/* ── App Shell ────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px 1fr;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-txt);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand.compact { color: var(--ink); }

.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dk));
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.brand h1 { margin: 0; font-size: 1rem; font-weight: 700; color: #fff; }
.brand p { margin: 0; font-size: .75rem; color: var(--sidebar-txt); opacity: .7; }

.nav { display: grid; gap: 2px; }

.nav-item {
  border: 0;
  background: transparent;
  color: var(--sidebar-txt);
  padding: 10px 14px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0;
  transition: opacity .15s;
}

.nav-item.active {
  background: var(--sidebar-hi);
  color: var(--sidebar-act);
  font-weight: 600;
}

.nav-item.active::before { opacity: 1; }

.nav-item:hover:not(.active) {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.tenant-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  display: grid;
  gap: 6px;
}

.tenant-card strong { color: #fff; font-size: .9rem; }
.tenant-card span { font-size: .75rem; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

.ghost-btn {
  border: 0;
  background: transparent;
  color: var(--sidebar-txt);
  padding: 6px 0;
  cursor: pointer;
  font-size: .8rem;
  text-align: left;
  transition: color .15s;
}
.ghost-btn:hover { color: #fff; }

/* ── Theme Switcher (sidebar) ─────────────────────────────────── */
.theme-switcher {
  display: flex;
  gap: 6px;
  padding: 0 8px;
  margin-top: -8px;
}
.theme-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.theme-dot:hover, .theme-dot.active { transform: scale(1.2); border-color: #fff; }
.theme-dot.t-teal   { background: #00b4a0; }
.theme-dot.t-indigo { background: #6c47ff; }
.theme-dot.t-slate  { background: #f97316; }

/* ── Main Content ─────────────────────────────────────────────── */
.main { padding: 24px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
}

.eyebrow {
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .08em;
  margin: 0;
}

#viewTitle {
  margin: 4px 0 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
}

/* ── Metrics ──────────────────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dk));
  opacity: 0;
  transition: opacity .2s;
}
.metric:hover::after { opacity: 1; }

.metric span { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.metric strong { font-size: 2.2rem; font-weight: 800; color: var(--ink); }
.metric.warning strong { color: var(--warn); }

/* ── Panels & Cards ───────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.split-layout    { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 20px; }
.form-grid       { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: 1 / -1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.stack-list { display: grid; gap: 10px; }

/* ── Items / Cards ────────────────────────────────────────────── */
.item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: var(--panel);
  transition: box-shadow .15s, border-color .15s;
}
.item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); border-color: var(--primary); }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.item-row strong { font-weight: 600; }

/* ── Pills / Badges ───────────────────────────────────────────── */
.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 10px;
  background: #e8f0fe;
  color: #1a3a6e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.pill.delayed { background: #fce8e6; color: #8f2013; }
.pill.good    { background: #d7f5e9; color: #0a5c36; }
.pill.muted   { background: #f1f5f9; color: #64748b; }

/* ── Buttons ──────────────────────────────────────────────────── */
.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dk));
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
  font-size: .9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: opacity .15s, transform .1s;
}
.primary-btn:hover { opacity: .92; transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

.secondary-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
  font-size: .9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: opacity .15s;
}
.secondary-btn:hover { opacity: .9; }

.mini-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: .8rem;
  transition: background .12s, border-color .12s;
}
.mini-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Forms ────────────────────────────────────────────────────── */
label { display: grid; gap: 5px; color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

input, select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 180, 160, .12);
}

fieldset {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 14px;
}
fieldset label { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .875rem; color: var(--ink); }
legend { font-weight: 700; color: var(--ink); font-size: .85rem; padding: 0 6px; }

/* ── Tables ───────────────────────────────────────────────────── */
.task-table { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; min-width: 960px; border-collapse: collapse; }
thead { background: var(--surface); }
th { padding: 12px 14px; text-align: left; font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--surface); }

/* ── View transitions ─────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; animation: fadeSlide .22s ease; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.wide { grid-column: 1 / -1; }

/* ── Misc ─────────────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-message { min-height: 20px; margin-bottom: 12px; }
.error-text { color: var(--danger) !important; font-weight: 700; }

/* ── Admin tabs ───────────────────────────────────────────────── */
.tab-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-pill {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  transition: all .15s;
}
.tab-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,180,160,.25); }
.tab-pill:hover:not(.active) { border-color: var(--primary); color: var(--primary); }
.admin-tab-panel { display: none; }
.admin-tab-panel.active-tab { display: block; }

/* ── AI Quick Chips ───────────────────────────────────────────── */
.ai-chip {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  transition: all .15s;
  white-space: nowrap;
}
.ai-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

/* ── AI Chat ──────────────────────────────────────────────────── */
.chat-area { display: flex; flex-direction: column; gap: .6rem; padding: .75rem; min-height: 280px; max-height: 420px; overflow-y: auto; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
.chat-bubble { max-width: 80%; padding: .6rem .85rem; border-radius: 14px; font-size: .875rem; line-height: 1.5; }
.chat-bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--primary-dk)); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.ai { align-self: flex-start; background: #fff; border: 1.5px solid var(--line); border-bottom-left-radius: 4px; }
.chat-bubble.ai.thinking { color: var(--muted); font-style: italic; }
.chat-input-row { display: flex; gap: .5rem; align-items: center; }
.chat-input-row input { flex: 1; }

/* ── Performance ──────────────────────────────────────────────── */
.score-bar-wrap { background: #e9ecef; border-radius: .25rem; height: 8px; margin-top: .25rem; }
.score-bar { height: 8px; border-radius: .25rem; transition: width .5s cubic-bezier(.4,0,.2,1); }
.score-bar.green  { background: linear-gradient(90deg, var(--good), #34d399); }
.score-bar.yellow { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.score-bar.red    { background: linear-gradient(90deg, var(--danger), #f87171); }
.score-ring { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; color: #fff; margin-right: .75rem; flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.perf-card { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem; border-bottom: 1px solid var(--line); }
.perf-card:last-child { border-bottom: none; }
.perf-meta { flex: 1; }
.perf-narrative { font-size: .8rem; color: var(--muted); margin-top: .35rem; line-height: 1.5; }

/* ── Calendar / Attendance ────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: .5rem; }
.cal-day { aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .65rem; background: #e9ecef; font-weight: 600; }
.cal-day.present { background: var(--good); color: #fff; }
.cal-day.absent  { background: var(--danger); color: #fff; }
.cal-day.half    { background: var(--warn); color: #fff; }

/* ── Geofence / Settings ──────────────────────────────────────── */
.fence-type-toggle { display: flex; gap: .5rem; margin-bottom: .5rem; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stat-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
.stat-row:last-child { border-bottom: none; }

/* ── Broadcast ────────────────────────────────────────────────── */
.broadcast-target { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.broadcast-target label { display: flex; align-items: center; gap: .3rem; font-size: .875rem; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-shell            { grid-template-columns: 1fr; }
  .sidebar              { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .brand                { flex: 1; min-width: 160px; }
  .nav                  { flex-direction: row; flex: 100%; order: 3; overflow-x: auto; padding-bottom: 4px; }
  .nav-item             { white-space: nowrap; padding: 8px 12px; }
  .theme-switcher       { align-self: center; }
  .tenant-card          { flex-direction: row; align-items: center; flex: 100%; order: 4; margin-top: 0; grid-template-columns: auto 1fr auto auto; }
  .metric-grid          { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid,
  .split-layout,
  .form-grid            { grid-template-columns: 1fr; }
  fieldset              { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .main                 { padding: 12px; }
  .metric-grid          { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric strong        { font-size: 1.6rem; }
  .settings-grid        { grid-template-columns: 1fr; }
  fieldset              { grid-template-columns: 1fr; }
  table                 { min-width: 720px; }
  #viewTitle            { font-size: 1.2rem; }
  .chat-layout          { flex-direction: column; height: auto; min-height: calc(100vh - 90px); }
  .chat-sidebar         { width: 100%; min-width: 100%; height: 180px; border-right: none; border-bottom: 1px solid var(--line); }
  .chat-msg-bubble      { max-width: 88%; }
}

/* ── Chat ─────────────────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - 120px);
  border-radius: .75rem;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.chat-sidebar {
  width: 260px;
  min-width: 240px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  flex-shrink: 0;
}
.chat-sidebar-head {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
}
.chat-sidebar-head h3 { margin: 0; font-size: .9rem; }
.chat-room-group { padding: .25rem 0; }
.chat-room-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .5rem 1rem .25rem;
}
.chat-room-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem 1rem;
  cursor: pointer;
  transition: background .12s;
  border-left: 3px solid transparent;
}
.chat-room-item:hover  { background: var(--panel); }
.chat-room-item.active { background: var(--panel); border-left-color: var(--primary); }
.chat-room-icon { font-size: .95rem; flex-shrink: 0; }
.chat-room-info { flex: 1; min-width: 0; }
.chat-room-name {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-room-last {
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.chat-room-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex-shrink: 0; }
.chat-room-time { font-size: .65rem; color: var(--muted); }
.chat-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 700;
  padding: .1rem .38rem;
  min-width: 17px;
  text-align: center;
  line-height: 1.6;
}
.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-thread-head {
  padding: .65rem 1.2rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  background: var(--panel);
  font-size: .88rem;
  display: flex;
  align-items: center;
}
.chat-message-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  background: var(--surface);
}
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .88rem;
  align-self: center;
  margin: auto;
}
.chat-msg-group { display: flex; flex-direction: column; gap: .12rem; }
.chat-msg-group.mine   { align-items: flex-end; }
.chat-msg-group.theirs { align-items: flex-start; }
.chat-msg-name  { font-size: .7rem; color: var(--muted); padding: 0 .45rem; }
.chat-msg-bubble {
  max-width: 68%;
  padding: .45rem .78rem;
  border-radius: .7rem;
  font-size: .84rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg-group.mine   .chat-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: .2rem;
}
.chat-msg-group.theirs .chat-msg-bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: .2rem;
}
.chat-msg-time { font-size: .65rem; color: var(--muted); padding: 0 .45rem; }
.chat-file-bubble {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .7rem;
  border-radius: .55rem;
  max-width: 260px;
  cursor: pointer;
  transition: opacity .15s;
}
.chat-file-bubble:hover { opacity: .85; }
.chat-msg-group.mine   .chat-file-bubble { background: var(--primary-dk, #007f70); color: #fff; }
.chat-msg-group.theirs .chat-file-bubble { background: var(--panel); border: 1px solid var(--line); }
.chat-date-divider {
  text-align: center;
  font-size: .68rem;
  color: var(--muted);
  margin: .4rem 0;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.chat-date-divider::before,
.chat-date-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chat-composer {
  padding: .65rem .9rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.chat-composer-row { display: flex; gap: .45rem; align-items: center; }
.chat-composer-row input { flex: 1; }
.chat-attach-btn {
  cursor: pointer;
  padding: .38rem .55rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--surface);
  font-size: 1rem;
  user-select: none;
  transition: background .12s;
  flex-shrink: 0;
}
.chat-attach-btn:hover { background: var(--line); }
.chat-file-preview {
  margin-bottom: .45rem;
  background: var(--surface);
  border-radius: .375rem;
  padding: .38rem .7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .78rem;
  gap: .5rem;
  border: 1px solid var(--line);
}
/* Unread badge on sidebar nav item */
.nav-item .chat-badge { vertical-align: middle; margin-left: .35rem; }

/* ── Delivery Portal ─────────────────────────────────────── */
.delivery-tabs { display:flex; gap:6px; margin-bottom:20px; border-bottom:2px solid #e5e7eb; padding-bottom:0; }
.dtab { background:none; border:none; padding:8px 18px; font-size:.9rem; color:#666; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-2px; transition:all .15s; border-radius:6px 6px 0 0; }
.dtab.active { color:var(--primary); border-bottom-color:var(--primary); font-weight:600; }
.dtab:hover { background:#f3f4f6; color:var(--primary); }

.delivery-form-card { background:#fff; border-radius:10px; border:1px solid #e5e7eb; padding:24px; max-width:680px; }

.delivery-table { width:100%; border-collapse:collapse; font-size:.88rem; }
.delivery-table th { background:#f9fafb; padding:10px 12px; text-align:left; color:#555; font-weight:600; border-bottom:2px solid #e5e7eb; }
.delivery-table td { padding:10px 12px; border-bottom:1px solid #f0f0f0; vertical-align:middle; }
.delivery-table tr:last-child td { border-bottom:none; }
.delivery-table tr:hover td { background:#fafafa; }

.delivery-link { font-family:monospace; font-size:.8rem; color:#0d9488; background:#f0fdfa; padding:3px 8px; border-radius:4px; word-break:break-all; }
.delivery-badge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:.75rem; font-weight:600; }
.delivery-badge.active { background:#dcfce7; color:#166534; }
.delivery-badge.expired { background:#fee2e2; color:#991b1b; }

.client-card { background:#fff; border:1px solid #e5e7eb; border-radius:10px; padding:16px 20px; margin-bottom:12px; display:flex; align-items:center; gap:16px; }
.client-logo { width:48px; height:48px; border-radius:8px; object-fit:cover; background:#f3f4f6; flex-shrink:0; }
.client-logo-placeholder { width:48px; height:48px; border-radius:8px; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; font-size:1.2rem; font-weight:700; flex-shrink:0; }
.client-info { flex:1; min-width:0; }
.client-info h4 { font-size:.95rem; font-weight:600; margin-bottom:2px; }
.client-info p { font-size:.8rem; color:#888; }
.client-actions { display:flex; gap:8px; }

.dl-count-badge { background:#e0f2fe; color:#0369a1; padding:2px 7px; border-radius:10px; font-size:.75rem; font-weight:600; }
