:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #607080;
  --line: #d9e0e7;
  --accent: #176f6b;
  --accent-dark: #0f5552;
  --warning: #d9980f;
  --warning-dark: #a96800;
  --error: #b42318;
  --error-bg: #fff0ed;
  --ok: #166534;
  --ok-bg: #ecfdf3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

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

.tool-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.sidebar-header {
  display: grid;
  gap: 14px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand small {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.tool-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.tool-link:hover {
  background: #f1f5f9;
  color: var(--text);
}

.tool-link.is-active {
  border-color: #b7d3d1;
  background: #edf7f6;
  color: var(--accent-dark);
}

.tool-link.is-disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

.tool-link.is-disabled:hover {
  background: transparent;
  color: #94a3b8;
}

.tool-link small {
  flex: 0 0 auto;
  color: inherit;
  font-size: 0.75rem;
}

.sidebar-account {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #e7eef4;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-account strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.content-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 2rem;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.15rem;
}

.panel {
  display: block;
  margin-bottom: 18px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-panel {
  padding: 18px;
}

.selected-device-panel {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}

.selected-device-panel span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.selected-device-panel strong {
  min-width: 0;
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.login-screen {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
}

.home-intro {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.home-intro h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.home-intro p {
  max-width: 46rem;
  margin: 0;
  color: var(--muted);
}

.login-screen .alert {
  width: min(420px, 100%);
}

.login-panel {
  width: min(420px, 100%);
  margin-bottom: 0;
}

.login-button {
  width: 100%;
}

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

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-error {
  color: var(--error);
  font-size: 0.82rem;
}

label,
dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
}

.button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.button-secondary {
  background: #334155;
}

.button-warning {
  background: var(--warning);
  color: #17202a;
}

.button-warning:hover {
  background: var(--warning-dark);
  color: #ffffff;
}

.button-danger {
  background: #b42318;
}

.button-danger:hover {
  background: #912018;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid;
}

.alert-ok {
  border-color: #bbf7d0;
  background: var(--ok-bg);
  color: var(--ok);
}

.alert-error {
  border-color: #fecaca;
  background: var(--error-bg);
  color: var(--error);
}

.alert-warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.alert a {
  color: inherit;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.field-inline {
  margin-bottom: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.results-meta-row {
  margin-top: 0;
  margin-bottom: 14px;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-summary {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.vo-project-table strong,
.vo-project-table small {
  display: block;
}

.vo-project-table small {
  margin-top: 3px;
  color: var(--muted);
}

.table-actions {
  text-align: right;
  white-space: nowrap;
}

.table-action-group {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.table-action-group form {
  margin: 0;
}

.vo-empty-state {
  display: grid;
  gap: 4px;
  padding: 26px 0;
  text-align: center;
}

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

.project-identity-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.project-identity-band div {
  display: grid;
  gap: 3px;
  padding: 14px 18px;
  background: var(--panel);
}

.project-identity-band span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.project-identity-band strong {
  overflow-wrap: anywhere;
}

.text-ok {
  color: var(--ok);
}

.text-warning {
  color: #92400e;
}

.vo-project-content-width,
.vo-project-form,
.project-identity-band.vo-project-content-width,
.danger-zone.vo-project-content-width {
  width: min(100%, 820px);
  max-width: 820px;
}

.form-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin: 6px 0 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.form-section-heading:not(:first-of-type) {
  margin-top: 20px;
}

.form-section-heading h2 {
  margin: 0;
}

.form-section-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.input-with-unit input {
  border-radius: 6px 0 0 6px;
}

.input-with-unit span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.checkbox-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 8px 0 22px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
}

.checkbox-field strong,
.checkbox-field small {
  display: block;
}

.checkbox-field small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 400;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
  border-color: #f0b4ae;
}

.danger-zone h2,
.danger-zone p {
  margin: 0;
}

.danger-zone h2 {
  color: #912018;
  font-size: 1rem;
}

.danger-zone p {
  margin-top: 4px;
  color: var(--muted);
}

.danger-zone form {
  flex: 0 0 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;
}

.text-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.project-context-band,
.assessment-snapshot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.assessment-snapshot {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.project-context-band div,
.assessment-snapshot div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--panel);
}

.project-context-band span,
.assessment-snapshot span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.project-context-band strong,
.assessment-snapshot strong {
  overflow-wrap: anywhere;
}

.vo-assessment-table strong,
.vo-assessment-table small {
  display: block;
}

.vo-assessment-table small {
  margin-top: 3px;
  color: var(--muted);
}

.assessment-status-draft {
  background: #e0f2fe;
  color: #075985;
}

.assessment-status-review {
  background: #fef3c7;
  color: #92400e;
}

.assessment-status-finalized {
  background: #fef3c7;
  color: #854d0e;
}

.assessment-status-published {
  background: var(--ok-bg);
  color: var(--ok);
}

.assessment-status-superseded {
  background: #e5e7eb;
  color: #475569;
}

.assessment-content-width {
  width: min(100%, 940px);
  max-width: 940px;
}

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

.assessment-field-wide {
  grid-column: 1 / -1;
}

.json-field {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
}

.assessment-method-section[hidden] {
  display: none;
}

.device-search-feedback {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.device-search-feedback[hidden] {
  display: none;
}

[data-device-search-results] {
  transition: opacity 0.15s ease;
}

[data-device-search-results].is-loading {
  opacity: 0.55;
}

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

.device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.device-main {
  min-width: 0;
}

.device-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.device-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 0.78rem;
}

.history-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.history-table th,
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

.history-table td {
  color: var(--text);
}

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

.history-table code {
  color: #334155;
  font-size: 0.82rem;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-success {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-failed {
  background: var(--error-bg);
  color: var(--error);
}

.status-running {
  background: #eff6ff;
  color: #1d4ed8;
}

.status-validated {
  background: #fffbeb;
  color: #92400e;
}

.history-error-row td {
  padding-top: 0;
  color: var(--error);
  font-size: 0.86rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.attribute-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.attribute-header h2 {
  margin-bottom: 4px;
}

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

.price-editor {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.price-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.price-meta span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.price-meta strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.price-meta small {
  color: var(--muted);
  font-size: 0.82rem;
}

.price-field {
  margin-bottom: 0;
}

.attribute-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attribute-key {
  min-width: 0;
}

.attribute-key label {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}

.attribute-key span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.confirm-import {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.confirm-copy {
  min-width: 0;
}

.confirm-copy h2 {
  margin-bottom: 4px;
}

.confirm-import form {
  flex: 0 0 auto;
}

.import-status {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

.import-status.is-visible {
  display: flex;
}

.import-status[hidden] {
  display: none;
}

.import-error {
  margin-top: 14px;
  margin-bottom: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.summary-grid div {
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.messages {
  margin: 0;
  padding-left: 20px;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 16px;
  background: #101828;
  color: #f8fafc;
  border-radius: 6px;
  font-size: 0.9rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .assessment-snapshot > :last-child {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .app-layout {
    display: block;
  }

  .tool-sidebar {
    position: static;
    height: auto;
    gap: 16px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-nav {
    grid-template-columns: 1fr;
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .content-shell,
  .shell {
    width: min(100% - 20px, 1040px);
    padding-top: 20px;
  }

  .topbar,
  .grid,
  .search-row,
  .device-row,
  .attribute-header,
  .price-editor,
  .attribute-row,
  .selected-device-panel,
  .confirm-import,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .page-actions,
  .form-section-heading,
  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .danger-zone .button {
    width: 100%;
  }

  .page-actions .button {
    width: 100%;
  }

  .form-section-heading span {
    text-align: left;
  }

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

  .project-context-band,
  .assessment-snapshot,
  .assessment-fields-grid {
    grid-template-columns: 1fr;
  }

  .assessment-snapshot > :last-child {
    grid-column: auto;
  }

  .table-action-group {
    align-items: stretch;
    flex-direction: column;
  }

  .table-action-group .button {
    width: 100%;
  }

  .confirm-import {
    display: grid;
    align-items: start;
  }

  .confirm-import form,
  .confirm-import .button {
    width: 100%;
  }

  .attribute-header {
    display: grid;
  }

  .topbar {
    display: block;
  }

  h1 {
    font-size: 1.55rem;
  }
}
