:root {
  --ink: #f6efe6;
  --muted: #c4aea4;
  --line: #3d242c;
  --line-strong: #5a3038;
  --canvas: #10080c;
  --surface: #1c1016;
  --header: #070406;
  --header-line: #3a1818;
  --accent: #e85d04;
  --accent-soft: #3a1c0c;
  --ok: #b6f5c8;
  --ok-bg: #123226;
  --ok-line: #1f6b45;
  --warn: #ffc56b;
  --warn-bg: #3a240c;
  --warn-line: #8a5a16;
  --gap: #ff8b96;
  --gap-bg: #3a1218;
  --gap-line: #8a3038;
  --info: #ffd0a8;
  --info-bg: #3a2214;
  --info-line: #8a4e24;
  --neutral: #e7d7cf;
  --neutral-bg: #2a1a20;
  --neutral-line: #5a3a44;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, rgba(232, 93, 4, 0.18), transparent 46%),
    var(--canvas);
  color-scheme: dark;
}

html[data-scheme="light"] body {
  color-scheme: light;
  background: var(--canvas);
}
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
}

.skip:focus {
  top: 12px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  background: var(--header);
  color: var(--ink);
  border-bottom: 1px solid var(--header-line);
}

.bar,
.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-product {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-org {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.header-status:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.header-status.is-user {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

#header-status-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-facts {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
}

.profile-facts dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-facts dd {
  margin: 4px 0 0;
}

#panel-profile {
  padding-top: 28px;
}

.text-button {
  display: inline-block;
  margin: 8px 0 20px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6a00;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.22);
}

.hero {
  position: relative;
  padding: 36px 0 8px;
}

.hero-copy {
  position: relative;
  padding-right: 108px;
}

.hero-mask {
  position: absolute;
  top: 0;
  right: 0;
  width: 92px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(232, 93, 4, 0.45));
  pointer-events: none;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 28px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.lede {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metrics div {
  padding: 16px 18px 14px;
}

.metrics div + div {
  border-left: 1px solid var(--line);
}

.metrics dd {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metrics dt {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}

.metrics p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.workspace {
  padding: 28px 0 64px;
}

.tablist {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-strong);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.tab:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.card-link:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-count {
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--neutral);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.tab[aria-selected="true"] .tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.banner {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--info-line);
  border-radius: 10px;
  background: var(--info-bg);
  color: #ffd7b0;
}

.banner.error {
  border-color: var(--gap-line);
  background: var(--gap-bg);
  color: var(--gap);
}

.panel {
  padding-top: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 260px;
}

.field-narrow {
  flex-basis: 180px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.toolbar-note {
  margin: 0 0 8px auto;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

td:nth-child(n + 2),
th:nth-child(n + 2) {
  white-space: nowrap;
}

th {
  background: var(--header);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--accent-soft);
}

.placeholder-row td,
.empty-cell {
  color: var(--muted);
  background: var(--surface);
}

.control-ref {
  display: inline-block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: #ffb088;
}

.control-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.control-desc {
  margin: 4px 0 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--neutral-line);
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--neutral);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn);
}

.badge-gap {
  background: var(--gap-bg);
  border-color: var(--gap-line);
  color: var(--gap);
}

.badge-info {
  background: var(--info-bg);
  border-color: var(--info-line);
  color: var(--info);
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card:hover {
  border-color: #e85d04;
}

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

.card-type {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card h2,
.card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

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

.card-meta {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--neutral);
  font-size: 13px;
}

.card-meta span {
  color: var(--muted);
}

.card-link {
  align-self: flex-start;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
}

.card-empty {
  min-height: 0;
  grid-column: 1 / -1;
  box-shadow: none;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--header);
  color: var(--muted);
  font-size: 13px;
}

.footer-bar {
  min-height: 64px;
  align-items: center;
}

.footer-bar p {
  margin: 0;
}

@media (max-width: 860px) {
  .hero-copy {
    padding-right: 0;
  }

  .hero-mask {
    position: static;
    display: block;
    margin-bottom: 12px;
  }

  .hero-layout,
  .metrics {
    grid-template-columns: 1fr;
  }

  .metrics div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .bar,
  .footer-bar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }

  .toolbar-note {
    margin-left: 0;
  }
}

.account-bar,
.gate-actions,
.record-form,
.member-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.account-bar {
  align-items: center;
}

.company-switch select,
.header-button,
.gate button,
.record-form button,
.member-row button,
.member-row select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.gate,
.record-form,
.member-list {
  margin-top: 16px;
}

