:root {
  --bg: #0b0c10;
  --surface: #12141a;
  --surface-2: #1a1d27;
  --surface-3: #212433;
  --border: #252836;
  --border-2: #2e3346;
  --text: #e2e5f0;
  --text-muted: #7b8194;
  --text-dim: #4a5066;
  --primary: #6366f1;
  --primary-hover: #4f52d8;
  --primary-glow: rgba(99,102,241,.25);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #38bdf8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
  --transition: .15s ease;
  --sidebar-w: 220px;
}

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

html, body { height: 100%; overflow-x: hidden; overscroll-behavior: none; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem;   font-weight: 600; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ── Login ──────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse at 60% 30%, rgba(99,102,241,.12) 0%, transparent 65%),
              radial-gradient(ellipse at 20% 80%, rgba(139,92,246,.08) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(99,102,241,.08);
  animation: slideUp .3s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

.login-logo-text { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.login-logo-text span { color: var(--text-muted); font-weight: 400; font-size: .85rem; display: block; }

.login-card h2 { margin-bottom: 4px; }
.login-card p  { color: var(--text-muted); margin-bottom: 28px; font-size: .875rem; }

.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: .85rem;
  display: none;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .03em; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], input[type=tel], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input:not([type]), .input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px; /* Touch target accessibility */
}
input:focus, .input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
input::placeholder, .input::placeholder, textarea::placeholder { color: var(--text-dim); }
input[type=date], input[type=datetime-local], input[type=time] { color-scheme: dark; }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }
select option { background: var(--surface-2); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
  min-height: 44px; /* Touch target accessibility */
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 0 0 3px var(--primary-glow); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-success { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.25); }
.btn-success:hover { background: rgba(34,197,94,.25); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon {
  padding: 7px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: .95rem; }

/* ── App Layout ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* tracks visible viewport; excludes browser chrome + virtual keyboard */
  overflow: hidden;
}

@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }
  .sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    overflow: visible !important;
  }
  .main-content {
    flex: 1;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .login-card {
    width: 90%;
    padding: 20px;
  }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .sidebar-logo { padding: 10px; }
  .btn-full { width: 100%; }
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-label { font-size: .95rem; font-weight: 700; }
.sidebar-logo-sub   { font-size: .7rem; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 8px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon { flex-shrink: 0; display: inline-flex; }
.svg-icon { width: 1em; height: 1em; display: inline-block; flex-shrink: 0; }
.btn .svg-icon { width: 1rem; height: 1rem; }
.login-logo-icon .svg-icon { width: 22px; height: 22px; }
.sidebar-logo-icon .svg-icon { width: 18px; height: 18px; }
.nav-icon .svg-icon { width: 16px; height: 16px; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name  { font-size: .825rem; font-weight: 500; }
.user-role  { font-size: .7rem; color: var(--text-muted); }

/* ── Main content ───────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }

.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.mobile-nav-toggle .svg-icon { width: 18px; height: 18px; }
.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(2px);
}
.mobile-nav-backdrop[hidden] { display: none; }

.content { padding: 24px 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { padding: 20px; }

/* ── Stats grid ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-link {
  width: 100%;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}
.stat-link:hover,
.stat-link:focus-visible {
  background: var(--surface-2);
  border-color: var(--border-2);
}
.stat-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.stat-link:active { transform: translateY(1px); }
.stat-label  { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value  { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-sub    { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.stat-icon   { float: right; opacity: .6; margin-top: -4px; }
.stat-icon .svg-icon { width: 1.5rem; height: 1.5rem; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
@media (max-width: 480px) {
  .col-hide-xs { display: none; }
  th, td { padding: 10px 10px; }
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-admin   { background: rgba(99,102,241,.18); color: #a5b4fc; }
.badge-user    { background: rgba(107,114,128,.18); color: #9ca3af; }
.badge-success { background: rgba(34,197,94,.15);  color: #86efac; }
.badge-danger  { background: rgba(239,68,68,.15);  color: #fca5a5; }
.badge-warning { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-info    { background: rgba(56,189,248,.15); color: #7dd3fc; }

/* ── Toggle switch ──────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-track::before {
  content: "";
  position: absolute;
  left: 3px; top: 3px;
  width: 14px; height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-track { background: rgba(99,102,241,.3); border-color: var(--primary); }
.toggle input:checked + .toggle-track::before { transform: translateX(16px); background: var(--primary); }

/* ── Access grid ────────────────────────────────────────────────────────── */
.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.access-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.access-item.enabled { border-color: rgba(99,102,241,.35); }
.access-name { font-size: .825rem; font-weight: 500; }
.access-icon { display: inline-flex; margin-right: 8px; color: var(--primary); }
.access-icon .svg-icon { width: 1.1rem; height: 1.1rem; }

/* ── Config form ────────────────────────────────────────────────────────── */
.config-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.config-tab {
  padding: 8px 14px;
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.config-tab:hover  { color: var(--text); }
.config-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.config-tab.enabled::after { content: "●"; font-size: .5rem; color: var(--success); margin-left: 5px; vertical-align: middle; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-body   { padding: 20px 24px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.2rem; padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-wide { width: 680px; }

@media (max-width: 480px) {
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
  }
  .modal-wide { width: 100%; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-body   { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 200;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: slideLeft .2s ease;
  border-left: 3px solid;
}
.toast-success { background: var(--surface-2); border-color: var(--success); }
.toast-error   { background: var(--surface-2); border-color: var(--danger); }
.toast-info    { background: var(--surface-2); border-color: var(--primary); }

/* ── Code / monospace ───────────────────────────────────────────────────── */
.mono {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: .8rem;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--info);
}
.key-reveal {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.key-value {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  color: var(--success);
  word-break: break-all;
}
.copy-box {
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  white-space: pre;
}

/* ── Activity ───────────────────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 1px; }
.activity-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .825rem;
  transition: background var(--transition);
}
.activity-row:hover { background: var(--surface-2); }
.activity-time { font-size: .72rem; color: var(--text-dim); white-space: nowrap; min-width: 80px; }
.activity-actor { font-weight: 600; color: var(--primary); white-space: nowrap; }
.activity-action { color: var(--text-muted); }
.activity-detail { color: var(--text-dim); font-size: .78rem; }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.empty-icon { margin-bottom: 12px; opacity: .5; display: flex; justify-content: center; }
.empty-icon .svg-icon { width: 2.5rem; height: 2.5rem; }
.empty-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.empty-sub { font-size: .825rem; }

/* ── DB Connections UI ──────────────────────────────────────────────────── */
.conn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.conn-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.conn-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.conn-badge {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}
.conn-badge-mysql    { background: rgba(56,189,248,.15); color: #7dd3fc; }
.conn-badge-postgres { background: rgba(99,102,241,.15); color: #a5b4fc; }
.conn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Path picker (git repos) ───────────────────────────────────────────── */
.path-picker {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.path-picker-input { flex: 1; min-width: 0; }
.path-picker-field { position: relative; }
.path-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.path-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: .8rem;
}
.path-suggestion:hover { background: var(--surface-2); }
.path-suggestion-name { font-weight: 500; flex-shrink: 0; }
.path-suggestion-path {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.path-browser-crumb {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  word-break: break-all;
}
.path-browser-crumb button,
.path-crumb,
.path-crumb-root {
  background: none;
  border: none;
  color: var(--info);
  cursor: pointer;
  padding: 0 2px;
  font: inherit;
}
.path-browser-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.path-browser-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: .85rem;
}
.path-browser-row:last-child { border-bottom: none; }
.path-browser-row:hover { background: var(--surface-3); }
.path-browser-row.selected {
  background: rgba(99, 102, 241, .2);
  outline: 1px solid var(--primary);
}
.path-browser-row-parent { color: var(--text-muted); }
.path-browser-empty {
  padding: 16px;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
}

/* ── Gateway status ─────────────────────────────────────────────────────── */
.gw-process {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: .8rem;
}
.gw-process-summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}
.gw-process-summary::-webkit-details-marker { display: none; }
.gw-proc-server { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.gw-proc-server svg { width: 14px; height: 14px; }
.gw-proc-who {
  color: var(--text-muted); font-size: .78rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gw-chevron svg { width: 15px; height: 15px; transition: transform .15s ease; }
.gw-process[open] .gw-chevron svg { transform: rotate(180deg); }
.gw-pulse {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}
.gw-process-body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
}
.gw-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 16px;
  margin: 10px 0 14px;
}
.gw-detail { display: flex; flex-direction: column; gap: 1px; }
.gw-detail-k { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.gw-detail-v { font-size: .82rem; }
.gw-hist-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.gw-hist-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.05));
}
.gw-hist-row:last-child { border-bottom: none; }
.gw-hist-icon svg { width: 13px; height: 13px; color: var(--text-muted); }
.gw-hist-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gw-hist-time { font-size: .72rem; color: var(--text-muted); flex-shrink: 0; }
.gw-hist-empty { font-size: .78rem; color: var(--text-muted); padding: 4px 0; }

/* ── User detail tabs ───────────────────────────────────────────────────── */
.user-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
  width: fit-content;
}
.user-tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.user-tab:hover  { color: var(--text); }
.user-tab.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* ── Server config sections ─────────────────────────────────────────────── */
.server-config-section {
  margin-bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.server-config-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.server-config-header:hover { background: var(--surface-3); }
.server-config-name { font-size: .875rem; font-weight: 600; }
.server-config-icon, .cfg-arrow { display: inline-flex; color: var(--primary); }
.server-config-icon .svg-icon { width: 1.2rem; height: 1.2rem; }
.cfg-arrow .svg-icon { width: 1rem; height: 1rem; }
.server-config-body { padding: 16px; border-top: 1px solid var(--border); }
.server-config-body.hidden { display: none; }

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }
@keyframes slideLeft { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: none } }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .4 } }
@keyframes spin { from { transform: rotate(0) } to { transform: rotate(360deg) } }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ── Axiom dashboard shell ──────────────────────────────────────────────── */
/* The Axiom dashboard inside the admin uses a horizontal flex layout with a
 * fixed 280px project sidebar and a flex-1 main pane. These classes replace
 * the inline styles that previously hard-coded the widths so the media query
 * below can convert the sidebar into a drawer on narrow viewports. */
.axiom-shell {
  display: flex;
  height: calc(100vh - 92px);
  margin: -24px -32px -24px -24px;
  border-top: 1px solid var(--border);
  position: relative;
}
.axiom-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.axiom-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
.axiom-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}
.axiom-mobile-toggle:hover { background: var(--surface-3); }
.axiom-sidebar-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  display: none;
}

