/*
  Organaizer UI
  Theme colors are in themes.css — this file uses var(--token) everywhere.
*/

:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 34px;
  --space-7: 48px;
  --space-8: 72px;

  --container: 1120px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 18% 10%, var(--body-glow-1), transparent 55%),
    radial-gradient(900px 600px at 85% 20%, var(--body-glow-2), transparent 60%),
    radial-gradient(900px 700px at 60% 85%, var(--body-glow-3), transparent 60%),
    var(--body-bg);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.stack > * + * { margin-top: var(--space-4); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow2);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  user-select: none;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); border-color: var(--stroke2); background: var(--card2); box-shadow: var(--shadow2); }
.btn:active { transform: translateY(0px) scale(0.99); }

.btn-primary {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.btn-primary:hover { border-color: var(--accent2); background: linear-gradient(135deg, var(--accent-hover, var(--accent)), var(--accent2)); }

.btn-ghost {
  background: transparent;
  border-color: var(--stroke2);
}

.card {
  border: 1px solid var(--stroke);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card-inner { padding: clamp(18px, 3vw, 28px); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--space-6);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(14px + var(--safe-area-top)) 0 14px;
  padding-left: var(--safe-area-left);
  padding-right: var(--safe-area-right);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.16), 0 0 48px rgba(34, 211, 238, 0.22);
}

.nav-links { display: flex; gap: 10px; align-items: center; }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
}

.hero {
  padding: clamp(36px, 6vw, 76px) 0 clamp(26px, 5vw, 62px);
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 5.2vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.8px;
}

.hero p {
  margin: 14px 0 0;
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.5;
  color: var(--muted);
  max-width: 64ch;
}

.hero-cta { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }

.panel {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--card);
  padding: 14px;
}

.form {
  display: grid;
  gap: 14px;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.input, .field input, .field textarea, .field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.input:focus, .field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.12);
}

.hint { color: var(--faint); font-size: 13px; line-height: 1.35; }

.flash {
  margin: var(--space-4) 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
}
.flash.notice { border-color: rgba(34, 211, 238, 0.28); }
.flash.alert { border-color: rgba(239, 68, 68, 0.32); }

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 520ms ease, transform 520ms ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ==============================
   Dashboard Layout
   ============================== */

.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 200ms ease;
}

.dashboard-layout:has(.sidebar.is-collapsed) {
  grid-template-columns: 68px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-4) 0;
  padding-top: calc(var(--space-4) + var(--safe-area-top));
  padding-left: var(--safe-area-left);
  border-right: 1px solid var(--stroke);
  background: var(--sidebar-bg);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  transition: width 200ms ease, padding 200ms ease;
  width: 240px;
}

.sidebar.is-collapsed {
  width: 68px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-5);
  min-height: 36px;
  position: relative;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.3px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: color 120ms ease, background 120ms ease;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  color: var(--text);
  background: var(--card);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: background 120ms ease, color 120ms ease;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-link:hover {
  background: var(--card);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link--active {
  background: rgba(124, 58, 237, 0.18);
  color: var(--text);
  border-color: rgba(124, 58, 237, 0.25);
}
.sidebar-link--active:hover {
  background: rgba(124, 58, 237, 0.24);
}

.sidebar-link--loading {
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}

.sidebar-link--loading .sidebar-icon::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sidebar-spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes sidebar-spin {
  to { transform: rotate(360deg); }
}

.sidebar-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 16px;
}

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  padding: var(--space-2);
  border-top: 1px solid var(--stroke);
  margin-top: var(--space-2);
}

.sidebar-logout-btn {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}

/* Collapsed state: hide text, center icons */
.sidebar.is-collapsed .sidebar-brand-text,
.sidebar.is-collapsed .sidebar-link-text,
.sidebar.is-collapsed .system-badge { display: none; }

.sidebar.is-collapsed .sidebar-brand { justify-content: center; }
.sidebar.is-collapsed .sidebar-top { justify-content: center; padding: 0; }
.sidebar.is-collapsed .sidebar-collapse-btn {
  padding: 8px;
  font-size: 18px;
  color: var(--muted);
}
.sidebar.is-collapsed .sidebar-link { justify-content: center; padding: 10px; }
.sidebar.is-collapsed .sidebar-nav { padding: 0 6px; }
.sidebar.is-collapsed .sidebar-footer { padding: 6px; gap: 2px; }
.sidebar.is-collapsed .sidebar-footer .sidebar-link { justify-content: center; padding: 10px; }
.sidebar.is-collapsed .sidebar-logout-btn { text-align: center; }
.sidebar.is-collapsed .theme-picker { flex-wrap: wrap; gap: 4px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: calc(14px + var(--safe-area-top));
  left: calc(14px + var(--safe-area-left));
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--sidebar-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  backdrop-filter: blur(10px);
}

.main-content {
  padding: var(--space-6) var(--space-6);
  min-height: 100vh;
  max-width: 1100px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 26px;
  font-weight: 950;
  letter-spacing: -0.4px;
  margin: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--faint);
  margin-bottom: var(--space-3);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep::before { content: "/"; }

/* ==============================
   Data Tables
   ============================== */

.data-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  min-width: 500px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--card);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--stroke);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(255, 255, 255, 0.03); }

.data-table .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ==============================
   Tags / Status
   ============================== */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tag-get { background: rgba(34, 211, 238, 0.15); color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.25); }
.tag-post { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.25); }
.tag-put { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.25); }
.tag-patch { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.25); }
.tag-delete { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.25); }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
}
.status-dot--active { background: var(--ok); box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.status-dot--inactive { background: var(--faint); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

/* ==============================
   Modals
   ============================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg1);
  border: 1px solid var(--stroke2);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 520px;
  width: 90%;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 var(--space-4);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: var(--space-5);
}

/* ==============================
   Chat Interface
   ============================== */

/* Chat page: allow full width so the layout has room */
.main-content:has(.chat-page) {
  max-width: none;
}

.chat-page {
  width: 100%;
  max-width: 100%;
}

/* Chat header with agent selector */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--stroke);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-header-info { display: flex; flex-direction: column; }
.chat-header-name { font-weight: 800; font-size: 16px; }
.chat-header-meta { font-size: 12px; color: var(--faint); }
.chat-header-right { display: flex; gap: var(--space-2); }

.chat-agent-switcher {
  position: relative;
}

.chat-agent-switch-btn {
  cursor: pointer;
  font-size: 10px;
  color: var(--faint);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  list-style: none;
  transition: color 120ms ease;
}
.chat-agent-switch-btn:hover { color: var(--text); }
.chat-agent-switch-btn::-webkit-details-marker { display: none; }

.chat-agent-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  min-width: 220px;
  background: var(--bg1);
  border: 1px solid var(--stroke2);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-agent-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}