.gate {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.invite-link {
  overflow-wrap: anywhere;
  color: var(--accent);
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-row {
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#mfa-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 12px 0;
  background: #fff;
  border-radius: 8px;
}

.app-frame {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

#sidebar {
  width: 250px;
  flex: 0 0 250px;
  padding: 28px 0 40px;
  background: var(--header);
  border-right: 1px solid var(--header-line);
}

.side-label {
  margin: 0;
  padding: 0 22px;
}

.side-brand {
  display: block;
  width: 206px;
  height: auto;
  margin: 0 22px 22px;
}

.company-side-label {
  margin: -12px 22px 18px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.company-side-label.is-big {
  font-size: 22px;
  line-height: 1.2;
}

.company-logo-text {
  margin: 0 22px 12px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.side-label {
  margin: 18px 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-group summary.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 0 4px;
  padding: 8px 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.side-group summary.side-label::-webkit-details-marker {
  display: none;
}

.side-group summary.side-label::marker {
  content: "";
}

.side-group summary.side-label::after {
  content: "▾";
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  transform: rotate(-90deg);
}

.side-group[open] summary.side-label::after {
  transform: none;
}

#sidebar details.side-group:not([open]) > a {
  display: none;
}

#sidebar a {
  display: block;
  padding: 9px 22px;
  color: var(--ink);
  text-decoration: none;
}

#sidebar a:hover,
#sidebar a.is-active {
  background: var(--surface);
  color: var(--accent);
}

.company-page {
  padding: 36px 0 64px;
}

.company-page p,
.company-page-body p,
.company-page-body ul,
.company-page-body ol {
  max-width: 62ch;
  margin: 16px 0 0;
  color: var(--ink);
  font-size: 18px;
}

.company-page-body :is(h1, h2, h3, h4) {
  margin: 0;
}

.company-page-body :is(h2, h3, h4, p, ul, ol, blockquote, table, pre) {
  margin-top: 16px;
}

.company-page-body a {
  color: var(--accent);
}

.app-main {
  flex: 1;
  min-width: 0;
}

.era-app h2 {
  margin: 0 0 16px;
}

.era-crumb,
.era-hint,
.era-empty {
  color: var(--muted);
}

.era-note {
  margin: 0 0 16px;
  color: var(--ok);
}

.era-actions,
.era-status {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.era-report {
  margin-top: 28px;
}

.era-report h3 {
  margin-bottom: 8px;
}

.era-pie {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}

.era-template {
  white-space: pre-wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.field-wide,
.check-field {
  flex-basis: 100%;
}

.era-table-wrap,
.heat-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.era-table,
.heat-map {
  width: 100%;
  border-collapse: collapse;
}

.era-table th,
.era-table td,
.heat-map th,
.heat-map td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.shell:has(.ide) {
  width: 100%;
  max-width: none;
  margin: 0;
}

.workspace:has(.ide) {
  padding: 0;
}

.ide {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 320px;
  height: calc(100vh - 73px);
  min-height: 560px;
  background: var(--header);
  color: var(--ink);
  border-top: 1px solid var(--line);
}

.ide-files,
.ide-chat,
.ide-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.ide-files,
.ide-chat {
  background: var(--canvas);
}

.ide-files {
  border-right: 1px solid var(--line);
}

.ide-chat {
  border-left: 1px solid var(--line);
}

.ide-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ide-pane-tools {
  display: flex;
  gap: 4px;
}

.ide-pane-head button,
.ide-pane-tools button,
.ide-chat-form button,
.ide-meta button {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.ide-file-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 12px;
  overflow: auto;
}

.ide-file {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ide-file small {
  color: var(--muted);
  font-size: 11px;
}

.ide-file-row {
  display: flex;
  align-items: center;
}

.ide-file-row .ide-file {
  flex: 1;
  min-width: 0;
}

.ide-file.is-off span {
  color: var(--muted);
}

.ide-switch {
  flex: none;
  height: 22px;
  margin-right: 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.ide-switch[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.ide-file.is-active {
  background: var(--surface);
}

.live-custom {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

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

.live-card h2,
.live-card p {
  margin: 0;
}

.live-card h2 {
  font-size: 16px;
}

.live-card p {
  margin-top: 4px;
}

.company-mount {
  padding: 0 16px;
}

.company-mount:empty {
  display: none;
}

.company-banner {
  margin: 12px auto;
  max-width: 1120px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--header);
}

.ide-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 36px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
}

.ide-tab button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  cursor: pointer;
}

.ide-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.ide-meta input,
.ide-meta select,
.ide-agent select,
.ide-chat-form textarea {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.ide-meta input[name="name"] {
  flex: 1 1 140px;
  min-width: 140px;
}

.ide-meta input[name="slug"],
.ide-meta input[name="description"] {
  flex: 0 0 140px;
}

.ide-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ide-code {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  resize: none;
}

.ide-foot,
.ide .era-note {
  margin: 0;
  padding: 6px 14px 10px;
  color: var(--muted);
  font-size: 12px;
}

.ide-agent {
  padding: 0 10px 8px;
}

.ide-agent select {
  width: 100%;
}

.ide-chat-log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.ide-chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ide-bubble {
  align-self: flex-end;
  max-width: 92%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  white-space: pre-wrap;
}

.ide-bubble-agent {
  align-self: flex-start;
  background: var(--accent-soft);
}

.ide-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.ide-chat-form textarea {
  flex: 1;
  height: auto;
  min-height: 72px;
  padding: 8px;
  resize: none;
}

#admin-nav .side-label {
  margin-top: 8px;
}

.era-table input,
.era-table select,
.era-table button,
.era-actions button,
.era-status button,
.heat-cell {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.era-table input[type="text"],
.era-table input[type="number"] {
  width: 100%;
  min-width: 72px;
}

.heat-map {
  min-width: 640px;
}

.heat-cell {
  width: 100%;
  cursor: pointer;
}

.heat-low {
  background: #123226;
}

.heat-mid {
  background: #3a240c;
}

.heat-high {
  background: #3a1218;
}

@media (max-width: 860px) {
  .app-frame {
    flex-direction: column;
  }

  #sidebar {
    width: auto;
    flex-basis: auto;
    border-right: 0;
    border-bottom: 1px solid var(--header-line);
  }

  .ide {
    grid-template-columns: 1fr;
    height: auto;
  }

  .ide-files,
  .ide-chat {
    min-height: 280px;
  }

  .ide-code {
    min-height: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
