:root {
  --bg: #0B0D15;
  --bg-glow-1: rgba(52, 211, 153, 0.07);
  --bg-glow-2: rgba(129, 140, 248, 0.05);

  --surface: #131620;
  --surface-elevated: #191D28;
  --surface-glass: rgba(255, 255, 255, 0.03);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(255, 255, 255, 0.18);
  --border-active: #34D399;

  --primary: #34D399;
  --primary-dark: #10B981;
  --primary-subtle: rgba(52, 211, 153, 0.12);

  --text: #F1F5F9;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.30);
  --text-inverse: #0B0D15;

  --error: #F87171;
  --error-bg: rgba(248, 113, 113, 0.10);
  --success: #34D399;
  --success-bg: rgba(52, 211, 153, 0.10);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --radius-inner: 14px;
  --radius-outer: 20px;
  --radius-pill: 9999px;

  --cubic-smooth: cubic-bezier(0.32, 0.72, 0, 1);
  --cubic-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --cubic-out: cubic-bezier(0.16, 1, 0.3, 1);

  --duration: 0.6s;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -15%, var(--bg-glow-1), transparent),
    radial-gradient(ellipse 50% 35% at 85% 90%, var(--bg-glow-2), transparent);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
  position: relative;
  z-index: 1;
}

/* --- Header --- */

.header-shell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-outer);
  padding: 1px;
  margin: 44px auto 32px;
  max-width: 480px;
  position: relative;
}

.header-shell::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius-outer) + 1px);
  padding: 1px;
  background: conic-gradient(from 180deg at 50% 50%,
    rgba(52, 211, 153, 0.15),
    rgba(129, 140, 248, 0.08),
    rgba(52, 211, 153, 0.02),
    rgba(129, 140, 248, 0.08),
    rgba(52, 211, 153, 0.15)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.header {
  background: var(--surface-elevated);
  border-radius: calc(var(--radius-outer) - 1px);
  padding: 28px 24px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::after {
  content: '';
  position: absolute;
  top: -60%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(ellipse at 30% 40%, rgba(52, 211, 153, 0.04), transparent 60%);
  pointer-events: none;
}

.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
  margin-bottom: 6px;
  position: relative;
}

.instructions {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.7;
  text-align: left;
  position: relative;
  margin-top: 10px;
}

.instructions p {
  margin-bottom: 2px;
}

/* --- Card Shell --- */

.card-shell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-outer);
  padding: 1px;
  margin-bottom: 16px;
  animation: cardIn var(--duration) var(--cubic-out) both;
}

.card-shell:nth-child(2) { animation-delay: 0.05s; }
.card-shell:nth-child(3) { animation-delay: 0.10s; }
.card-shell:nth-child(4) { animation-delay: 0.15s; }

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-inner {
  background: var(--surface);
  border-radius: calc(var(--radius-outer) - 1px);
  padding: 28px 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card-inner h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-inner h2::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Fields --- */

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  outline: none;
  transition:
    border-color var(--duration) var(--cubic-smooth),
    box-shadow var(--duration) var(--cubic-smooth),
    background var(--duration) var(--cubic-smooth);
  -webkit-appearance: none;
  appearance: none;
}

.field textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.field input:hover,
.field textarea:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.06);
}

.field input:focus-visible,
.field textarea:focus-visible {
  border-color: var(--border-focus);
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.field-error {
  font-size: 11px;
  font-weight: 500;
  color: var(--error);
  margin-top: 6px;
  min-height: 0;
  transition: opacity 0.3s ease;
  padding-left: 2px;
}

.field-error:empty {
  margin-top: 0;
  opacity: 0;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 2px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

/* --- Tab Bar --- */

.tab-bar {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: -8px auto 16px;
}

.tab-btn {
  flex: 1;
  max-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* --- Tab Panel --- */

.tab-panel {
  display: block;
}

.tab-panel[hidden] {
  display: none;
}

/* --- Dosagem Radio (Lateralidade) --- */

.dosagem-tipo {
  display: flex;
  gap: 8px;
}

.dosagem-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  letter-spacing: 0.04em;
}

.dosagem-radio:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.dosagem-radio:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}

.dosagem-radio input {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

/* --- Camera Section --- */

.camera-section {
  margin-top: 16px;
}

.camera-section video {
  width: 100%;
  border-radius: var(--radius-inner);
  background: #000;
  display: none;
  aspect-ratio: 4/3;
  object-fit: cover;
}

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

.btn-camera {
  flex: 1;
  min-width: 120px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-camera:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.photo-preview {
  margin-top: 12px;
  text-align: center;
}

.photo-preview img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-inner);
  border: 1px solid var(--border-active);
  background: #000;
}

/* --- Galeria Section --- */

.galeria-section {
  margin-top: 16px;
}

.galeria-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-inner);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.galeria-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.galeria-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 12px;
  line-height: 1;
}

.galeria-upload-area p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Button (Primary Pill) --- */

.btn-primary {
  width: 100%;
  height: 52px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-inverse);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  position: relative;
  transition:
    background var(--duration) var(--cubic-smooth),
    transform 0.3s var(--cubic-spring),
    box-shadow var(--duration) var(--cubic-smooth);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px rgba(52, 211, 153, 0.2),
    0 2px 8px rgba(52, 211, 153, 0.1);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.4s var(--cubic-spring);
}

.btn-arrow svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--text-inverse);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s var(--cubic-spring);
}

.btn-primary:hover:not(:disabled) .btn-arrow {
  transform: translateX(2px) translateY(-1px);
}

.btn-primary:hover:not(:disabled) .btn-arrow svg {
  transform: translateX(1px);
}

.btn-primary .spinner:not(.hidden) ~ .btn-arrow {
  display: none;
}

/* --- Spinner --- */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--text-inverse);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* --- Feedback --- */

.feedback {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-inner);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  animation: cardIn 0.4s var(--cubic-out) both;
}

.feedback.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.15);
}

.feedback.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

.feedback.info {
  background: rgba(129, 140, 248, 0.10);
  color: #818CF8;
  border: 1px solid rgba(129, 140, 248, 0.15);
}

/* --- Footer --- */

.footer {
  text-align: center;
  padding: 32px 0 8px;
  position: relative;
}

.footer span {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.footer::before {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--border);
  margin: 0 auto 16px;
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .container {
    padding: 0 12px 32px;
  }

  .header-shell {
    margin: 20px auto 24px;
  }

  .header {
    padding: 24px 18px 22px;
  }

  .header h1 {
    font-size: 20px;
  }

  .card-inner {
    padding: 22px 16px;
  }

  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .field input[type="text"],
  .field input[type="date"],
  .field input[type="number"],
  .field textarea {
    height: 44px;
    font-size: 14px;
  }

  .btn-primary {
    height: 48px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card-shell {
    animation: none;
  }

  .btn-primary:hover:not(:disabled) {
    transform: none;
  }
}