/* ── Axiom components ─────────────────────────────────────────────────── */

/* Project sidebar rows */
.ax-proj-row { padding: 10px 12px; cursor: pointer; display: flex; align-items: flex-start; gap: 9px; border-bottom: 1px solid var(--border); transition: background .1s; }
.ax-proj-row:hover, .ax-proj-row.selected { background: var(--surface-2); }
.ax-proj-label { font-size: .85rem; word-break: break-word; display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.ax-proj-sub { font-size: .67rem; color: var(--text-muted); font-family: monospace; margin-top: 2px; line-height: 1.3; word-break: break-all; }
.ax-count { font-size: .7rem; color: var(--text-muted); flex-shrink: 0; }
.ax-chk { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 3px; border: 1.5px solid var(--border); background: transparent; flex-shrink: 0; transition: background .1s, border-color .1s; font-size: .65rem; color: #fff; }
.ax-chk.on { background: var(--primary); border-color: var(--primary); }
.ax-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Header / strip bars */
.ax-header { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 48px; justify-content: space-between; }
.ax-header-left { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; min-width: 0; }
.ax-strip { padding: 7px 16px; border-bottom: 1px solid var(--border); font-size: .78rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ax-strip-run { background: rgba(245,158,11,.07); }
.ax-strip-queue { background: rgba(99,102,241,.07); }
.ax-strip-label { font-weight: 600; flex-shrink: 0; }
.ax-run-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); margin-right: 5px; animation: pulse 1.4s ease-in-out infinite; }

/* Queue panel */
.ax-queue-panel { border-bottom: 1px solid var(--border); background: var(--surface); }
.ax-queue-hd { display: flex; align-items: center; gap: 8px; padding: 8px 16px; width: 100%; background: none; border: none; cursor: pointer; color: var(--text); }
.ax-queue-hd:hover { background: var(--surface-2); }
.ax-queue-count { font-size: .65rem; background: var(--primary); color: #fff; border-radius: 10px; padding: 0 6px; line-height: 1.5; }
.ax-queue-panel.collapsed .ax-queue-body { display: none; }
.ax-queue-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--border); }
.ax-queue-row-content { flex: 1; min-width: 0; }
.ax-queue-goal { font-size: .82rem; line-height: 1.4; word-break: break-word; }
.ax-queue-meta { font-size: .68rem; color: var(--text-muted); margin-top: 2px; font-family: monospace; word-break: break-all; }
.ax-queue-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ax-queue-action-btn { min-height: 36px; min-width: 52px; padding: 0 10px; }
.ax-queue-edit-ta { width: 100%; font-size: .82rem; resize: vertical; min-height: 52px; box-sizing: border-box; }

/* Task input bar */
.ax-task-bar { border-bottom: 1px solid var(--border); background: var(--surface); }
.ax-task-toggle { display: none; } /* hidden on desktop — bar always open */
.ax-task-body { padding: 12px 16px; }
.ax-task-row { display: flex; gap: 10px; align-items: flex-end; }
.ax-task-row textarea { flex: 1; resize: vertical; min-height: 52px; font-size: .9rem; min-width: 0; }
.ax-task-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: .7rem; color: var(--text-muted); flex-wrap: wrap; gap: 6px; }
.ax-task-adv { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 8px; }
.ax-task-adv input { flex: 1; min-width: 0; font-size: .78rem; padding: 5px 8px; }

