:root {
  --bg: #070d1a;
  --bg-panel: rgba(255, 255, 255, 0.035);
  --bg-panel-solid: #0e1a30;
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-input-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-hover: rgba(226, 97, 28, 0.4);
  --fg: #eef2f8;
  --muted: #8b9bb8;
  --accent: #e2611c;
  --accent-2: #14b8a6;
  --danger: #fb7185;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  /* Custom chevron for every select */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b9bb8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; }

html { color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* Ambient gradient mesh */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px 400px at 15% -5%, rgba(226, 97, 28, 0.12), transparent 60%),
    radial-gradient(700px 500px at 85% 10%, rgba(20, 184, 166, 0.10), transparent 60%),
    radial-gradient(500px 400px at 50% 100%, rgba(226, 97, 28, 0.05), transparent 60%);
}

::selection { background: rgba(226, 97, 28, 0.3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 13px 28px;
  background: rgba(7, 13, 26, 0.78);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 1px 24px rgba(0, 0, 0, 0.25);
  border-bottom: none;
}
header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(226, 97, 28, 0.5), transparent);
}

.brand { display: flex; align-items: center; gap: 11px; white-space: nowrap; }
.brand-mark { filter: drop-shadow(0 0 10px rgba(226, 97, 28, 0.5)); flex-shrink: 0; }
.brand-word {
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 14px;
}
.brand-word em {
  font-style: normal;
  color: var(--accent);
  margin-left: 2px;
}
.brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  border: 1px solid rgba(226, 97, 28, 0.4);
  border-radius: 99px;
  padding: 3px 9px;
  margin-left: 4px;
  text-shadow: 0 0 10px rgba(226, 97, 28, 0.4);
}
.brand-tag-login {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-top: 6px;
}
.brand-bar {
  width: 8px;
  height: 24px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(226, 97, 28, 0.6);
}

nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }

.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 9px 15px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: 9px;
  position: relative;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--fg); background: var(--bg-panel); }
.tab.active { color: var(--fg); background: var(--bg-panel); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 15px;
  right: 15px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(226, 97, 28, 0.5);
}

/* ---- Buttons ---- */
.ghost {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s, transform 0.1s, background 0.15s;
}
.ghost:hover { color: var(--fg); border-color: var(--border-hover); background: var(--bg-input-hover); }
.ghost:active { transform: translateY(1px); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- Layout ---- */
main { flex: 1; padding: 28px; max-width: 1024px; width: 100%; margin: 0 auto; display: flex; }

.panel { display: none; flex: 1; flex-direction: column; gap: 18px; }
.panel.active { display: flex; animation: fadeUp 0.25s ease; }

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

/* ---- Selects (custom-styled everywhere) ---- */
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-input) var(--chevron) no-repeat right 12px center;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 36px 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
select:hover { border-color: var(--border-strong); background-color: var(--bg-input-hover); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15); }
select option { background: var(--bg-panel-solid); color: var(--fg); padding: 8px; }

/* ---- Switch toggles (checkboxes) ---- */
.toggle { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 99px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: transparent;
}
.toggle input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: #041018;
}

/* ---- Chat ---- */
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 320px; padding: 4px; }
.msg {
  max-width: 78%;
  padding: 13px 17px;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14px;
  animation: fadeUp 0.2s ease;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #041018;
  font-weight: 500;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 20px rgba(226, 97, 28, 0.25);
}
.msg.assistant {
  align-self: flex-start;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-left: 2px solid rgba(226, 97, 28, 0.5);
  backdrop-filter: blur(8px);
  border-bottom-left-radius: 5px;
}
.msg.error { align-self: flex-start; background: rgba(251, 113, 133, 0.1); border: 1px solid rgba(251, 113, 133, 0.3); color: var(--danger); }
.msg.thinking { display: flex; gap: 5px; align-items: center; padding: 16px 18px; }
.thinking .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s infinite;
}
.thinking .dot:nth-child(2) { animation-delay: 0.15s; }
.thinking .dot:nth-child(3) { animation-delay: 0.3s; }
/* ---- Plan card (Plan → Execute → Verify) ---- */
.plan-card {
  align-self: flex-start;
  max-width: 78%;
  background: linear-gradient(160deg, rgba(226, 97, 28, 0.07), rgba(226, 97, 28, 0.03));
  border: 1px solid rgba(226, 97, 28, 0.25);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  font-size: 13px;
  animation: fadeUp 0.25s ease;
}
.plan-head {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}
.plan-step { display: flex; align-items: center; gap: 8px; padding: 3px 0; color: var(--muted); transition: color 0.2s; }
.plan-step .step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--muted);
  flex-shrink: 0;
  font-size: 9px; line-height: 8px; text-align: center;
}
.plan-step.running { color: var(--fg); }
.plan-step.running .step-dot { border-color: var(--accent); background: var(--accent); animation: stepPulse 1s infinite; }
.plan-step.done { color: var(--ok); }
.plan-step.done .step-dot { border-color: var(--ok); background: none; color: var(--ok); }
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 97, 28, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(226, 97, 28, 0); }
}

