:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6f8;
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; }

button, input, textarea { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.panel, .workspace {
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(21, 30, 48, 0.08);
}

.form-panel { padding: 22px; }

.brand-block {
  border-bottom: 1px solid #e3e8ef;
  padding-bottom: 16px;
  margin-bottom: 18px;
}

.kicker { color: #0f766e; font-size: 12px; font-weight: 700; text-transform: uppercase; }

h1 { font-size: 24px; line-height: 1.18; margin: 8px 0 0; letter-spacing: 0; }

.settings-grid { display: grid; gap: 14px; }

label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #334155; }

input, textarea {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 11px;
  color: #111827;
  background: #ffffff;
}

textarea { min-height: 108px; resize: vertical; line-height: 1.45; }

input:focus, textarea:focus { outline: 2px solid #0f766e; outline-offset: 1px; }

.field-grid { display: grid; grid-template-columns: 1fr 100px; gap: 12px; }

.primary-button, .secondary-button, .actions button, .tab-button {
  min-height: 38px;
  border: 1px solid #b9c4d4;
  border-radius: 6px;
  padding: 8px 12px;
  color: #1f2937;
  background: #ffffff;
  cursor: pointer;
}

.primary-button { border-color: #0f766e; background: #0f766e; color: #ffffff; font-weight: 800; }
.secondary-button { background: #ffffff; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.chat-log {
  display: grid;
  gap: 10px;
  max-height: 310px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #f8fafc;
}

.chat-message {
  max-width: 88%;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.from-agent { justify-self: start; background: #ffffff; }
.from-user { justify-self: end; border-color: #0f766e; color: #083f3a; background: #e6f4f1; }

.chat-form { display: grid; gap: 10px; margin-top: 12px; }

.chat-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.chat-actions .primary-button { justify-self: stretch; }

.attachment-list { display: grid; gap: 6px; }

.attachment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 12px;
  background: #ffffff;
}

.attachment-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-item button { border: 0; color: #b42318; background: transparent; cursor: pointer; }

.settings-panel { margin-top: 14px; border: 1px solid #d8dee8; border-radius: 8px; padding: 10px 12px; }
.settings-panel summary { cursor: pointer; font-size: 13px; font-weight: 800; color: #334155; }
.settings-panel .settings-grid { margin-top: 12px; }

.status { margin-top: 16px; min-height: 38px; border-radius: 6px; padding: 10px 12px; background: #eef6f4; color: #14534d; font-size: 13px; }

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

.toolbar, .actions { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid #e3e8ef; }
.actions { justify-content: flex-end; background: #f8fafc; }

.tab-button.active { border-color: #1d4ed8; color: #1d4ed8; background: #eff6ff; font-weight: 800; }

.tab-content { display: none; overflow: auto; padding: 20px; }
.tab-content.active { display: block; }
.empty-state { color: #64748b; font-size: 15px; }

.document-card { max-width: 940px; margin: 0 auto; border: 1px solid #111827; background: #ffffff; }

.doc-header { display: grid; grid-template-columns: 1fr 210px; border-bottom: 1px solid #111827; }
.doc-title, .doc-meta { padding: 10px; }
.doc-title { text-align: center; border-right: 1px solid #111827; }
.doc-title strong { display: block; font-size: 14px; }
.doc-title span { display: block; margin-top: 6px; font-size: 12px; }
.doc-title h2 { margin: 12px 0 0; font-size: 15px; }
.doc-meta { display: grid; gap: 7px; font-size: 12px; }

.doc-section { padding: 16px 20px; border-top: 1px solid #d8dee8; }
.doc-section h3 { margin: 0 0 10px; font-size: 14px; }
.doc-section p, .doc-section li { font-size: 13px; line-height: 1.55; }

.document-diagram-output {
  min-height: 360px;
  overflow: auto;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
}

.document-diagram-output svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }

.records-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.records-table th, .records-table td { border: 1px solid #9ca3af; padding: 7px; vertical-align: top; }
.records-table th { background: #eef2f7; }

pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; }

.bpmn-canvas { width: 100%; height: 500px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; overflow: hidden; }
.bpmn-canvas .djs-container { width: 100%; height: 100%; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .doc-header { grid-template-columns: 1fr; }
  .doc-title { border-right: 0; border-bottom: 1px solid #111827; }
}

.hidden { display: none; }

.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px 0; }

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
}

.history-item:hover { background: #e8f0fe; border-color: #4a6cf7; }
.history-item-name { font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-meta { color: #64748b; white-space: nowrap; font-size: 11px; }