.chat-agent-dropdown-item:hover { background: var(--card); text-decoration: none; }
.chat-agent-dropdown-item--active { background: rgba(124, 58, 237, 0.15); color: var(--accent2); }

/* Unified 2-column chat: main + activity */
.chat-layout-unified {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-4);
  min-height: 0;
  height: calc(100vh - 160px);
  width: 100%;
}

.chat-layout-unified > * {
  min-width: 0;
}

.chat-sidebar-agents {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-sidebar-agent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
}

.chat-sidebar-agent:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar-agent--active {
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent2);
}

.chat-sidebar-agent .tag--system {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent);
  border-radius: 4px;
}

.chat-sidebar-agent .tag--own {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--ok);
  border-radius: 4px;
}

.chat-sidebar-new {
  font-size: 0.85rem;
  color: var(--accent2);
  padding: var(--space-2) 0;
}

.chat-sidebar-conversations {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.chat-sidebar-conv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
}

.chat-sidebar-conv:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar-conv--active {
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent2);
}

.chat-sidebar-conv-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.chat-container {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}

.chat-activity-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: hidden;
}

.chat-activity-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--faint);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}

.chat-activity-panel {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-activity-empty {
  font-size: 0.85rem;
  color: var(--faint);
  margin: 0;
  padding: var(--space-2);
}

/* Activity feed widgets: reasoning block */
.chat-activity-reasoning {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
}

.chat-activity-reasoning-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}

.chat-activity-reasoning-content {
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Activity feed widgets: tool call card */
.chat-activity-tool-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.chat-activity-tool-card:hover {
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

.chat-activity-tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-activity-tool-icon {
  font-size: 1rem;
  opacity: 0.9;
}

.chat-activity-tool-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

.chat-activity-tool-args {
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.chat-activity-tool-args summary {
  cursor: pointer;
  color: var(--faint);
  user-select: none;
  padding: 4px 0;
  font-weight: 500;
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-activity-tool-args summary:hover {
  color: rgba(255, 255, 255, 0.6);
}

.chat-activity-tool-args summary::marker {
  content: "";
}

.chat-activity-tool-args summary::before {
  content: "▶";
  display: inline-block;
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  color: var(--faint);
}

.chat-activity-tool-args[open] summary::before {
  transform: rotate(90deg);
}

.chat-activity-tool-args-body {
  margin: 6px 0 0 0;
  padding: 8px;
  font-size: 0.7rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.8);
}

.chat-activity-tool-status {
  font-size: 0.75rem;
  font-weight: 600;
}

.chat-activity-tool-status--pending {
  color: var(--faint);
}

.chat-activity-tool-status--success {
  color: #86efac;
}

.chat-activity-tool-status--error {
  color: #fca5a5;
}

.chat-activity-tool-result {
  margin: 6px 0 0 0;
  padding: 8px;
  font-size: 0.72rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.85);
  max-height: 200px;
  overflow-y: auto;
}

/* Sub-agent activity cards */
.chat-activity-subagent-card {
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.chat-activity-subagent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-activity-subagent-icon {
  font-size: 1.1rem;
}

.chat-activity-subagent-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
}

.chat-activity-subagent-model {
  font-size: 0.72rem;
  color: var(--faint);
  margin-bottom: 4px;
}

.chat-activity-subagent-progress {
  font-size: 0.75rem;
  color: var(--accent, #a78bfa);
  font-style: italic;
  margin-bottom: 4px;
}

.chat-activity-intermediate {
  background: rgba(124, 58, 237, 0.06);
  border-left: 3px solid var(--accent, #7c3aed);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text);
  font-style: italic;
  opacity: 0.85;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-bubble--user {
  align-self: flex-end;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent2) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.chat-bubble--assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--stroke);
}

.chat-bubble--streaming {
  border-left: 3px solid var(--accent, #7c3aed);
}

.chat-bubble--streaming [data-stream-content]::after {
  content: "▋";
  animation: blink-cursor 0.8s infinite;
  color: var(--accent, #7c3aed);
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.chat-bubble--intermediate {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--stroke);
  opacity: 0.7;
  font-style: italic;
  font-size: 0.9em;
}

.chat-bubble--tool {
  align-self: flex-start;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.20);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 12px;
  max-width: 90%;
}

.chat-bubble--error {
  align-self: flex-start;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.30);
  color: #fca5a5;
}

.chat-bubble-role {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}

.chat-bubble-content {
  line-height: 1.6;
}

.chat-bubble-image {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.chat-bubble-content .chat-bubble-image:last-child {
  margin-bottom: 0;
}

/* ---- Pending image preview (input area) ---- */
.chat-image-preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 8px;
}
.chat-image-preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
}
.chat-image-preview-remove {
  font-size: 13px;
  padding: 6px 12px;
}

/* ---- Markdown inside chat bubbles ---- */
.chat-bubble-content h1,
.chat-bubble-content h2,
.chat-bubble-content h3 {
  margin: 12px 0 6px 0;
  color: #fff;
  line-height: 1.3;
}
.chat-bubble-content h1 { font-size: 1.15em; }
.chat-bubble-content h2 { font-size: 1.05em; }
.chat-bubble-content h3 { font-size: 0.95em; }
.chat-bubble-content h1:first-child,
.chat-bubble-content h2:first-child,
.chat-bubble-content h3:first-child {
  margin-top: 0;
}

.chat-bubble-content p {
  margin: 0 0 8px 0;
}
.chat-bubble-content p:last-child {
  margin-bottom: 0;
}

.chat-bubble-content ul,
.chat-bubble-content ol {
  margin: 6px 0;
  padding-left: 20px;
}
.chat-bubble-content li {
  margin-bottom: 3px;
}

.chat-bubble-content strong {
  color: #fff;
  font-weight: 700;
}

.chat-bubble-content em {
  color: rgba(255, 255, 255, 0.85);
}

.chat-bubble-content code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 0.88em;
  color: var(--accent2);
}

.chat-bubble-content pre {
  background: var(--code-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.chat-bubble-content pre code {
  background: none;
  padding: 0;
  color: var(--accent2);
  font-size: 0.85em;
}

.chat-bubble-content blockquote {
  border-left: 3px solid rgba(124, 58, 237, 0.5);
  margin: 8px 0;
  padding: 4px 12px;
  color: rgba(255, 255, 255, 0.7);
}

.chat-bubble-content table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.9em;
  width: 100%;
}
.chat-bubble-content th,
.chat-bubble-content td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 10px;
  text-align: left;
}
.chat-bubble-content th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
  color: #fff;
}

