:root {
  color-scheme: light;
  --bg: #edf4fb;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --ink: #09264b;
  --muted: #5a6e87;
  --line: #cddbeb;
  --green: #0057a6;
  --green-strong: #003f7d;
  --red: #e31e24;
  --amber: #d64322;
  --blue: #00aeef;
  --white: #ffffff;
  --party-blue: #0057a6;
  --party-blue-dark: #003f7d;
  --party-cyan: #00aeef;
  --party-red: #e31e24;
  --shadow: 0 18px 46px rgba(0, 57, 116, 0.14);
  --radius: 8px;
  --sidebar: 288px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 22px;
  color: #f7fbf8;
  background: #183529;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: #f3c467;
  color: #173327;
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand strong,
.brand small {
  display: block;
  min-width: 0;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: #c8d5cd;
  font-size: 12px;
}

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

.nav-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 7px 10px;
  color: #dce8df;
  text-decoration: none;
  border-radius: var(--radius);
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: #f3c467;
  line-height: 1;
}

.nav-icon svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.domain-box {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
}

.account-panel {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--party-blue-dark);
  background: #ffffff;
  font-weight: 900;
}

.account-panel small,
.account-panel strong,
.account-panel p {
  display: block;
  min-width: 0;
}

.account-panel small {
  margin-bottom: 3px;
  color: #bdeeff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.account-panel strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel p {
  margin: 6px 0 0;
  color: #d9ecff;
  font-size: 12px;
  line-height: 1.35;
}

.domain-status {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #f3c467;
}

.domain-box strong,
.domain-box small {
  display: block;
}

.domain-box small {
  margin-top: 4px;
  color: #c8d5cd;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #c8d5cd;
  font-size: 12px;
}

.legal-links a {
  color: inherit;
}

.legal-links a:hover {
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 26px clamp(16px, 3vw, 38px) 40px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.topbar-actions,
.form-actions,
.toolbar,
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  line-height: 1.1;
}

.primary-button {
  color: #ffffff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-strong);
}

.secondary-button {
  color: var(--green-strong);
  background: #eef5ed;
  border-color: #c9d8c8;
}

.demo-button {
  flex: 1 1 320px;
  justify-content: flex-start;
  text-align: left;
}

.demo-button span:last-child {
  white-space: normal;
}

.auth-entry {
  min-width: 176px;
  justify-content: flex-start;
  text-align: left;
}

.auth-entry > span:last-child {
  display: grid;
  gap: 2px;
}

.auth-entry small {
  color: #5f7894;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.auth-entry.is-active {
  color: #ffffff;
  background: rgba(0, 87, 166, 0.42);
  border-color: rgba(255, 255, 255, 0.32);
}

.auth-entry.is-active small {
  color: #bdeeff;
}

