/* BotVa Admin — Clean Modern Light Theme */

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

:root {
  --mc-bg: #f8f9fb;
  --mc-white: #ffffff;
  --mc-surface: #ffffff;
  --mc-surface2: #f3f4f6;
  --mc-border: #e5e7eb;
  --mc-border-hover: #d1d5db;
  --mc-text: #111827;
  --mc-text-secondary: #6b7280;
  --mc-text-dim: #9ca3af;
  --mc-accent: #16a34a;
  --mc-accent-light: #f0fdf4;
  --mc-accent-hover: #15803d;
  --mc-green: #10b981;
  --mc-green-light: #ecfdf5;
  --mc-red: #ef4444;
  --mc-red-light: #fef2f2;
  --mc-yellow: #f59e0b;
  --mc-yellow-light: #fffbeb;
  --mc-blue: #3b82f6;
  --mc-blue-light: #eff6ff;
  --mc-purple: #8b5cf6;
  --mc-purple-light: #f5f3ff;
  --mc-orange: #f97316;
  --mc-orange-light: #fff7ed;

  --bot-default: #3b82f6;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-sm: 6px;
}

/* === Base === */
html { background: transparent; }
body {
  background: var(--mc-bg);
  color: var(--mc-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--mc-accent); text-decoration: none; }
a:hover { color: var(--mc-accent-hover); }
strong { font-weight: 600; }
h2 { font-size: 1.35rem; font-weight: 700; color: var(--mc-text); margin-bottom: 1rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; color: var(--mc-text); margin-top: 1.75rem; margin-bottom: 0.6rem; }
h4 { font-size: 0.9rem; font-weight: 600; color: var(--mc-text); margin-top: 1.25rem; margin-bottom: 0.5rem; }
p { color: var(--mc-text-secondary); margin-bottom: 0.5rem; }
small { color: var(--mc-text-dim); font-size: 0.8rem; }
code {
  background: var(--mc-surface2);
  color: var(--mc-accent);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.82em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}
pre { background: var(--mc-surface2); border-radius: var(--radius-sm); padding: 0.75rem; font-size: 0.82rem; overflow-x: auto; }
hr { border: none; border-top: 1px solid var(--mc-border); margin: 1rem 0; }
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.2rem; color: var(--mc-text-secondary); }

/* === Mobile top bar (hidden on desktop) === */
.mobile-topbar {
  display: none;
  background: var(--mc-white);
  border-bottom: 1px solid var(--mc-border);
  padding: 0 0.75rem;
  align-items: center;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.mobile-topbar .logo {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--mc-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* === Sidebar overlay (mobile) === */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 149;
}
.sidebar-overlay.open { display: block; }

/* === App layout === */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* === Sidebar === */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--mc-white);
  border-right: 1px solid var(--mc-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}
.sidebar-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--mc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  min-height: 48px;
}
.sidebar-header .logo {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--mc-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
}
.logo .logo-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  background: var(--mc-accent);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  font-weight: 700;
}
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--mc-text-dim);
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--mc-text); background: var(--mc-surface2); }
.sidebar-toggle .icon-collapsed { display: none; }
.sidebar-collapsed .sidebar-toggle .icon-expanded { display: none; }
.sidebar-collapsed .sidebar-toggle .icon-collapsed { display: block; }

.sidebar .nav-links {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  flex: 1;
  gap: 1px;
}
.nav-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}
.sidebar .nav-links > a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  color: var(--mc-text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  position: relative;
}
.sidebar .nav-links > a > i { min-width: 16px; flex-shrink: 0; }
.sidebar .nav-links > a:hover {
  color: var(--mc-text);
  background: var(--mc-surface2);
}
.sidebar .nav-links > a.active {
  color: var(--mc-accent);
  background: var(--mc-accent-light);
  border-left-color: var(--mc-accent);
  font-weight: 600;
}

