* { box-sizing: border-box; }
:root {
  --bg: #0b0d12;
  --card: #14171f;
  --card-edge: #1f2433;
  --card-edge-hover: #2c3145;
  --text: #eef0f5;
  --text-mute: #8b93a3;
  --text-dim: #5e667a;
  --accent: #5eead4;        /* teal — used sparingly for highlights */
  --accent-soft: rgba(94, 234, 212, 0.12);
  --good: #7ee2a0;
  --warn: #ffd166;
  --bad:  #ff8a80;
  --info: #a0c1ff;
}
body {
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  margin: 0;
  background:
    radial-gradient(1100px 540px at 20% -10%, #16213a 0%, transparent 55%),
    radial-gradient(900px 480px at 90% -20%, #1a1428 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: fadeIn 220ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px 32px;
}
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 18px;
}
header h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, #e7e9ee 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
header .meta {
  font-size: 12px;
  color: var(--text-mute);
  display: flex;
  gap: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 14px;
  transition: border-color 160ms ease;
}
.card:hover { border-color: var(--card-edge-hover); }
.card h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #c8cdda;
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-edge);
}
.card h2 .muted { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.muted { color: var(--text-mute); font-weight: 400; }
.dim { color: var(--text-dim); font-size: 11px; }
.strong { font-weight: 600; color: #f3f5f8; }

/* TOP STRIP */
.top-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 22px 24px;
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.04) 0%, transparent 100%), var(--card);
}
.top-strip .bigstat + .bigstat { border-left: 1px solid var(--card-edge); padding-left: 18px; }
.bigstat .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-mute);
  font-weight: 600;
  margin-bottom: 6px;
}
.bigstat .value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: #f8fafc;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.bigstat:first-child .value {
  font-size: 42px;
  background: linear-gradient(180deg, #ffffff 0%, #b9c2d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bigstat .value.mix {
  font-size: 13px;
  font-weight: normal;
  margin-top: 4px;
}
.bigstat .sub {
  font-size: 11px;
  margin-top: 2px;
}

