html {
  color-scheme: light only;
}

:root {
  --white: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light only;
  }
}

body {
  margin: 0;
}

.helm-shell {
  display: flex;
  min-height: 100vh;
}

.helm-sidebar {
  width: 250px;
  min-height: 100vh;
  background: var(--primary);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s ease;
  overflow: hidden;
}

.helm-sidebar.collapsed {
  width: 64px;
}

.helm-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.helm-brand > a {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-decoration: none;
  font-size: 1.1rem;
}

.sidebar-toggle {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.25rem;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.site-context {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.site-context span,
.site-context small {
  display: block;
}

.site-context span {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.site-context strong {
  display: block;
  color: var(--white);
  margin-top: 0.25rem;
}

.site-context small {
  color: rgba(255, 255, 255, 0.65);
}

.helm-sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.helm-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
  padding: 0.7rem 1.25rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.helm-sidebar nav a i {
  font-size: 1.25rem;
  min-width: 1.25rem;
}

.helm-sidebar nav a:hover,
.helm-sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

.helm-sidebar nav a.active {
  border-left-color: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.sidebar-foot > span,
.sidebar-foot a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.helm-sidebar.collapsed .helm-brand > a,
.helm-sidebar.collapsed .site-context,
.helm-sidebar.collapsed nav a span,
.helm-sidebar.collapsed .sidebar-foot span span,
.helm-sidebar.collapsed .sidebar-foot a span {
  display: none;
}

.helm-sidebar.collapsed .helm-brand {
  justify-content: center;
  padding-inline: 0;
}

.helm-sidebar.collapsed .sidebar-toggle i::before {
  content: "\E13C";
}

.helm-sidebar.collapsed nav a {
  justify-content: center;
  padding-inline: 0;
}

.helm-sidebar.collapsed .sidebar-foot {
  flex-direction: column;
  align-items: center;
  padding-inline: 0;
}

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

.helm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  padding: 1.5rem 2rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.helm-topbar h1 {
  margin: 0.15rem 0 0;
  padding: 0 0 0.4rem;
  border-bottom: 3px solid var(--accent);
  display: inline-block;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.topbar-status,
.button-row,
.inline-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.helm-content {
  padding-top: 2rem;
}

.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 2rem;
  margin-bottom: 2rem;
}

.page-intro p {
  max-width: 720px;
  margin-top: 0;
  color: var(--muted);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric {
  background: var(--primary);
  color: var(--white);
  padding: 1.25rem;
  border-left: 4px solid var(--accent);
}

.metric strong {
  display: block;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 400;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.78);
}

.desk-grid,
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 1.5rem;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 2rem;
  margin-bottom: 2rem;
}

.surface h2,
.surface h3 {
  display: inline-block;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.surface-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.surface-head > .button {
  white-space: nowrap;
}

.surface-head h2,
.surface-head h3,
.surface-head p {
  margin-top: 0;
}

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

.tool-list,
.ledger-list,
.context-list,
.decision-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tool-list li,
.context-list li,
.decision-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.tool-list li:last-child,
.context-list li:last-child,
.decision-list li:last-child {
  border-bottom: 0;
}

.tool-list strong,
.context-list strong {
  display: block;
}

.tool-list small,
.context-list small {
  display: block;
  color: var(--muted);
}

.ledger-list li {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.ledger-list time,
.ledger-list small {
  color: var(--muted);
}

.ledger-list code,
.command-key {
  overflow-wrap: anywhere;
}

.badge-error {
  background: var(--danger);
  color: var(--white);
}

.command-preview {
  background: var(--status-info-bg);
  border-left: 4px solid var(--status-info-border);
  padding: 1rem;
  margin: 1rem 0;
}

.command-preview code {
  display: block;
  margin-top: 0.5rem;
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.identity-block {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.identity-item {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.identity-item span {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.empty-state {
  border: 1px dashed var(--border);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--muted);
}

.empty-state i {
  display: block;
  color: var(--accent);
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state h3 {
  border: 0;
  color: var(--color);
  display: block;
}

.table-actions {
  white-space: nowrap;
}

.table-actions form {
  display: inline-block;
  margin: 0;
}

.table-actions button {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.command-table,
.capability-table {
  table-layout: fixed;
  width: 100%;
}

.command-table th:nth-child(1) { width: 22%; }
.command-table th:nth-child(2) { width: 13%; }
.command-table th:nth-child(3) { width: 21%; }
.command-table th:nth-child(4) { width: 9%; }
.command-table th:nth-child(5) { width: 26%; }
.command-table th:nth-child(6) { width: 9%; }

.capability-table th:nth-child(1) { width: 14%; }
.capability-table th:nth-child(2) { width: 42%; }
.capability-table th:nth-child(3) { width: 12%; }
.capability-table th:nth-child(4) { width: 18%; }
.capability-table th:nth-child(5) { width: 14%; }

.command-table td,
.capability-table td {
  overflow-wrap: anywhere;
}

.ledger-detail {
  margin-top: 0.5rem;
}

.ledger-detail summary {
  cursor: pointer;
  color: var(--primary);
}

.ledger-detail pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.875rem;
}

.ledger-list li > div {
  min-width: 0;
}

.ledger-detail > small {
  display: block;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.policy-warning {
  margin-top: 1rem;
}

.login-page {
  background: var(--primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 2rem;
  margin: 0 auto;
}

.login-card h1 {
  color: var(--primary);
  border-bottom: 3px solid var(--accent);
  display: inline-block;
  padding-bottom: 0.5rem;
}

.login-card .eyebrow {
  color: var(--accent);
}

@media (max-width: 1100px) {
  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1.5rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
  }

  .responsive-table tr:first-child {
    padding-top: 0;
  }

  .responsive-table tr:last-child {
    border-bottom: 0;
  }

  .responsive-table td {
    border: 0;
    padding: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .responsive-table .table-actions {
    align-self: end;
  }
}

@media (max-width: 800px) {
  .helm-sidebar {
    width: 64px;
  }

  .helm-sidebar .helm-brand > a,
  .helm-sidebar .site-context,
  .helm-sidebar nav a span,
  .helm-sidebar .sidebar-foot span span,
  .helm-sidebar .sidebar-foot a span,
  .sidebar-toggle {
    display: none;
  }

  .helm-sidebar nav a {
    justify-content: center;
    padding-inline: 0;
  }

  .helm-sidebar .sidebar-foot {
    flex-direction: column;
    align-items: center;
    padding-inline: 0;
  }

  .helm-topbar,
  .page-intro,
  .surface-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-strip,
  .identity-block {
    grid-template-columns: 1fr;
  }

  .ledger-list li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .responsive-table tr {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