/* Sidebar footer (docs, lang, theme) */
.sidebar-footer {
  padding: 0.5rem 0;
  border-top: 1px solid var(--mc-border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  color: var(--mc-text-dim);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.12s, background 0.12s;
  border-left: 3px solid transparent;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-action > i { min-width: 16px; flex-shrink: 0; }
.sidebar-action:hover {
  color: var(--mc-text);
  background: var(--mc-surface2);
}

/* Content area */
.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* === Collapsed sidebar === */
.sidebar-collapsed .sidebar {
  width: 52px;
  min-width: 52px;
  overflow: visible;
}
.sidebar-collapsed .sidebar-header {
  padding: 0.85rem 0.5rem;
  justify-content: center;
}
.sidebar-collapsed .sidebar-header .logo .nav-label { display: none; }
.sidebar-collapsed .sidebar-toggle { display: none; }
/* Show toggle on hover of header */
.sidebar-collapsed .sidebar-header:hover .sidebar-toggle { display: flex; }
.sidebar-collapsed .sidebar-header:hover .logo { display: none; }

.sidebar-collapsed .sidebar .nav-links > a {
  padding: 0.55rem 0;
  justify-content: center;
  border-left-width: 3px;
}
.sidebar-collapsed .sidebar .nav-links > a .nav-label {
  position: absolute;
  left: 100%;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 0.85rem 0 0.6rem;
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  color: var(--mc-text-secondary);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 100;
}
.sidebar-collapsed .sidebar .nav-links > a:hover .nav-label {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.sidebar-collapsed .sidebar .nav-links > a.active:hover .nav-label {
  color: var(--mc-accent);
  background: var(--mc-accent-light);
}

/* Collapsed dropdown */
.sidebar-collapsed .nav-dropdown-toggle {
  padding: 0.55rem 0;
  justify-content: center;
}
.sidebar-collapsed .nav-dropdown-toggle .nav-label,
.sidebar-collapsed .nav-dropdown-toggle .nav-chevron { display: none; }
.sidebar-collapsed .nav-dropdown-menu {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 150px;
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: 0 6px 6px 0;
  box-shadow: var(--shadow-md);
  padding: 0.3rem;
  z-index: 100;
}

/* Collapsed footer actions */
.sidebar-collapsed .sidebar-footer { align-items: center; }
.sidebar-collapsed .sidebar-action {
  padding: 0.45rem 0;
  justify-content: center;
  width: 100%;
}
.sidebar-collapsed .sidebar-action .nav-label {
  position: absolute;
  left: 100%;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 0.85rem 0 0.6rem;
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  box-shadow: var(--shadow-md);
  font-size: 0.78rem;
  color: var(--mc-text-dim);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 100;
}
.sidebar-collapsed .sidebar-action:hover .nav-label {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Nav separator */
.nav-separator {
  padding: 0.6rem 1rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mc-text-dim);
  opacity: 0.7;
}
.sidebar-collapsed .nav-separator .nav-label { display: none; }
.sidebar-collapsed .nav-separator { padding: 0.4rem 0; border-bottom: 1px solid var(--mc-border); margin: 0 0.5rem; }

/* Nav dropdown (sidebar version) */
.nav-dropdown {
  display: flex;
  flex-direction: column;
  position: relative;
}
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--mc-text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  font-family: inherit;
  text-align: left;
  width: 100%;
}
.nav-dropdown-toggle > i { min-width: 16px; flex-shrink: 0; }
.nav-chevron { margin-left: auto; }
.nav-dropdown-toggle:hover { color: var(--mc-text); background: var(--mc-surface2); }
.nav-dropdown.active > .nav-dropdown-toggle {
  color: var(--mc-accent);
  border-left-color: var(--mc-accent);
}
.nav-dropdown-menu {
  display: none;
  padding: 0.15rem 0 0.15rem 0;
  background: var(--mc-surface2);
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem 0.35rem 2.2rem;
  color: var(--mc-text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.12s;
}
.nav-dropdown-divider {
  height: 1px;
  background: var(--mc-border);
  margin: 0.2rem 0.75rem;
}
.nav-dropdown-menu a:hover { background: var(--mc-white); color: var(--mc-text); }
.nav-dropdown-menu a.active { color: var(--mc-accent); background: var(--mc-accent-light); }

/* === Main content === */
.mc-main {
  max-width: 1100px;
  width: 100%;
  flex: 1;
  padding: 1.5rem;
}

/* === Page background icon (watermark) === */
.page-bg-icon {
  position: fixed;
  bottom: -80px;
  left: 120px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.04;
  color: var(--mc-text);
  transition: left 0.2s ease;
}
.sidebar-collapsed .page-bg-icon {
  left: -30px;
}
.page-bg-icon > i,
.page-bg-icon > svg {
  width: 520px !important;
  height: 520px !important;
  stroke-width: 0.5 !important;
}

/* === Cards === */
.card {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--mc-border-hover); }
.card header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0;
  background: none;
  border: none;
}
.card .card-stats {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--mc-text-secondary);
  margin-bottom: 0.65rem;
}
.card .card-stats .stat-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.card .card-stats .stat-row .icon { width: 16px; text-align: center; font-size: 0.75rem; opacity: 0.7; }
.card .card-stats .stat-value { color: var(--mc-text); font-weight: 600; }
.card .card-stats .stat-error { color: var(--mc-red); font-weight: 500; }

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-running { background: var(--mc-green-light); color: var(--mc-green); }
.badge-stopped { background: var(--mc-red-light); color: var(--mc-red); }
.badge-active { background: var(--mc-green-light); color: var(--mc-green); }
.badge-paused { background: var(--mc-yellow-light); color: var(--mc-yellow); }
/* Bot badges are generated dynamically */

