:root {
  --centevi-blue: #2563eb;
  --centevi-blue-dark: #173f7a;
  --centevi-cyan: #2bdbdc;
  --centevi-ink: #172033;
  --centevi-muted: #64748b;
  --centevi-surface: rgba(255, 255, 255, 0.9);
  --centevi-border: rgba(37, 99, 235, 0.14);
  --centevi-soft: #edf4ff;
  --status-ok: #10b787;
  --status-work: #d98028;
  --status-alert: #d9292d;
  --accent: var(--centevi-blue);
  font-family: "Poppins", "Segoe UI", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--centevi-ink);
  background:
    linear-gradient(145deg, rgba(248, 251, 255, 0.98) 0%, rgba(238, 244, 251, 0.98) 50%, rgba(247, 245, 255, 0.98) 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 34px 18px 56px;
}

.clean-shell {
  display: grid;
  place-items: start center;
}

.workspace {
  max-width: 1440px;
  margin: 0 auto;
  background: var(--centevi-surface);
  border: 1px solid var(--centevi-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 58px rgba(30, 64, 175, 0.12);
}

.topbar {
  min-height: 68px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--centevi-border);
  background: rgba(255, 255, 255, 0.86);
}

.logo-block {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.icon-button,
.primary-button,
.segmented button {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
}

.primary-button {
  height: 38px;
  padding: 0 22px;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(90deg, var(--centevi-blue), var(--centevi-cyan));
}

label {
  display: grid;
  gap: 8px;
  color: #1b2a5c;
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--centevi-ink);
  background: rgba(255, 255, 255, 0.92);
  font-weight: 700;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

input:focus,
select:focus {
  border-color: var(--centevi-blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.preview-wrap {
  min-width: 0;
  width: 100%;
  padding: 0;
  display: grid;
  align-content: start;
  background: transparent;
  overflow: auto;
}

.clean-preview {
  width: min(100%, 980px);
  min-height: auto;
  background: transparent;
}

.recipe-card {
  --accent: var(--centevi-blue);
  width: min(100%, 920px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--centevi-border);
  border-radius: 8px;
  background: var(--centevi-surface);
  box-shadow: 0 22px 54px rgba(30, 64, 175, 0.13);
  backdrop-filter: blur(12px);
}

.clean-preview .recipe-card {
  width: min(100%, 920px);
}

.recipe-card.theme-green {
  --accent: #018b63;
}

.recipe-body {
  padding: 28px;
  position: relative;
}

.utility-actions {
  position: absolute;
  top: 22px;
  right: 28px;
  z-index: 2;
}

.clear-button {
  min-height: 34px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--centevi-blue-dark);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(30, 64, 175, 0.1);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

.clear-button:hover,
.clear-button:focus {
  border-color: rgba(37, 99, 235, 0.42);
  color: var(--centevi-blue);
  box-shadow: 0 14px 30px rgba(30, 64, 175, 0.15);
  outline: none;
  transform: translateY(-1px);
}

.recipe-meta {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 0;
  padding-bottom: 20px;
}

.centevi-logo {
  width: min(100%, 390px);
  max-height: 110px;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 16px 20px rgba(23, 63, 122, 0.12));
}

.rules-panel {
  margin-top: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  border: 0;
  background: transparent;
}

.rules-panel select {
  min-height: 44px;
}

.eye-rules {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--centevi-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(30, 64, 175, 0.08);
  position: relative;
  overflow: hidden;
}

.eye-rules::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--centevi-blue), var(--centevi-cyan));
}

.eye-rules h2 {
  margin: 0 0 16px;
  color: var(--centevi-ink);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.eye-rules h2 span {
  display: inline-grid;
  min-width: 38px;
  min-height: 28px;
  margin-left: 8px;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--centevi-blue), var(--centevi-cyan));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

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

.checks label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 8px;
  background: #fff;
  color: #1b2a5c;
  font-size: 11px;
  line-height: 1.18;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.checks label:has(input:checked) {
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.1);
}

.checks label:hover {
  border-color: rgba(37, 99, 235, 0.32);
  transform: translateY(-1px);
}

