:root {
  color-scheme: dark;
  --bg: #03101f;
  --bg-2: #061b34;
  --panel: #071a31;
  --panel-2: #0a223f;
  --panel-3: #0c2b52;
  --sidebar: #020814;
  --atfx-blue: #0756b8;
  --atfx-blue-soft: rgba(7, 86, 184, 0.18);
  --atfx-red: #ee4e1c;
  --atfx-red-soft: rgba(238, 78, 28, 0.17);
  --line: rgba(130, 176, 229, 0.22);
  --line-strong: rgba(238, 78, 28, 0.5);
  --text: #f6f9ff;
  --muted: #a9bbd4;
  --faint: #6f819b;
  --good: #35d184;
  --warn: #f4b451;
  --bad: #ff6b5f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(7, 86, 184, 0.22), transparent 34%),
    linear-gradient(180deg, #020915 0%, var(--bg) 46%, #020814 100%);
  color: var(--text);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.026) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.72), transparent 78%);
}

.demo-shell {
  min-height: 100vh;
  position: relative;
}

.login-panel {
  width: min(600px, calc(100vw - 32px));
  margin: 8vh auto;
  padding: 42px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--atfx-red);
  background:
    linear-gradient(180deg, rgba(10, 34, 63, 0.96), rgba(4, 18, 35, 0.96)),
    var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.login-brand-row,