.chat-bubble-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  margin: 10px 0;
}

.chat-flow-diagram {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--surface, #f5f5f5);
  border-radius: 8px;
  overflow: auto;
}
.chat-flow-diagram-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--muted, #666);
}
.chat-flow-diagram .mermaid {
  display: flex;
  justify-content: center;
}
.chat-flow-diagram .mermaid svg {
  max-width: 100%;
}
.flow-viewer-card .mermaid {
  display: flex;
  justify-content: center;
  min-height: 120px;
}
.flow-viewer-card .mermaid svg {
  max-width: 100%;
}

.chat-bubble-content a {
  color: var(--accent2);
  text-decoration: underline;
}

/* ---- Tool call indicator ---- */
.chat-tool-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
  padding: 3px 0;
}
.chat-tool-icon {
  font-size: 13px;
  color: var(--accent2);
}
.chat-tool-names {
  font-weight: 700;
  color: var(--accent2);
}

.chat-tool-calls {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-tool-call-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent2);
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: var(--space-4);
  border-top: 1px solid var(--stroke);
  background: var(--card);
  border-radius: 0 0 var(--radius-md) 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.chat-input-area.chat-drop-over {
  background: rgba(34, 211, 238, 0.08);
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.35);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-attach-image-btn {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background 180ms ease;
}

.chat-attach-image-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-attach-image-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.chat-input {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  resize: none;
}
.chat-input:focus {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.10);
}

.chat-record-btn {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  position: relative;
  transition: all 180ms ease;
}

.chat-record-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-record-btn.is-recording {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  animation: recordingPulse 1.5s ease-in-out infinite;
}

.chat-record-btn.is-recording::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: rgba(239, 68, 68, 0.3);
  animation: recordingPulse 1.5s ease-in-out infinite;
  z-index: -1;
}

.chat-record-btn.is-processing {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

.chat-record-btn .recording-timer {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@keyframes recordingPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

.chat-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--faint);
  font-size: 13px;
}

.chat-loading-text {
  white-space: pre-line;
}

.chat-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent2);
  animation: chatPulse 1.2s ease-in-out infinite;
}
.chat-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ==============================
   Empty State
   ============================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 var(--space-2);
}

.empty-state-text {
  color: var(--muted);
  font-size: 14px;
  max-width: 400px;
  margin: 0 0 var(--space-5);
}

/* ==============================
   Metric Cards
   ============================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.metric-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--card);
  padding: var(--space-5);
  backdrop-filter: blur(8px);
}

.metric-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: var(--space-2);
}

.metric-value {
  font-size: 36px;
  font-weight: 950;
  letter-spacing: -0.5px;
  line-height: 1;
}

.metric-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--space-1);
}

/* ==============================
   JSON Editor
   ============================== */

.json-editor {
  width: 100%;
  min-height: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--input-bg);
  color: var(--accent2);
  padding: 14px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  tab-size: 2;
}
.json-editor:focus {
  border-color: rgba(34, 211, 238, 0.40);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.08);
}
.json-editor.is-invalid {
  border-color: rgba(239, 68, 68, 0.50);
}

.json-editor-hint {
  font-size: 12px;
  margin-top: 4px;
}
.json-editor-hint.is-valid { color: var(--ok); }
.json-editor-hint.is-invalid { color: var(--danger); }

/* ==============================
   Utility classes
   ============================== */

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.flex-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace; }
.font-bold { font-weight: 900; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.50);
}

.btn-success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}

.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: 14px;
}

.detail-label {
  font-weight: 800;
  color: var(--faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 2px;
}

.detail-value {
  color: var(--text);
  word-break: break-all;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast--visible {
  opacity: 1;
  transform: translateX(0);
}
.toast--hiding {
  opacity: 0;
  transform: translateX(40px);
}
.toast--success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.toast--error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(185, 28, 28, 0.9));
  border: 1px solid rgba(252, 165, 165, 0.3);
}
.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.toast-text {
  flex: 1;
  line-height: 1.4;
}
.toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { color: #fff; }

@media (max-width: 640px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

.flash-inline {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--space-4);
}
.flash-inline.success { border-color: rgba(34, 197, 94, 0.30); background: rgba(34, 197, 94, 0.08); color: var(--ok); }
.flash-inline.error { border-color: rgba(239, 68, 68, 0.30); background: rgba(239, 68, 68, 0.08); color: var(--danger); }

/* ==============================
   Organaizer Assistant Chat
   ============================== */

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-5);
  gap: var(--space-3);
}

.chat-welcome-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
  margin-bottom: var(--space-2);
}

.chat-welcome-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.chat-welcome-text {
  font-size: 14px;
  color: var(--muted);
  max-width: 440px;
  line-height: 1.6;
}

.chat-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-4);
  width: 100%;
  max-width: 500px;
}

.chat-suggestion-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 180ms ease;
  text-align: left;
  font-family: inherit;
}

.chat-suggestion-btn:hover {
  background: var(--card2);
  border-color: var(--stroke2);
  color: var(--text);
  transform: translateY(-1px);
}

.sidebar-link--organaizer {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), color-mix(in srgb, var(--accent2) 6%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--radius-sm);
}

.sidebar-link--organaizer:hover {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent2) 12%, transparent));
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.system-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent2);
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 999px;
}

/* ==============================
   Billing
   ============================== */

.billing-current-plan {
  margin-bottom: var(--space-6);
}

.billing-plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(34, 211, 238, 0.04));
  flex-wrap: wrap;
}

.billing-plan-name {
  font-size: 22px;
  font-weight: 950;
  letter-spacing: -0.3px;
}

