:root {
  color-scheme: light;
  --ink: #0b2545;
  --muted: #587188;
  --line: #d6e2ec;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --green: #0b83a5;
  --green-dark: #147b95;
  --blue: #1578c1;
  --red: #bd4d5b;
  --amber: #aa7211;
  --shadow: 0 6px 18px rgba(21, 62, 91, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f4f7fa;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

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

button.icon {
  width: 36px;
  padding: 0;
}

button.active {
  border-color: var(--green-dark);
  background: #e8f2fb;
  color: var(--green-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #eef3f6;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(11, 37, 69, 0.12);
  overflow: hidden;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.login-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.login-brand h1,
.login-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-brand h1 {
  font-size: 20px;
}

.login-brand p,
.login-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-copy {
  padding: 22px 24px 4px;
}

.login-copy h2 {
  font-size: 18px;
}

.login-panel .login {
  padding: 16px 24px 22px;
  border-bottom: 0;
}

.login-panel .login button {
  min-height: 42px;
  margin-top: 2px;
}

.login-status {
  min-height: 42px;
  padding: 11px 24px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.login-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.login-status.connected span {
  background: var(--green);
}

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

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.module-list {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.module-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.menu-list {
  overflow: auto;
  padding: 0 12px 18px;
}

.menu-group {
  margin: 12px 0;
}

.menu-group h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  margin-bottom: 5px;
  min-height: 34px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 68px;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.context-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.context-bar select {
  min-width: 150px;
}

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.status {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}

.status strong {
  font-size: 14px;
}

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

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

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 94px;
  box-shadow: var(--shadow);
}

.card small {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.card strong {
  display: block;
  font-size: 24px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  min-height: 54px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
  max-height: 470px;
}

.compact-table {
  max-height: 320px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafb;
  color: #314456;
  z-index: 1;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr[onclick] {
  cursor: pointer;
}

tbody tr[onclick]:hover,
tr.selected-row {
  background: #e8f2fb;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.lock-note {
  border-top: 1px solid var(--line);
  background: #fff8e8;
  color: var(--amber);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
}

.linked-note {
  border-bottom: 1px solid var(--line);
  background: #f4fafc;
  color: var(--green-dark);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef3f6;
  color: #314456;
  font-size: 12px;
  font-weight: 700;
}

.badge.green { background: #e8f2fb; color: var(--green-dark); }
.badge.amber { background: #fff0d4; color: var(--amber); }
.badge.red { background: #ffe2e2; color: var(--red); }

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

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.master-detail {
  display: grid;
  gap: 14px;
}

.sub-panel {
  box-shadow: none;
}

.report-sections {
  display: grid;
  gap: 4px;
}

.report-section + .report-section {
  border-top: 1px solid var(--line);
}

.section-title {
  padding: 12px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h4 {
  margin: 0;
  font-size: 13px;
}

.report-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 86px;
  text-align: left;
  width: 100%;
}

.report-tile strong {
  display: block;
  margin-bottom: 6px;
}

.report-tile span {
  color: var(--muted);
  font-size: 12px;
}

.report-tile em {
  display: block;
  margin-top: 8px;
  color: var(--amber);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.process-body,
.report-detail {
  padding: 14px;
}

.report-launch {
  padding: 34px 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.report-launch button {
  min-width: 128px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.report-filters label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.report-filters label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-filters input,
.report-filters select {
  width: 100%;
  min-width: 0;
}

.readiness {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fbfcfd;
}

.section-title.inline {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.section-title.inline span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.readiness-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.readiness-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 82px;
  background: white;
}

.readiness-card strong,
.readiness-card span {
  display: block;
}

.readiness-card span {
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.readiness-card.pending {
  border-color: #efc5c5;
  background: #fff8f8;
}

.readiness-card.pending span {
  color: var(--red);
}

.readiness-card ul {
  margin: 8px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 12px;
  background: #e7edf2;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-bar {
  height: 100%;
  background: var(--blue);
  transition: width 180ms ease;
}

.process-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0 14px;
  gap: 12px;
}

.process-meta span,
.step-row small,
.detail-line span,
.usage-block p {
  color: var(--muted);
  font-size: 12px;
}

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

.step-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.step-row > span {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: #eef3f6;
  color: #314456;
  font-size: 12px;
  font-weight: 800;
}

.step-row strong,
.usage-block strong,
.detail-line strong {
  display: block;
}

.step-row.traced > span,
.step-row.executed > span,
.step-row.skipped > span {
  background: #e8f2fb;
  color: var(--green-dark);
}

.step-row.skipped p {
  color: var(--muted);
}

.step-row.blocked > span,
.step-row.missing > span,
.step-row.needs-mapping > span {
  background: #ffe2e2;
  color: var(--red);
}

.step-row p {
  margin: 6px 0 0;
  color: var(--red);
  font-size: 12px;
}

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

.report-action {
  grid-column: 1 / -1;
  border: 1px solid #c5e1d5;
  background: #f4fafc;
  color: var(--green-dark);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.report-detail h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.detail-line,
.usage-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fbfcfd;
}

.usage-block p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.empty.compact {
  padding: 18px;
  text-align: left;
}

.error {
  color: var(--red);
}

.error-banner {
  border: 1px solid #f0b4b4;
  background: #fff1f1;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(23, 32, 42, 0.25);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  background: white;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .report-grid { grid-template-columns: 1fr; }
  .report-detail { grid-template-columns: 1fr; }
  .readiness-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
.linked-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 12px 0;
}
.linked-filters label {
  display: grid;
  gap: 4px;
  min-width: 150px;
}
.linked-filters span { align-self: center; color: #5c6875; }