/* Project chips */
.ax-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 8px; border-radius: 12px; font-size: .74rem; white-space: nowrap; }
.ax-chip-primary { background: var(--primary); color: #fff; }
.ax-chip-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.ax-chip-remove { cursor: pointer; opacity: .65; font-size: .9rem; line-height: 1; padding: 0 1px; }
.ax-chip-remove:hover { opacity: 1; }
.ax-chip-label { font-size: .58rem; font-weight: 700; letter-spacing: .3px; opacity: .8; }

/* Activity feed */
.ax-feed { flex: 1; overflow-y: auto; }
.ax-feed-row { padding: 11px 16px 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; border-left: 3px solid transparent; transition: background .1s; overflow: hidden; max-width: 100%; }
.ax-feed-row:hover { background: var(--surface-2); }
.ax-feed-row.expanded { background: var(--surface-2); }
.ax-feed-hd { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.ax-feed-hd-l { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ax-pill { padding: 2px 9px; border-radius: 10px; font-size: .63rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; flex-shrink: 0; color: #fff; }
.ax-pill-muted { background: var(--surface-3) !important; color: var(--text-muted) !important; }
.ax-feed-time { font-size: .7rem; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
.ax-feed-goal { font-size: .86rem; line-height: 1.45; color: var(--text); margin-bottom: 2px; word-break: break-word; overflow-wrap: anywhere; }
/* Expanded timeline content: clamp diff/pre blocks to row width */
.ax-feed-row pre, .ax-feed-row .ax-diff-wrap { max-width: 100%; overflow-x: auto; }
.ax-feed-row [style*="font-family:monospace"] { word-break: break-all; }
.ax-feed-approach { font-size: .72rem; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.ax-feed-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 8px; }
.ax-feed-meta { font-size: .66rem; color: var(--text-muted); }
.ax-file-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.ax-file-chip { font-family: monospace; font-size: .69rem; background: var(--surface-2); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* ── Axiom: full overhaul for mobile ───────────────────────────────────── */

  /* Shell: drop fixed height, let the page scroll naturally */
  .axiom-shell {
    margin: -16px -14px -24px -14px;
    height: auto;
    min-height: calc(100svh - 60px);
    flex-direction: column;
  }

  /* Main: let content flow, remove clip */
  .axiom-main {
    overflow: visible;
    height: auto;
    min-height: 0;
  }

  /* Feed: let the page scroll, not the inner box */
  .ax-feed {
    overflow-y: visible;
    min-height: 120px;
  }

  /* Sidebar: fixed drawer (parent no longer has a stable height) */
  .axiom-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0; right: auto;
    z-index: 200;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .axiom-sidebar.axiom-mobile-open { transform: translateX(0); }

  /* Backdrop covers full screen */
  .axiom-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    display: none;
  }
  .axiom-sidebar.axiom-mobile-open ~ .axiom-sidebar-backdrop { display: block; }
  .axiom-mobile-toggle { display: inline-flex; }

  /* Header bar */
  .ax-header { padding: 8px 12px; min-height: 44px; flex-wrap: wrap; gap: 6px; }
  .ax-header-left { flex: 1; min-width: 0; flex-wrap: wrap; gap: 4px; }

  /* Chips: shrink and allow wrapping */
  .ax-chip { font-size: .7rem; padding: 2px 7px 2px 6px; max-width: calc(100vw - 72px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ax-chip-label { display: none; }

  /* Strips */
  .ax-strip { padding: 6px 12px; font-size: .72rem; flex-wrap: wrap; gap: 6px; }

  /* Task bar: collapsible on mobile */
  .ax-task-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 10px 14px;
    background: none; border: none; cursor: pointer;
    font-size: .82rem; font-weight: 600; color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .ax-task-toggle-label { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ax-task-toggle-arrow { font-size: .7rem; color: var(--text-muted); flex-shrink: 0; }
  .ax-task-bar.ax-task-collapsed .ax-task-body { display: none; }
  .ax-task-bar.ax-task-collapsed .ax-task-toggle { border-bottom: none; }

  /* When open: stack textarea above button */
  .ax-task-body { padding: 10px 12px; }
  .ax-task-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .ax-task-row textarea { width: 100%; min-height: 60px; font-size: .875rem; box-sizing: border-box; }
  .ax-task-row > .btn { width: 100%; padding: 10px; }
  .ax-task-meta { flex-wrap: wrap; }
  .ax-task-hint { display: none; }

  /* Feed rows */
  .ax-feed-row { padding: 10px 12px 10px 10px; }
  .ax-feed-hd { flex-wrap: wrap; gap: 4px; }
  .ax-feed-time { display: none; }
  .ax-feed-foot { flex-wrap: wrap; gap: 6px; }
  .ax-feed-meta { font-size: .65rem; }

  /* File strip chips */
  .ax-file-chip { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 768px) {
  #app { position: relative; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  .mobile-nav-toggle { display: inline-flex; }
  .main { width: 100%; }
  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }
  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .content { padding: 16px 14px 24px; }
  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .card-header {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }
  .card-header > div {
    width: 100%;
    flex-wrap: wrap;
  }
  .user-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .user-tab { white-space: nowrap; }
  .access-grid,
  .conn-grid { grid-template-columns: 1fr; }
  .activity-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .gw-process summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* Tables on mobile — stack key columns, hide secondary */
  td, th { padding: 8px 10px; }
  .table-wrap table { font-size: .8rem; }

  /* Toast — top center on mobile instead of bottom-right */
  #toasts {
    bottom: auto;
    top: 16px;
    right: 12px;
    left: 12px;
    align-items: center;
  }
  .toast { min-width: 0; width: 100%; max-width: 100%; text-align: center; }

  /* Governor scope input area */
  #gov-scope-display + div,
  .card-body > div[style*="display:flex"][style*="gap:8px"] {
    flex-wrap: wrap;
  }
  #gov-scope-input { min-width: 100% !important; }

  /* Stats grid — force single column with reasonable min height */
  .stat-value { font-size: 1.5rem; }
  .stat-card { padding: 14px 16px; }

  /* Topbar actions wrap cleanly */
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .topbar-heading { flex: 1; }

}

/* ── EOS Prompts editor ───────────────────────────────────────────────────── */
.prompt-path { overflow: hidden; text-overflow: ellipsis; max-width: 420px; display: block; }
.prompt-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 600px;
  border-top: 1px solid var(--border);
}
.prompt-pane { display: flex; flex-direction: column; }
.prompt-pane-editor { border-right: 1px solid var(--border); }
.prompt-pane-preview { overflow: hidden; }
.prompt-pane-label {
  padding: 6px 14px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.prompt-editor-ta {
  flex: 1;
  width: 100%;
  min-height: 560px;
  background: var(--surface);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: .80rem;
  line-height: 1.65;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  word-wrap: off;
  white-space: pre;
}
.prompt-preview-body {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  font-size: .84rem;
  line-height: 1.7;
}
/* On mobile: stack vertically, hide preview by default, toggle shows it */
@media (max-width: 768px) {
  .prompt-path { max-width: 100%; }
  .prompt-preview-toggle { display: inline-flex; }
  .prompt-panes {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .prompt-pane-editor { border-right: none; border-bottom: 1px solid var(--border); }
  .prompt-editor-ta { min-height: 60vmax; }
  /* When preview is toggled on, hide editor and show preview */
  .prompt-panes.preview-active .prompt-pane-editor { display: none; }
  .prompt-panes:not(.preview-active) .prompt-pane-preview { display: none; }
}
@media (min-width: 769px) {
  /* Always show both panes on desktop; hide the toggle button */
  .prompt-preview-toggle { display: none; }
  .prompt-panes.preview-active .prompt-pane-editor { display: flex; }
  .prompt-panes:not(.preview-active) .prompt-pane-preview { display: flex; }
}

/* ── EOS two-level nav ────────────────────────────────────────────────────── */
.eos-nav { margin-bottom: 20px; }
.eos-main-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.eos-main-tabs::-webkit-scrollbar { display: none; }
.eos-main-tab { flex-shrink: 0; }
.eos-main-tab {
  padding: 6px 18px 9px;
  font-size: .875rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s;
}
.eos-main-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.eos-main-tab:hover:not(.active) { color: var(--text); }
.eos-sub-tabs-wrap {
  position: relative;
}
.eos-sub-tabs-wrap::after {
  content: "";
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
}
.eos-sub-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.eos-sub-tabs::-webkit-scrollbar { display: none; }
.eos-sub-tabs .btn { flex-shrink: 0; }

/* ── EOS card-table: tables flip to stacked cards on mobile ──────────────── */
@media (max-width: 768px) {
  .eos-ct table,
  .eos-ct thead,
  .eos-ct tbody { display: block; }
  .eos-ct thead { display: none; }

  .eos-ct tbody tr {
    display: flex;
    flex-direction: column;
    margin: 0 12px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
  }

  .eos-ct tbody tr.eos-detail-row {
    margin-top: -10px;
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    background: var(--surface-2);
    cursor: default;
  }

  .eos-ct td {
    display: block;
    padding: 7px 12px 7px 108px;
    border-bottom: 1px solid var(--border-2);
    min-height: 34px;
    font-size: .8rem;
    position: relative;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
  }
  .eos-ct td:last-child { border-bottom: none; }

  .eos-ct td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .63rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    width: 88px;
    line-height: 1.3;
  }

  .eos-ct td[data-primary] {
    order: -1;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .88rem;
    min-height: auto;
  }
  .eos-ct td[data-primary]::before { display: none; }

  .eos-ct td[colspan] {
    padding: 12px 14px;
    width: 100% !important;
    background: var(--surface-2);
  }
  .eos-ct td[colspan]::before { display: none; }

  .eos-ct td[data-label="Level"] { min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
  .eos-ct td[data-label="Level"]::before { top: 12px; transform: none; }

  /* two-column grids in Effectiveness and Goals forms → single column */
  .eos-2col { grid-template-columns: 1fr !important; }
}

/* ── Calendar ─────────────────────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-header-cell {
  background: var(--surface-2);
  padding: 8px 4px;
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.cal-cell {
  background: var(--bg);
  height: 100px;
  overflow: hidden;
  padding: 4px;
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.today { background: color-mix(in srgb, var(--primary) 8%, var(--bg)); }
.cal-cell.today .cal-day-num { color: var(--primary); font-weight: 700; }
.cal-cell.selected { background: color-mix(in srgb, var(--primary) 15%, var(--bg)); outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-cell.selected .cal-day-num { color: var(--primary); font-weight: 700; }
.cal-cell.other-month .cal-day-num { color: var(--text-dim); }
.cal-cell.other-month { background: var(--surface-2); opacity: .6; }
.cal-day-num { font-size: .78rem; color: var(--text-muted); margin-bottom: 3px; }
.cal-event-chip {
  display: block;
  font-size: .67rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  line-height: 1.5;
}
.cal-event-chip.type-meeting   { background: rgba(59,130,246,.18); color: var(--primary); }
.cal-event-chip.type-deadline  { background: rgba(239,68,68,.18);  color: var(--danger); font-weight:600; }
.cal-event-chip.type-task      { background: rgba(245,158,11,.18); color: var(--warning); }
.cal-event-chip.type-event     { background: rgba(34,197,94,.18);  color: var(--success); }
.cal-event-chip.source-eos     { border-left: 2px solid var(--primary); }
.cal-event-chip.source-transcription { border-left: 2px solid var(--warning); }
.cal-more { font-size: .65rem; color: var(--text-dim); padding: 1px 4px; }
.cal-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.cal-nav-title { font-size:1.1rem; font-weight:600; }
.cal-form-row { display:flex; gap:12px; }
.cal-form-row .field { flex:1; min-width:0; }

@media (max-width: 768px) {
  .cal-cell { height: 80px; padding: 3px; }
  .cal-event-chip { font-size: .6rem; padding: 1px 3px; }
  .cal-header-cell { padding: 6px 2px; font-size: .65rem; }
  .cal-day-num { font-size: .75rem; }
  .cal-nav-title { font-size: .95rem; }
}

@media (max-width: 480px) {
  /* stretch grid edge-to-edge */
  #cal-grid-wrap { margin: 0 -14px; }
  .cal-grid { border-radius: 0; border-left: none; border-right: none; gap: 0; }
  .cal-cell {
    min-height: 0;
    aspect-ratio: 1;
    padding: 4px 2px 2px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .cal-cell:nth-child(7n) { border-right: none; }
  /* single-letter day headers */
  .cal-header-cell { font-size: 0; padding: 6px 0; }
  .cal-header-cell::before { content: attr(data-short); font-size: .65rem; font-weight: 600; }
  /* day number centered */
  .cal-day-num { font-size: .8rem; margin-bottom: 2px; }
  /* hide text chips, show dot instead */
  .cal-event-chip { display: none; }
  .cal-cell.has-events .cal-day-num { position: relative; }
  .cal-cell.has-events .cal-day-num::after {
    content: "";
    display: block;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--primary);
    margin: 2px auto 0;
  }
  .cal-more { display: none; }
  /* upcoming list tighter */
  #cal-upcoming { margin-top: 16px; }
  /* stack form rows vertically in modals */
  .cal-form-row { flex-direction: column; gap: 0; }
}

/* ── FAB ──────────────────────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,.45);
  z-index: 90;
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
  .fab { display: flex; }
  .cal-add-desktop { display: none; }
}

/* ── Calendar sync menu item ──────────────────────────────────────────────── */
.sync-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  text-align: left;
  font-size: .83rem;
  color: var(--text);
  cursor: pointer;
}
.sync-menu-item:hover { background: var(--surface-3); }

/* ── Contacts ──────────────────────────────────────────────────────────────── */
.contacts-shell {
  display: flex;
  gap: 0;
  height: calc(100vh - 108px);
  overflow: hidden;
  margin: -24px -28px;
}
.contacts-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.contacts-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.contacts-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .85rem;
}
.contacts-list { flex: 1; overflow-y: auto; }
.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.contact-row:hover, .contact-row.active { background: var(--surface-2); }
.contact-row.active { border-left: 3px solid var(--primary); }
.contact-row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.contact-row-info { min-width: 0; }
.contact-row-name { font-size: .87rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-row-sub { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contacts-main { flex: 1; overflow-y: auto; padding: 24px; }
.contacts-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--text-muted); }

/* Contact detail */
.contact-detail { max-width: 680px; }
.contact-detail-back { display: none; margin-bottom: 12px; }
.contact-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.contact-detail-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.contact-detail-info { flex: 1; min-width: 0; }
.contact-detail-name { font-size: 1.15rem; font-weight: 600; margin-bottom: 3px; }
.contact-detail-role { font-size: .83rem; color: var(--text-muted); }
.contact-detail-actions { display: flex; gap: 4px; flex-shrink: 0; }
.contact-detail-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.contact-field-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .83rem;
  color: var(--primary);
  text-decoration: none;
}
.contact-field-link:hover { text-decoration: underline; }
.contact-detail-notes {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: .84rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Interaction timeline */
.interaction-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.interaction-type {
  flex-shrink: 0;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 4px;
  height: fit-content;
  margin-top: 2px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.interaction-type.type-email    { background: rgba(59,130,246,.15); color: var(--primary); }
.interaction-type.type-call     { background: rgba(34,197,94,.15);  color: var(--success); }
.interaction-type.type-meeting  { background: rgba(99,102,241,.15); color: #a5b4fc; }
.interaction-type.type-signal   { background: rgba(245,158,11,.15); color: var(--warning); }
.interaction-body { flex: 1; min-width: 0; }
.interaction-summary { font-size: .87rem; font-weight: 500; margin-bottom: 3px; }
.interaction-detail { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; white-space: pre-wrap; }
.interaction-meta { font-size: .72rem; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.btn-link-danger { background: none; border: none; cursor: pointer; color: var(--danger); font-size: .9rem; opacity: .5; padding: 0; line-height: 1; }
.btn-link-danger:hover { opacity: 1; }

/* Mobile contacts */
@media (max-width: 768px) {
  .contacts-shell { flex-direction: column; height: auto; min-height: calc(100dvh - 108px); margin: -16px -14px; }
  .contacts-sidebar { width: 100%; border-right: none; max-height: none; overflow: visible; }
  .contacts-list { overflow-y: visible; }
  .contacts-main { padding: 16px; overflow-y: visible; }
  .contact-detail-back { display: block; }
  .contacts-shell.detail-open .contacts-sidebar { display: none; }
  .contacts-shell:not(.detail-open) .contacts-main { display: none; }
  .contacts-add-desktop { display: none; }
}

/* ── Calendar modal form rows ────────────────────────────────────────────── */
.cal-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
@media (max-width: 480px) {
  .cal-form-row { grid-template-columns: 1fr; }
}

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat-shell {
  display: flex;
  flex-direction: row;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}
.chat-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}
.chat-sidebar-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 10px 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-sidebar-hd-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 4px;
}
.chat-conv-empty {
  padding: 20px 14px;
  font-size: .8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
  margin-bottom: 1px;
}
.chat-conv-item:hover { background: var(--surface-3); }
.chat-conv-item.active { background: var(--surface-3); }
.chat-conv-item.active .chat-conv-item-title { color: var(--primary); font-weight: 500; }
.chat-conv-item-body {
  flex: 1;
  min-width: 0;
}
.chat-conv-item-title {
  font-size: .82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.chat-conv-item-meta {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-menu-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .88rem;
  opacity: 0;
  transition: opacity .12s, background .12s;
  line-height: 1;
}
.chat-conv-menu-btn:hover { background: var(--border-2); color: var(--text); }
.chat-conv-item:hover .chat-conv-menu-btn,
.chat-conv-item.active .chat-conv-menu-btn { opacity: 1; }
.chat-sidebar-backdrop {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(0,0,0,.55);
}
.chat-sidebar-backdrop[hidden] { display: none; }
.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: auto;
}
.chat-convs-toggle { display: none; }
.chat-welcome {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 24px 0;
}
.chat-welcome-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.chat-welcome-icon .svg-icon { width: 24px; height: 24px; }
.chat-welcome-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.chat-welcome-sub { font-size: .84rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 20px; }
.chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chat-starter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: .8rem;
  cursor: pointer;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.chat-starter:hover { background: var(--surface-3); border-color: var(--primary); color: var(--primary); }
.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 85%;
  min-width: 0;
}
.chat-msg-user    { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-assistant { align-self: flex-start; }
.chat-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg-avatar .svg-icon { width: 14px; height: 14px; }
.chat-conv-menu-btn .svg-icon { width: 16px; height: 16px; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .875rem;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
}
.chat-bubble pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble img { max-width: 100%; height: auto; }
.chat-bubble table { max-width: 100%; display: block; overflow-x: auto; }
.chat-msg-user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg-assistant .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  white-space: pre-wrap;
}
.chat-msg-assistant .chat-bubble p   { margin: 0 0 8px; }
.chat-msg-assistant .chat-bubble p:last-child { margin-bottom: 0; }
.chat-msg-assistant .chat-bubble ul,
.chat-msg-assistant .chat-bubble ol  { padding-left: 20px; margin: 6px 0; }
.chat-msg-assistant .chat-bubble li  { margin-bottom: 3px; }
.chat-msg-assistant .chat-bubble code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: .82em; }
.chat-thinking { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.chat-thinking span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  opacity: .35;
  animation: chat-thinking-pulse 1.2s infinite ease-in-out;
}
.chat-thinking span:nth-child(2) { animation-delay: .15s; }
.chat-thinking span:nth-child(3) { animation-delay: .3s; }
.chat-tool-status { font-size: .72rem; color: var(--text-muted); opacity: .8; font-style: italic; }
.chat-tool-active { margin-top: 6px; }
.chat-cursor { opacity: .7; animation: chat-cursor-blink .8s step-end infinite; }
@keyframes chat-cursor-blink { 0%,100% { opacity: .7; } 50% { opacity: 0; } }
.chat-stopped-badge { font-size: .7rem; color: var(--text-muted); margin-top: 8px; }
.chat-bubble-stopped { opacity: .8; }
.chat-scroll-btn {
  position: absolute;
  bottom: 70px;
  right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  font-size: .9rem;
  line-height: 1;
  z-index: 2;
  transition: opacity .15s, background .12s;
}
.chat-scroll-btn:hover { background: var(--surface-2); }
.chat-scroll-btn[hidden] { display: none; }
@keyframes chat-thinking-pulse {
  0%, 80%, 100% { opacity: .25; transform: scale(.85); }
  40%           { opacity: 1;   transform: scale(1); }
}
.chat-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface-2);
}
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: .875rem;
  color: var(--text);
  resize: none;
  min-height: 40px;
  max-height: 160px;
  line-height: 1.5;
  overflow-y: auto;
  font-family: inherit;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-send-btn { flex-shrink: 0; height: 40px; padding: 0 14px; }

/* Chat view: flex-fill layout so the shell always fits the visible viewport
   exactly — no fragile calc(100vh - Npx) that breaks when the topbar wraps,
   the virtual keyboard appears, or browser chrome shifts on mobile. */
.view-chat .main { overflow: hidden; }
.view-chat .content {
  min-height: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.view-chat .chat-shell {
  flex: 1;
  min-height: 0;
  height: auto;
}
@media (max-width: 768px) {
  .view-chat .topbar { flex-wrap: nowrap; }
  .view-chat .topbar-actions { width: auto; }
  .view-chat .chat-shell {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .view-chat .chat-footer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  /* Sidebar: slide-in drawer on mobile */
  .chat-sidebar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    z-index: 5;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.45);
  }
  .chat-sidebar.open { transform: translateX(0); }
  .chat-conv-menu-btn { opacity: 1; }
  .chat-convs-toggle { display: inline-flex; }
}

/* ── Transcription ───────────────────────────────────────────────────────── */

.tx-shell { display: flex; flex-direction: column; gap: 20px; max-width: 1100px; }
.tx-model-sel-pill {
  padding: 5px 10px;
  font-size: .78rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
}

/* ── Recording Hero ── */
.tx-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px 24px 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.tx-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(99,102,241,.08) 0%, transparent 70%);
  pointer-events: none;
}