.billing-plan-detail {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.billing-plan-limits {
  font-size: 12px;
  color: var(--faint);
  margin-top: 8px;
}
.billing-usage-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.billing-usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.billing-usage-fill--warn {
  background: #fbbf24;
}
.billing-usage-fill--critical {
  background: var(--danger);
}

.billing-section-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 var(--space-4);
}

.billing-coupon-section {
  margin-bottom: var(--space-6);
}

.billing-coupon-form {
  display: flex;
  gap: var(--space-2);
  max-width: 400px;
}

.billing-plans-section {
  margin-bottom: var(--space-6);
}

.billing-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.billing-plan-option {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--card);
  transition: transform 140ms ease, border-color 140ms ease;
}
.billing-plan-option:hover {
  transform: translateY(-2px);
  border-color: var(--stroke2);
}

.billing-plan-option-name {
  font-size: 18px;
  font-weight: 900;
}

.billing-plan-option-price {
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -0.5px;
}

.billing-plan-option-period {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.billing-plan-option-features {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

/* ==============================
   Flow Cards
   ============================== */

.flow-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.flow-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.flow-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke2);
  background: var(--card2);
  text-decoration: none;
}

.flow-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.flow-card-name {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.flow-card-meta {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
}

.flow-card-preview {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--stroke);
}

@media (max-width: 560px) {
  .flow-cards-grid { grid-template-columns: 1fr; }
}

/* ==============================
   Data Cards & Row Cards
   ============================== */

.data-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.data-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.data-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke2);
  background: var(--card2);
  text-decoration: none;
}

.data-card-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(124, 58, 237, 0.10);
  border: 1px solid rgba(124, 58, 237, 0.20);
  flex-shrink: 0;
}

.data-card-body { flex: 1; min-width: 0; }
.data-card-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-card-meta { display: flex; gap: var(--space-3); font-size: 12px; color: var(--faint); margin-top: 4px; }
.data-card-arrow { font-size: 18px; color: var(--faint); flex-shrink: 0; }

/* Row cards (expandable, for show_table) */
.row-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.row-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--card);
  overflow: hidden;
  transition: border-color 140ms ease;
}
.row-card[open] { border-color: var(--stroke2); }

.row-card-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  color: var(--text);
  transition: background 120ms ease;
}
.row-card-summary:hover { background: var(--card2); }
.row-card-summary::-webkit-details-marker { display: none; }

.row-card-index {
  font-size: 12px;
  font-weight: 800;
  color: var(--faint);
  flex-shrink: 0;
  width: 32px;
}

.row-card-preview {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-card-chevron {
  font-size: 10px;
  color: var(--faint);
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.row-card[open] .row-card-chevron { transform: rotate(180deg); }

.row-card-body {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--stroke);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.row-card-field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-2);
  font-size: 13px;
  padding: 4px 0;
}

.row-card-field-label {
  font-weight: 800;
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 2px;
}

.row-card-field-value {
  color: var(--text);
  word-break: break-word;
}

@media (max-width: 560px) {
  .data-cards-grid { grid-template-columns: 1fr; }
  .row-card-field { grid-template-columns: 1fr; }
}

/* ==============================
   Home / Overview
   ============================== */

.home-greeting {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 950;
  letter-spacing: -0.5px;
  margin-bottom: var(--space-6);
}

.home-assistant-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(124, 58, 237, 0.25);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.10), rgba(34, 211, 238, 0.06));
  text-decoration: none;
  color: var(--text);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  margin-bottom: var(--space-6);
}
.home-assistant-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.15);
  text-decoration: none;
}

.home-assistant-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.30);
  flex-shrink: 0;
}

.home-assistant-body { flex: 1; }

.home-assistant-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.home-assistant-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.home-assistant-arrow {
  font-size: 22px;
  color: var(--faint);
  flex-shrink: 0;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.home-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
  text-align: center;
}
.home-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke2);
  background: var(--card2);
  text-decoration: none;
}

.home-stat-icon {
  font-size: 24px;
  opacity: 0.8;
}

.home-stat-value {
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -0.5px;
  line-height: 1;
}

.home-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 560px) {
  .home-stats { grid-template-columns: 1fr; }
  .home-assistant-card { flex-direction: column; text-align: center; }
  .home-assistant-arrow { display: none; }
}

/* ==============================
   Theme Picker
   ============================== */

.theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--space-3);
}

.theme-picker-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--faint);
  margin-right: auto;
}

.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
  flex-shrink: 0;
}

.theme-swatch:hover {
  transform: scale(1.15);
  border-color: var(--stroke2);
}