/* Event type badges */
.badge-event {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'SF Mono', monospace;
}
.badge-event-tool_call { background: var(--mc-blue-light); color: var(--mc-blue); }
.badge-event-command { background: var(--mc-green-light); color: var(--mc-green); }
.badge-event-error { background: var(--mc-red-light); color: var(--mc-red); }
.badge-event-session_start { background: var(--mc-purple-light); color: var(--mc-purple); }
.badge-event-session_clear { background: var(--mc-orange-light); color: var(--mc-orange); }

/* API key badges */
.badge-set { background: var(--mc-green-light); color: var(--mc-green); }
.badge-missing { background: var(--mc-red-light); color: var(--mc-red); }
.badge-optional { background: var(--mc-surface2); color: var(--mc-text-dim); }

/* === Grids === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

/* === Stat cards === */
.stat-card {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 0.68rem;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.stat-card .stat-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--mc-text);
}

/* === Bot nav (sub-navigation) === */
.bot-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  padding: 0.2rem;
  background: var(--mc-surface2);
  border-radius: 8px;
}
.bot-nav::-webkit-scrollbar { display: none; }
.bot-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--mc-text-secondary);
  transition: all 0.12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.bot-nav a:hover { color: var(--mc-text); background: var(--mc-white); box-shadow: var(--shadow-sm); }
