:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #657188;
  --line: #dfe6ef;
  --blue: #1d5fd1;
  --blue-soft: #e7f0ff;
  --green: #14845c;
  --amber: #a86600;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(25, 38, 64, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: not-allowed; }
.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
.app-shell { min-height: 100vh; }
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 420px;
  gap: 48px;
  align-items: center;
  padding: 8vw;
  background:
    linear-gradient(135deg, rgba(29, 95, 209, .14), transparent 34%),
    radial-gradient(circle at 78% 20%, rgba(20, 132, 92, .14), transparent 26%),
    #f6f8fb;
}
.login-brand { max-width: 780px; display: flex; gap: 24px; align-items: flex-start; }
.brand-mark {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: linear-gradient(135deg, #114db5, #159a70);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 30px;
  box-shadow: var(--shadow);
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 10px; font-size: 20px; box-shadow: none; }
.eyebrow { color: var(--blue); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.login-brand h1 { font-size: clamp(40px, 5vw, 72px); line-height: 1; margin: 8px 0 18px; letter-spacing: 0; }
.login-copy { font-size: 20px; color: var(--muted); max-width: 620px; }
.login-card {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(223,230,239,.9);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}
.login-card label { display: grid; gap: 8px; color: var(--muted); font-weight: 700; }
.error-text { color: var(--red); min-height: 20px; margin: 0; }
.dashboard { padding: 22px; display: grid; gap: 18px; }
.topbar, .tasks-card, .legend-panel, .chat-panel, .output-panel, .metrics-row article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(25, 38, 64, .04);
}
.topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metrics-row article { padding: 16px; display: grid; gap: 8px; }
.metrics-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metrics-row strong { font-size: 26px; }
.tasks-card { padding: 16px; }
.section-head, .panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
h2, h3 { margin: 0; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }
.section-head p, .panel-head p { margin: 4px 0 0; font-size: 13px; }
.filters { display: flex; gap: 10px; min-width: 360px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--panel-soft); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fbff; }
.status-pill {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--blue-soft);
  color: var(--blue);
}
.status-pill.ready { color: var(--amber); background: #fff4df; }
.status-pill.draft { color: var(--green); background: #e6f7ef; }
.status-pill.error { color: var(--red); background: #ffe9e7; }
.workspace-grid {
  display: grid;
  grid-template-columns: 290px minmax(380px, 1fr) minmax(430px, .95fr);
  gap: 18px;
  align-items: start;
}
.legend-panel, .chat-panel, .output-panel { padding: 16px; min-height: 640px; }
.legend-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.legend-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}
.legend-list strong { display: block; margin-bottom: 6px; }
.legend-list span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.compliance-box {
  margin-top: 16px;
  border: 1px solid #b8d5ff;
  background: #f0f6ff;
  border-radius: 8px;
  padding: 12px;
}
.chat-panel { display: grid; grid-template-rows: auto 1fr auto; }
.chat-log {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  min-height: 360px;
}
.message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.message.user { margin-left: auto; background: var(--blue); color: #fff; }
.message.system { background: #edf2f7; color: var(--ink); }
.chat-form { display: grid; gap: 10px; margin-top: 12px; }
.chat-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.output-sections { display: grid; gap: 12px; max-height: 980px; overflow: auto; padding-right: 4px; }
.output-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.output-section.muted { background: var(--panel-soft); }
.output-section h3 { font-size: 16px; margin-bottom: 8px; }
.output-section pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #273244;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.output-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.output-list li { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
a { color: var(--blue); text-decoration: none; font-weight: 700; }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .legend-panel, .chat-panel, .output-panel { min-height: auto; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .login-screen { grid-template-columns: 1fr; padding: 24px; }
  .topbar, .section-head { flex-direction: column; align-items: stretch; }
  .filters, .topbar-actions, .chat-options { min-width: 0; grid-template-columns: 1fr; flex-direction: column; }
  .metrics-row { grid-template-columns: 1fr; }
  .dashboard { padding: 12px; }
}
