:root {
  color-scheme: light;
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --ink: #18211f;
  --muted: #64706b;
  --line: #dfe4dc;
  --green: #2f6f5e;
  --green-strong: #194e43;
  --mint: #d9eee5;
  --blue: #315f86;
  --amber: #b97522;
  --red: #b8483c;
  --shadow: 0 18px 44px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 272px 1fr;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 16px;
}

.login-logo {
  width: 92px;
  height: 92px;
  border-radius: 8px;
  object-fit: cover;
  background: #061014;
}

.login-error {
  border: 1px solid #f0c8c2;
  border-radius: 8px;
  background: #fff0ee;
  color: var(--red);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.role-hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  background: #172622;
  color: #eef7f2;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: #061014;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #b7c9c0;
  font-size: 13px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #dfeae5;
  background: transparent;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item span {
  width: 20px;
  text-align: center;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 6px;
}

.sidebar-note small,
.sidebar-note span {
  color: #b7c9c0;
}

.app-shell {
  min-width: 0;
  padding: 28px;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.tenant-switch {
  min-width: 260px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1.05;
  max-width: 780px;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 0;
}

.primary-action,
.secondary-action,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
}

.primary-action {
  background: var(--green);
  color: white;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

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

.secondary-action {
  background: var(--mint);
  color: var(--green-strong);
  padding: 0 14px;
  font-weight: 800;
}

.danger-action {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  background: #f7dedb;
  color: var(--red);
  padding: 0 14px;
  font-weight: 800;
}

.icon-button {
  width: 36px;
  display: grid;
  place-items: center;
  background: #edf2ee;
  color: var(--ink);
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.workspace-grid.wide-left {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  gap: 7px;
}

.project-list {
  display: grid;
  gap: 10px;
}

.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.project-card:hover,
.project-card:focus {
  border-color: var(--green);
  box-shadow: 0 12px 28px rgba(47, 111, 94, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.project-card h3 {
  margin: 0 0 5px;
  font-size: 17px;
}

.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--green-strong);
  background: var(--mint);
  white-space: nowrap;
  align-self: start;
}

.badge.warning {
  color: #713f12;
  background: #f7e5c3;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

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

.timeline li {
  border-left: 4px solid var(--line);
  padding: 0 0 0 12px;
}

.timeline li.done {
  border-left-color: var(--green);
}

.timeline strong {
  display: block;
  margin-bottom: 3px;
}

.timeline span {
  color: var(--muted);
  font-size: 13px;
}

.project-form,
.assistant-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.assistant-form {
  grid-template-columns: 1fr;
}

.full {
  grid-column: 1 / -1;
}

.hidden {
  display: none;
}

.dropzone {
  min-height: 168px;
  border: 2px dashed #b7c7be;
  border-radius: 8px;
  background: #f7fbf8;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone span,
.empty-state {
  color: var(--muted);
}

.extraction-result {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

#createFromUploadBtn {
  width: 100%;
  margin-top: 12px;
}

.card-text-input {
  margin-top: 14px;
}

.upload-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 12px;
}

.upload-review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.upload-review .full {
  grid-column: 1 / -1;
}

.import-notice {
  border-left: 4px solid var(--amber);
  background: #fff8e8;
  color: #68400d;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.field-chip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
  font-size: 13px;
}

.document-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.document-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.document-item strong {
  font-size: 14px;
}

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

.advisor-list {
  display: grid;
  gap: 10px;
}

.advisor-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 8px;
}

.advisor-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.advisor-card h3 {
  margin: 0;
  font-size: 16px;
}

.advisor-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.advisor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workflow-list {
  display: grid;
  gap: 12px;
}

.workflow-notice,
.workflow-step-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf8;
  color: var(--green-strong);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.workflow-step-note {
  margin-bottom: 0;
  background: #fff8e8;
  color: #68400d;
}

.workflow-step-note.ready {
  background: var(--mint);
  color: var(--green-strong);
}

.workflow-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.workflow-card.active {
  border-color: var(--green);
  background: #f3fbf6;
}

.workflow-card.locked {
  opacity: 0.62;
}

.workflow-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.workflow-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.workflow-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

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

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-list li.done {
  color: var(--green-strong);
}

.check-list li small {
  margin-left: auto;
  color: var(--muted);
  white-space: nowrap;
}

.todo-check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 8px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

.todo-check input {
  width: 16px;
  min-height: 16px;
  margin-top: 1px;
}

.workflow-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-action {
  border: 0;
  border-radius: 8px;
  background: var(--mint);
  color: var(--green-strong);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
  margin-left: 4px;
}

.primary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.check-list li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  margin-top: 6px;
  flex: 0 0 auto;
}

.workflow-card.done .check-list li::before {
  background: var(--green);
}

.email-preview {
  margin-top: 14px;
}

.field-chip strong {
  color: var(--ink);
}

.answer-panel,
.document-preview-panel {
  min-height: 360px;
}

.assistant-answer {
  display: grid;
  gap: 12px;
}

.recommendation {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.recommendation h3 {
  margin: 0 0 8px;
}

.recommendation ul {
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
}

.document-preview {
  min-height: 280px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  font-family: "Cascadia Mono", Consolas, monospace;
  line-height: 1.55;
  background: #fbfcfa;
  color: #26312e;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
  background: rgba(23, 38, 34, 0.45);
}

.dialog-card {
  width: min(420px, calc(100vw - 36px));
  padding: 24px;
  display: grid;
  gap: 14px;
  position: relative;
}

.dialog-card p {
  color: var(--muted);
  margin-bottom: 4px;
}

.close-dialog {
  position: absolute;
  top: 12px;
  right: 12px;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .metric-grid,
  .workspace-grid,
  .workspace-grid.wide-left {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .project-card {
    display: grid;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-form {
    grid-template-columns: 1fr;
  }

  .upload-review-grid {
    grid-template-columns: 1fr;
  }
}
