:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --panel: #151f36;
  --border: #243252;
  --text: #e8eefc;
  --muted: #93a4c7;
  --accent: #22c55e;
  --accent2: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2b4d 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #123528 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
}

a { color: var(--accent2); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #04120a;
}
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pill {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
}
.pill.ok { border-color: #166534; color: #86efac; }
.pill.warn { border-color: #854d0e; color: #fde68a; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(340px, 1.1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}
.layout-3 {
  grid-template-columns: minmax(300px, 1.15fr) minmax(240px, 0.75fr) minmax(300px, 1.1fr);
}
@media (max-width: 1200px) {
  .layout-3 { grid-template-columns: 1fr 1fr; }
  .layout-3 .preview-pane { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .layout, .layout-3 { grid-template-columns: 1fr; }
  .preview-pane { border-left: none !important; border-top: 1px solid var(--border); min-height: 70vh; }
  .inputs-pane { border-left: none !important; border-top: 1px solid var(--border); }
}

.chat-pane, .preview-pane, .inputs-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-pane {
  border-right: 1px solid var(--border);
  background: rgba(17, 26, 46, 0.55);
}
.inputs-pane {
  border-right: 1px solid var(--border);
  background: rgba(12, 18, 32, 0.75);
  max-height: calc(100vh - 64px);
  overflow: hidden;
}
.preview-pane {
  border-left: 1px solid transparent;
  background: rgba(8, 12, 22, 0.5);
}
/* Two-column for Glenn (simple mode): chat + preview only */
.layout-simple {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(280px, 1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}
@media (max-width: 900px) {
  .layout-simple {
    grid-template-columns: 1fr;
  }
}

.guide-banner {
  margin: 0 1.1rem 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #1e3a2f;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(14, 165, 233, 0.08));
}
.guide-step {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #86efac;
  margin-bottom: 0.35rem;
}
.guide-prompt {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.guide-hint {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.answer-choices {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0 1.1rem 0.75rem;
}
.wishlist-box {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #1e3a2f;
  background: rgba(34, 197, 94, 0.1);
  color: #d1fae5;
  font-size: 0.88rem;
  line-height: 1.45;
}
.wishlist-box strong {
  color: #86efac;
  display: block;
  margin-bottom: 0.35rem;
}
.answer-btn {
  font: inherit;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  animation: answerIn 0.25s ease both;
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #132033;
  transform: translateY(-1px);
}
.answer-btn:active:not(:disabled) {
  transform: translateY(0);
}
.answer-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.answer-btn-label {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}
@keyframes answerIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1.1rem 0.55rem;
}
.chip-btn {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--muted);
  cursor: pointer;
}
.chip-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.action-toast {
  margin: 0 1.1rem 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid #166534;
  color: #bbf7d0;
  font-size: 0.78rem;
}
.msg .md-strong { font-weight: 700; color: #f0fdf4; }
.msg.assistant .bogged-line {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
  color: #fde68a;
  font-style: italic;
}
.brief-form {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.brief-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.brief-form input,
.brief-form textarea {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
}
.brief-form textarea { min-height: 56px; resize: vertical; }
.brief-form-actions {
  padding: 0.65rem 1rem 0.9rem;
  border-top: 1px solid var(--border);
}

.pane-title {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.pane-title h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.progress {
  width: 140px;
  height: 8px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.35s ease;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.msg {
  max-width: 92%;
  padding: 0.8rem 0.95rem;
  border-radius: 12px;
  line-height: 1.45;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
}
.msg.user {
  align-self: flex-end;
  background: #163528;
  border: 1px solid #1f6b45;
}
.msg .role {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.msg.typing { opacity: 0.7; font-style: italic; }

.composer {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem 1rem;
  background: rgba(11, 18, 32, 0.9);
}
.composer-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font: inherit;
}
.composer textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  border-color: var(--accent);
}
.btn {
  border: none;
  border-radius: 12px;
  padding: 0.7rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: #04120a;
  background: var(--accent);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.mic {
  min-width: 52px;
  background: #1e3a5f;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.mic.listening {
  background: #7f1d1d;
  border-color: #ef4444;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.composer-hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.checklist {
  padding: 0 1.1rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip.done {
  border-color: #166534;
  color: #86efac;
  background: rgba(22, 101, 52, 0.2);
}

/* Preview dashboard */
.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}
.dash {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.dash-top {
  padding: 1rem 1.15rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #17233d, var(--bg2));
}
.dash-top h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}
.dash-top .sub { color: var(--muted); font-size: 0.85rem; }
.badge-demo {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: #422006;
  color: var(--warn);
  border: 1px solid #854d0e;
}

.module-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}
.mod-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  background: #0f172a;
  cursor: pointer;
  user-select: none;
}
.mod-toggle input { accent-color: var(--accent); }
.mod-toggle.on {
  color: #d1fae5;
  border-color: #166534;
  background: rgba(22, 101, 52, 0.25);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.1rem;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
}
.kpi .label { color: var(--muted); font-size: 0.75rem; }
.kpi .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--accent);
}
.kpi .hint { color: var(--muted); font-size: 0.7rem; margin-top: 0.2rem; }

.charts {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem;
  padding: 0 1.1rem 1.1rem;
}
@media (max-width: 700px) {
  .charts { grid-template-columns: 1fr; }
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
}
.card h4 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  height: 140px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  height: 100%;
  justify-content: flex-end;
}
.bar {
  width: 100%;
  max-width: 36px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  min-height: 4px;
}
.bar-col span { font-size: 0.65rem; color: var(--muted); }

.donut-row {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}
.donut {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0 38%, #38bdf8 38% 62%, #a78bfa 62% 80%, #fbbf24 80% 100%);
  position: relative;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 22px;
  background: var(--panel);
  border-radius: 50%;
}
.legend { flex: 1; font-size: 0.78rem; color: var(--muted); }
.legend div { margin: 0.2rem 0; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 500; }
.tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: #1e293b;
  color: var(--muted);
}
.tag.low { background: #7f1d1d; color: #fecaca; }
.tag.hire { background: #1e3a5f; color: #bae6fd; }

.hidden { display: none !important; }
.footer-note {
  padding: 0 1.1rem 1.1rem;
  font-size: 0.72rem;
  color: var(--muted);
}
