:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #637169;
  --line: #d7ddd3;
  --paper: #f7f8f3;
  --panel: #ffffff;
  --sage: #24362f;
  --sage-2: #476355;
  --green: #27714f;
  --blue: #315f9f;
  --amber: #b26a12;
  --red: #b33b32;
  --rose: #f4e7e3;
  --gold: #f5ead2;
  --sky: #e3edf8;
  --mint: #e4f1e9;
  --shadow: 0 18px 45px rgba(23, 33, 29, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(36, 54, 47, 0.08), transparent 38%),
    repeating-linear-gradient(0deg, rgba(36, 54, 47, 0.035) 0 1px, transparent 1px 34px),
    var(--paper);
  color: var(--ink);
  font-family: "Aptos", "Sohne", "Helvetica Neue", sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(36, 54, 47, 0.15), transparent 42%),
    var(--paper);
}

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

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

.login-copy {
  margin-bottom: 0;
  color: var(--muted);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

select:disabled,
input:disabled {
  color: var(--muted);
  background: #f1f3ee;
  cursor: not-allowed;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
  background: var(--sage);
  color: white;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 28px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
}

.rail-nav {
  display: grid;
  gap: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 26px;
}

.icon-button:hover,
.icon-button.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}

.workspace {
  width: min(1460px, 100%);
  padding: 30px;
}

.topbar,
.section-heading,
.surface-header,
.status-strip,
.topbar-actions,
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

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

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

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
}

h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.status-strip {
  margin-bottom: 28px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.status-strip span {
  color: var(--muted);
}

.sync-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-field,
.compact-field {
  grid-template-columns: auto minmax(120px, 1fr);
  align-items: center;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.button.primary {
  background: var(--sage);
  color: white;
}

.button.secondary {
  border-color: var(--line);
  background: white;
  color: var(--sage);
}

.full-width {
  width: 100%;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: rise 220ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-heading {
  margin-bottom: 16px;
}

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

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

.metric strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric b {
  display: block;
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 40px;
  line-height: 1;
}

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

.split-grid,
.agent-layout,
.broker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.broker-grid {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.25fr);
  margin-bottom: 18px;
}

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

.surface-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.surface-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.record-list,
.pipeline-list,
.feed-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.feed-item {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.feed-item.alert {
  border-color: rgba(179, 59, 50, 0.28);
  background: #fff8f6;
}

.feed-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.feed-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.record:hover {
  border-color: rgba(36, 54, 47, 0.38);
}

.record-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.record-title h4 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.record-meta,
.record-next {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.record-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.type-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--sky);
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.blocked {
  background: var(--rose);
  color: var(--red);
}

.status-pill.overdue {
  background: var(--gold);
  color: var(--amber);
}

.status-pill.due-today,
.status-pill.due-soon {
  background: var(--sky);
  color: var(--blue);
}

.status-pill.complete {
  background: #e8e8e2;
  color: #686a62;
}

.pipeline-row {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebe3;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage-2);
}

.form-grid {
  display: grid;
  gap: 13px;
  padding: 16px;
}

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

.span-2 {
  grid-column: span 2;
}

.sticky-form {
  position: sticky;
  top: 20px;
}

.chat-surface {
  align-self: start;
}

.chat-log {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
}

.chat-message {
  width: min(92%, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.chat-message.user {
  justify-self: end;
  border-color: rgba(36, 54, 47, 0.3);
  background: var(--sage);
  color: white;
}

.chat-message.system {
  background: #f4f7f1;
  color: var(--muted);
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.narrow-surface {
  max-width: 820px;
}

.checklist-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f4f7f1;
}

.checklist-panel strong {
  display: block;
  margin-bottom: 8px;
}

.checklist-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.report-box {
  min-height: 460px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: var(--ink);
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split-grid,
  .agent-layout,
  .broker-grid {
    grid-template-columns: 1fr;
  }

  .sticky-form {
    position: static;
  }
}

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

  .rail {
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto;
    padding: 10px 14px;
  }

  .brand-mark {
    margin: 0;
  }

  .rail-nav {
    grid-auto-flow: column;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .surface-header,
  .status-strip,
  .topbar-actions,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

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

  .record {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-items: start;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