/* TOKEN MIX BAR */
.mix {
  display: flex;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
  background: #0a0c11;
}
.mix.mini { height: 6px; width: 100%; }
.seg { display: block; height: 100%; min-width: 0; }
.seg-input      { background: #6ea8fe; }
.seg-cache-1h   { background: #ef476f; }
.seg-cache-5m   { background: #ffb454; }
.seg-cache-read { background: #2f9e7a; }
.seg-output     { background: #c8a8ff; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin: 0 4px 0 8px;
  vertical-align: middle;
}
.dot-input      { background: #6ea8fe; }
.dot-cache-1h   { background: #ef476f; }
.dot-cache-5m   { background: #ffb454; }
.dot-cache-read { background: #2f9e7a; }
.dot-output     { background: #c8a8ff; }
.dot-active {
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: livePulse 1.6s ease-in-out infinite;
}
.dot-idle   { background: var(--text-dim); }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 6px var(--good); }
  50%      { box-shadow: 0 0 14px var(--good); }
}

/* ---- Live now strip ---- */
.live-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px;
  background: linear-gradient(90deg, rgba(126, 226, 160, 0.05), transparent 70%), var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 12px;
}
.live-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--good);
}
.live-label::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 8px var(--good);
  animation: livePulse 1.6s ease-in-out infinite;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.25);
  border-radius: 999px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.live-pill .proj { font-weight: 600; color: var(--accent); }
.live-pill .act { color: var(--text-mute); font-family: "SF Mono", Menlo, monospace; font-size: 11px; }
.live-pill .age { color: var(--text-dim); font-size: 10.5px; }
.live-strip .live-empty { color: var(--text-mute); font-style: italic; }
.live-strip .live-idle-count { color: var(--text-dim); margin-left: auto; font-size: 11px; }

/* ---- Bottom compact row (model · events · inbox) ---- */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 0.7fr;
  gap: 14px;
  margin-bottom: 14px;
}
.bottom-row .card { margin-bottom: 0; height: 100%; }
.bottom-row .card.compact h2 { font-size: 10.5px; margin-bottom: 10px; padding-bottom: 6px; }
.bottom-row .card.compact table th,
.bottom-row .card.compact table td { padding: 5px 8px; font-size: 11.5px; }
@media (max-width: 1100px) {
  .bottom-row { grid-template-columns: 1fr; }
}

/* TIMELINE — slim sparkline */
.timeline {
  display: flex;
  align-items: flex-end;
  height: 56px;
  gap: 3px;
  padding: 0;
}
.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.bar {
  width: 100%;
  background: linear-gradient(to top, var(--accent), #6ea8fe);
  min-height: 1px;
  border-radius: 2px 2px 0 0;
  transition: opacity 0.15s, transform 0.15s;
  opacity: 0.85;
}
.bar:hover { opacity: 1; transform: scaleY(1.04); transform-origin: bottom; }
.hour-label {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
/* highlight current UTC hour subtly */
.bar-wrap.is-now .bar { box-shadow: 0 0 8px rgba(94, 234, 212, 0.5); }
.bar-wrap.is-now .hour-label { color: var(--accent); font-weight: 700; }

/* TABLES */
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #1d2230;
  font-size: 12.5px;
}
th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b93a3;
  font-weight: 500;
  border-bottom-color: #2a3042;
}
tr.row-active { background: rgba(60, 200, 120, 0.04); }
tr.row-idle td { opacity: 0.65; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: "SF Mono", Menlo, monospace; }
.action { font-family: "SF Mono", Menlo, monospace; font-size: 12px; }
.tag {
  display: inline-block;
  background: #1d2230;
  color: #c8cdda;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: "SF Mono", Menlo, monospace;
}

/* HISTORY */
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 12px;
  font-family: "SF Mono", Menlo, monospace;
}
.history-list li {
  padding: 4px 0;
  border-bottom: 1px solid #1d2230;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.history-list .ts { width: 70px; flex-shrink: 0; }
.history-list .host { width: 50px; flex-shrink: 0; font-size: 11px; }
.history-list .tool { flex-shrink: 0; }
.history-list .action { flex: 1; color: #e7e9ee; }

code, .mono {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11.5px;
}

/* DATE SELECTOR */
.date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chip {
  display: inline-block;
  background: var(--card);
  color: #c8cdda;
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { background: #1d2230; border-color: var(--card-edge-hover); color: var(--text); }
.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.35);
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.15);
}
.date-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.date-input input[type="date"] {
  background: #161922;
  color: #c8cdda;
  border: 1px solid #232838;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  color-scheme: dark;
}
.date-input button {
  background: #2f9e7a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.date-input button:hover { background: #38b58a; }
.period-label {
  margin-left: auto;
  font-size: 11px;
}

/* CLICKABLE PROJECT ROWS */
.projects-table .project-row { cursor: pointer; transition: background 0.1s; }
.projects-table .project-row:hover { background: rgba(110, 168, 254, 0.06); }
.projects-table .caret { color: #5e667a; width: 18px; user-select: none; }
.session-rows.hidden { display: none; }
.session-rows td { padding: 0 0 12px 32px; background: #11141c; border-bottom: 2px solid #232838; }
table.sessions.inline { margin: 6px 0; background: transparent; }
table.sessions.inline th { font-size: 9.5px; }
tr.row-external td { opacity: 0.55; font-style: italic; }
tr.row-external:hover td { opacity: 0.8; }
.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #3cc878;
  box-shadow: 0 0 6px #3cc878;
  margin: 0 4px;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.utc-note { font-size: 10px; opacity: 0.7; }
.cross-tag {
  display: inline-block;
  background: rgba(255, 209, 102, 0.10);
  color: #ffd166;
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: -apple-system, "SF Pro Text", sans-serif;
  font-style: normal;
  margin-top: 2px;
}
.micro { font-size: 10.5px; }
code {
  background: #1d2230;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
table.sessions td.prompt {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}
.project-drill h2 { color: #ffd166; }
footer {
  margin-top: 24px;
  font-size: 11px;
  text-align: center;
}
table.events td:nth-child(5) { font-family: "SF Mono", Menlo, monospace; font-size: 11px; }

/* ---- Drift banner ---- */
.card.drift {
  padding: 14px 20px;
  display: flex; align-items: center; gap: 18px;
  border: 1px solid var(--card-edge);
  position: relative; overflow: hidden;
}
.card.drift::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.card.drift-ok::before     { background: var(--good); box-shadow: 0 0 18px rgba(126, 226, 160, 0.45); }
.card.drift-notice::before { background: var(--info); box-shadow: 0 0 18px rgba(160, 193, 255, 0.45); }
.card.drift-warn::before   { background: var(--warn); box-shadow: 0 0 18px rgba(255, 209, 102, 0.45); }
.card.drift-alarm::before  { background: var(--bad);  box-shadow: 0 0 18px rgba(255, 138, 128, 0.55); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.drift-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 1.0px;
  text-transform: uppercase;
}
.drift-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
}
.card.drift-ok .drift-pill     { background: rgba(126, 226, 160, 0.13); color: var(--good); }
.card.drift-ok .drift-pill::before     { background: var(--good); box-shadow: 0 0 8px var(--good); }
.card.drift-notice .drift-pill { background: rgba(160, 193, 255, 0.13); color: var(--info); }
.card.drift-notice .drift-pill::before { background: var(--info); box-shadow: 0 0 8px var(--info); }
.card.drift-warn .drift-pill   { background: rgba(255, 209, 102, 0.13); color: var(--warn); }
.card.drift-warn .drift-pill::before   { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.card.drift-alarm .drift-pill  { background: rgba(255, 138, 128, 0.16); color: var(--bad); }
.card.drift-alarm .drift-pill::before  { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

.drift-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.drift-summary {
  font-size: 13.5px; color: var(--text); font-weight: 500;
  letter-spacing: -0.1px;
}
.drift-summary .drift-label {
  color: var(--text-mute); font-weight: 600; text-transform: uppercase;
  font-size: 10.5px; letter-spacing: 0.7px; margin-right: 10px;
}
.drift-stats {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 11px;
}
.drift-stat {
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.drift-stat b { color: var(--text); font-weight: 600; margin-right: 4px; }
.drift-stat.is-warn { color: var(--bad); border-color: rgba(255, 138, 128, 0.35); }
.drift-stat.is-info { color: var(--info); border-color: rgba(160, 193, 255, 0.35); }

.drift-signals { margin: 0; padding: 0 0 0 18px; font-size: 11.5px; list-style: none; }
.drift-signals li { color: var(--text-mute); margin: 3px 0; padding-left: 14px; position: relative; }
.drift-signals li::before { content: "→"; position: absolute; left: 0; color: var(--text-dim); }
.drift-signals li.drift-alarm  { color: var(--bad); }
.drift-signals li.drift-warn   { color: var(--warn); }
.drift-signals li.drift-notice { color: var(--info); }

/* ---- Outcome marking buttons (modal) ---- */
.outcome-buttons { margin: 10px 0 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.outcome-buttons button {
  padding: 4px 12px; font-size: 12px; border-radius: 4px;
  border: 1px solid #2c3145; cursor: pointer;
  background: #1d2230; color: #e7e9ee; font-weight: 600;
}
.outcome-buttons button:hover { background: #252a3a; }
.outcome-buttons .btn-correct { border-color: #2d6e3f; color: #7ee2a0; }
.outcome-buttons .btn-partial { border-color: #a36318; color: #ffd166; }
.outcome-buttons .btn-wrong   { border-color: #a01818; color: #ff8a80; }
.outcome-buttons input[type=text] {
  flex: 1; min-width: 200px;
  padding: 4px 10px; font-size: 12px; border-radius: 4px;
  border: 1px solid #2c3145; background: #0f1115; color: #e7e9ee;
}

/* ---- Delegations ---- */
.deleg-summary { margin-bottom: 10px; font-size: 12.5px; color: #c8cdda; }
.deleg-summary .warn { color: #ff7a59; margin-left: 8px; }
table.delegations { width: 100%; border-collapse: collapse; font-size: 12px; }
table.delegations th, table.delegations td {
  padding: 5px 8px;
  border-bottom: 1px solid #232838;
  text-align: left;
  vertical-align: top;
}
table.delegations th { color: #8b93a3; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
table.delegations tr.delegation-row { cursor: pointer; }
table.delegations tr.delegation-row:hover { background: #1d2230; }
table.delegations tr.row-failed td { background: #2a1a18; }
table.delegations tr.row-contract td { background: #2a2618; }
.tag.warn { background: #3a1f17; color: #ff9b80; padding: 1px 6px; border-radius: 3px; font-size: 10.5px; margin-left: 4px; }
.verdict { font-weight: 600; padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.verdict-pass     { background: #16341f; color: #7ee2a0; }
.verdict-fail     { background: #3a1a1a; color: #ff8a80; }
.verdict-partial  { background: #3a2e16; color: #ffd166; }
.verdict-unclear  { background: #2a2e3a; color: #b0b6c4; }
.verdict-unknown  { background: #2a2e3a; color: #b0b6c4; }
.outcome { font-weight: 600; padding: 1px 5px; border-radius: 3px; font-size: 10.5px; }
.outcome-correct { background: #16341f; color: #7ee2a0; }
.outcome-wrong   { background: #3a1a1a; color: #ff8a80; }
.outcome-partial { background: #3a2e16; color: #ffd166; }

/* Delegation log modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh; z-index: 1000;
}
.modal.hidden { display: none; }
.modal-inner {
  background: #161922;
  border: 1px solid #2c3145;
  max-width: 920px; width: 100%; max-height: 92vh;
  overflow: auto;
  border-radius: 10px;
  padding: 24px 26px;
  position: relative;
  color: #e7e9ee;
}
.modal-close {
  position: absolute; top: 6px; right: 12px;
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: #8b93a3;
}
.modal-close:hover { color: #e7e9ee; }
.modal-inner h3 { margin-top: 0; font-size: 14px; }
.modal-inner pre {
  background: #0f1115;
  padding: 12px;
  border-radius: 4px;
  overflow: auto;
  max-height: 60vh;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-inner details { margin: 10px 0; }
.modal-inner summary { cursor: pointer; font-weight: 600; color: #c8cdda; }

/* ── Team Chat (Telegram-style feed inside the Inbox card) ─────────────── */
.card.tc-panel { display: flex; flex-direction: column; min-height: 280px; }
.card.tc-panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card.tc-panel h2 .muted { font-weight: 400; }
.card.tc-panel .tc-actions { margin-left: auto; display: flex; gap: 6px; }
.tc-icon-btn {
  background: transparent;
  border: 1px solid var(--card-edge);
  color: var(--text-mute);
  border-radius: 8px;
  width: 28px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
}
.tc-icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.tc-icon-btn:disabled { opacity: 0.5; cursor: wait; }

.tc-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding: 8px 6px 8px 2px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--card-edge) transparent;
  background:
    radial-gradient(800px 300px at 0% 0%, rgba(94,234,212,0.04) 0%, transparent 60%),
    radial-gradient(800px 300px at 100% 100%, rgba(160,193,255,0.04) 0%, transparent 60%);
  border-radius: 8px;
}
.tc-stream::-webkit-scrollbar { width: 6px; }
.tc-stream::-webkit-scrollbar-thumb { background: var(--card-edge); border-radius: 3px; }
.card.tc-panel.tc-expanded .tc-stream { max-height: 75vh; }
.card.tc-panel.tc-expanded {
  position: fixed;
  inset: 6vh 6vw;
  z-index: 100;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  border: 1px solid var(--card-edge-hover);
}

.tc-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: tcFadeIn 220ms ease;
}
.tc-msg-self { justify-content: flex-end; }
@keyframes tcFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #0b0d12;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.tc-avatar-travel  { background: linear-gradient(135deg, #ffb46b 0%, #ff7b54 100%); }
.tc-avatar-home    { background: linear-gradient(135deg, #6cd9ff 0%, #4a8cff 100%); }
.tc-avatar-cluster { background: linear-gradient(135deg, #b07eff 0%, #6e4dd1 100%); }
.tc-avatar-sandy   { background: linear-gradient(135deg, #5eead4 0%, #14b8a6 100%); }
.tc-avatar-other   { background: linear-gradient(135deg, #888 0%, #555 100%); color: #eee; }

.tc-bubble {
  max-width: 78%;
  padding: 6px 11px 5px;
  border-radius: 14px;
  background: #1c2030;
  border: 1px solid var(--card-edge);
  font-size: 13px;
  line-height: 1.45;
  position: relative;
}
.tc-msg-other .tc-bubble { border-bottom-left-radius: 4px; }
.tc-msg-self  .tc-bubble {
  background: linear-gradient(135deg, #14b8a6 0%, #0d8b80 100%);
  color: #06140f;
  border: 1px solid #0d8b80;
  border-bottom-right-radius: 4px;
}
.tc-bubble-travel  { border-color: rgba(255,180,107,0.25); }
.tc-bubble-home    { border-color: rgba(108,217,255,0.25); }
.tc-bubble-cluster { border-color: rgba(176,126,255,0.25); }

.tc-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--info);
  margin-bottom: 1px;
  letter-spacing: 0.3px;
  text-transform: lowercase;
}
.tc-bubble-travel  .tc-name { color: #ffb46b; }
.tc-bubble-home    .tc-name { color: #6cd9ff; }
.tc-bubble-cluster .tc-name { color: #b07eff; }

.tc-text {
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
.tc-msg-self .tc-text { color: #06140f; }
.tc-text code {
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tc-msg-self .tc-text code { background: rgba(255,255,255,0.18); color: #062019; }

.tc-meta {
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.tc-msg-self .tc-meta { color: rgba(6, 20, 15, 0.55); }

/* Backdrop when expanded */
.tc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(4px);
  z-index: 99;
  animation: tcFadeIn 200ms ease;
}

/* Footer reload link */
.footer-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: border-color .15s;
}
.footer-link:hover { border-bottom-color: var(--accent); }

/* Listener health dot in the Team Chat card header */
.tc-health {
  font-size: 12px;
  line-height: 1;
  cursor: help;
  filter: drop-shadow(0 0 4px currentColor);
  margin-left: -2px;
}
.tc-health-fresh  { color: var(--good); }
.tc-health-stale  { color: var(--warn); }
.tc-health-down   { color: var(--bad); }
.tc-health-absent { color: var(--text-dim); filter: none; }

/* ============================================================
   Pending Mail Drafts panel — phase-1 mail-ops outbound HITL gate
   ============================================================ */
.mail-draft-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.mail-draft {
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 120ms ease;
}
.mail-draft:hover { border-color: var(--card-edge-hover); }
.mail-draft-meta {
  font-size: 11.5px;
  color: var(--text-mute);
  margin-bottom: 6px;
  line-height: 1.5;
}
.mail-draft-meta code {
  font-size: 11.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
}
.mail-draft-meta .dim { color: var(--text-dim); }
.mail-cc-label { margin-left: 6px; }
.mail-draft-cc {
  font-size: 11.5px;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 4px;
  padding: 1px 6px;
  min-width: 240px;
  margin: 0 2px;
}
.mail-draft-cc:focus { outline: none; border-color: var(--accent); }
.mail-draft-cc::placeholder { color: var(--text-dim); }
.mail-draft-subject {
  font-size: 13.5px;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: 0.1px;
}
.mail-inbound-context {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--card-edge);
  border-radius: 4px;
  font-size: 12px;
}
.mail-inbound-context summary {
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
  outline: none;
}
.mail-inbound-context summary:hover { color: var(--text); }
.mail-inbound-context summary b { color: var(--text); font-weight: 500; }
.mail-inbound-body {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}
.mail-draft-body {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 140px;
  outline: none;
  transition: border-color 120ms ease;
}
.mail-draft-body:focus { border-color: var(--accent); }
.mail-draft-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.mail-draft-actions button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--card-edge);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.mail-draft-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--card-edge-hover);
}
/* First button = ✓ Send → accent (teal). Second = Edit-and-Send → neutral. Third = ✗ Reject → red on hover. */
.mail-draft-actions button:nth-child(1) { color: var(--good); }
.mail-draft-actions button:nth-child(1):hover {
  background: rgba(126, 226, 160, 0.12);
  border-color: var(--good);
}
.mail-draft-actions button:nth-child(3) { color: var(--bad); }
.mail-draft-actions button:nth-child(3):hover {
  background: rgba(255, 138, 128, 0.12);
  border-color: var(--bad);
}
.mail-draft-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mail-draft-status {
  margin-left: auto;
  font-size: 11.5px;
}

/* === Redesign 2026-05-09: Hero KPI strip (compact v0.5) === */
.hero-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 12px;
}
.hero-tile {
  background: #181b25;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 0;
  align-items: baseline;
  cursor: pointer;
  transition: border-color 160ms ease, transform 80ms ease;
}
.hero-tile:hover { border-color: var(--card-edge-hover); }
.hero-tile:active { transform: translateY(1px); }
.hero-tile .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  font-weight: 600;
  grid-column: 2;
  grid-row: 1;
}
.hero-tile .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1;
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  font-variant-numeric: tabular-nums;
}
.hero-tile .sub {
  font-size: 10.5px;
  color: var(--text-dim);
  grid-column: 2;
  grid-row: 2;
  line-height: 1.25;
}
.hero-tile.health-ok    .value { color: var(--good); }
.hero-tile.health-warn  .value { color: var(--warn); }
.hero-tile.health-stale .value { color: var(--info); }
.hero-tile.health-bad   .value { color: var(--bad); }
.hero-tile.needs-warn   .value { color: var(--warn); }

/* Demoted spend line under header */
.spend-demoted {
  font-size: 12px;
  color: var(--text-mute);
  margin: 4px 0 0;
  cursor: pointer;
}
.spend-demoted:hover { color: var(--text); }
.spend-demoted b { color: var(--text); font-weight: 500; }

/* === Redesign 2026-05-09: Primary 2-col grid === */
.primary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.primary-grid > .card { margin-bottom: 0; }  /* grid handles spacing */

@media (max-width: 1100px) {
  .primary-grid { grid-template-columns: 1fr; }
}

/* Activity stream card — denser line spacing than default cards */
.activity-stream-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  max-height: 340px;
  overflow-y: auto;
}
.activity-stream-list li {
  display: grid;
  grid-template-columns: 56px 80px 1fr;
  gap: 8px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--card-edge);
  color: var(--text-mute);
}
.activity-stream-list li:last-child { border-bottom: none; }
.activity-stream-list .as-time { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.activity-stream-list .as-proj { color: var(--accent); font-weight: 500; }
.activity-stream-list .as-act  { color: var(--text); }

/* === Redesign 2026-05-09: Diagnostics collapser === */
.diagnostics {
  background: rgba(20, 23, 31, 0.5);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 14px;
}
.diagnostics > summary {
  padding: 12px 18px;
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-mute);
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.diagnostics > summary::-webkit-details-marker { display: none; }
.diagnostics > summary::before {
  content: "▸";
  color: var(--text-dim);
  transition: transform 120ms ease;
  display: inline-block;
}
.diagnostics[open] > summary::before { transform: rotate(90deg); }
.diagnostics-body {
  padding: 8px 18px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.diagnostics-body > .card { margin-bottom: 0; }
@media (max-width: 1100px) {
  .diagnostics-body { grid-template-columns: 1fr; }
}

/* === Redesign 2026-05-09 v0.3: 3-column app shell (sidebar + main + chat rail) === */
.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 340px;
  min-height: 100vh;
  width: 100%;
}

@media (max-width: 1400px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .chat-rail { display: none; }  /* rail collapses on narrow viewports — sidebar still has it */
}

/* --- Sidebar --- */
.sidebar {
  background: #10131a;
  border-right: 1px solid var(--card-edge);
  padding: 18px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  padding: 0 18px;
  background: linear-gradient(90deg, #e7e9ee 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-mute);
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.sidebar-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-item.active {
  color: var(--text);
  background: rgba(94, 234, 212, 0.08);
  border-left-color: var(--accent);
}
.sidebar-item .si-icon {
  display: inline-block;
  width: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.sidebar-item.active .si-icon { color: var(--accent); }
.sidebar-item .si-badge {
  margin-left: auto;
  background: var(--warn);
  color: #000;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}
.sidebar-foot {
  padding: 0 14px;
  border-top: 1px solid var(--card-edge);
  padding-top: 12px;
}
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: var(--text-mute);
  cursor: help;
}
.health-pill .hp-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.health-pill .hp-sub { color: var(--text-dim); font-weight: 400; }
.health-pill.health-ok    { color: var(--good); }
.health-pill.health-warn  { color: var(--warn); }
.health-pill.health-stale { color: var(--info); }
.health-pill.health-bad   { color: var(--bad); }

/* --- Main content area --- */
.main-content {
  padding: 22px 28px 28px;
  min-width: 0;  /* allow children to shrink in grid */
  overflow-x: hidden;
}
.main-content > .topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 14px;
}
.topbar-left h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, #e7e9ee 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Chat rail (always visible) --- */
.chat-rail {
  background: #10131a;
  border-left: 1px solid var(--card-edge);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.chat-rail .tc-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 14px 14px 0;
  overflow: hidden;
}
.chat-rail .tc-panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  margin: 0 0 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--card-edge);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-rail .tc-panel h2 .cr-title { font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
.chat-rail .tc-panel h2 .cr-meta { margin-left: auto; font-size: 10px; }
.chat-rail .tc-panel h2 .tc-actions { margin-left: 4px; }
.chat-rail .tc-stream {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 14px;
}

/* === Redesign 2026-05-09 v0.4: Compact ticker rail === */
.chat-rail .cr-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--card-edge);
}
.cr-title-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.cr-title-link:hover { color: var(--accent); }
.cr-meta { margin-left: auto; font-size: 10px; }
.cr-ticker {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cr-pill {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-mute);
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease;
}
.cr-pill:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--card-edge);
  color: var(--text);
}
.cr-pill-from {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--card-edge-hover);
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.cr-pill-self .cr-pill-from { background: var(--accent); color: #06281f; }
.cr-pill-from-home   { background: #4a6cf7; color: #fff; }
.cr-pill-from-cluster { background: #f7884a; color: #fff; }
.cr-pill-from-travel  { background: #5eead4; color: #06281f; }
.cr-pill-body {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cr-pill-name {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}
.cr-pill-text {
  font-size: 12px;
  color: inherit;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
.cr-pill-time {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  align-self: flex-start;
  padding-top: 2px;
}

/* Full-width chat view on /chats route */
.chats-full {
  max-height: none;  /* override the default tc-stream cap */
}

/* === Topbar refresh button + auto-refresh toggle === */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.refresh-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  width: 28px; height: 28px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease, transform 200ms ease;
  padding: 0;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.is-loading { animation: spin-cw 700ms linear infinite; }
.refresh-btn:disabled { cursor: wait; opacity: 0.6; }
@keyframes spin-cw { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.auto-refresh-toggle {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.auto-refresh-toggle input { cursor: pointer; }

/* ── Login screen ──────────────────────────────────────────────────────── */
.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 30% -10%, #16213a 0%, transparent 55%),
    radial-gradient(900px 480px at 80% 110%, #1a1428 0%, transparent 50%),
    var(--bg);
}
.login-shell {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  transition: border-color 200ms ease;
}
.login-card:hover { border-color: var(--card-edge-hover); }
.login-title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.4px;
  background: linear-gradient(90deg, #e7e9ee 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub {
  margin: 4px 0 24px;
  font-size: 12.5px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-mute);
  font-weight: 600;
}
.login-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  outline: none;
  transition: border-color 120ms ease;
}
.login-input:focus { border-color: var(--accent); }
.login-error {
  margin-top: 4px;
  padding: 8px 10px;
  background: rgba(255, 138, 128, 0.1);
  border-left: 2px solid var(--bad);
  border-radius: 4px;
  color: var(--bad);
  font-size: 12px;
}
.login-button {
  margin-top: 12px;
  background: var(--accent);
  color: #0b0d12;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.login-button:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(94, 234, 212, 0.25); }
.login-button:active { transform: translateY(0); }
.login-footer {
  margin: 22px 0 0;
  font-size: 11px;
  text-align: center;
}
.login-footer code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--text);
}

.login-password-row {
  position: relative;
  display: flex;
  align-items: stretch;
}
.login-password-row .login-input {
  flex: 1;
  padding-right: 44px;
}
.login-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease;
}
.login-eye:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.login-eye:focus { outline: 1px solid var(--accent); outline-offset: 1px; }