/* Orb + waveform wrapper */
.tx-orb-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tx-waveform {
  position: absolute;
  inset: -20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.tx-waveform.active { opacity: 1; }
.tx-wv-bar {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: rgba(239,68,68,.6);
  transform-origin: center;
}
.tx-waveform.active .tx-wv-bar { animation: tx-wv 1s ease-in-out infinite; }
.tx-wv-bar:nth-child(1)  { animation-delay: 0s;    }
.tx-wv-bar:nth-child(2)  { animation-delay: .08s;  }
.tx-wv-bar:nth-child(3)  { animation-delay: .16s;  }
.tx-wv-bar:nth-child(4)  { animation-delay: .24s;  }
.tx-wv-bar:nth-child(5)  { animation-delay: .32s;  }
.tx-wv-bar:nth-child(6)  { animation-delay: .40s;  }
.tx-wv-bar:nth-child(7)  { animation-delay: .32s;  }
.tx-wv-bar:nth-child(8)  { animation-delay: .24s;  }
.tx-wv-bar:nth-child(9)  { animation-delay: .16s;  }
.tx-wv-bar:nth-child(10) { animation-delay: .08s;  }
@keyframes tx-wv {
  0%, 100% { transform: scaleY(1);   }
  50%       { transform: scaleY(4.5); }
}

/* The big mic orb */
.tx-orb {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,.35);
  background: linear-gradient(145deg, var(--primary), #7c3aed);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--primary-glow), 0 0 0 0 rgba(99,102,241,.3);
  transition: transform .15s, box-shadow .15s, background .2s, border-color .2s;
  position: relative;
  z-index: 1;
}
.tx-orb:hover { transform: scale(1.06); box-shadow: 0 6px 28px var(--primary-glow); }
.tx-orb .svg-icon { width: 26px; height: 26px; }
.tx-orb.recording {
  background: linear-gradient(145deg, #dc2626, #ef4444);
  border-color: rgba(239,68,68,.5);
  box-shadow: 0 4px 20px rgba(239,68,68,.45);
  animation: tx-orb-pulse 1.8s ease-in-out infinite;
}
@keyframes tx-orb-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(239,68,68,.4), 0 0 0 0 rgba(239,68,68,.2); }
  50%       { box-shadow: 0 4px 20px rgba(239,68,68,.5), 0 0 0 14px rgba(239,68,68,0); }
}

