:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --border: #d7dde8;
  --text: #132033;
  --muted: #627085;
  --primary: #1e66f5;
  --secondary: #f59e0b;
  --success: #0f9d58;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; }

.shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.brand-lockup { display: flex; align-items: center; gap: 14px; padding: 8px 4px 2px; }
.brand-lockup h1 { margin: 0 0 4px; font-size: 22px; }
.brand-lockup p { margin: 0; color: var(--muted); }
.brand-badge {
  width: 52px; height: 52px; border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white; font-weight: 800; font-size: 20px;
  box-shadow: var(--shadow);
}

.section-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.section-head h2 { margin: 0; font-size: 18px; }
.stack { display: flex; flex-direction: column; }
.gap-md { gap: 12px; }
.gap-sm { gap: 8px; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.overline { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--muted); font-weight: 700; }
.hidden { display: none !important; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input,
.field select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}
.field input:focus,
.field select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 102, 245, 0.12);
}

.btn, .icon-btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  transition: 0.2s ease;
}
.btn:hover, .icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #4f46e5); color: white; border: none; }
.btn-secondary { background: linear-gradient(135deg, var(--secondary), #fb923c); color: #fff; border: none; }
.icon-btn { width: 46px; height: 46px; display: inline-grid; place-items: center; font-size: 18px; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: rgba(30, 102, 245, 0.12); color: var(--primary);
}
.pill-soft { background: rgba(15, 23, 42, 0.06); color: var(--muted); }
.status-dot { width: 12px; height: 12px; border-radius: 999px; background: #cbd5e1; display: inline-block; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 6px rgba(15, 157, 88, 0.12); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.12); }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, #122139, #1f3d73 55%, #335ca8);
  color: white;
}
.hero h2 { margin: 6px 0 8px; font-size: 28px; }
.hero p { margin: 0; max-width: 760px; color: rgba(255,255,255,0.85); }
.hero .overline { color: rgba(255,255,255,0.72); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn { background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.18); }
.hero .btn-primary { background: linear-gradient(135deg, #f59e0b, #f97316); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 16px;
  min-height: 0;
}

.chat-panel, .proposal-panel { min-height: 72vh; display: flex; flex-direction: column; }
.messages {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(180deg, #fbfdff 0%, #f6f9fe 100%);
  min-height: 340px;
  max-height: 55vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.message.assistant { align-self: flex-start; background: #eef4ff; border: 1px solid #cfe0ff; }
.message.user { align-self: flex-end; background: #1e293b; color: white; }
.message.system { align-self: center; background: #fff8e8; border: 1px solid #f8d58d; color: #7a4b00; }

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 6px;
}
.quick-reply {
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: white;
  padding: 8px 12px;
  color: var(--text);
}
.quick-reply:hover { border-color: var(--primary); color: var(--primary); }

.upload-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px 0;
}
.upload-field input { padding: 10px; }

.composer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.proposal-toolbar { margin-bottom: 10px; }
.proposal-editor {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  min-height: 480px;
  background: white;
  overflow: auto;
  line-height: 1.55;
}
.proposal-editor:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 102, 245, 0.12); }
.proposal-editor h1, .proposal-editor h2, .proposal-editor h3 { color: var(--text); }
.proposal-editor ul { padding-left: 18px; }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 26px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f5f8ff 100%);
}
.loader {
  width: 46px; height: 46px;
  border-radius: 999px;
  border: 4px solid rgba(30, 102, 245, 0.18);
  border-top-color: var(--primary);
  animation: spin 0.85s linear infinite;
}
.loading-title { font-weight: 800; }
.loading-message { color: var(--muted); text-align: center; max-width: 440px; }

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

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .content-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .hero, .chat-panel, .proposal-toolbar, .section-head > div, .loading-state { display: none !important; }
  .main, .proposal-panel, .proposal-editor, body { padding: 0 !important; margin: 0 !important; background: white !important; box-shadow: none !important; }
  .proposal-panel.card { border: none !important; box-shadow: none !important; }
  .proposal-editor { border: none !important; min-height: auto !important; }
}