.status-line { margin-left: 8px; font-size: 12.5px; color: var(--muted); font-style: normal; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-welcome {
  text-align: center;
  color: var(--muted);
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  position: relative;
}
.chat-welcome::before,
.chat-welcome::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.chat-welcome::before {
  width: 180px; height: 180px;
  background: rgba(226, 97, 28, 0.15);
  top: -30px; left: 12%;
  animation: float 7s ease-in-out infinite;
}
.chat-welcome::after {
  width: 220px; height: 220px;
  background: rgba(20, 184, 166, 0.13);
  bottom: -40px; right: 10%;
  animation: float 9s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.chat-welcome .big {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--accent);
}
.chat-welcome .suggestions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.chat-welcome .suggestion {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 99px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-welcome .suggestion:hover {
  color: var(--accent);
  border-color: var(--border-hover);
  box-shadow: 0 0 14px rgba(226, 97, 28, 0.15);
  transform: translateY(-1px);
}

.chat-input { display: flex; gap: 10px; }
.chat-input input, .chat-input select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 13px 17px;
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input select { padding-right: 36px; }
.chat-input input { flex: 1; }
.chat-input input:focus, .chat-input select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15), 0 0 24px rgba(226, 97, 28, 0.08);
}
.chat-input button {
  background: var(--accent);
  border: none;
  color: #041018;
  font-weight: 700;
  font-family: var(--font);
  padding: 13px 28px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(226, 97, 28, 0.25);
}
.chat-input button:hover { filter: brightness(1.1); box-shadow: 0 6px 24px rgba(226, 97, 28, 0.35); }
.chat-input button:active { transform: translateY(1px); }
.chat-input button:disabled { opacity: 0.5; cursor: default; filter: none; box-shadow: none; }

/* ---- Lists & cards ---- */
.toolbar { display: flex; gap: 10px; align-items: center; }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  backdrop-filter: blur(8px);
  position: relative;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  animation: fadeUp 0.3s ease backwards;
}
/* Staggered entrance */
.list .card:nth-child(2) { animation-delay: 0.03s; }
.list .card:nth-child(3) { animation-delay: 0.06s; }
.list .card:nth-child(4) { animation-delay: 0.09s; }
.list .card:nth-child(5) { animation-delay: 0.12s; }
.list .card:nth-child(6) { animation-delay: 0.15s; }
.list .card:nth-child(n+7) { animation-delay: 0.18s; }
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, rgba(226, 97, 28, 0.35), transparent 40%, rgba(226, 97, 28, 0.22));
  opacity: 0;
  transition: opacity 0.2s;
  z-index: -1;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.card:hover::before { opacity: 1; }
.card .title { font-size: 14px; line-height: 1.45; font-weight: 500; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 7px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card .actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.card .actions button { font-size: 12px; padding: 6px 12px; border-radius: 7px; border: none; cursor: pointer; font-family: var(--font); font-weight: 600; transition: filter 0.15s, transform 0.1s; }
.card .actions button:hover { filter: brightness(1.15); }
.card .actions button:active { transform: translateY(1px); }

.btn-approve { background: var(--ok); color: #052e1b; }
.btn-reject { background: none; border: 1px solid rgba(251, 113, 133, 0.5) !important; color: var(--danger); }
.btn-reject:hover { background: rgba(251, 113, 133, 0.1); }

/* ---- Pills ---- */
.pill { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.5px; box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.04); }
.pill.p1 { background: rgba(251, 113, 133, 0.15); color: var(--danger); border: 1px solid rgba(251, 113, 133, 0.35); text-shadow: 0 0 10px rgba(251, 113, 133, 0.4); }
.pill.p2 { background: rgba(251, 191, 36, 0.12); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.35); text-shadow: 0 0 10px rgba(251, 191, 36, 0.35); }
.pill.p3 { background: rgba(20, 184, 166, 0.12); color: var(--accent-2); border: 1px solid rgba(20, 184, 166, 0.35); text-shadow: 0 0 10px rgba(20, 184, 166, 0.35); }
.pill.status { background: var(--bg-input); color: var(--muted); border: 1px solid var(--border); }