.theme-swatch--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.theme-swatch--midnight { background: #07070c; }
.theme-swatch--dark { background: #0f172a; }
.theme-swatch--gray { background: #27272a; }
.theme-swatch--light { background: #f1f5f9; }

/* collapsed sidebar theme swatches */
.sidebar.is-collapsed .theme-picker-label { display: none; }
.sidebar.is-collapsed .theme-picker { justify-content: center; padding: 8px 4px; flex-wrap: wrap; gap: 4px; }

/* ==============================
   Responsive
   ============================== */

@media (max-width: 920px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }

  .dashboard-layout,
  .dashboard-layout:has(.sidebar.is-collapsed) { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px !important;
    z-index: 50;
    transition: left 200ms ease;
  }
  .sidebar.is-collapsed .sidebar-brand-text,
  .sidebar.is-collapsed .sidebar-link-text,
  .sidebar.is-collapsed .system-badge { display: inline; }
  .sidebar.is-collapsed .sidebar-link { justify-content: flex-start; padding: 10px var(--space-3); }
  .sidebar.is-collapsed .sidebar-nav { padding: 0 var(--space-2); }
  .sidebar.is-collapsed .sidebar-footer { padding: var(--space-2); }
  .sidebar.is-collapsed .sidebar-brand { justify-content: flex-start; }
  .sidebar.is-collapsed .sidebar-collapse-btn { font-size: 16px; padding: 4px; }
  .sidebar.is-collapsed .sidebar-top { justify-content: space-between; padding: 0 var(--space-3); }

  .sidebar.is-open { left: 0; }
  .sidebar.is-open + .sidebar-overlay { display: block; }
  .sidebar-toggle { display: block; }
  .main-content {
    padding: var(--space-5) var(--space-4);
    padding-top: calc(60px + var(--safe-area-top));
    padding-left: calc(var(--space-4) + var(--safe-area-left));
    padding-right: calc(var(--space-4) + var(--safe-area-right));
  }
  .detail-grid { grid-template-columns: 1fr; }

  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  .btn-sm {
    min-height: 44px;
    padding: 10px 14px;
  }
  .sidebar-link {
    min-height: 44px;
    padding: 12px var(--space-3);
  }
  .breadcrumb a {
    padding: 10px 4px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .data-table .actions {
    gap: 12px;
  }
  .data-table .actions a,
  .data-table .actions button {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-input-area {
    padding-left: calc(var(--space-4) + var(--safe-area-left));
    padding-right: calc(var(--space-4) + var(--safe-area-right));
    padding-bottom: calc(var(--space-4) + var(--safe-area-bottom));
  }
  .chat-messages {
    padding-bottom: calc(var(--space-5) + var(--safe-area-bottom));
  }
  .chat-suggestion-btn {
    min-height: 44px;
  }
  .chat-record-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .chat-layout-unified {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 140px);
  }
  .chat-container,
  .chat-activity-column {
    min-width: 0;
  }
  .chat-activity-column {
    min-height: 280px;
  }
  .chat-header { flex-wrap: wrap; }

  .field input,
  .field textarea,
  .field select,
  .input {
    font-size: 16px;
  }
  .card-inner {
    padding: clamp(14px, 2.5vw, 24px);
  }
  .form {
    gap: 18px;
  }
}

@media (max-width: 768px) {
  .main-content { padding-left: calc(var(--space-4) + var(--safe-area-left)); padding-right: calc(var(--space-4) + var(--safe-area-right)); }

  .nav-row { position: relative; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: var(--space-2);
    margin-top: var(--space-2);
    background: rgba(7, 7, 12, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  }
  .nav.is-open .nav-links { display: flex; }
  .nav-links .btn, .nav-links .btn-ghost, .nav-links .btn-primary {
    justify-content: center;
    min-height: 44px;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 400px) {
  .container { padding-left: var(--space-3); padding-right: var(--space-3); }
  .main-content { padding-left: calc(var(--space-3) + var(--safe-area-left)); padding-right: calc(var(--space-3) + var(--safe-area-right)); }

  .modal-content {
    width: calc(100% - var(--space-4));
    max-width: none;
    margin: var(--space-2);
    border-radius: var(--radius);
  }
  .modal-actions .btn,
  .modal-actions button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .reveal, .input, .field input { transition: none !important; }
  .btn:hover { transform: none; }
  .sidebar { transition: none !important; }
  .chat-loading-dot { animation: none; opacity: 0.5; }
}


/* ============================================================
   LANDING REDESIGN
   ============================================================ */

/* ── CSS custom property for aurora rotation ── */
@property --aurora-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* ── Keyframes ─────────────────────────────────────────────── */

@keyframes grid-drift {
  from { background-position: 0 0; }
  to   { background-position: 40px 40px; }
}

@keyframes ai-pulse {
  0%, 100% {
    color: #22d3ee;
    text-shadow: 0 0 18px rgba(34,211,238,0.7), 0 0 40px rgba(34,211,238,0.35);
  }
  50% {
    color: #67e8f9;
    text-shadow: 0 0 28px rgba(34,211,238,1), 0 0 60px rgba(34,211,238,0.5), 0 0 100px rgba(124,58,237,0.3);
  }
}

@keyframes aurora-spin {
  to { --aurora-angle: 360deg; }
}

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

@keyframes float-y-slow {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-14px) rotate(2deg); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes terminal-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes line-reveal-1 { 0%,  4% { opacity:0; } 5%,100% { opacity:1; } }
@keyframes line-reveal-2 { 0%, 14% { opacity:0; } 15%,100% { opacity:1; } }
@keyframes line-reveal-3 { 0%, 24% { opacity:0; } 25%,100% { opacity:1; } }
@keyframes line-reveal-4 { 0%, 34% { opacity:0; } 35%,100% { opacity:1; } }
@keyframes line-reveal-5 { 0%, 44% { opacity:0; } 45%,100% { opacity:1; } }
@keyframes line-reveal-6 { 0%, 54% { opacity:0; } 55%,100% { opacity:1; } }
@keyframes line-reveal-7 { 0%, 64% { opacity:0; } 65%,100% { opacity:1; } }
@keyframes line-reveal-8 { 0%, 74% { opacity:0; } 75%,100% { opacity:1; } }
@keyframes line-reveal-9 { 0%, 84% { opacity:0; } 85%,100% { opacity:1; } }

@keyframes beam-slide {
  0%   { transform: translateX(-100%) skewX(-12deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateX(400%) skewX(-12deg); opacity: 0; }
}

@keyframes orb-drift-1 {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(60px,-40px) scale(1.08); }
  66%     { transform: translate(-30px,50px) scale(0.95); }
}
@keyframes orb-drift-2 {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(-50px,30px) scale(1.05); }
  66%     { transform: translate(40px,-60px) scale(0.97); }
}
@keyframes orb-drift-3 {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(30px,40px) scale(1.06); }
}

@keyframes step-line {
  from { width: 0; }
  to   { width: 100%; }
}

/* ── Navbar ────────────────────────────────────────────────── */

.l-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  transition: background 0.3s ease, backdrop-filter 0.3s ease, border-color 0.3s ease;
  border-bottom: 1px solid transparent;
}

.l-nav.nav--scrolled {
  background: rgba(7, 7, 12, 0.82);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom-color: rgba(255,255,255,0.07);
}

.l-nav-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ── Brand logo ────────────────────────────────────────────── */

.l-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-decoration: none !important;
  color: var(--text);
}

.l-brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(124,58,237,0.8);
  flex-shrink: 0;
}

.l-brand-ai {
  color: #22d3ee;
  animation: ai-pulse 3s ease-in-out infinite;
  display: inline;
}

.l-brand-word { color: var(--text); }

/* ── Nav links ─────────────────────────────────────────────── */

.l-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.l-nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
  text-decoration: none !important;
}

.l-nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  text-decoration: none !important;
}

.l-nav-btn {
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.2s;
}

.l-nav-btn-ghost {
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text);
  background: transparent;
}
.l-nav-btn-ghost:hover {
  background: rgba(255,255,255,0.07);
  text-decoration: none !important;
}