.danger-button {
  color: #ffffff;
  background: var(--red);
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.full-width {
  width: 100%;
}

.form-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.metrics-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.metric {
  padding: 16px;
  background: var(--surface);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 28px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.split-layout,
.document-layout,
.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.workspace-layout {
  grid-template-columns: minmax(340px, 0.72fr) minmax(0, 1.28fr);
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-heading.compact {
  align-items: center;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--green-strong);
  background: #e4efe5;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.red {
  color: #84251f;
  background: #f8dfdc;
}

.status-pill.amber {
  color: #7b440a;
  background: #faebcf;
}

.status-pill.blue {
  color: #1f4f78;
  background: #dcebf7;
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label > span {
  color: #334039;
  font-size: 13px;
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cabfae;
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffefa;
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 102, 76, 0.16);
}

.consent-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.checkbox-row {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

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

.previous-toggle {
  margin-top: 2px;
  padding: 12px;
  border: 1px solid #b8cce2;
  border-radius: var(--radius);
  background: #f2f8ff;
}

.previous-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  border: 1px solid #b8cce2;
  border-radius: var(--radius);
  background: #f8fbff;
}

.previous-fields[hidden] {
  display: none;
}

.file-upload small {
  color: var(--muted);
  line-height: 1.45;
}

.file-list {
  display: grid;
  gap: 8px;
  margin: -4px 0 0;
  padding: 0;
  list-style: none;
}

.file-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border: 1px solid #b8cce2;
  border-radius: var(--radius);
  background: #f8fbff;
}

.file-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list small {
  flex: 0 0 auto;
  color: var(--muted);
}

.analysis-panel {
  position: sticky;
  top: 24px;
}

.flow-visual {
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8f5ec;
}

.flow-visual svg {
  display: block;
  width: 100%;
  height: auto;
}

.flow-line {
  fill: none;
  stroke: #c8b98f;
  stroke-width: 6;
  stroke-linecap: round;
}

.flow-node circle {
  fill: #fffdf7;
  stroke: var(--green);
  stroke-width: 4;
}

.flow-node path {
  fill: none;
  stroke: var(--green-strong);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.analysis-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.analysis-block p,
.analysis-block li {
  color: var(--muted);
  line-height: 1.5;
}

.analysis-block ul {
  margin: 0;
  padding-left: 19px;
}

.search-field {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 0;
  align-items: center;
  flex: 1 1 240px;
  min-width: 220px;
  border: 1px solid #cabfae;
  border-radius: var(--radius);
  background: #fffefa;
}

.search-field span {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.search-field input {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.toolbar {
  margin-bottom: 14px;
}

.toolbar select {
  flex: 0 0 180px;
}

.case-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 4px;
}

.case-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffefa;
}

.case-card:hover,
.case-card.is-selected {
  border-color: var(--green);
  background: #f4faef;
}

.case-card-top,
.case-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.case-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-meta {
  flex-wrap: wrap;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
}

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

.detail-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-row span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-row p {
  margin: 0;
  line-height: 1.5;
}

.attachment-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #b8cce2;
  border-radius: var(--radius);
  color: var(--party-blue-dark);
  background: #eef7ff;
  font-weight: 800;
}

.attachment-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-link small {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 700;
}

.attachment-link:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.status-actions {
  margin-top: 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.document-preview textarea {
  min-height: 560px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

.response-report {
  min-height: 460px;
}

.report-score {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  color: #ffffff;
  background: conic-gradient(var(--green) var(--score), #d8d0c0 0);
  font-size: 24px;
  font-weight: 900;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
}

.check-list strong {
  display: block;
  margin-bottom: 4px;
}

.check-list span {
  color: var(--muted);
  line-height: 1.45;
}

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

.wide-panel {
  grid-column: 1 / -1;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2d8c7;
}

.bar-fill {
  height: 100%;
  width: var(--value);
  border-radius: inherit;
  background: var(--green);
}

.agency-table {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.agency-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 90px 140px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fffefa;
}

.agency-row.header {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  background: #f6f0e3;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #1e2823;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 18, 39, 0.54);
  backdrop-filter: blur(4px);
}

.auth-dialog {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: #fffefa;
  box-shadow: 0 28px 70px rgba(2, 17, 43, 0.28);
}

.auth-dialog-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.auth-dialog-header strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
}

.auth-dialog-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form[hidden],
.auth-error[hidden] {
  display: none;
}

.auth-error {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid #edc6cb;
  border-radius: var(--radius);
  color: #9d2330;
  background: #fff3f5;
  line-height: 1.45;
}

.auth-error.success {
  border-color: #b9d6f4;
  color: var(--party-blue-dark);
  background: #eef7ff;
}

.legal-page {
  background: var(--bg);
}

.legal-document {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.legal-document h1 {
  margin: 16px 0 18px;
}

.legal-document section {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.legal-document p,
.legal-document li {
  color: var(--muted);
  line-height: 1.62;
}

.legal-document ul {
  margin-bottom: 0;
  padding-left: 20px;
}

.legal-note {
  padding: 14px 16px;
  border: 1px solid #d9c28a;
  border-radius: var(--radius);
  color: #6b470d;
  background: #fff4cf;
}

.back-link {
  color: var(--green-strong);
  font-weight: 800;
}

.legal-button {
  margin-top: 8px;
  color: #ffffff;
  text-decoration: none;
}

/* Party visual system */
.sidebar {
  position: sticky;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0) 24%),
    var(--party-blue);
}

.sidebar::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  content: "";
  background: linear-gradient(90deg, #ffffff 0 33%, var(--party-cyan) 33% 66%, var(--party-red) 66% 100%);
}

.brand {
  grid-template-columns: 62px minmax(0, 1fr);
}

.brand-mark {
  width: 62px;
  height: 62px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 32, 82, 0.18);
}

.brand-mark img {
  display: block;
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.brand small,
.domain-box small,
.legal-links {
  color: #d9ecff;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 4px 0 0 var(--party-red);
}

.nav-icon {
  color: #ffffff;
  background: rgba(0, 174, 239, 0.2);
}

.domain-status {
  background: var(--party-red);
}

.main {
  background:
    linear-gradient(180deg, rgba(0, 87, 166, 0.08), rgba(237, 244, 251, 0) 340px),
    var(--bg);
}

.topbar {
  min-height: 86px;
  padding: 18px;
  flex-wrap: wrap;
  border: 1px solid rgba(0, 87, 166, 0.22);
  border-radius: var(--radius);
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(0, 63, 125, 0.98), rgba(0, 87, 166, 0.92)),
    var(--party-blue);
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  flex: 1 1 360px;
  min-width: 0;
}

.topbar h1 {
  color: #ffffff;
  font-size: clamp(30px, 3.4vw, 42px);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.eyebrow {
  color: #bdeeff;
  overflow-wrap: anywhere;
}

.party-lockup {
  display: grid;
  place-items: center;
  width: 154px;
  height: 60px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #ffffff;
}

.party-lockup img {
  display: block;
  width: auto;
  max-width: calc(100% - 14px);
  height: 52px;
  object-fit: contain;
}

.primary-button {
  background: var(--party-red);
}

.primary-button:hover {
  background: #bd171d;
}

.secondary-button {
  color: var(--party-blue-dark);
  background: #eef7ff;
  border-color: #b9d6f4;
}

.icon-button {
  color: var(--party-blue-dark);
}

.metrics-band {
  background: #b9d6f4;
}

.metric {
  position: relative;
}

.metric::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  content: "";
  background: var(--party-blue);
}

.metric:nth-child(2)::before,
.metric:nth-child(4)::before {
  background: var(--party-red);
}

.metric:nth-child(3)::before {
  background: var(--party-cyan);
}

.metric strong {
  color: var(--party-blue-dark);
}

.badge,
.status-pill {
  color: var(--party-blue-dark);
  background: #e4f4ff;
}

.status-pill.red {
  color: #9d0f15;
  background: #ffe2e4;
}

.status-pill.amber {
  color: #8a2b17;
  background: #ffe7df;
}

.status-pill.blue {
  color: var(--party-blue-dark);
  background: #dcefff;
}

label > span {
  color: #173b66;
}

input,
select,
textarea,
.search-field {
  border-color: #b8cce2;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--party-blue);
  box-shadow: 0 0 0 3px rgba(0, 87, 166, 0.16);
}

.checkbox-row input:checked {
  accent-color: var(--party-red);
}

.flow-visual {
  background: #f2f8ff;
}

.flow-line {
  stroke: #b4d9f5;
}

.flow-node circle {
  fill: #ffffff;
  stroke: var(--party-blue);
}

.flow-node path {
  stroke: var(--party-red);
}

.case-card,
.check-list li,
.agency-row {
  background: #ffffff;
}

.case-card:hover,
.case-card.is-selected {
  border-color: var(--party-blue);
  background: #f2f8ff;
  box-shadow: inset 4px 0 0 var(--party-red);
}

.score-ring {
  background: conic-gradient(var(--party-red) var(--score), #d5e5f4 0);
}

.bar-track {
  background: #d5e5f4;
}

.bar-fill {
  background: var(--party-blue);
}

.agency-table {
  background: #b9d6f4;
}

.agency-row.header {
  background: #eef7ff;
}

.toast {
  background: var(--party-blue-dark);
}

.legal-note {
  border-color: #9bcff5;
  color: var(--party-blue-dark);
  background: #eef7ff;
}

.back-link {
  color: var(--party-blue-dark);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 14px;
    gap: 14px;
  }

  .brand {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .brand-mark img {
    width: 44px;
    height: 44px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    overflow: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    grid-template-columns: 28px minmax(120px, 1fr);
  }

  .domain-box {
    display: none;
  }

  .split-layout,
  .document-layout,
  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .analysis-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px 12px 28px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
  }

  .topbar > div:first-child {
    flex: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    justify-content: stretch;
  }

  .party-lockup {
    grid-column: 1 / -1;
    width: 100%;
    height: 72px;
  }

  .party-lockup img {
    width: auto;
    max-width: min(160px, calc(100% - 16px));
    height: 62px;
  }

  .topbar-actions .primary-button,
  .topbar-actions .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .auth-dialog {
    padding: 18px;
  }

  .metrics-band,
  .form-grid,
  .previous-fields,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .panel-heading {
    display: grid;
  }

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

  .detail-row,
  .agency-row,
  .bar-row,
  .report-score {
    grid-template-columns: 1fr;
  }

  .toolbar select,
  .search-field {
    flex-basis: 100%;
    min-width: 0;
  }

  .case-card-top,
  .case-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .case-card strong,
  .bar-label {
    white-space: normal;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 34px;
  }

  .main {
    padding-inline: 8px;
  }

  .panel {
    padding: 14px;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  .form-actions,
  .status-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-dialog-header {
    align-items: stretch;
    flex-direction: column;
  }
}