.empty { color: var(--muted); text-align: center; padding: 48px 0; font-size: 14px; }

/* ---- Persona selector + agents admin ---- */
.persona-select { min-width: 130px; }

.persona-form {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(8px);
}
.persona-form.hidden { display: none; }
.persona-form h3 { font-size: 15px; }
.persona-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.persona-form input,
.persona-form textarea,
.persona-form select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.persona-form select { padding-right: 36px; }
.persona-form input:focus,
.persona-form textarea:focus,
.persona-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15); }
.form-actions { display: flex; gap: 10px; }
.form-actions button[type="submit"] {
  background: var(--accent);
  border: none;
  color: #041018;
  font-weight: 700;
  font-family: var(--font);
  padding: 11px 24px;
  border-radius: 9px;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
}
.form-actions button[type="submit"]:hover { filter: brightness(1.1); box-shadow: 0 4px 18px rgba(226, 97, 28, 0.25); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.card .actions .btn-edit { background: none; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.card .actions .btn-edit:hover { color: var(--fg); border-color: var(--border-hover); }
.card .actions .btn-default { background: none; border: 1px solid rgba(226, 97, 28, 0.4); color: var(--accent); font-weight: 500; }
.card .actions .btn-default:hover { background: rgba(226, 97, 28, 0.08); }
.default-tag { color: var(--accent); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Home dashboard ---- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.metric {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: fadeUp 0.25s ease;
}
.metric:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.metric::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.7;
}
.metric .value {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  color: var(--fg);
}
.metric .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; }
.metric.alert .value { color: var(--danger); }
.metric.alert::before { background: var(--danger); }
.section-title {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* Pipeline strip + client stages */
.pipeline { display: flex; gap: 8px; flex-wrap: wrap; }

/* Alphabet index */
.alpha-index { display: flex; gap: 3px; flex-wrap: wrap; }
.alpha-index button {
  min-width: 26px;
  padding: 3px 6px;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.12s;
}
.alpha-index button:hover { color: var(--fg); background: var(--bg-panel); }
.alpha-index button.active { color: var(--accent); border-color: var(--border-hover); background: var(--bg-panel); }
.alpha-index button.has-clients { color: var(--fg); }
#clientSearch {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-family: var(--font);
  flex: 1;
  max-width: 260px;
}
#clientSearch:focus { outline: none; border-color: var(--accent); }
.pipeline .stage {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.pipeline .stage b { color: var(--fg); }
.pill.stage-lead { background: var(--bg-input); color: var(--muted); border: 1px solid var(--border); }
.pill.stage-proposal { background: rgba(20,184,166,0.12); color: var(--accent-2); border: 1px solid rgba(20,184,166,0.3); }
.pill.stage-negotiation { background: rgba(251,191,36,0.12); color: var(--warn); border: 1px solid rgba(251,191,36,0.3); }
.pill.stage-won { background: rgba(52,211,153,0.12); color: var(--ok); border: 1px solid rgba(52,211,153,0.3); }
.pill.stage-lost { background: rgba(251,113,133,0.12); color: var(--danger); border: 1px solid rgba(251,113,133,0.3); }

/* ---- Integrations ---- */
.integration-card { flex-direction: column; align-items: stretch; }
.integration-head { display: flex; justify-content: space-between; align-items: center; }
.integration-head .title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.int-group { display: flex; flex-direction: column; gap: 12px; }
.int-group + .int-group { margin-top: 22px; }
.brand-card { flex-direction: column; align-items: stretch; }
.brand-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand-head .title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand-channel { margin-top: 12px; }
.channel-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.channel-head .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-fields { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(160px, 2fr) auto minmax(90px, 1fr); gap: 8px; margin-top: 6px; align-items: center; }
.channel-fields input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.channel-fields input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15); }
@media (max-width: 760px) { .channel-fields { grid-template-columns: 1fr 1fr; } }
.integration-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.integration-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.integration-fields input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.integration-fields input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15); }
.integration-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.integration-actions .save {
  background: var(--accent);
  border: none;
  color: #041018;
  font-weight: 700;
  font-family: var(--font);
  padding: 9px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
}
.integration-actions .save:hover { filter: brightness(1.1); box-shadow: 0 4px 16px rgba(226, 97, 28, 0.25); }
.test-result { font-size: 13px; font-weight: 500; }
.test-result.ok { color: var(--ok); }
.test-result.fail { color: var(--danger); }

