:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #687385;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --soft: #eef6f5;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

.input-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
}

.brand-row,
.toolbar,
.column-head,
.actions,
.two-cols,
.saved-head {
  display: flex;
  align-items: center;
}

.brand-copy {
  display: grid;
  gap: 10px;
}

.brand-logo,
.doc-logo {
  max-width: 88px;
  height: auto;
  display: block;
}

.login-logo {
  max-width: 72px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.brand-row,
.toolbar,
.column-head {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 25px;
}

h2 {
  font-size: 21px;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.two-cols {
  align-items: start;
  gap: 12px;
}

.two-cols label {
  flex: 1;
}

.primary-action,
.actions button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  min-height: 44px;
  margin-top: 4px;
  background: var(--accent);
  color: white;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.saved-panel {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.saved-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.saved-panel h3 {
  margin: 0;
  font-size: 15px;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.documents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.documents-empty {
  color: var(--muted);
  font-size: 13px;
}

.document-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
  cursor: pointer;
}

.document-item:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.document-type {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.document-date {
  color: var(--muted);
  font-size: 12px;
}

#contract-button {
  border-color: #1d4ed8;
  color: #1d4ed8;
}

#contract-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.actions button[id^="ai-"] {
  border-color: #7c3aed;
  color: #6d28d9;
}

.proposal-preview .doc-brand {
  margin-bottom: 14px;
}

.proposal-preview .doc-footer {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.proposal-preview .doc-footer strong {
  color: #1d4ed8;
  font-size: 11px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  font-size: 22px;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.login-error {
  margin: 0;
  color: #b91c1c;
  font-size: 13px;
}

.workspace-panel {
  min-width: 0;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-content: start;
}

.workspace-panel.assistant-open {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}

.assistant-toggle {
  border-color: #7c3aed !important;
  color: #6d28d9 !important;
  font-weight: 800;
}

.assistant-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 126px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.assistant-panel[hidden] {
  display: none !important;
}

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.assistant-head h3 {
  margin: 0;
  font-size: 17px;
}

.assistant-head-actions {
  display: flex;
  gap: 6px;
}

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  background: #f8fafc;
}

.assistant-message {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.assistant-message p {
  margin: 0;
}

.assistant-message-user {
  justify-self: end;
  background: #ede9fe;
  color: #4c1d95;
  border: 1px solid #ddd6fe;
}

.assistant-message-bot {
  justify-self: start;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid var(--line);
}

.assistant-message-bot strong {
  color: #1d4ed8;
}

.assistant-typing {
  opacity: 0.7;
  font-style: italic;
}

.assistant-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.assistant-chip {
  border: 1px solid #ddd6fe;
  background: #f5f3ff;
  color: #5b21b6;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.assistant-chip:hover {
  background: #ede9fe;
}

.assistant-form {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.assistant-form textarea {
  resize: vertical;
  min-height: 72px;
}

.assistant-form .primary-action {
  margin-top: 0;
  min-height: 40px;
}


.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.actions button {
  min-height: 38px;
  background: #f8fafc;
  border-color: var(--line);
  color: var(--ink);
  padding: 8px 12px;
}

.actions button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  margin-top: 18px;
  height: calc(100vh - 126px);
  min-height: 560px;
}

.editor-column,
.preview-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.column-head {
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#proposal-editor {
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 18px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  resize: none;
}

.proposal-preview {
  overflow: auto;
  padding: 28px;
  line-height: 1.58;
}

.proposal-preview h1 {
  margin-bottom: 22px;
  font-size: 28px;
}

.proposal-preview .doc-brand {
  margin-bottom: 24px;
}

.proposal-preview h2 {
  margin-top: 28px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: #1d4ed8;
  font-size: 18px;
}

.proposal-preview .sign-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
}

.proposal-preview .sign-table th,
.proposal-preview .sign-table td {
  border: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.proposal-preview p,
.proposal-preview li {
  color: #2f3a47;
}

@media (max-width: 980px) {
  .app-shell,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .workspace-panel.assistant-open {
    grid-template-columns: 1fr;
  }

  .assistant-panel {
    height: min(520px, 70vh);
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-grid {
    height: auto;
  }

  #proposal-editor,
  .proposal-preview {
    min-height: 460px;
  }
}

@media (max-width: 620px) {
  .workspace-panel,
  .input-panel {
    padding: 16px;
  }

  .toolbar,
  .two-cols {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }
}
