/* ═══════════════════════════════════════════════════════════
   OptiReceita — Folha de estilos
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --cor-primaria: #1a2e5a;
  --cor-primaria-clara: #2a4478;
  --cor-primaria-escura: #0f1d3a;
  --navy: var(--cor-primaria);
  --navy-light: var(--cor-primaria-clara);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, .12), 0 12px 40px rgba(0, 0, 0, .06);
  --transition: 200ms cubic-bezier(.4, 0, .2, 1);
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ──────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 50%, var(--navy) 100%);
  color: #fff;
  padding: 1.5rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(26, 46, 90, 0.15);
}

.app-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(59, 130, 246, .2) 0%, transparent 60%);
  animation: headerGlow 8s ease-in-out infinite alternate;
}

@keyframes headerGlow {
  0% { transform: translate(0, 0); }
  100% { transform: translate(5%, -5%); }
}

.app-header > * {
  position: relative;
  z-index: 1;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
}

.header-brand .logo-icon {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, .15);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  flex-shrink: 0;
}

.header-brand .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  text-align: left;
}

.header-text p {
  font-size: .75rem;
  opacity: .8;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
}

/* ── Navegação por abas ──────────────────────────────── */
.app-nav {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255, 255, 255, .75);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}

.nav-link.active {
  color: var(--navy);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}

/* ── Banner de configuração ──────────────────────────── */
.config-banner {
  max-width: 960px;
  margin: -1.6rem auto 0;
  padding: 0 1.5rem;
  position: relative;
  z-index: 11;
}

.config-banner .banner-inner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius-sm);
  padding: .6rem 1rem;
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  box-shadow: var(--shadow);
}

.config-banner a {
  color: #92400e;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Main Layout ─────────────────────────────────────── */
.app-main {
  max-width: 960px;
  margin: -1.6rem auto 0;
  padding: 0 1.5rem 2rem;
  position: relative;
  z-index: 10;
}

.config-banner:not([hidden]) + .app-main {
  margin-top: 1rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
  margin: 1.25rem 0 1rem;
  letter-spacing: -.01em;
}

/* ── Card / Section ──────────────────────────────────── */
.section-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: fadeUp .5s ease both;
}

.section-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(255, 255, 255, 0.8);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Form Fields ─────────────────────────────────────── */
.field-row {
  display: grid;
  gap: .75rem;
}

.field-row.cols-3 { grid-template-columns: 1fr 2fr 1fr; }
.field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.field-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.field-group label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.field-group input[type="text"],
.field-group input[type="number"],
.field-group input[type="date"],
.field-group input[type="tel"],
.field-group select,
.field-group textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  background: #fafbfc;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
  background: #fff;
}

.field-group textarea {
  resize: vertical;
  min-height: 60px;
}

.field-hint {
  font-size: .72rem;
  color: var(--text-muted);
}

/* ── Combobox de paciente ────────────────────────────── */
.combo {
  position: relative;
}

.combo-input-row {
  display: flex;
  gap: .4rem;
}

.combo-input-row input {
  flex: 1;
}

.combo-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 500;
}

.combo-dropdown.open {
  display: block;
}

.combo-option {
  padding: .55rem .75rem;
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  transition: background var(--transition);
}

.combo-option:hover,
.combo-option.highlighted {
  background: #eef2ff;
}

.combo-option .combo-sub {
  color: var(--text-muted);
  font-size: .75rem;
}

.combo-empty {
  padding: .55rem .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
}

.paciente-selecionado {
  margin-top: .35rem;
  font-size: .78rem;
  color: var(--success);
  font-weight: 600;
  min-height: 1.1em;
}

/* ── Toggle switch ───────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .9rem;
  cursor: pointer;
  user-select: none;
}

.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.toggle-row input[type="checkbox"]:checked {
  background: var(--accent);
}

.toggle-row input[type="checkbox"]:checked::after {
  left: 21px;
}

.toggle-row span {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Grades Table ────────────────────────────────────── */
.grades-wrapper {
  overflow-x: auto;
}

.grades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.grades-table th {
  background: var(--navy);
  color: #fff;
  padding: .5rem .35rem;
  font-weight: 600;
  text-align: center;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.grades-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.grades-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

.grades-table th.section-header {
  background: var(--navy-light);
  font-size: .75rem;
  letter-spacing: .08em;
}

.grades-table td {
  padding: .3rem .2rem;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.grades-table td.eye-label {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--navy);
  width: 40px;
  font-size: .78rem;
}

.grades-table input {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: .35rem .2rem;
  width: 100%;
  text-align: center;
  font-family: inherit;
  font-size: .82rem;
  background: transparent;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
  cursor: pointer;
}

.grades-table input:hover { background: #f8fafc; }

.grades-table input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .1);
}

.dnp-row {
  margin-top: 1rem;
}

