body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(165deg, #e8eef6 0%, #f6f8fb 45%, #f3f6fb 100%);
  color: #222;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.green {
  border-color: #65b36e;
  background: linear-gradient(to bottom, #fbfffc, #ffffff);
}
.yellow {
  border-color: #e4ba53;
  background: linear-gradient(to bottom, #fffcf4, #ffffff);
}
.red {
  border-color: #db6a6a;
  background: linear-gradient(to bottom, #fff8f8, #ffffff);
}

.calc-layout .card p {
  margin: 2px 0;
  line-height: 1.3;
}

.explanations {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #c8ced6;
  background: #f8fafc;
  border-radius: 8px;
  padding-left: 10px;
  padding-right: 10px;
  padding-bottom: 8px;
}

.explanations h3 {
  margin: 2px 0 6px 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}

.explanations p {
  font-size: 12px;
  color: #334155;
  margin: 3px 0;
  line-height: 1.3;
}

.recommendation-block {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-feature-settings: "tnum" 1;
  font-size: 14px;
  line-height: 1.38;
  color: #1e293b;
}

.recommendation-block .recommendation-title {
  margin: 0 0 8px 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f172a;
}

.recommendation-placeholder {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.recommendation-warning.warning {
  font-size: 13px;
  font-weight: 600;
}

.recommendation-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 500ms ease, opacity 380ms ease;
}

.recommendation-content.visible {
  max-height: 320px;
  opacity: 1;
}

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

.recommendation-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.38;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.recommendation-list li::before {
  content: counter(item);
  counter-increment: item;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #dbe7f7;
  color: #1e3a5f;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  flex-shrink: 0;
}

.recommendation-list {
  counter-reset: item;
}

.recommendation-list.visible li {
  opacity: 1;
  transform: translateY(0);
}

.recommendation-list.visible li:nth-child(1) { transition-delay: 40ms; }
.recommendation-list.visible li:nth-child(2) { transition-delay: 140ms; }
.recommendation-list.visible li:nth-child(3) { transition-delay: 240ms; }
.recommendation-list.visible li:nth-child(4) { transition-delay: 340ms; }

input,
select,
button {
  padding: 10px 12px;
  border: 1px solid #c7d2e0;
  border-radius: 8px;
  font-size: 15px;
}

button {
  cursor: pointer;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 600;
  transition: all 160ms ease;
}

button:hover {
  background: #eef4ff;
  border-color: #91a8cc;
}

.card > label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.card > label input,
.card > label select {
  width: 100%;
  box-sizing: border-box;
  font-weight: 400;
}

.disclaimer {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}

.disclaimer-footer {
  opacity: 0.8;
}

.header-compact {
  display: grid;
  gap: 6px;
  margin-bottom: 2px;
}

.header-compact h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.header-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.top-banner {
  width: 100%;
  max-height: 110px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid #dbe3ef;
  background: #000000;
  padding: 6px;
  box-sizing: border-box;
}

.warning {
  color: #8a2e2e;
  font-weight: 600;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  padding: 8px 10px;
}

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

.admin-settings-page {
  gap: 8px;
}

.admin-rate-unit-form {
  align-items: flex-end;
}

.admin-rate-unit-label {
  display: grid;
  gap: 10px;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 360px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.admin-rate-unit-label select {
  width: 100%;
  box-sizing: border-box;
  font-weight: 400;
}

.admin-settings-kv {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-settings-kv p {
  margin: 0;
  padding: 4px 8px;
  line-height: 1.25;
  font-size: 13px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.between {
  justify-content: space-between;
  align-items: center;
}

.row p {
  margin: 0;
  padding: 6px 8px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eaf2ff;
  border: 1px solid #c8daf8;
  color: #1e3a5f;
  font-size: 13px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th,
.history-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: #334155;
}

.calc-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }
  .header-title-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

.admin-users-table {
  margin-top: 12px;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.password-mask-col {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.12em;
  color: #64748b;
}

.row-inactive td {
  color: #94a3b8;
}

.inactive-badge {
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  text-transform: uppercase;
}

.archived-badge {
  font-size: 11px;
  font-weight: 700;
  color: #5b21b6;
  text-transform: uppercase;
}

.row-archived td {
  color: #64748b;
}

.btn-archive {
  border-color: #c4b5fd;
  color: #5b21b6;
}

.btn-archive:hover:not(:disabled) {
  background: #f5f3ff;
  border-color: #a78bfa;
}

.help-text-muted {
  font-size: 12px;
  color: #64748b;
  margin: 10px 0 0 0;
  line-height: 1.4;
}

.user-edit-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  display: grid;
  gap: 10px;
}

.user-edit-panel h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: #0f172a;
}

.user-edit-panel > label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.user-edit-panel > label input,
.user-edit-panel > label select {
  width: 100%;
  box-sizing: border-box;
  font-weight: 400;
}

.checkbox-inline {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-inline input {
  width: auto;
}

.btn-compact {
  padding: 6px 10px;
  font-size: 13px;
}

.btn-danger-outline {
  border-color: #fca5a5;
  color: #991b1b;
}

.btn-danger-outline:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #f87171;
}

.btn-secondary {
  background: #fff;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background: #f1f5f9;
}

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

.protocol-catalog {
  margin-bottom: 18px;
}

.protocol-catalog-title {
  margin: 0 0 12px 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.protocol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.protocol-grid-card {
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(to bottom, #fbfcfe, #ffffff);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
}

.protocol-grid-card--inactive {
  opacity: 0.72;
  background: #f8fafc;
}

.protocol-grid-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.protocol-grid-id {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  font-family: ui-monospace, monospace;
}

.protocol-grid-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.protocol-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
}

.protocol-badge--default {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.protocol-badge--inactive {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.protocol-grid-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

.protocol-grid-desc {
  margin: 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.35;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.protocol-grid-meta {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.protocol-grid-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.protocol-create-form {
  margin-top: 8px;
}

.protocol-rows-readonly h3 {
  margin-top: 0;
}

.protocol-rows-table-wrap {
  max-width: 100%;
}

.protocol-rows-table th {
  font-size: 11px;
  vertical-align: bottom;
}

.protocol-rows-table .protocol-rows-instruction {
  white-space: normal;
  min-width: 220px;
  max-width: 420px;
  line-height: 1.35;
}

.concentration-actions {
  white-space: normal;
}

.concentration-actions .btn-compact {
  margin-right: 4px;
  margin-bottom: 4px;
}

.band-options {
  display: grid;
  gap: 10px;
}

.band-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid #dfe5ee;
  border-radius: 10px;
  cursor: pointer;
  background: #fbfcfe;
  transition: border-color 160ms ease, background 160ms ease;
}

.band-option:hover {
  border-color: #91a8cc;
  background: #f8fafc;
}

.band-option.selected {
  border-color: #65b36e;
  background: linear-gradient(to bottom, #fbfffc, #ffffff);
}

.band-option input {
  margin-top: 4px;
  width: auto;
}

.band-option-body {
  flex: 1;
  display: grid;
  gap: 6px;
}

.band-option-body ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #475569;
  line-height: 1.35;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.stat-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  background: #f8fafc;
  display: grid;
  gap: 4px;
}

.stat-card.stat-highlight {
  border-color: #fca5a5;
  background: linear-gradient(to bottom, #fff8f8, #ffffff);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.history-table tr.row-mismatch td {
  background: #fff1f2;
}

form.nav-form {
  display: inline;
  margin: 0;
}

form.nav-form button {
  margin: 0;
}

form.logout-form {
  display: inline;
  margin: 0;
}

form.logout-form button {
  margin: 0;
}

/* --- Visual polish (PHP app) --- */

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid #7ba3d4;
  outline-offset: 2px;
}

input:hover,
select:hover {
  border-color: #91a8cc;
}

button.btn-primary {
  background: linear-gradient(180deg, #1e4a7a 0%, #163a61 100%);
  color: #ffffff;
  border-color: #143252;
  box-shadow: 0 4px 14px rgba(22, 58, 97, 0.22);
}

button.btn-primary:hover {
  background: linear-gradient(180deg, #255a92 0%, #1a4470 100%);
  border-color: #1a4470;
  box-shadow: 0 6px 18px rgba(22, 58, 97, 0.28);
}

.card {
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

.card:hover {
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.band-option {
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.band-option:has(input:checked) {
  box-shadow: 0 4px 16px rgba(101, 179, 110, 0.18);
}

.stat-card {
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.recommendation-placeholder.is-thinking {
  animation: verify-pulse 1.5s ease-in-out infinite;
  letter-spacing: 0.02em;
}

@keyframes verify-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.recommendation-title.reveal-in {
  animation: fade-up-in 0.55s ease forwards;
}

@keyframes fade-up-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recommendation-title.result-match,
.recommendation-title.result-mismatch {
  display: flex;
  align-items: center;
  gap: 10px;
}

.recommendation-title.result-match::before,
.recommendation-title.result-mismatch::before {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.recommendation-title.result-match::before {
  content: "✓";
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.recommendation-title.result-mismatch::before {
  content: "!";
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.verify-result-panel.card.green {
  box-shadow: 0 10px 32px rgba(101, 179, 110, 0.12);
}

.verify-result-panel.card.red {
  box-shadow: 0 10px 32px rgba(219, 106, 106, 0.14);
}

#verify-decision-path-lines p {
  animation: fade-up-in 0.35s ease;
}

.explanations {
  border-left: 3px solid #c8daf8;
}

.header-compact h1 {
  background: linear-gradient(90deg, #0f172a 0%, #1e3a5f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  margin: 0;
}

.modal-panel h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.modal-panel p {
  margin: 0;
  line-height: 1.45;
  color: #334155;
}

.verify-chat {
  min-height: 280px;
}

.verify-chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.verify-chat-bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  animation: fade-up-in 0.35s ease;
  white-space: pre-wrap;
}

.verify-chat-bubble.assistant {
  align-self: flex-start;
  background: linear-gradient(180deg, #eef4fb 0%, #e8f0fa 100%);
  border: 1px solid #d4e3f7;
  color: #1e293b;
}

.verify-chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(180deg, #1e4a7a 0%, #163a61 100%);
  color: #ffffff;
  border: 1px solid #143252;
  box-shadow: 0 4px 14px rgba(22, 58, 97, 0.18);
}

.verify-chat-composer {
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
  margin-top: 6px;
  display: grid;
  gap: 10px;
}

.verify-chat-field {
  display: grid;
  gap: 6px;
}

.verify-chat-field input,
.verify-chat-field select {
  width: 100%;
  box-sizing: border-box;
}

.verify-chat-actions {
  display: flex;
  justify-content: flex-end;
}

.verify-chat-error {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #b91c1c;
}

.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;
}

@media (prefers-reduced-motion: reduce) {
  .recommendation-placeholder.is-thinking,
  .recommendation-title.reveal-in,
  #verify-decision-path-lines p,
  .verify-chat-bubble {
    animation: none;
  }

  .stat-card:hover {
    transform: none;
  }
}