.checks label:has(input:disabled) {
  color: #94a3b8;
  background: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.34);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.checks input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--centevi-blue);
}

.control-miopia-option[hidden],
.monofocal-only-option[hidden],
.bifocal-only-option[hidden],
.foto-ar-blue-option[hidden] {
  display: none;
}

.meta-field {
  display: grid;
  gap: 4px;
  text-align: center;
  color: var(--centevi-ink);
  font-size: 12px;
  font-weight: 900;
}

.meta-field strong {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 6px;
  background: #fff;
  font-size: 15px;
}

.meta-field .order,
.meta-field strong.order {
  color: var(--status-alert);
}

.meta-field.pill {
  min-height: 32px;
  align-self: end;
  place-items: center;
  border-radius: 6px;
  background: #10b787;
  color: #fff;
  font-size: 13px;
}

.patient-lines {
  margin: 18px 0 14px;
  font-size: 15px;
  font-weight: 800;
}

.patient-lines p {
  margin: 5px 0;
}

.rx-table {
  width: 100%;
  margin-top: 22px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  table-layout: fixed;
  background: #fff;
  box-shadow: 0 14px 34px rgba(30, 64, 175, 0.08);
  font-size: 14px;
  font-weight: 800;
}

.rx-table th,
.rx-table td {
  height: 46px;
  border-right: 1px solid rgba(37, 99, 235, 0.14);
  border-bottom: 1px solid rgba(37, 99, 235, 0.14);
  text-align: center;
  vertical-align: middle;
  padding: 6px;
  word-break: break-word;
}

.rx-table .rx-input {
  width: 100%;
  min-height: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  color: var(--centevi-ink);
  font-size: inherit;
  font-weight: 800;
  text-align: left;
}

.rx-table .rx-input:focus {
  background: #f8fbff;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.34);
}

.rx-table thead th {
  background: linear-gradient(180deg, #f7fbff, #edf4ff);
  color: #1b2a5c;
  font-size: 12px;
}

.rx-table tbody th {
  color: var(--centevi-blue-dark);
  background: #fbfdff;
}

.rx-table tr:last-child th,
.rx-table tr:last-child td {
  border-bottom: 0;
}

.rx-table th:last-child,
.rx-table td:last-child {
  border-right: 0;
}

.rx-table th:nth-child(1) {
  width: 52px;
}

.rx-table th:nth-child(6) {
  width: 118px;
}

.observations-card {
  margin-top: 22px;
  padding: 18px 20px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-left: 5px solid #94a3b8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(30, 64, 175, 0.08);
}

.observations-card[data-state="terminado"] {
  border-left-color: var(--status-ok);
}

.observations-card[data-state="base_tallado"] {
  border-left-color: var(--status-work);
}

.observations-card[data-state="revision_tecnica"] {
  border-left-color: var(--status-alert);
}

#observationText p {
  margin: 7px 0;
  color: var(--centevi-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

#observationText .eye-observation-title {
  margin-top: 12px;
  color: var(--centevi-blue-dark);
  font-size: 15px;
  font-weight: 800;
}

#observationText .eye-observation-title:first-child {
  margin-top: 0;
}

#observationText .price-list-indication {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

[contenteditable="true"] {
  outline: none;
}

[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.34);
}

@media (max-width: 920px) {
  .app-shell {
    padding: 22px 12px 42px;
  }

  .recipe-body {
    padding: 20px;
  }

  .utility-actions {
    position: static;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
  }

  .rules-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .recipe-meta,
  .form-grid.three,
  .checks {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  .actions {
    justify-content: end;
  }

  .recipe-body {
    padding: 14px;
  }

  .centevi-logo {
    width: min(100%, 310px);
  }

  .rx-table {
    font-size: 12px;
  }

  .rx-table th,
  .rx-table td {
    height: 42px;
    padding: 4px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar {
    display: none;
  }

  .app-shell,
  .preview-wrap {
    padding: 0;
  }

  .workspace,
  .recipe-card {
    border: 0;
    box-shadow: none;
  }

  .layout {
    display: block;
    min-height: 0;
  }

  .recipe-card {
    width: 100%;
  }
}