.header-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.login-brand-row {
  justify-content: space-between;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.login-brand-row span,
.mode-pill,
.status-pill {
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 7px 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
}

.brand-logo {
  display: block;
  width: 132px;
  height: auto;
}

.eyebrow {
  margin: 0 0 9px;
  color: #8dbdff;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 3vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 { font-size: 1.8rem; letter-spacing: 0; }

h3 {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.lead, .demo-header p, .hero-panel p, .notice {
  color: var(--muted);
  line-height: 1.6;
}

.micro-copy {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 0.82rem;
}

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

.login-form label,
.provision-form label,
.proposal-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.login-form label { grid-column: 1 / -1; }

input,
select {
  width: 100%;
  border: 1px solid rgba(141, 189, 255, 0.2);
  background: #030c18;
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  border-radius: 4px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(7, 86, 184, 0.55);
  border-color: rgba(141, 189, 255, 0.75);
}

button {
  border: 1px solid var(--atfx-blue);
  border-left: 4px solid var(--atfx-red);
  background: linear-gradient(180deg, #0d65cf, var(--atfx-blue));
  color: #ffffff;
  padding: 13px 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
}

button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: 0.6; }

.login-form button { grid-column: 1 / -1; }
.form-error, .form-note { color: var(--warn); font-weight: 800; }

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

.demo-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(2, 8, 20, 0.98);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  min-height: 78px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand .brand-logo {
  width: 96px;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.94rem;
}

.sidebar-brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.nav-group {
  display: grid;
  gap: 7px;
}

.nav-group-title {
  color: var(--faint);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 10px 2px;
}

.nav-item {
  min-height: 40px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  background: transparent;
  color: rgba(231, 238, 248, 0.72);
  box-shadow: none;
  text-align: left;
  padding: 0 12px;
  position: relative;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.08);
  border-left-color: var(--atfx-red);
  color: #ffffff;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.user-badge {
  color: #d8e8ff;
  font-weight: 900;
  font-size: 0.8rem;
}

.demo-workspace {
  min-width: 0;
  padding: 26px;
}

.demo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

.panel,
.metric,
.notice-panel,
.record-card {
  border: 1px solid rgba(141, 189, 255, 0.16);
  background: rgba(7, 26, 49, 0.92);
  border-radius: 6px;
}

.panel,
.notice-panel {
  padding: 22px;
}

.notice-panel {
  grid-column: 1 / -1;
  color: var(--muted);
  border-left: 4px solid var(--atfx-red);
}

.hero-panel {
  background:
    linear-gradient(135deg, rgba(7, 86, 184, 0.28), rgba(238, 78, 28, 0.08)),
    rgba(7, 26, 49, 0.94);
  border-left: 4px solid var(--atfx-red);
}

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

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.35rem;
}

.metric.positive strong,
.positive,
.status-pill.success { color: var(--good); }

.metric.warning strong,
.status-pill.warning { color: var(--warn); }

.equity-chart {
  width: 100%;
  height: 260px;
  background:
    linear-gradient(180deg, rgba(141, 189, 255, 0.08), rgba(141, 189, 255, 0.015)),
    #041323;
  border-radius: 4px;
}

.equity-chart polyline {
  fill: none;
  stroke: #62a6ff;
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.table-frame {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid rgba(141, 189, 255, 0.12);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.kv {
  display: grid;
  gap: 12px;
  margin: 0;
}

.kv div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(141, 189, 255, 0.1);
  padding-bottom: 10px;
}

.kv dt { color: var(--muted); }
.kv dd {
  margin: 0;
  text-align: right;
  font-weight: 900;
}

.kv small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.client-list,
.message-list,
.folder-pane,
.chat-layout aside {
  display: grid;
  gap: 8px;
}

.client-row,
.message-row,
.folder-pane button,
.chat-layout aside button {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 1px solid rgba(141, 189, 255, 0.12);
  border-left: 2px solid transparent;
  background: rgba(255, 255, 255, 0.026);
  color: var(--text);
  text-align: left;
}

.client-row.active,
.message-row.active,
.folder-pane button.active {
  border-left-color: var(--atfx-red);
  background: var(--atfx-blue-soft);
}

.client-row span,
.client-row em,
.message-row span,
.message-row em,
.chat-layout aside small {
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
}

.profile-blocks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.profile-blocks section {
  border: 1px solid rgba(141, 189, 255, 0.12);
  border-radius: 6px;
  padding: 14px;
}

.pill-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pipeline-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.pipeline-stage {
  min-height: 520px;
  border: 1px solid rgba(141, 189, 255, 0.16);
  border-radius: 6px;
  background: rgba(7, 26, 49, 0.88);
  padding: 12px;
}

.pipeline-stage header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pipeline-stage header span {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
}

.opportunity-card,
.record-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.opportunity-card dl,
.record-card dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.opportunity-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.opportunity-card dd,
.opportunity-card dt { margin: 0; }

.comms-layout,
.chat-layout {
  display: grid;
  grid-template-columns: 220px minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.message-preview,
.chat-layout main {
  border: 1px solid rgba(141, 189, 255, 0.12);
  border-radius: 6px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.12);
}

.chat-layout {
  grid-template-columns: 260px minmax(0, 1fr);
}

.chat-thread {
  display: grid;
  gap: 12px;
  min-height: 310px;
  align-content: start;
}

.chat-bubble {
  width: min(620px, 82%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.04);
}

.chat-bubble.right {
  justify-self: end;
  background: var(--atfx-blue-soft);
}

.chat-bubble span {
  color: var(--muted);
  font-size: 0.78rem;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

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

.record-card span,
.record-card p {
  color: var(--muted);
  margin: 0;
}

.proposal-form button {
  grid-column: 1 / -1;
}

.compliance-note,
.empty-state {
  border: 1px solid rgba(141, 189, 255, 0.12);
  border-radius: 6px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.026);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .demo-sidebar {
    position: static;
    height: auto;
  }
  .sidebar-nav {
    max-height: 340px;
  }
  .section-grid,
  .metric-grid,
  .split-layout,
  .profile-blocks,
  .comms-layout,
  .chat-layout,
  .automation-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .span-2,
  .span-3 {
    grid-column: span 1;
  }
}

@media (max-width: 680px) {
  .login-panel,
  .demo-workspace {
    padding: 18px;
  }
  .login-brand-row,
  .demo-header {
    display: block;
  }
  .brand-logo {
    width: 112px;
    margin-bottom: 14px;
  }
  .login-form,
  .provision-form,
  .proposal-form,
  .chat-composer {
    grid-template-columns: 1fr;
  }
}