.l-nav-btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  box-shadow: 0 0 20px rgba(124,58,237,0.35);
}
.l-nav-btn-primary:hover {
  background: #6d28d9;
  box-shadow: 0 0 30px rgba(124,58,237,0.55);
  text-decoration: none !important;
}

/* ── Hero ──────────────────────────────────────────────────── */

.l-hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding-top: 64px;
}

/* Animated dot grid */
.l-hero-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-drift 25s linear infinite;
  pointer-events: none;
}

/* Animated orbs */
.l-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  will-change: transform;
}
.l-orb-1 {
  width: 600px; height: 600px;
  background: rgba(124, 58, 237, 0.22);
  top: -100px; left: -150px;
  animation: orb-drift-1 18s ease-in-out infinite;
}
.l-orb-2 {
  width: 500px; height: 500px;
  background: rgba(34, 211, 238, 0.15);
  top: 20%; right: -100px;
  animation: orb-drift-2 22s ease-in-out infinite;
}
.l-orb-3 {
  width: 400px; height: 400px;
  background: rgba(239, 68, 68, 0.08);
  bottom: 0; left: 40%;
  animation: orb-drift-3 16s ease-in-out infinite;
}

.l-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 80px 24px 100px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
}

/* Hero text side */
.l-hero-text { display: flex; flex-direction: column; gap: 0; }

.l-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(34,211,238,0.25);
  background: rgba(34,211,238,0.06);
  font-size: 13px;
  font-weight: 600;
  color: #22d3ee;
  letter-spacing: 0.3px;
  width: fit-content;
  margin-bottom: 24px;
  animation: fade-up 0.6s ease both;
}

.l-eyebrow-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 8px #22d3ee;
  animation: terminal-cursor 1.4s ease-in-out infinite;
}

.l-hero-title {
  font-size: clamp(44px, 6vw, 80px);
  font-weight: 900;
  line-height: 1.0;
  letter-spacing: -2px;
  margin: 0 0 24px;
  animation: fade-up 0.7s 0.1s ease both;
}

.l-hero-title-ai {
  color: #22d3ee;
  animation: ai-pulse 3s ease-in-out infinite;
  display: inline;
}

.l-hero-sub {
  font-size: clamp(16px, 1.8vw, 20px);
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 36px;
  max-width: 52ch;
  animation: fade-up 0.7s 0.2s ease both;
}

.l-hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  animation: fade-up 0.7s 0.3s ease both;
}

.l-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none !important;
  border: 1px solid transparent;
  box-shadow: 0 0 30px rgba(124,58,237,0.4), 0 4px 20px rgba(0,0,0,0.3);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.l-btn-primary::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: beam-slide 3.5s ease-in-out infinite 1s;
}
.l-btn-primary:hover {
  background: #6d28d9;
  box-shadow: 0 0 50px rgba(124,58,237,0.6), 0 8px 30px rgba(0,0,0,0.4);
  transform: translateY(-1px);
  text-decoration: none !important;
}

.l-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none !important;
  border: 1px solid rgba(255,255,255,0.14);
  transition: all 0.2s;
}
.l-btn-secondary:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.24);
  transform: translateY(-1px);
  text-decoration: none !important;
}

.l-hero-hint {
  font-size: 13px;
  color: var(--faint);
  margin-top: 20px;
  animation: fade-up 0.7s 0.4s ease both;
}

/* ── Terminal mockup ───────────────────────────────────────── */

.l-terminal-wrap {
  animation: fade-up 0.8s 0.3s ease both;
  position: relative;
}

.l-terminal-float {
  animation: float-y 6s ease-in-out infinite;
}