/* Label + timer below the orb */
.tx-orb-meta { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tx-orb-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .02em;
  transition: color .2s;
}
.tx-orb-label.recording { color: var(--danger); }
.tx-timer {
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
  font-weight: 700;
  color: var(--danger);
  letter-spacing: .05em;
  min-height: 1.2em;
}

/* Live transcript card inside the hero */
.tx-transcript-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.tx-tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tx-tc-title { font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.tx-tc-actions { display: flex; gap: 8px; align-items: center; }
.tx-live-text {
  display: block;
  width: 100%;
  min-height: 140px;
  max-height: 320px;
  padding: 16px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  line-height: 1.75;
  resize: vertical;
  overflow-y: auto;
  word-break: break-word;
  outline: none;
  box-sizing: border-box;
}
.tx-live-text::placeholder { color: var(--text-muted); font-style: italic; }

/* ── Extracted Tasks ── */
.tx-tasks-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  overflow: hidden;
}
.tx-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.tx-section-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.tx-task-count {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 10px;
}
.tx-task-list { padding: 8px 0; }
.tx-task-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.tx-task-card:last-child { border-bottom: none; }
.tx-task-card:hover { background: var(--surface-3); }
.tx-task-card input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 15px; height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}
.tx-task-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .75rem;
}
.tx-task-icon.type-task     { background: rgba(99,102,241,.15); color: var(--primary); }
.tx-task-icon.type-deadline { background: rgba(239,68,68,.15);  color: var(--danger);  }
.tx-task-icon.type-meeting  { background: rgba(34,197,94,.15);  color: var(--success); }
.tx-task-icon.type-event    { background: rgba(245,158,11,.15); color: var(--warning); }
.tx-task-body { flex: 1; min-width: 0; }
.tx-task-title { font-size: .875rem; font-weight: 500; color: var(--text); line-height: 1.4; }
.tx-task-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.tx-chip {
  font-size: .68rem;
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tx-chip.due { background: rgba(245,158,11,.1); color: var(--warning); border-color: rgba(245,158,11,.2); }

/* Destination bar */
.tx-dest-bar {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.tx-dest-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; padding-top: 6px; white-space: nowrap; }
.tx-dest-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.tx-dest-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.tx-dest-pill input[type="checkbox"] { display: none; }
.tx-dest-pill.active {
  border-color: var(--primary);
  background: rgba(99,102,241,.1);
  color: var(--primary);
}
.tx-dest-pill.trello.active {
  border-color: #0052cc;
  background: rgba(0,82,204,.1);
  color: #4c9aff;
}
.tx-dest-pill .svg-icon { width: 13px; height: 13px; }
.tx-trello-selectors {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 2px;
}
.tx-trello-sel {
  padding: 5px 10px;
  font-size: .78rem;
  border-radius: 8px;
  border: 1.5px solid rgba(0,82,204,.4);
  background: rgba(0,82,204,.06);
  color: var(--text);
  cursor: pointer;
  min-width: 150px;
}

/* Push bar */
.tx-push-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ── History Timeline ── */
.tx-history-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  overflow: hidden;
}
.tx-timeline { padding: 8px 0 4px; }
.tx-timeline-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