/* ---- Storyline ---- */
.storyline { position: relative; padding-left: 28px; display: flex; flex-direction: column; gap: 12px; }
.storyline::before {
  content: "";
  position: absolute;
  left: 8px; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.3;
}
.story-day {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-top: 14px;
}
.story-event { position: relative; }
.story-event::before {
  content: "";
  position: absolute;
  left: -24px; top: 18px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(226, 97, 28, 0.6);
}
.story-event.kind-task::before { background: var(--accent-2); box-shadow: 0 0 10px rgba(20, 184, 166, 0.6); }
.story-persona {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 4px;
}
.story-artifact { margin-top: 10px; }
.story-artifact img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }

/* Two lanes: agent (left, burnt orange) vs client (right, indigo) */
.story-event.lane-client {
  margin-left: 56px;
  border-left: 2px solid var(--accent-2);
  background: linear-gradient(160deg, rgba(20, 184, 166, 0.06), rgba(255, 255, 255, 0.02));
}
.story-event.lane-client::before { background: var(--accent-2); }
.lane-tag { font-size: 10px; font-weight: 700; color: var(--accent-2); letter-spacing: 1px; text-transform: uppercase; margin-left: 6px; }
.email-body {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}
.episode-steps { max-height: 400px; overflow-y: auto; }

/* Nav more dropdown */
.nav-more { position: relative; }
.nav-more-menu {
  position: absolute;
  top: 100%; left: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 130px;
}
.nav-more-menu .tab { text-align: left; }
.file-group-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-group-title .group-actions { display: flex; gap: 6px; }
.file-group-title button { font-size: 11px; padding: 4px 10px; }
.file-card .thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.file-card:hover .thumb { transform: scale(1.04); }
.file-card .pdf-badge {
  width: 64px;
  height: 64px;
  border-radius: 9px;
  background: rgba(226, 97, 28, 0.16);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #f97316;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.file-card { align-items: center; }
.file-card .file-main { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1; }
.file-card .file-name { font-size: 13.5px; font-weight: 500; word-break: break-all; }
.file-card .actions button { font-weight: 500; }
.card.subagent { margin-left: 34px; border-left: 2px solid var(--accent-2); }
.card.subagent .title::before { content: "↳ "; color: var(--accent-2); }
.btn-copy { background: none; border: 1px solid var(--border); color: var(--muted); }
.btn-copy:hover { color: var(--fg); border-color: var(--border-hover); }
.btn-open { background: var(--bg-input); border: 1px solid var(--border); color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; }
.btn-publish { background: none; border: 1px solid rgba(226, 97, 28, 0.4); color: var(--accent); }

/* ---- Custom tools + jobs ---- */
.code-view {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  color: var(--muted);
  margin-top: 10px;
  width: 100%;
}
.card .details-toggle { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 4px 0; font-family: var(--font); }
.card .details-toggle:hover { text-decoration: underline; }

/* ---- Workflows ---- */
.step-row {
  display: grid;
  grid-template-columns: 130px 1fr 2fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.step-row input[type="text"], .step-row select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  border-radius: 8px;
}
.step-row select { padding-right: 32px; }
.step-row .step-remove { padding: 6px 10px; }
.pill.running { background: rgba(226, 97, 28, 0.12); color: var(--accent); border: 1px solid rgba(226, 97, 28, 0.3); }
.pill.waiting_approval { background: rgba(251, 191, 36, 0.12); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.3); }
.pill.done { background: rgba(52, 211, 153, 0.12); color: var(--ok); border: 1px solid rgba(52, 211, 153, 0.3); }
.pill.failed, .pill.cancelled { background: rgba(251, 113, 133, 0.12); color: var(--danger); border: 1px solid rgba(251, 113, 133, 0.3); }
.step-flow { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.6; }
.step-flow .gate-mark { color: var(--warn); }

