:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #5b667a;
  --line: #d9e1ec;
  --red: #b42318;
  --blue: #1f5fbf;
  --green: #1f7a4d;
  --amber: #9a5b13;
  --soft-blue: #eef5ff;
  --soft-red: #fff3f1;
  --soft-green: #effaf4;
}

.permanent-test-banner {
  position: sticky;
  inset-block-start: 0;
  z-index: 1000;
  padding: 0.7rem 1rem;
  background: #7f1d1d;
  color: #fff;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.04em;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.offline-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.offline-card {
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
}

.offline-card h1 {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 1.6rem;
}

.offline-card p {
  margin: 0 0 10px;
}

button,
input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

button {
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled),
button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--soft-blue);
}

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

input,
select {
  width: 100%;
  padding: 8px 10px;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2rem, 2rem);
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

p,
span {
  color: var(--muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px min(5vw, 54px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-stack {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.status-pill {
  min-width: 132px;
  border: 1px solid #b7e0c4;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--soft-green);
  color: var(--green);
  text-align: center;
  font-weight: 900;
}

.status-note {
  font-size: 0.82rem;
  font-weight: 800;
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 20px auto 52px;
  display: grid;
  gap: 16px;
}

.safety-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #fac5bd;
  border-left: 6px solid var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--soft-red);
}

.safety-band strong {
  color: var(--red);
}

.login-surface {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 22px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
}

.login-intro p {
  max-width: 620px;
}

.login-form,
.tool-form,
.view-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-form,
.tool-form {
  display: grid;
  gap: 2px;
  padding: 16px;
}

.login-form output {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.login-form output[data-tone="danger"] {
  color: var(--red);
}

.platform-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.sidebar button {
  width: 100%;
  text-align: left;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 16px;
}

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

.pwa-banner,
.pwa-status-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfcfe;
}

.pwa-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner span {
  color: var(--ink);
  font-weight: 800;
}

.pwa-status-card {
  margin-top: 14px;
}

.session-strip div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.session-strip strong,
.session-strip span {
  overflow-wrap: anywhere;
}

.view-panel {
  padding: 16px;
}

.section-head,
.inline-actions,
.test-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.metric-item,
.item-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.metric-item strong,
.item-card strong {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.metric-item span,
.item-card span {
  overflow-wrap: anywhere;
}

.role-note,
.blocked-box,
.result-box {
  margin-top: 12px;
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  padding: 12px;
  background: #fff8ed;
  color: var(--ink);
  font-weight: 700;
}

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

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

.inline-actions {
  align-items: stretch;
}

.inline-actions button {
  flex: 1 1 92px;
}

.privacy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.privacy-actions button {
  flex: 1 1 150px;
}

.modal-card {
  width: min(100% - 32px, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--ink);
}

.modal-card::backdrop {
  background: rgb(23 32 51 / 0.42);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.test-toolbar {
  margin-bottom: 14px;
}

.test-toolbar label {
  margin: 0;
}

.test-toolbar select {
  width: min(100%, 320px);
}

.test-runner {
  display: grid;
  gap: 10px;
}

.answer-grid {
  display: grid;
  gap: 8px;
}

.answer-grid button {
  min-height: 48px;
  text-align: left;
}

.tool-form h3 {
  margin-bottom: 4px;
}

.platform-access-shell,
.permission-shell,
.closure-grid,
.data-contract-grid,
.db-readiness-grid,
.migration-readiness-grid {
  display: grid;
  gap: 10px;
}

@media (max-width: 820px) {
  .topbar,
  .safety-band,
  .session-strip,
  .pwa-banner,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-stack {
    justify-items: start;
  }

  .login-surface,
  .platform-layout,
  .split-grid,
  .operator-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar button {
    min-height: 44px;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .test-toolbar button,
  .test-toolbar select,
  .session-strip button,
  .pwa-banner button,
  .inline-actions button {
    width: 100%;
  }
}