/* ── Checkboxes ──────────────────────────────────────── */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .6rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.checkbox-item:hover {
  background: rgba(238, 242, 255, 0.7);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.checkbox-item.checked {
  background: #eef2ff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.checkbox-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.checkbox-item:hover input[type="checkbox"] { border-color: var(--accent); }

.checkbox-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-item input[type="checkbox"]:checked::after {
  content: '✓';
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  position: absolute;
}

.checkbox-item span {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Prisma Box ──────────────────────────────────────── */
.prisma-box {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
}

.prisma-box .prisma-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}

.lente-prisma-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 1.5rem 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26, 46, 90, .35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(26, 46, 90, .45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: var(--navy);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: var(--navy);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, .3);
}

.btn-accent:hover {
  box-shadow: 0 6px 20px rgba(59, 130, 246, .4);
  transform: translateY(-1px);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

.btn-sm {
  padding: .35rem .7rem;
  font-size: .75rem;
}

/* ── Listas (pacientes / histórico) ──────────────────── */
.list-toolbar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.list-toolbar .search-input {
  flex: 1;
  min-width: 200px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  font-family: inherit;
  font-size: .88rem;
  background: #fff;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.list-toolbar .search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  margin-bottom: .6rem;
  transition: all var(--transition);
  flex-wrap: wrap;
}

.list-item:hover {
  border-color: rgba(59, 130, 246, .35);
  box-shadow: var(--shadow);
}

.list-item-main {
  flex: 1;
  min-width: 180px;
}

.list-item-title {
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
}

.list-item-sub {
  font-size: .76rem;
  color: var(--text-muted);
}

.list-item-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: .88rem;
}

.count-badge {
  display: inline-block;
  background: #eef2ff;
  color: var(--accent);
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .55rem;
  margin-left: .4rem;
}

/* ── Configurações ───────────────────────────────────── */
.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo-preview {
  width: 72px;
  height: 72px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #fff;
  padding: 4px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.color-row input[type="color"] {
  width: 48px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  padding: 2px;
}

.margens-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-top: .75rem;
}

/* ── Modal genérico ──────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  animation: fadeBg .2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--navy);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--text);
}

.modal-body {
  padding: 1.25rem;
  font-size: .88rem;
  color: var(--text);
}

.modal-body ul {
  margin: .5rem 0 0 1.25rem;
}

.modal-body li {
  margin-bottom: .25rem;
}

.modal-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--navy);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transform: translateY(12px);
  transition: all .3s ease;
  pointer-events: none;
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Footer ───────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .75rem;
}

/* ── Wheel Picker ────────────────────────────────────── */
.esf-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(15, 29, 58, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.esf-picker-overlay.active {
  display: flex;
  opacity: 1;
}

.esf-picker-card {
  background: #fff;
  border-radius: 24px;
  width: 340px;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.esf-picker-overlay.active .esf-picker-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.esf-picker-header {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-radius: 24px 24px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.esf-picker-title {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.1rem;
}

.esf-picker-close {
  background: #e2e8f0;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.esf-picker-close:hover {
  background: #cbd5e1;
  color: var(--navy);
}

.picker-presets {
  display: flex;
  gap: 6px;
  padding: 12px 24px 0;
  justify-content: center;
}

.preset-btn {
  flex: 1;
  padding: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: #eef2ff;
  border-color: var(--accent);
  color: var(--accent);
}

.esf-picker-body {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
}

.esf-stepper-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: #f1f5f9;
  color: var(--navy);
  font-size: 2rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  user-select: none;
  flex-shrink: 0;
}

.esf-stepper-btn:active {
  background: #e2e8f0;
  transform: translateY(2px);
  box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
}

.esf-wheel-container {
  flex: 1;
  height: 160px;
  position: relative;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
}

.esf-wheel-selection-overlay {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 40px;
  margin-top: -20px;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgba(59, 130, 246, 0.08);
  pointer-events: none;
  border-radius: 8px;
}

.esf-wheel-list {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  padding: 60px 0;
}

.esf-wheel-list::-webkit-scrollbar { display: none; }

.esf-wheel-item {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 500;
  scroll-snap-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  cursor: pointer;
  opacity: 0.5;
}

.esf-wheel-item.active {
  color: var(--accent);
  font-size: 1.7rem;
  font-weight: 800;
  opacity: 1;
  letter-spacing: -0.02em;
}

.esf-picker-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 24px 24px;
  background: #fff;
}

.esf-input-active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2) !important;
  background: #eef2ff !important;
  color: var(--accent) !important;
  font-weight: 700 !important;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 700px) {
  .field-row.cols-3 { grid-template-columns: 1fr 1fr; }
  .field-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .lente-prisma-row { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr 1fr; }
  .margens-grid { grid-template-columns: 1fr 1fr; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; }
  .header-text h1 { font-size: 1.15rem; }
  .app-header { padding: 1.25rem 1rem 2.75rem; }
  .section-card { padding: 1.1rem; }
}

/* ── Spinner ──────────────────────────────────────────── */
.btn .spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { opacity: .6; }

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

/* ── Indicador de sincronização ────────────────────────── */
.sync-status {
  position: absolute;
  top: .9rem;
  right: 1rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: .25rem .7rem;
  font-size: .7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .9);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.sync-status[data-status="synced"] .sync-dot { background: #34d399; }
.sync-status[data-status="syncing"] .sync-dot {
  background: #fbbf24;
  animation: pulse 1s ease-in-out infinite;
}
.sync-status[data-status="offline"] .sync-dot { background: #fb923c; }
.sync-status[data-status="error"] .sync-dot { background: #f87171; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ── Tela de login ─────────────────────────────────────── */
.login-msg {
  font-size: .8rem;
  color: var(--text-muted);
  min-height: 1.2em;
  margin-top: .25rem;
}

.login-msg.erro { color: var(--danger); }