/* Date group separator */
.tx-date-group {
  padding: 12px 20px 6px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

/* Individual timeline entry */
.tx-tl-entry {
  display: flex;
  align-items: stretch;
  padding: 0 20px 0 16px;
  position: relative;
}
.tx-tl-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  flex-shrink: 0;
  padding-top: 18px;
}
.tx-tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-3);
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}
.tx-tl-dot.approved { background: var(--success); border-color: var(--success); }
.tx-tl-dot.pending  { background: var(--primary);  border-color: var(--primary);  }
.tx-tl-line {
  width: 1px;
  flex: 1;
  background: var(--border);
  margin-top: 4px;
  min-height: 20px;
}
.tx-tl-entry:last-child .tx-tl-line { display: none; }
.tx-tl-content { flex: 1; min-width: 0; padding: 10px 0 10px 12px; }

/* The card inside each timeline entry */
.tx-tl-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s;
}
.tx-tl-card:hover { border-color: rgba(99,102,241,.3); }
.tx-tl-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.tx-tl-time {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.tx-tl-time span { color: var(--text-muted); font-weight: 400; }
.tx-badge {
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tx-badge.approved { background: rgba(34,197,94,.15);  color: var(--success); }
.tx-badge.pending  { background: rgba(99,102,241,.12); color: var(--primary);  }
.tx-item-pill {
  font-size: .68rem;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(34,197,94,.1);
  color: var(--success);
  font-weight: 500;
  white-space: nowrap;
}
.tx-trello-pill {
  font-size: .68rem;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(0,82,204,.12);
  color: #4c9aff;
  font-weight: 500;
  white-space: nowrap;
}
.tx-tl-acts { display: flex; gap: 4px; margin-left: auto; }
.tx-tl-acts button {
  padding: 3px 8px;
  font-size: .72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
}
.tx-tl-acts button:hover { background: var(--surface-3); color: var(--text); border-color: rgba(99,102,241,.3); }
.tx-tl-acts button.primary-act { background: rgba(99,102,241,.12); color: var(--primary); border-color: rgba(99,102,241,.3); }

.tx-tl-summary {
  padding: 0 14px 10px;
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.tx-tl-preview {
  padding: 0 14px 10px;
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Expanded session detail panel */
.tx-session-detail {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.tx-detail-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.tx-detail-section:last-child { border-bottom: none; }
.tx-detail-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.tx-detail-transcript {
  font-size: .82rem;
  color: var(--text);
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.tx-detail-tasks { display: flex; flex-direction: column; gap: 6px; }
.tx-detail-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.tx-detail-task-row .tx-task-icon { width: 22px; height: 22px; border-radius: 6px; font-size: .65rem; }
.tx-detail-items { display: flex; flex-direction: column; gap: 6px; }
.tx-detail-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.tx-detail-item-row a { color: #4c9aff; text-decoration: none; font-size: .72rem; }
.tx-detail-item-row a:hover { text-decoration: underline; }
.tx-detail-reopen {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 768px) {
  .tx-hero { padding: 28px 16px 24px; }
  .tx-orb { width: 60px; height: 60px; }
  .tx-orb .svg-icon { width: 22px; height: 22px; }
  .tx-dest-bar { flex-direction: column; gap: 10px; }
  .tx-trello-selectors { flex-direction: column; gap: 6px; }
  .tx-trello-sel { min-width: unset; width: 100%; }
  .tx-tl-entry { padding: 0 12px 0 10px; }
}

/* ── Timesheet ───────────────────────────────────────────────────────────── */
.ts-shell { max-width: 1100px; }
.ts-saved-panel { align-self: flex-start; position: sticky; top: 16px; }
.ts-saved-item {
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.ts-saved-item:last-child { border-bottom: none; }
.ts-saved-item:hover { background: var(--surface-2); }
.ts-saved-item.ts-saved-active { background: var(--primary-glow); border-left: 2px solid var(--primary); }
.ts-saved-label {
  font-size: .82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.ts-saved-dates {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.ts-section { margin-bottom: 20px; }
.ts-section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.ts-section-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: .72rem;
}
.ts-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.ts-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ts-dr-picker {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  user-select: none;
}
.ts-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ts-cal-month { font-weight: 600; font-size: .9rem; }
.ts-cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: .8rem;
  line-height: 1;
  transition: background .12s, color .12s;
}
.ts-cal-nav:hover { background: var(--surface-3); color: var(--text); }
.ts-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.ts-cal-dow {
  text-align: center;
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0 6px;
}
.ts-cal-day {
  text-align: center;
  font-size: .8rem;
  padding: 7px 2px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s;
}
.ts-cal-day:hover { background: var(--surface-3); }
.ts-cal-day.ts-cal-start,
.ts-cal-day.ts-cal-end {
  background: var(--primary);
  color: #fff;
}
.ts-cal-day.ts-cal-start       { border-radius: 4px 0 0 4px; }
.ts-cal-day.ts-cal-end         { border-radius: 0 4px 4px 0; }
.ts-cal-day.ts-cal-start.ts-cal-end { border-radius: 4px; }
.ts-cal-day.ts-cal-in-range    { background: var(--primary-glow); border-radius: 0; }
.ts-dr-label {
  margin-top: 8px;
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2em;
}
.ts-tab-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.ts-tab {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 14px;
  font-size: .78rem;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}
.ts-tab:hover { background: var(--surface-2); color: var(--text); }
.ts-tab.active { background: var(--primary); color: #fff; }
.ts-prompt-editor {
  width: 100%;
  resize: vertical;
  font-size: .84rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  min-height: 96px;
}
.ts-prompt-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: .84rem;
  min-height: 80px;
  line-height: 1.65;
}
.ts-hidden { display: none !important; }
.ts-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 700px) {
  .ts-shell > div { flex-direction: column !important; }
  .ts-saved-panel {
    position: static !important;
    min-width: 0 !important;
    max-width: none !important;
    width: 100%;
  }
  #ts-saved-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px !important; }
  .ts-saved-item {
    flex: 1 1 160px;
    border-bottom: none !important;
    border: 1px solid var(--border);
    border-radius: 6px;
  }
  .ts-saved-item.ts-saved-active { border-left-width: 2px; }
}

@media (max-width: 480px) {
  .card-header { flex-wrap: wrap; gap: 6px; }
  .card-header > div[style*="display:flex"] { flex-wrap: wrap; }
  #ts-output-card .card-header > div { flex-wrap: wrap; row-gap: 4px; }
}

/* ── Kanban ─────────────────────────────────────────────────────────────── */
.kanban-shell { display: flex; gap: 16px; height: calc(100vh - 180px); min-height: 480px; }
.kanban-sidebar {
  width: 200px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.kanban-sidebar-hd {
  font-size: .65rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 8px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
}
.kanban-board-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; border-radius: 6px;
  padding: 7px 10px; cursor: pointer; color: var(--text); font-size: .82rem;
  text-align: left; transition: background .12s;
}
.kanban-board-btn:hover { background: var(--surface-2); }
.kanban-board-btn.active { background: var(--surface-3); }
.kanban-board-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-board-name { flex: 1; }
.kanban-board-count {
  font-size: .7rem; color: var(--text-muted);
  background: var(--surface-2); padding: 1px 7px; border-radius: 10px;
}
.kanban-board-btn.active .kanban-board-count { background: var(--bg); color: var(--text); }

.kanban-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; overflow: hidden;
}
.kanban-board-header { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.kanban-board-dot-lg { width: 14px; height: 14px; border-radius: 50%; }

.kanban-columns {
  display: flex; gap: 10px; flex: 1; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.kanban-column {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  max-height: 100%;
  scroll-snap-align: start;
}
.kanban-column.collapsed .kanban-column-cards { display: none; }
.kanban-column-hd { cursor: pointer; user-select: none; }
.kanban-column-hd:hover { background: var(--surface-2); }
.kanban-collapse-icon { font-size: .7rem; color: var(--text-dim); }
.kanban-column-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.kanban-column-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-column-name {
  flex: 1; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text);
}
.kanban-column-count {
  font-size: .7rem; color: var(--text-muted);
  background: var(--surface-2); padding: 1px 7px; border-radius: 10px;
}
.kanban-add-btn {
  background: transparent; border: 0; padding: 2px 4px; cursor: pointer;
  color: var(--text-muted); border-radius: 4px;
}
.kanban-add-btn:hover { background: var(--surface-3); color: var(--text); }
.kanban-add-btn .svg-icon { width: 14px; height: 14px; }

.kanban-column-cards {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 40px;
}
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 14px; cursor: grab; transition: border-color .12s, transform .08s;
  overflow: hidden; flex-shrink: 0; position: relative;
}
.kanban-card-selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: rgba(99,102,241,.06);
}
.kanban-card-chk {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff;
  transition: background .1s, border-color .1s;
}
.kanban-card-chk.checked { background: var(--primary); border-color: var(--primary); }
.kanban-card-chk.checked::after { content: "✓"; }
.kanban-bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--surface-1); border: 2px solid var(--primary);
  border-radius: 8px;
  position: sticky; top: 0; z-index: 10;
}
.kanban-card.has-cover { padding-top: 0; }
.kanban-card-cover {
  display: block; width: calc(100% + 28px); margin: 0 -14px 10px; height: 120px;
  object-fit: cover; border-radius: 6px 6px 0 0;
}
.kanban-card:hover { border-color: var(--primary); }
.kanban-card:active { cursor: grabbing; }
.kanban-img-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 12px;
}
.kanban-img-thumb {
  position: relative; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; transition: border-color .12s;
}
.kanban-img-thumb:hover { border-color: var(--primary); }
.kanban-img-thumb.is-cover { border-color: var(--primary); }
.kanban-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kanban-img-thumb-actions {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .15s;
}
.kanban-img-thumb:hover .kanban-img-thumb-actions { opacity: 1; }
.kanban-img-thumb-actions button {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); border-radius: 4px;
  color: #fff; font-size: .7rem; padding: 3px 6px; cursor: pointer; white-space: nowrap;
}
.kanban-img-thumb-actions button:hover { background: rgba(255,255,255,.25); }
.kanban-img-drop-zone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 20px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  font-size: .82rem; color: var(--text-muted); margin-top: 12px;
}
.kanban-img-drop-zone.drag-over { border-color: var(--primary); background: rgba(99,102,241,.06); color: var(--primary); }
.kanban-img-drop-zone input[type=file] { display: none; }
.kanban-card-title {
  font-size: .85rem; font-weight: 500; color: var(--text); line-height: 1.35;
  word-break: break-word;
}
.kanban-card-stakeholder {
  font-size: .72rem; color: var(--text-muted); margin-top: 3px;
}
.kanban-card-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.kanban-card-ghost { opacity: .4; }
.kanban-card-drag { transform: rotate(2deg); box-shadow: var(--shadow); }

