/* Drug Tariff Compare — professional UI */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f4c81;
  --primary-hover: #0a3a66;
  --primary-soft: #e8f1fa;
  --success: #0d9488;
  --danger-bg: #fef2f2;
  --danger-border: #fecdd3;
  --danger-text: #9f1239;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --container-w: 1080px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow);
}

.site-header__inner {
  max-width: var(--container-w);
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.site-tagline {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 400;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.steps {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.steps li:not(:last-child)::after {
  content: "→";
  color: var(--border);
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

.steps .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
}

.steps li.is-active .num {
  background: var(--primary);
  color: #fff;
}

.steps li.is-done .num {
  background: var(--success);
  color: #fff;
}

.steps li.is-active {
  color: var(--text);
  font-weight: 500;
}

/* Vertical numbered list (do not use .steps — that is the horizontal stepper) */
.howto-list {
  margin: 1rem 0 1.25rem;
  padding-left: 1.35rem;
  list-style: decimal;
  display: block;
}

.howto-list li {
  margin-bottom: 0.85rem;
  display: list-item;
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.6;
}

.howto-list li:last-child {
  margin-bottom: 0;
}

.howto-list code {
  font-size: 0.88em;
  word-break: break-word;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 1.5rem;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 0.4rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #cfe0f3;
  border-radius: 999px;
}

.card--secondary {
  margin-top: 1.25rem;
}

.card__title {
  margin: 0 0 0.35rem;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card__lead {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;  
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.link-muted {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.link-muted:hover {
  color: var(--primary);
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.alert--info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

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

.alert--error {
  background: #fef2f2;
  border-color: #fecdd3;
  color: #9f1239;
}

.success-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  margin: auto;
  width: min(22rem, calc(100vw - 2rem));
  max-width: min(22rem, calc(100vw - 2rem));
  max-height: min(90vh, 100%);
  background: transparent;
  overflow: hidden;
  box-sizing: border-box;
}

.success-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.success-dialog__inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.success-dialog__title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.success-dialog__lead {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.success-dialog__filename {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  max-width: 100%;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

.success-dialog__hint {
  margin: 0 0 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.success-dialog .btn {
  width: 100%;
  margin-top: 0;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-options {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem 0.85rem;
  background: #fafbfc;
}

.form-options__summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 0.8125rem;
  margin: 0;
}

.form-options__summary::-webkit-details-marker {
  display: none;
}

.form-options .field-hint {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.form-options__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.65rem;
}

@media (max-width: 640px) {
  .form-options__grid {
    grid-template-columns: 1fr;
  }
}

.field-label--sub {
  font-size: 0.78rem;
  margin-top: 0.35rem;
}

.field-textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.8125rem;
  font-family: inherit;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  resize: vertical;
  min-height: 4rem;
  box-sizing: border-box;
}

.field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-group label,
label.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
  font-weight: 400;
}

input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 0.875rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafbfc;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

select {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  margin-top: 0.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn--ghost {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #cfe0f3;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  margin-right: 10px;
}

.btn--ghost:hover {
  background: #dbeafa;
  text-decoration: none;
}

.btn--download {
  margin-top: 0.75rem;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
}

.form-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-start;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 2rem;
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .grid-two {
    grid-template-columns: 1fr;
  }
}

.panel {
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.panel:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.panel__heading {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  font-weight: 500;
  color: var(--text-muted);
  width: 58%;
  font-size: 0.875rem;
}

.stats-table td {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.stats-table tr:last-child th,
.stats-table tr:last-child td {
  border-bottom: none;
}

.note {
  margin: 1.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.note code {
  font-size: 0.8em;
  background: #f1f5f9;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.site-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.review-table-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.review-table th,
.review-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.review-table th:first-child,
.review-table td:first-child {  
  max-width: 145px;
  white-space: normal;
}

.review-table th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

.review-table tbody tr:nth-child(even) {
  background: #fcfdff;
}

.review-table tbody tr:hover {
  background: #f5f9ff;
}

.status-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
}

.status-pill--unmatched {
  color: #9f1239;
  background: #fff1f2;
  border-color: #fecdd3;
}

.status-pill--mismatch {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.review-action-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  flex-direction: column;
  flex-wrap: wrap;
}

.review-note-input {
  width: 200px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.review-action-form .btn {
  margin-top: 0;
  min-width: 64px;
}

.review-action-buttons {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.review-filter-form {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.review-filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-filter-form input[type="text"] {
  min-width: 220px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.pagination-bar {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.btn.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.btn--compact {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.review-meta-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
}

.review-meta-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-help {
  margin: 0 0 0.9rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 8px;
  color: #1e3a8a;
  font-size: 0.84rem;
  line-height: 1.45;
}

.review-explainer {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.review-explainer h3 {
  margin: 0.1rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text);
}

.review-explainer p {
  margin: 0 0 0.5rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.review-explainer p:last-child {
  margin-bottom: 0;
}

/* Loading overlay — server work in progress */
body.is-loading {
  overflow: hidden;
}

body.is-loading .site-header,
body.is-loading main .card {
  pointer-events: none;
  user-select: none;
}

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.loading-overlay.is-open {
  display: flex;
}

.loading-overlay__panel {
  max-width: 26rem;
  width: 100%;
  padding: 1.75rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  text-align: center;
}

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: loading-spin 0.75s linear infinite;
}

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

.loading-overlay__title {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}

.loading-overlay__detail {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
  min-height: 2.6em;
}

.loading-progress {
  margin: 0 0 1rem;
  text-align: left;
}

.loading-progress__track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.loading-progress__bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, #1a6fb8 100%);
  transition: width 0.25s ease-out;
}

.loading-progress__label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.loading-overlay__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