/* ---- Auth gate ---- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(7, 13, 26, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.3s ease;
}
.login-card input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 97, 28, 0.15); }
.login-card button {
  background: var(--accent);
  border: none;
  color: #041018;
  font-weight: 700;
  font-family: var(--font);
  padding: 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: filter 0.15s;
}
.login-card button:hover { filter: brightness(1.1); }
.login-card .linklike {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 0 0;
  margin-top: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.login-card .linklike:hover { filter: brightness(1.2); }
.login-error { color: var(--danger); font-size: 13px; min-height: 16px; }
.user-badge { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---- User avatar menu ---- */
.user-menu { position: relative; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid transparent;
  background-clip: padding-box;
  color: var(--fg);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  position: relative;
  transition: transform 0.15s;
}
.avatar::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: var(--accent);
  z-index: -1;
}
.avatar:hover { transform: scale(1.06); }
.user-dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  width: 230px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 50;
  animation: fadeUp 0.15s ease;
}
.user-dropdown-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-dropdown-head .user-email { font-size: 13px; font-weight: 600; word-break: break-all; }
.user-dropdown-head .user-role { font-size: 11.5px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; margin-top: 3px; }
.user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: var(--font);
}
.user-dropdown button:hover { background: var(--bg-input-hover); }
.user-dropdown button.danger { color: var(--danger); }

/* ---- Drill-down drawer + lightbox ---- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(7, 13, 26, 0.6);
  backdrop-filter: blur(4px);
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 92vw);
  background: var(--bg-panel-solid);
  border-left: 1px solid var(--border-strong);
  box-shadow: -12px 0 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-size: 15px; word-break: break-word; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-body .detail-row { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.drawer-body .detail-row .k { color: var(--muted); min-width: 110px; flex-shrink: 0; font-weight: 500; }
.drawer-body .detail-row .v { word-break: break-word; white-space: pre-wrap; flex: 1; }
.drawer-body .detail-row .v a { color: var(--accent); }
.drawer-body .detail-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.drawer-body .detail-imgs img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.drawer-body .drawer-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
/* Forms hosted in the drawer get their title from the drawer head */
.drawer-body .persona-form { background: none; border: none; padding: 0; backdrop-filter: none; }
.drawer-body .persona-form h3 { display: none; }
.drawer-body .drawer-actions button, .drawer-body .drawer-actions a {
  font-size: 13px; padding: 9px 18px; border-radius: 8px; cursor: pointer;
  font-family: var(--font); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(7, 13, 26, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 88vw;
  max-height: 88vh;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--border-hover); }

/* Markdown content in assistant messages */
.msg.md { white-space: normal; }
.msg.md p { margin: 0 0 10px; }
.msg.md p:last-child { margin-bottom: 0; }
.msg.md h1, .msg.md h2, .msg.md h3, .msg.md h4 { font-size: 15px; margin: 14px 0 6px; }
.msg.md ul, .msg.md ol { margin: 6px 0 10px; padding-left: 20px; }
.msg.md li { margin: 3px 0; }
.msg.md strong { color: var(--fg); font-weight: 700; }
.msg.md code { background: var(--bg-input); padding: 2px 6px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; }
.msg.md pre { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.msg.md pre code { background: none; padding: 0; }
.msg.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; width: 100%; }
.msg.md th, .msg.md td { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; }
.msg.md th { background: var(--bg-input); font-weight: 600; }
.msg.md a { color: var(--accent); }
.msg.md blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--muted); margin: 8px 0; }
.msg.md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ---- Agent graph (orchestration visual) ---- */
.graph-wrap {
  position: relative;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(500px 260px at 50% 50%, rgba(226, 97, 28, 0.05), transparent 70%),
    rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
#agentGraph { width: 100%; height: 100%; display: block; }
.graph-tip {
  position: absolute;
  z-index: 5;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow);
  max-width: 240px;
}
.graph-tip b { display: block; margin-bottom: 2px; }
.graph-tip span { color: var(--muted); }

/* ---- Tokenomics ---- */
.sparkline { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.sparkline .bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.sparkline .bar:hover { opacity: 1; }
.cost-bar { height: 6px; border-radius: 99px; background: var(--accent); margin-top: 6px; }

/* Voice input */
.mic-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 46px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 17px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mic-btn:hover { color: var(--fg); border-color: var(--border-hover); }
.mic-btn.recording {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  animation: micPulse 1.2s infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(251, 113, 133, 0); }
}

/* ---- Skeleton loading ---- */
.skeleton {
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-panel) 25%, rgba(255, 255, 255, 0.07) 50%, var(--bg-panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 1400px) {
  .user-badge { display: none; }
  .tab { padding: 9px 11px; font-size: 13px; }
  header { gap: 18px; }
  .brand { letter-spacing: 2px; font-size: 13px; }
}

@media (max-width: 720px) {
  header { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  main { padding: 16px; }
  .msg { max-width: 92%; }
  .chat-input button { padding: 13px 18px; }
  .step-row { grid-template-columns: 1fr; }
}