@media (max-width: 768px) {
  .kanban-shell { flex-direction: column; height: auto; min-height: 0; }
  .kanban-sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    flex-shrink: 0; max-height: 56px;
  }
  .kanban-sidebar-hd { display: none; }
  .kanban-board-btn { white-space: nowrap; flex-shrink: 0; }
  .kanban-main { padding: 10px; }
  .kanban-board-header { flex-wrap: wrap; }
  /* Columns stack vertically on mobile, each full-width and collapsible */
  .kanban-columns {
    flex-direction: column; overflow-x: hidden; overflow-y: visible;
    gap: 8px;
  }
  .kanban-column { width: 100%; max-height: none; }
  .kanban-column-cards { max-height: 50vh; touch-action: pan-y; }
  .kanban-main { overflow-y: auto; }
  /* Stacked columns start collapsed if empty or non-priority */
  .kanban-filter-bar input { width: 100%; }
  .kanban-filter-bar select { flex: 1 1 auto; min-width: 0; }
}

/* Kanban filter bar */
.kanban-filter-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 8px;
}
.kanban-filter-bar input,
.kanban-filter-bar select {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 0 10px; border-radius: 6px;
  font-size: .78rem; height: 30px; line-height: 30px;
  appearance: none; -webkit-appearance: none;
}
.kanban-filter-bar select { padding-right: 26px; cursor: pointer; min-width: 110px; max-width: 200px; }
.kanban-filter-bar select:hover { border-color: var(--border-2); }
.kanban-filter-bar input:focus,
.kanban-filter-bar select:focus { outline: 0; border-color: var(--primary); }
.kanban-filter-search { position: relative; display: flex; align-items: center; }
.kanban-filter-search-icon {
  position: absolute; left: 9px; color: var(--text-dim);
  display: flex; pointer-events: none;
}
.kanban-filter-search-icon .svg-icon { width: 14px; height: 14px; }
.kanban-filter-search input { width: 200px; padding-left: 30px; }
.kanban-filter-clear { color: var(--text-muted); }
.kanban-filter-clear:hover { color: var(--danger); }
.kanban-filter-clear .svg-icon { width: 12px; height: 12px; margin-right: 4px; }
@media (max-width: 768px) {
  .kanban-filter-bar { padding: 8px; gap: 6px; width: 100%; }
  .kanban-filter-search { width: 100%; }
  .kanban-filter-search input { width: 100%; }
  .kanban-filter-bar select { flex: 1 1 calc(50% - 4px); max-width: none; }
}

.kanban-card-age {
  font-size: .68rem; font-weight: 500;
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border);
  margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RLM — Real Estate / Legal / Mortgage
   ═══════════════════════════════════════════════════════════════════════════ */