.bot-nav a.active,
.bot-nav a[aria-current="page"] {
  background: var(--mc-accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* === Buttons === */
button, [role="button"], input[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid var(--mc-border);
  background: var(--mc-white);
  color: var(--mc-text);
  font-family: inherit;
  line-height: 1.4;
}
button:hover, [role="button"]:hover { background: var(--mc-surface2); border-color: var(--mc-border-hover); }

button[type="submit"], button.primary {
  background: var(--mc-accent);
  border-color: var(--mc-accent);
  color: #fff;
}
button[type="submit"]:hover, button.primary:hover { background: var(--mc-accent-hover); border-color: var(--mc-accent-hover); }

button.outline { background: transparent; color: var(--mc-text); border-color: var(--mc-border); }
button.contrast.outline { color: var(--mc-yellow); border-color: #fcd34d; }
button.contrast.outline:hover { background: var(--mc-yellow-light); }
button.secondary.outline { color: var(--mc-red); border-color: #fca5a5; }
button.secondary.outline:hover { background: var(--mc-red-light); }
button.danger { color: var(--mc-red); border-color: #fca5a5; background: var(--mc-red-light); }
button.danger:hover { background: #fee2e2; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-group { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
thead th {
  background: var(--mc-surface2);
  color: var(--mc-text-dim);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--mc-border);
  text-align: left;
}
tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--mc-border);
  color: var(--mc-text-secondary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }

figure { margin: 0; overflow-x: auto; }

.table-wrap {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
}
.table-wrap table { margin: 0; }

/* === Forms === */
form { margin: 0; }
input, select, textarea {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 3px var(--mc-accent-light);
  outline: none;
}
label {
  display: block;
  color: var(--mc-text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}
label > input, label > select, label > textarea { margin-top: 0.2rem; }
label > small { display: block; margin-bottom: 0.2rem; color: var(--mc-text-dim); }

textarea.code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 2;
  background: #fafbfc;
}

input[type="range"] {
  -webkit-appearance: auto;
  accent-color: var(--mc-accent);
  padding: 0;
  border: none;
  background: transparent;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 1rem;
}
.filter-bar label { flex: 0 0 auto; margin: 0; }
.filter-bar .filter-search { flex: 1; min-width: 150px; }
.filter-bar button { align-self: end; white-space: nowrap; }
.filter-bar select, .filter-bar input { margin: 0; }

/* Fieldset */
fieldset {
  border: 1px solid var(--mc-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}
legend { padding: 0 0.4rem; font-size: 0.82rem; color: var(--mc-text-secondary); font-weight: 500; }

/* === Alerts === */
.alert {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}
.alert-success { background: var(--mc-green-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--mc-red-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--mc-yellow-light); color: #92400e; border: 1px solid #fde68a; }

/* === Log viewer === */
.log-viewer {
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--mc-border);
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* === Memory salience bar === */
.salience-bar {
  display: inline-block;
  height: 4px;
  border-radius: 2px;
  background: var(--mc-accent);
}

/* === Pagination === */
nav ul {
  display: flex;
  gap: 0.2rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
nav ul li a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--mc-text-secondary);
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  transition: all 0.12s;
}
nav ul li a:hover { background: var(--mc-surface2); color: var(--mc-text); }
nav ul li a[aria-current="page"] { background: var(--mc-accent); color: #fff; border-color: var(--mc-accent); }

/* === Section header === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.section-header h3 { margin: 0; }

/* === Detail cells === */
.detail-cell {
  max-width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  font-family: 'SF Mono', monospace;
  font-size: 0.78rem;
  color: var(--mc-text-secondary);
}
.ts-cell {
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--mc-text-dim);
  font-variant-numeric: tabular-nums;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--mc-text-dim);
}
.empty-state .empty-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.5; }

/* === Card links === */
.card-links {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.card-links a {
  font-size: 0.72rem;
  color: var(--mc-text-secondary);
  text-decoration: none;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--mc-surface2);
  transition: all 0.12s;
}
.card-links a:hover { color: var(--mc-text); background: #e5e7eb; }

/* === Footer === */
.mc-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--mc-text-dim);
  font-size: 0.72rem;
  margin-top: auto;
}

/* === htmx === */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* === Pico article overrides (for System page grid) === */
article {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0;
  margin: 0;
}
article > header {
  background: var(--mc-surface2);
  border-bottom: 1px solid var(--mc-border);
  padding: 0.6rem 0.85rem;
  color: var(--mc-text-dim);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius) var(--radius) 0 0;
}
article > p { padding: 0.85rem; margin: 0; }

/* === Dark theme === */
[data-theme="dark"] {
  --mc-bg: #111318;
  --mc-white: #1a1d24;
  --mc-surface: #1a1d24;
  --mc-surface2: #22262e;
  --mc-bg-dim: #22262e;
  --mc-border: #2e333d;
  --mc-border-hover: #3b4150;
  --mc-text: #e4e6eb;
  --mc-text-secondary: #9ca3b0;
  --mc-text-dim: #6b7280;
  --mc-accent: #4ade80;
  --mc-accent-light: rgba(74,222,128,0.12);
  --mc-accent-hover: #86efac;
  --mc-green: #34d399;
  --mc-green-light: rgba(52,211,153,0.12);
  --mc-red: #f87171;
  --mc-red-light: rgba(248,113,113,0.1);
  --mc-yellow: #fbbf24;
  --mc-yellow-light: rgba(251,191,36,0.1);
  --mc-blue: #60a5fa;
  --mc-blue-light: rgba(96,165,250,0.12);
  --mc-purple: #a78bfa;
  --mc-purple-light: rgba(167,139,250,0.12);
  --mc-orange: #fb923c;
  --mc-orange-light: rgba(251,146,60,0.1);

  --bot-default: #60a5fa;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
}
[data-theme="dark"] .page-bg-icon { opacity: 0.04; }
[data-theme="dark"] tbody tr:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .card-links a:hover { background: #2e333d; }
[data-theme="dark"] textarea.code { background: #111318; }
[data-theme="dark"] .alert-success { background: rgba(52,211,153,0.1); color: #6ee7b7; border-color: rgba(52,211,153,0.2); }
[data-theme="dark"] .alert-error { background: rgba(248,113,113,0.1); color: #fca5a5; border-color: rgba(248,113,113,0.2); }
[data-theme="dark"] .alert-warning { background: rgba(251,191,36,0.1); color: #fcd34d; border-color: rgba(251,191,36,0.2); }
[data-theme="dark"] .log-viewer { border-color: var(--mc-border); }
[data-theme="dark"] button.contrast.outline { border-color: rgba(251,191,36,0.3); }
[data-theme="dark"] button.secondary.outline { border-color: rgba(248,113,113,0.3); }
[data-theme="dark"] button.danger { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.25); }
[data-theme="dark"] .sidebar { background: #1a1d24; }
[data-theme="dark"] .mobile-topbar { background: #1a1d24; }
[data-theme="dark"] .nav-dropdown-menu { background: #22262e; }
[data-theme="dark"] .nav-dropdown-menu a:hover { background: #1a1d24; }
[data-theme="dark"] .sidebar-collapsed .sidebar .nav-links > a .nav-label,
[data-theme="dark"] .sidebar-collapsed .sidebar-action .nav-label,
[data-theme="dark"] .sidebar-collapsed .nav-dropdown-menu { background: #1a1d24; }

/* Auto dark theme based on OS preference */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --mc-bg: #111318;
    --mc-white: #1a1d24;
    --mc-surface: #1a1d24;
    --mc-surface2: #22262e;
    --mc-bg-dim: #22262e;
    --mc-border: #2e333d;
    --mc-border-hover: #3b4150;
    --mc-text: #e4e6eb;
    --mc-text-secondary: #9ca3b0;
    --mc-text-dim: #6b7280;
    --mc-accent: #4ade80;
    --mc-accent-light: rgba(74,222,128,0.12);
    --mc-accent-hover: #86efac;
    --mc-green: #34d399;
    --mc-green-light: rgba(52,211,153,0.12);
    --mc-red: #f87171;
    --mc-red-light: rgba(248,113,113,0.1);
    --mc-yellow: #fbbf24;
    --mc-yellow-light: rgba(251,191,36,0.1);
    --mc-blue: #60a5fa;
    --mc-blue-light: rgba(96,165,250,0.12);
    --mc-purple: #a78bfa;
    --mc-purple-light: rgba(167,139,250,0.12);
    --mc-orange: #fb923c;
    --mc-orange-light: rgba(251,146,60,0.1);
    --bot-default: #60a5fa;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
  }
  html:not([data-theme="light"]) .page-bg-icon { opacity: 0.04; }
  html:not([data-theme="light"]) tbody tr:hover { background: rgba(255,255,255,0.03); }
  html:not([data-theme="light"]) .card-links a:hover { background: #2e333d; }
  html:not([data-theme="light"]) textarea.code { background: #111318; }
  html:not([data-theme="light"]) .alert-success { background: rgba(52,211,153,0.1); color: #6ee7b7; border-color: rgba(52,211,153,0.2); }
  html:not([data-theme="light"]) .alert-error { background: rgba(248,113,113,0.1); color: #fca5a5; border-color: rgba(248,113,113,0.2); }
  html:not([data-theme="light"]) .alert-warning { background: rgba(251,191,36,0.1); color: #fcd34d; border-color: rgba(251,191,36,0.2); }
  html:not([data-theme="light"]) button.contrast.outline { border-color: rgba(251,191,36,0.3); }
  html:not([data-theme="light"]) button.secondary.outline { border-color: rgba(248,113,113,0.3); }
  html:not([data-theme="light"]) button.danger { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.25); }
  html:not([data-theme="light"]) .sidebar { background: #1a1d24; }
  html:not([data-theme="light"]) .mobile-topbar { background: #1a1d24; }
  html:not([data-theme="light"]) .nav-dropdown-menu { background: #22262e; }
  html:not([data-theme="light"]) .nav-dropdown-menu a:hover { background: #1a1d24; }
  html:not([data-theme="light"]).sidebar-collapsed .sidebar .nav-links > a .nav-label,
  html:not([data-theme="light"]).sidebar-collapsed .sidebar-action .nav-label,
  html:not([data-theme="light"]).sidebar-collapsed .nav-dropdown-menu { background: #1a1d24; }
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  color: var(--mc-text-dim);
  display: flex;
  align-items: center;
}
.theme-toggle:hover { color: var(--mc-text); background: none; border: none; }

/* === Gallery === */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.gallery-item {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.gallery-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--mc-surface2);
}
.gallery-meta {
  padding: 0.4rem 0.55rem 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.gallery-date {
  font-size: 0.68rem;
  color: var(--mc-text-dim);
  font-variant-numeric: tabular-nums;
}
.gallery-prompt {
  padding: 0.25rem 0.55rem 0.45rem;
  font-size: 0.72rem;
  color: var(--mc-text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.lightbox.active { display: flex; }
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  background: none !important;
  border: none !important;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1001;
  padding: 0.3rem;
  line-height: 1;
}
.lightbox-close:hover { color: #ccc; background: none !important; }
.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: var(--radius);
  object-fit: contain;
}
.lightbox-info {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: #e4e6eb;
  max-width: 600px;
  text-align: center;
}

/* === Generate/Edit Workspace === */
.gen-workspace {
  display: flex;
  gap: 1rem;
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.gen-workspace-preview {
  width: 180px;
  min-height: 180px;
  flex-shrink: 0;
  border: 1px solid var(--mc-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mc-surface2);
}
.gen-workspace-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gen-workspace-preview img[src=""] { display: none; }
.gen-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: var(--mc-text-dim);
  font-size: 0.78rem;
}
.gen-workspace-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}
.gen-workspace-form textarea {
  resize: vertical;
  min-height: 60px;
}
.gen-refs-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.gen-dropzone {
  border: 2px dashed var(--mc-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--mc-text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.gen-dropzone:hover, .gen-dropzone.dragover {
  border-color: var(--mc-accent);
  background: var(--mc-accent-light);
}
.gen-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.gen-preview-chip {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--mc-border);
}
.gen-preview-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gen-preview-rm {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6) !important;
  color: #fff;
  border: none !important;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.gen-preview-rm:hover { background: rgba(0,0,0,0.8) !important; }
.gen-workspace-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gen-loading-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--mc-text-secondary);
  font-size: 0.82rem;
}
.gen-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--mc-border);
  border-top-color: var(--mc-accent);
  border-radius: 50%;
  animation: gen-spin 0.8s linear infinite;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }

/* Gallery card edit button */
.gallery-item { position: relative; }
.gallery-edit-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55) !important;
  border: none !important;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.gallery-edit-btn:hover { background: rgba(0,0,0,0.75) !important; }
.gallery-item:hover .gallery-edit-btn { opacity: 1; }

/* === Burger menu === */
.burger-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.4rem;
  color: var(--mc-text-secondary);
  cursor: pointer;
  margin-left: auto;
}
.burger-toggle:hover { color: var(--mc-text); background: none; }

/* === Details / Summary (collapsible sections) === */
details {
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  background: var(--mc-white);
  overflow: hidden;
  padding-left: 10px;
}
details > summary {
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--mc-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--mc-text-dim);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
  flex-shrink: 0;
}
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { background: var(--mc-surface2); color: var(--mc-text); }
details[open] > summary { border-bottom: 1px solid var(--mc-border); }
details > :not(summary) { padding-inline: 0.85rem; }
details > :last-child { padding-bottom: 0.85rem; }
details > :not(summary):first-of-type { padding-top: 0.85rem; }
details.danger > summary { color: var(--mc-red); }
details.danger > summary::before { border-left-color: var(--mc-red); }
details.inline { border: none; background: none; }
details.inline > summary { padding: 0.4rem 0; }
details.inline > summary:hover { background: none; }
details.inline[open] > summary { border-bottom: none; }
details.inline > :not(summary) { padding-inline: 0; }
details.inline > :last-child { padding-bottom: 0; }

/* Form sections — consistent spacing between form elements */
.form-section {
  background: var(--mc-white);
  border: 1px solid var(--mc-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.form-section > label + label,
.form-section > .grid + .btn-group,
.form-section > textarea + .btn-group,
.form-section > textarea + button,
.form-section > .grid + button,
.form-section > label + .btn-group,
.form-section > label + button { margin-top: 0.75rem; }
.form-section > textarea { margin-top: 0.35rem; }

/* Section titles with icon — used for h3 inside bot pages */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--mc-text);
  margin: 1.5rem 0 0.6rem;
}
.section-title:first-child { margin-top: 0; }

/* Active button variant (for toggle-style button groups) */
.btn-group a[role="button"].active,
.btn-group button.active {
  background: var(--mc-accent);
  border-color: var(--mc-accent);
  color: #fff;
}

/* Breadcrumb-style navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--mc-text-dim);
  margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--mc-accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--mc-text-dim); }

/* File browser row icons */
.file-icon { color: var(--mc-text-dim); flex-shrink: 0; }

/* === Documentation content (rendered markdown) === */
.doc-content { padding: 1.5rem; line-height: 1.7; }
.doc-content h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--mc-border); }
.doc-content h2 { font-size: 1.2rem; font-weight: 600; margin: 1.75rem 0 0.6rem; }
.doc-content h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.doc-content h4 { font-size: 0.9rem; font-weight: 600; margin: 1rem 0 0.4rem; }
.doc-content p { margin-bottom: 0.6rem; color: var(--mc-text-secondary); }
.doc-content ul, .doc-content ol { padding-left: 1.5rem; margin-bottom: 0.6rem; }
.doc-content li { margin-bottom: 0.3rem; color: var(--mc-text-secondary); }
.doc-content pre { background: var(--mc-surface2); border: 1px solid var(--mc-border); border-radius: var(--radius-sm); padding: 0.85rem; font-size: 0.8rem; overflow-x: auto; margin-bottom: 0.75rem; }
.doc-content pre code { background: none; padding: 0; color: var(--mc-text); font-size: inherit; }
.doc-content code { background: var(--mc-surface2); color: var(--mc-accent); padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.85em; }
.doc-content table { width: 100%; border-collapse: collapse; margin-bottom: 0.75rem; font-size: 0.85rem; }
.doc-content th { background: var(--mc-surface2); padding: 0.5rem 0.75rem; text-align: left; font-weight: 600; font-size: 0.78rem; border-bottom: 1px solid var(--mc-border); color: var(--mc-text-dim); }
.doc-content td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--mc-border); color: var(--mc-text-secondary); }
.doc-content tr:last-child td { border-bottom: none; }
.doc-content blockquote { border-left: 3px solid var(--mc-accent); margin: 0.5rem 0; padding: 0.5rem 1rem; background: var(--mc-accent-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.doc-content blockquote p { color: var(--mc-text); margin: 0; }
.doc-content hr { border: none; border-top: 1px solid var(--mc-border); margin: 1.25rem 0; }
.doc-content a { color: var(--mc-accent); text-decoration: none; }
.doc-content a:hover { text-decoration: underline; }
.doc-content img { max-width: 100%; border-radius: var(--radius-sm); }
.doc-content strong { color: var(--mc-text); }

/* === Responsive === */
@media (max-width: 768px) {
  /* Show mobile topbar, hide desktop sidebar */
  .mobile-topbar { display: flex; }
  .sidebar-collapsed .sidebar,
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 240px;
    min-width: 240px;
    height: 100vh;
    z-index: 150;
    transition: left 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: none !important; }
  .sidebar-collapsed .sidebar .nav-links > a { padding: 0.45rem 1rem; justify-content: flex-start; }
  .sidebar-collapsed .sidebar .nav-links > a .nav-label { position: static; opacity: 1; transform: none; pointer-events: auto; display: inline; padding: 0; background: none; border: none; box-shadow: none; border-radius: 0; font-size: inherit; color: inherit; }
  .sidebar-collapsed .sidebar-header .logo .nav-label { display: inline !important; }
  .sidebar-collapsed .sidebar-header { justify-content: flex-start; }
  .sidebar-collapsed .nav-dropdown-toggle { padding: 0.45rem 1rem; justify-content: flex-start; }
  .sidebar-collapsed .nav-dropdown-toggle .nav-label,
  .sidebar-collapsed .nav-dropdown-toggle .nav-chevron { display: inline !important; }
  .sidebar-collapsed .nav-dropdown-menu { position: static; left: auto; min-width: auto; border-radius: 0; box-shadow: none; border: none; }
  .sidebar-collapsed .sidebar-action { padding: 0.4rem 1rem; justify-content: flex-start; }
  .sidebar-collapsed .sidebar-action .nav-label { position: static; opacity: 1; transform: none; pointer-events: auto; display: inline; padding: 0; background: none; border: none; box-shadow: none; border-radius: 0; font-size: inherit; color: inherit; }
  .burger-toggle { display: flex; }

  .mc-main { padding: 1rem; }
  .bot-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gen-workspace { flex-direction: column; }
  .gen-workspace-preview { width: 100%; min-height: 120px; max-height: 200px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .section-header { flex-wrap: wrap; gap: 0.5rem; }

  /* Tables — aggressively compact on mobile */
  table { font-size: 0.7rem; }
  thead th { padding: 0.25rem 0.3rem; font-size: 0.6rem; letter-spacing: 0.02em; }
  tbody td { padding: 0.25rem 0.3rem; }
  thead th, tbody td { width: auto !important; }
  .table-wrap { border-radius: 8px; }
  .detail-cell { max-width: 120px; font-size: 0.68rem; }
  .ts-cell { font-size: 0.68rem; white-space: normal; }
  .badge, .badge-event { font-size: 0.62rem; padding: 0.1rem 0.3rem; white-space: nowrap; }
  .hide-mobile { display: none; }

  /* Bot nav — compact tabs */
  .bot-nav a { padding: 0.3rem 0.55rem; font-size: 0.75rem; }

  .page-bg-icon { bottom: -50px; left: -50px; }
  .page-bg-icon > i, .page-bg-icon > svg { width: 280px !important; height: 280px !important; }
}

/* ── Clickable table rows ── */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--mc-bg-dim, #f1f3f5); }

/* ── Session Viewer ── */
.session-meta {
  background: var(--mc-surface, #f8f9fa);
  border: 1px solid var(--mc-border, #dee2e6);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}
.session-meta-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0;
  align-items: baseline;
}
.session-meta-label {
  font-weight: 600;
  min-width: 90px;
  color: var(--mc-text-dim, #6c757d);
  flex-shrink: 0;
}
.session-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.msg {
  border: 1px solid var(--mc-border, #dee2e6);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  background: var(--mc-surface, #fff);
}
.msg-user {
  border-left: 3px solid var(--mc-accent, #4a90d9);
}
.msg-assistant {
  border-left: 3px solid var(--mc-success, #28a745);
}
.msg-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  color: var(--mc-text-dim, #6c757d);
}
.msg-header strong {
  font-size: 0.82rem;
  color: var(--mc-text, #212529);
}
.msg-time {
  margin-left: auto;
  font-size: 0.72rem;
  opacity: 0.7;
}
.msg-num {
  font-size: 0.7rem;
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
}
.msg-body {
  font-size: 0.88rem;
  line-height: 1.6;
  word-break: break-word;
}
.msg-body .msg-text > :first-child { margin-top: 0; }
.msg-body .msg-text > :last-child { margin-bottom: 0; }
.msg-body pre {
  font-size: 0.78rem;
  max-height: 400px;
  overflow: auto;
  background: var(--mc-bg-dim, #f1f3f5);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}
.msg-thinking {
  margin: 0.35rem 0;
  opacity: 0.65;
  font-style: italic;
}
.msg-thinking summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mc-text-dim, #6c757d);
}
.msg-thinking pre {
  font-style: normal;
  max-height: 300px;
}
.msg-tool, .msg-tool-result {
  margin: 0.35rem 0;
  border-left: 2px solid var(--mc-info, #17a2b8);
  padding-left: 0.5rem;
}
.msg-tool-result {
  border-left-color: var(--mc-warning, #ffc107);
}
.msg-tool summary, .msg-tool-result summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mc-text-dim, #6c757d);
}
.msg-tool code {
  font-size: 0.76rem;
  background: var(--mc-bg-dim, #f1f3f5);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.msg-tool pre, .msg-tool-result pre {
  max-height: 250px;
}
