:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(7, 17, 31, 0.78);
  --panel-soft: rgba(19, 33, 58, 0.82);
  --line: rgba(145, 180, 255, 0.18);
  --text: #eef4ff;
  --muted: #aec2e6;
  --accent: #76a8ff;
  --accent-2: #93f5d5;
  --danger: #ff9090;
  --warning: #ffd480;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(118, 168, 255, 0.15), transparent 32%),
    radial-gradient(circle at top right, rgba(147, 245, 213, 0.12), transparent 28%),
    linear-gradient(180deg, #081120 0%, #0b1830 55%, #07111f 100%);
  color: var(--text);
}

.shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 60px;
}

.hero {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 20px;
  align-items: stretch;
}

.hero.compact .hero-copy {
  padding: 28px;
}

.hero-copy, .hero-card, .panel, .card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.hero-copy {
  padding: 32px;
}

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.05; margin-bottom: 14px; max-width: 12ch; }
h2 { margin-bottom: 10px; }
p { color: var(--muted); line-height: 1.6; }
.small-copy { font-size: 0.95rem; }

.hero-actions, .dashboard-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.button:hover { transform: translateY(-1px); }
.primary { background: linear-gradient(135deg, var(--accent), #9b8cff); color: white; }
.secondary { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--line); }
.tertiary { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.hero-card {
  padding: 24px;
  background: var(--panel-soft);
}
.hero-card-badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(147, 245, 213, 0.12);
  color: var(--accent-2);
}
.profile-card h2 {
  margin-bottom: 6px;
}

main {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}
.panel {
  padding: 24px;
}

.login-panel, .contact-panel {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 24px;
  align-items: start;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

input, textarea, select {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  align-items: end;
}

.inline-form .button {
  width: 100%;
}

.corpus-form {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.hint, .message { min-height: 24px; margin-bottom: 0; }
.message.error { color: var(--danger); }
.message.success { color: var(--accent-2); }
.message.warning { color: var(--warning); }
.hidden { display: none; }

.chat-backdrop.hidden,
.chat-drawer.hidden {
  display: none !important;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(0, 0, 0, 0.32);
}

.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  min-width: 84px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), #9b8cff);
  color: white;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.chat-fab-icon {
  font-size: 1rem;
  margin-right: 8px;
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  z-index: 45;
  display: grid;
  grid-template-rows: 1fr auto;
  border-left: 1px solid var(--line);
  background: rgba(6, 12, 24, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: -24px 0 80px rgba(0, 0, 0, 0.35);
}

.chat-composer {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.chat-composer {
  border-bottom: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(11, 20, 38, 0.96);
}

.chat-body {
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.chat-empty {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
}

.chat-bubble {
  max-width: 92%;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
}

.chat-bubble.user {
  margin-left: auto;
  background: rgba(118, 168, 255, 0.18);
}

.chat-bubble.assistant {
  margin-right: auto;
  background: rgba(147, 245, 213, 0.08);
}

.chat-role {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.6;
}

.chat-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-attachment-list,
.chat-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.88rem;
}

.chat-image-preview {
  display: block;
  max-width: 180px;
  max-height: 180px;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.chat-attachments-bar {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-dropzone {
  display: none;
  margin-bottom: 12px;
  padding: 18px;
  border: 1px dashed rgba(147, 245, 213, 0.45);
  border-radius: 18px;
  background: rgba(147, 245, 213, 0.08);
  color: var(--text);
}

.chat-dropzone p {
  margin: 6px 0 0;
  font-size: 0.92rem;
}

.chat-dropzone.active {
  display: block;
}

.chat-attach-button {
  width: fit-content;
}

#chat-files {
  display: none;
}

.chat-composer textarea {
  min-height: 90px;
  margin-bottom: 8px;
}

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.chat-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.dashboard-header, .grid, .stack {
  display: grid;
  gap: 18px;
}
.dashboard-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
}
.grid.four-up {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.six-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.seven-up {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stack {
  margin-top: 8px;
}
.stack section > h3 {
  margin-bottom: 10px;
}
.card { padding: 20px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.report-preview {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  padding: 18px;
}

.report-preview h4 {
  margin: 0 0 12px;
}

.report-preview pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
}

th, td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: top;
}
th { color: var(--accent-2); font-size: 0.88rem; text-transform: uppercase; letter-spacing: 0.05em; }

@media (max-width: 920px) {
  .hero, .contact-panel, .login-panel, .dashboard-header, .grid, .grid.four-up, .grid.six-up, .grid.seven-up { grid-template-columns: 1fr; }
  .shell { width: min(100% - 20px, 1180px); }
  h1 { max-width: none; }
  .chat-drawer { width: 100vw; }
  .chat-fab { right: 16px; bottom: 16px; }
}