.l-terminal {
  background: rgba(7, 7, 12, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(124,58,237,0.15),
    0 30px 80px rgba(0,0,0,0.6),
    0 0 60px rgba(124,58,237,0.08);
  backdrop-filter: blur(20px);
}

.l-terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.l-terminal-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.l-terminal-dot-r { background: #ef4444; }
.l-terminal-dot-y { background: #f59e0b; }
.l-terminal-dot-g { background: #22c55e; }

.l-terminal-title {
  font-size: 12px;
  color: var(--faint);
  margin-left: 8px;
  font-weight: 500;
}

.l-terminal-body {
  padding: 20px 22px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  min-height: 280px;
}

.l-chat-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.l-chat-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.l-chat-avatar-user { background: rgba(124,58,237,0.3); color: #a78bfa; }
.l-chat-avatar-ai   { background: rgba(34,211,238,0.2); color: #22d3ee; }

.l-chat-content { flex: 1; }

.l-chat-name {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: 0.3px;
}
.l-chat-name-user { color: #a78bfa; }
.l-chat-name-ai   { color: #22d3ee; }

.l-chat-text {
  color: rgba(255,255,255,0.82);
  font-size: 13px;
}

.l-chat-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  background: rgba(34,211,238,0.08);
  border: 1px solid rgba(34,211,238,0.2);
  color: #22d3ee;
  font-size: 12px;
  margin-top: 6px;
}

.l-chat-result {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(34,197,94,0.07);
  border: 1px solid rgba(34,197,94,0.2);
  color: #4ade80;
  font-size: 12px;
  margin-top: 6px;
}

/* Terminal line reveal animation */
.l-tl { animation-duration: 12s; animation-timing-function: steps(1); animation-iteration-count: infinite; }
.l-tl-1 { animation-name: line-reveal-1; }
.l-tl-2 { animation-name: line-reveal-2; }
.l-tl-3 { animation-name: line-reveal-3; }
.l-tl-4 { animation-name: line-reveal-4; }
.l-tl-5 { animation-name: line-reveal-5; }
.l-tl-6 { animation-name: line-reveal-6; }
.l-tl-7 { animation-name: line-reveal-7; }
.l-tl-8 { animation-name: line-reveal-8; }
.l-tl-9 { animation-name: line-reveal-9; }

.l-cursor {
  display: inline-block;
  width: 7px; height: 14px;
  background: #22d3ee;
  border-radius: 1px;
  vertical-align: middle;
  animation: terminal-cursor 0.9s ease-in-out infinite;
}

/* ── Section wrapper ───────────────────────────────────────── */

.l-section {
  position: relative;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

.l-section-header {
  text-align: center;
  margin-bottom: 64px;
}

.l-section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(124,58,237,0.3);
  background: rgba(124,58,237,0.07);
  font-size: 12px;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.l-section-title {
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.1;
  margin: 0 0 16px;
}

.l-section-sub {
  font-size: 17px;
  color: var(--muted);
  max-width: 56ch;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Pillars (3 cards) ─────────────────────────────────────── */

.l-pillars {
  padding: 100px 0;
  background: linear-gradient(180deg, transparent, rgba(124,58,237,0.03) 50%, transparent);
}

.l-pillars-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.l-pillar-card {
  position: relative;
  border-radius: 20px;
  padding: 32px 28px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.l-pillar-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  border-color: rgba(124,58,237,0.3);
}

/* Aurora border on hover */
.l-pillar-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  background: conic-gradient(from var(--aurora-angle), #7c3aed, #22d3ee, #ef4444, #7c3aed);
  animation: aurora-spin 4s linear infinite;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.l-pillar-card:hover::before { opacity: 1; }

.l-pillar-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  font-size: 22px;
}
.l-pillar-icon-purple { background: rgba(124,58,237,0.15); border: 1px solid rgba(124,58,237,0.25); }
.l-pillar-icon-cyan   { background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.22); }
.l-pillar-icon-green  { background: rgba(34,197,94,0.12);  border: 1px solid rgba(34,197,94,0.22); }

.l-pillar-title {
  font-size: 19px;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.3px;
}

.l-pillar-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

.l-pillar-tag {
  display: inline-block;
  margin-top: 16px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.l-pillar-tag-purple { background: rgba(124,58,237,0.15); color: #a78bfa; }
.l-pillar-tag-cyan   { background: rgba(34,211,238,0.12); color: #22d3ee; }
.l-pillar-tag-green  { background: rgba(34,197,94,0.12);  color: #4ade80; }

/* ── How it works (timeline) ───────────────────────────────── */

.l-how {
  padding: 100px 0;
}

.l-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  position: relative;
}

/* Connecting line */
.l-steps::before {
  content: '';
  position: absolute;
  top: 32px;
  left: calc(12.5%);
  right: calc(12.5%);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.4), rgba(34,211,238,0.4), rgba(124,58,237,0.4), transparent);
}

.l-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 16px;
  position: relative;
}

.l-step-num {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(7,7,12,0.9);
  transition: all 0.3s ease;
}
.l-step-num-1 { box-shadow: 0 0 20px rgba(124,58,237,0.4); border-color: rgba(124,58,237,0.4); color: #a78bfa; }
.l-step-num-2 { box-shadow: 0 0 20px rgba(34,211,238,0.3); border-color: rgba(34,211,238,0.3); color: #22d3ee; }
.l-step-num-3 { box-shadow: 0 0 20px rgba(239,68,68,0.25); border-color: rgba(239,68,68,0.25); color: #f87171; }
.l-step-num-4 { box-shadow: 0 0 20px rgba(34,197,94,0.3);  border-color: rgba(34,197,94,0.3);  color: #4ade80; }

.l-step-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 8px;
}

.l-step-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.l-step-arrow {
  position: absolute;
  top: 22px;
  right: -8px;
  font-size: 16px;
  color: rgba(255,255,255,0.2);
  z-index: 2;
}

/* ── Features grid ─────────────────────────────────────────── */

.l-features {
  padding: 100px 0;
  background: linear-gradient(180deg, transparent, rgba(34,211,238,0.02) 50%, transparent);
}

.l-features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.l-feat-card {
  position: relative;
  border-radius: 20px;
  padding: 36px 32px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.l-feat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(124,58,237,0.25);
}

/* Glow accent in corner */
.l-feat-card::after {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  opacity: 0.12;
  transition: opacity 0.3s;
}
.l-feat-card:hover::after { opacity: 0.22; }
.l-feat-card-purple::after { background: #7c3aed; top: -60px; right: -60px; }
.l-feat-card-cyan::after   { background: #22d3ee; top: -60px; right: -60px; }
.l-feat-card-red::after    { background: #ef4444; top: -60px; right: -60px; }
.l-feat-card-green::after  { background: #22c55e; top: -60px; right: -60px; }

.l-feat-icon {
  font-size: 28px;
  margin-bottom: 16px;
  display: block;
  animation: float-y-slow 5s ease-in-out infinite;
}

.l-feat-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.3px;
}

.l-feat-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 20px;
}

.l-feat-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.l-feat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.l-feat-check {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #4ade80;
  flex-shrink: 0;
}

/* ── Stats bar ─────────────────────────────────────────────── */

.l-stats {
  padding: 80px 0;
}

.l-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(255,255,255,0.07);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.07);
}

.l-stat-item {
  padding: 36px 24px;
  text-align: center;
  background: rgba(255,255,255,0.02);
  transition: background 0.2s;
}
.l-stat-item:hover { background: rgba(255,255,255,0.05); }

.l-stat-num {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 8px;
}
.l-stat-num-purple { color: #a78bfa; }
.l-stat-num-cyan   { color: #22d3ee; }
.l-stat-num-green  { color: #4ade80; }
.l-stat-num-red    { color: #f87171; }

.l-stat-label {
  font-size: 13px;
  color: var(--faint);
  font-weight: 500;
}

/* ── CTA final ─────────────────────────────────────────────── */

.l-cta-section {
  padding: 120px 0;
  position: relative;
  overflow: hidden;
}

.l-cta-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(800px 400px at 50% 50%, rgba(124,58,237,0.18), transparent 60%),
    radial-gradient(400px 300px at 20% 80%, rgba(34,211,238,0.1), transparent 60%);
  pointer-events: none;
}

.l-cta-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px;
}

.l-cta-title {
  font-size: clamp(32px, 4.5vw, 56px);
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.05;
  margin: 0 0 20px;
}

.l-cta-sub {
  font-size: 17px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 40px;
}

.l-cta-btns {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Footer ────────────────────────────────────────────────── */

.l-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 32px 24px;
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.l-footer-copy {
  font-size: 13px;
  color: var(--faint);
}

.l-footer-links {
  display: flex;
  gap: 20px;
}

.l-footer-link {
  font-size: 13px;
  color: var(--faint);
  text-decoration: none !important;
  transition: color 0.2s;
}
.l-footer-link:hover { color: var(--muted); text-decoration: none !important; }

/* ── Divider ───────────────────────────────────────────────── */

.l-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
  margin: 0 24px;
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 900px) {
  .l-hero-inner { grid-template-columns: 1fr; gap: 48px; padding: 60px 20px 80px; }
  .l-terminal-wrap { max-width: 480px; margin: 0 auto; }
  .l-pillars-grid { grid-template-columns: 1fr; }
  .l-steps { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  .l-steps::before { display: none; }
  .l-step-arrow { display: none; }
  .l-features-grid { grid-template-columns: 1fr; }
  .l-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .l-nav-links { display: none; }
}

@media (max-width: 600px) {
  .l-hero-title { letter-spacing: -1px; }
  .l-steps { grid-template-columns: 1fr; }
  .l-stats-grid { grid-template-columns: 1fr 1fr; }
  .l-cta-btns { flex-direction: column; align-items: center; }
  .l-footer { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .l-orb, .l-hero-grid, .l-brand-ai, .l-hero-title-ai,
  .l-btn-primary::after, .l-pillar-card::before,
  .l-feat-icon, .l-cursor, .l-tl { animation: none !important; }
  .l-brand-ai, .l-hero-title-ai { color: #22d3ee; }
}

/* ── Admin Panel ──────────────────────────────────────────── */

.admin-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg1);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}

.admin-nav-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm, 6px);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.admin-nav-tab:hover { color: var(--text); background: var(--card); }
.admin-nav-tab--active {
  color: var(--text);
  background: var(--card);
  box-shadow: var(--shadow);
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.admin-kpi-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-bottom: 0;
}

.admin-stat-highlight {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.admin-stat-highlight .metric-card-value {
  color: var(--accent);
}

.metric-card-value {
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text);
}
.metric-card-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: var(--space-1);
}

.admin-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.admin-section-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.admin-section-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.admin-section-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.admin-detail-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.admin-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--stroke) 50%, transparent);
}
.admin-detail-row:last-child { border-bottom: none; }
.admin-detail-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}
.admin-detail-value {
  font-size: 13px;
  color: var(--text);
  text-align: right;
}

.admin-empty {
  font-size: 13px;
  color: var(--faint);
  padding: var(--space-3) 0;
}

.admin-filters {
  margin-bottom: var(--space-4);
}
.admin-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.admin-filter-input {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm, 6px);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  min-width: 180px;
}
.admin-filter-input:focus {
  outline: none;
  border-color: var(--accent);
}
.admin-filter-select {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm, 6px);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.admin-filter-select:focus { outline: none; border-color: var(--accent); }

.admin-result-count {
  font-size: 13px;
  color: var(--faint);
  margin-bottom: var(--space-3);
}

.admin-coupon-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.admin-coupon-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-start;
}
.admin-coupon-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1;
}
.admin-form-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

/* Row-card as link/div (non-details) */
a.row-card, div.row-card:not(details) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--text);
  transition: background 120ms ease;
}
a.row-card:hover { background: var(--card2, rgba(255,255,255,.03)); }

.row-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.row-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-card-meta {
  font-size: 12px;
  color: var(--muted);
}
.row-card-side {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Tag variants */
.tag--default {
  background: color-mix(in srgb, var(--muted) 15%, transparent);
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.tag--ok {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.tag--warn {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.tag--accent {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.tag--danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* BEM button variants */
.btn--sm { padding: 6px 14px; font-size: 13px; }
.btn--ghost { background: transparent; border-color: var(--stroke2); }
.btn--accent {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.btn--accent:hover {
  border-color: var(--accent2);
  background: linear-gradient(135deg, var(--accent-hover, var(--accent)), var(--accent2));
}
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }

/* ── Admin Data Table ── */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--stroke);
  white-space: nowrap;
}
.admin-table tbody tr {
  border-bottom: 1px solid var(--stroke);
  transition: background 100ms ease;
}
.admin-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.admin-table td {
  padding: 10px 12px;
  vertical-align: middle;
  color: var(--text);
}
.admin-table-num {
  text-align: center !important;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
}
.admin-table-date {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.admin-table-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  text-decoration: none;
}
.admin-table-link:hover {
  color: var(--accent);
}
.admin-table-sub {
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .admin-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-section-grid { grid-template-columns: 1fr; }
  .admin-coupon-form-row { flex-direction: column; }
  .admin-filter-form { flex-direction: column; }
  .admin-filter-input, .admin-filter-select { width: 100%; }
  .row-card-side { flex-direction: column; align-items: flex-end; }
  .admin-table { font-size: 12px; }
  .admin-table td, .admin-table thead th { padding: 8px 6px; }
}

/* ==============================
   Profile page
   ============================== */
.profile-page {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-avatar-letter {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}
.profile-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.profile-email {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}
.profile-meta {
  color: var(--faint);
  font-size: 0.82rem;
  margin: 0;
}
.profile-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.profile-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.profile-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-4) 0;
}
.profile-errors {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  color: var(--danger);
  font-size: 0.88rem;
}
.profile-errors p { margin: 2px 0; }
.profile-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.profile-required {
  font-weight: 400;
  color: var(--faint);
  font-size: 0.78rem;
}
.profile-input {
  background: var(--bg);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.15s ease;
  width: 100%;
}
.profile-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.profile-divider {
  border: none;
  border-top: 1px solid var(--stroke);
  margin: var(--space-2) 0;
}
.profile-section-hint {
  font-size: 0.82rem;
  color: var(--faint);
  margin: 0;
}
.profile-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-2);
}

.profile-card--stats { }
.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-3);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
}
.profile-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.profile-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.profile-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
}
.profile-plan-name {
  font-weight: 700;
  color: var(--accent2);
}

.profile-card--danger {
  border-color: rgba(239, 68, 68, 0.2);
}
.profile-danger-text {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 var(--space-3) 0;
}

@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
}

/* ==============================
   Chat history panel
   ============================== */
.chat-usage-badge {
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  color: var(--muted);
}
.chat-usage-badge--warn {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}
.chat-usage-badge--critical {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.chat-history-toggle {
  font-size: 0.85rem;
}
.chat-history-panel {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  max-height: 300px;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 300px; }
}
.chat-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}
.chat-history-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.chat-history-panel .chat-sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}
.chat-sidebar-conv {
  text-decoration: none;
}
.chat-sidebar-conv:hover {
  text-decoration: none;
}