/* Stats row — horizontal flex of stat-cards */
.stats-row {
  display: flex; gap: 12px; margin-bottom: 16px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.stats-row .stat-card { flex: 1 1 120px; min-width: 90px; }

/* 2-col responsive grid */
.rlm-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

/* Detail header — back / title / action; wraps instead of overflowing on mobile */
.rlm-detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.rlm-detail-head h3 { margin: 0; flex: 1; min-width: 140px; font-size: 1.05rem; }

/* Section header — title + "+ Add" button, consistent across Parties/Tasks/Docs */
.rlm-section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 8px; flex-wrap: wrap; }
.rlm-section-head h3, .rlm-section-head h4 { margin: 0; }

/* Tables inside RLM cards scroll horizontally on narrow screens instead of breaking layout */
.rlm-table-card { overflow-x: auto; }
.rlm-table-card table { min-width: 420px; }

/* Phase tracker */
.rlm-phase-track {
  display: flex; align-items: center;
  margin-bottom: 16px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 6px;
  scrollbar-width: none;
}
.rlm-phase-track::-webkit-scrollbar { display: none; }

.rlm-phase-step {
  flex: 1 0 auto; min-width: 80px;
  text-align: center; font-size: .72rem; font-weight: 500;
  padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.rlm-phase-step.done {
  background: rgba(34,197,94,.1); color: var(--success);
  border-color: rgba(34,197,94,.25);
}
.rlm-phase-step.active {
  background: rgba(99,102,241,.15); color: var(--primary);
  border-color: rgba(99,102,241,.4); font-weight: 600;
}
.rlm-phase-arrow {
  color: var(--text-dim); font-size: .85rem; padding: 0 3px;
  flex-shrink: 0; user-select: none;
}

/* Escalation list */
.rlm-esc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.rlm-escalation-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: 8px; padding: 14px 16px;
}
.rlm-esc-title { font-weight: 600; font-size: .9rem; }
.rlm-esc-reason { color: var(--text-muted); font-size: .82rem; margin-top: 4px; }

/* Reliability mini-bar */
.mini-bar {
  width: 56px; height: 6px;
  background: var(--surface-3); border-radius: 3px; overflow: hidden;
}

/* Banners */
.banner {
  border-radius: 8px; padding: 10px 14px; font-size: .85rem;
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.banner-success { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.2); }
.banner-warn    { background: rgba(245,158,11,.12); color: #fcd34d; border: 1px solid rgba(245,158,11,.2); }

/* Compact table */
.table-sm td, .table-sm th { padding: 7px 12px; }

/* Extra-small button */
.btn-xs { font-size: .72rem; padding: 3px 8px; height: 24px; line-height: 1; }

/* ── RLM forms ───────────────────────────────────────────────────────────── */
/* Two-column field layout for related inputs (collapses on mobile) */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field-row .field { min-width: 0; }

/* Required marker + optional/help hint on field labels */
.field label .req  { color: var(--danger); margin-left: 2px; }
.field label .hint { color: var(--text-dim); font-weight: 400; letter-spacing: 0; text-transform: none; }
.field-help { font-size: .75rem; color: var(--text-dim); margin-top: 6px; line-height: 1.4; }

/* Chip-style multi-select (operator roles) */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip-check { position: relative; cursor: pointer; user-select: none; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  font-size: .8rem; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.chip-check:hover span { border-color: var(--primary); color: var(--text); }
.chip-check input:checked + span {
  background: var(--primary-glow); color: var(--primary);
  border-color: var(--primary); font-weight: 500;
}
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-glow); }

/* ── Entity email-domain chips ────────────────────────────────────────────── */
.eos-domain-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  background: var(--surface-3);
  color: var(--text);
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.eos-domain-chip button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 6px;
  border-radius: 50%;
}
.eos-domain-chip button:hover { color: var(--danger); background: var(--surface); }

/* ── RLM Parties (card list — replaces the old table) ─────────────────────── */
.rlm-parties-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.rlm-party-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rlm-party-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rlm-party-name { font-weight: 600; font-size: .9rem; flex: 1; min-width: 0; word-break: break-word; }
.rlm-party-role { font-size: .65rem; background: var(--surface-3); color: var(--text-muted); flex-shrink: 0; }
.rlm-party-contact { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; }
.rlm-party-email,
.rlm-party-phone { color: var(--primary); text-decoration: none; word-break: break-all; }
.rlm-party-email:hover,
.rlm-party-phone:hover { text-decoration: underline; }
.rlm-party-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; color: var(--text-muted);
  padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 2px;
}
.rlm-party-rel-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.rlm-party-rel-bar { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.rlm-party-rel-bar > div { height: 100%; border-radius: 2px; }
.rlm-party-rel-pct { font-weight: 600; min-width: 32px; text-align: right; }

/* ── Sources hub (central tab — sources × projects matrix) ──────────────── */
.rlm-hub-source {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.rlm-hub-source:last-child { border-bottom: none; }
.rlm-hub-source.rlm-hub-orphan { opacity: .7; }
.rlm-hub-source-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rlm-hub-source-label { font-weight: 500; font-size: .9rem; }
.rlm-hub-source-url   { font-size: .72rem; color: var(--primary); word-break: break-all; }
.rlm-hub-source-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rlm-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  background: var(--surface-3);
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.rlm-attach-chip button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .95rem;
  line-height: 1;
  padding: 0 5px;
  border-radius: 50%;
}
.rlm-attach-chip button:hover { color: var(--danger); background: var(--surface); }
.rlm-hub-attach-btn {
  font-size: .72rem;
  color: var(--primary);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.rlm-hub-attach-btn:hover { background: var(--surface-2); border-color: var(--primary); }

/* ── RLM Tasks (card list — replaces the old table) ───────────────────────── */
.rlm-tasks-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.rlm-task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rlm-task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rlm-task-verb { font-size: .65rem; background: var(--surface-3); }
.rlm-task-status { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-left: auto; }
.rlm-task-title { font-size: .88rem; font-weight: 500; word-break: break-word; line-height: 1.35; }
.rlm-task-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 2px;
}
.rlm-task-done { margin-left: auto; }

/* ── Project Sources (per-deal) ───────────────────────────────────────────── */
.rlm-sources-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.rlm-source-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.rlm-source-kind { flex-shrink: 0; }
.rlm-source-body { flex: 1; min-width: 0; }
.rlm-source-label { font-weight: 500; font-size: .85rem; word-break: break-word; }
.rlm-source-remove {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 1.1rem; cursor: pointer; padding: 4px 10px; flex-shrink: 0;
}
.rlm-source-remove:hover { color: var(--danger); }

/* ── RLM Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .rlm-grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .rlm-phase-step { padding: 5px 8px; font-size: .68rem; min-width: 64px; }
  .rlm-phase-arrow { padding: 0 1px; }

  /* RLM tables convert to card-stack layout via the shared .eos-ct rules
     above, so the table needs no min-width and shouldn't horizontal-scroll. */
  .rlm-table-card.eos-ct { overflow-x: visible; }
  .rlm-table-card.eos-ct table { min-width: 0; }

  /* Detail header: title goes full-width on its own line, in document order (after Back) */
  .rlm-detail-head h3 { font-size: 1rem; flex-basis: 100%; }

  .stats-row { flex-wrap: wrap; overflow-x: visible; }
  .stats-row .stat-card { flex: 1 1 calc(50% - 6px); min-width: 0; padding: 12px; }
  .stats-row .stat-value { font-size: 1.3rem; }

  /* Calendar: hide the description snippet on mobile — not enough room */
  .cal-upcoming-desc { display: none; }
}

/* ── Chat copy buttons ───────────────────────────────────────────────────── */
.chat-msg { position: relative; }
.chat-copy-btn {
  position: absolute;
  bottom: -6px; right: -6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  padding: 0;
  flex-shrink: 0;
}
.chat-msg-user .chat-copy-btn { right: auto; left: -6px; }
.chat-msg:hover .chat-copy-btn { opacity: 1; }
.chat-copy-btn .svg-icon { width: 12px; height: 12px; }
