:root {
  color-scheme: light;
  --bg: #f5f2ee;
  --bg-accent: #fef9f2;
  --ink: #1e1a17;
  --muted: #6f655b;
  --primary: #e45f2b;
  --primary-dark: #c94f20;
  --card: #ffffffcc;
  --border: #eadfd2;
  --shadow: 0 25px 60px rgba(36, 22, 9, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top right, #fff1df 0%, #f7efe5 45%, #f0e7dc 100%);
  color: var(--ink);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(31, 25, 20, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
  opacity: 0.6;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hidden {
  display: none !important;
}

h1,
h2,
h3 {
  font-family: "Spectral", serif;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(2rem, 2.8vw, 3rem);
}

h2 {
  font-size: clamp(1.3rem, 1.6vw, 1.8rem);
}

p {
  margin: 0;
  line-height: 1.5;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: rise 600ms ease both;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(245, 242, 238, 0.9);
  z-index: 5;
  overflow-y: auto;
}

.auth-card {
  width: min(420px, 92vw);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero-badge {
  background: var(--bg-accent);
  border-radius: 16px;
  padding: 18px 22px;
  text-align: center;
  min-width: 180px;
}

.hero-number {
  font-size: 2.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.hero-label {
  color: var(--muted);
  font-size: 0.95rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.subhead {
  color: var(--muted);
  max-width: 540px;
}

.user-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.summary-card {
  background: #fff8f1;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid #f1ddc7;
}

.summary-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 8px 0 4px;
}

.summary-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.inline-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.95rem;
  color: var(--muted);
}

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

input,
select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 20px rgba(228, 95, 43, 0.25);
}

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

.ghost {
  background: transparent;
  border: 1px dashed var(--primary);
  color: var(--primary);
}

.danger {
  background: #f8e1de;
  color: #b3472b;
}

.status {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 20px;
}

.divider {
  margin: 16px 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.meta-stack {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.clinic-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff3e6;
  border: 1px solid #f1ddc7;
  font-size: 0.85rem;
  color: var(--muted);
}

.mode-banner {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  font-size: 0.92rem;
  color: var(--muted);
}

.mode-banner div {
  background: #fff8f1;
  border: 1px solid #f1ddc7;
  border-radius: 12px;
  padding: 10px 12px;
}

.registo-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
  grid-auto-rows: minmax(min-content, max-content);
}

.registo-panel {
  background: #fff8f1;
  border: 1px solid #f1ddc7;
  border-radius: 14px;
  padding: 16px;
  min-width: 0;
}

.registo-panel h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.date-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entries {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.entry-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: center;
}

.entry-row input,
.entry-row select {
  width: 100%;
  min-width: 0;
}

.entry-row .entry-remove {
  justify-self: end;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.ocr-preview {
  margin-top: 16px;
  background: #fff7ef;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #f2dfcc;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 60px;
}

.drop-zone {
  border: 2px dashed #f0caa9;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  background: #fffaf4;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #fff1df;
}

.drop-zone input[type="file"] {
  width: 100%;
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.month-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 0.92rem;
}

.month-table th,
.month-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #efdccc;
}

.month-table th {
  font-weight: 600;
  color: var(--muted);
}

.month-table tbody tr:hover {
  background: #fff7ef;
}

.history-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.history-controls button.is-active {
  background: var(--primary);
  color: #fff;
  border: none;
}

.history-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10px, 1fr));
  gap: 4px;
  align-items: end;
  min-height: 180px;
  margin-top: 18px;
}

.history-bar {
  background: linear-gradient(180deg, #f7b46f 0%, #e66533 100%);
  border-radius: 6px 6px 2px 2px;
  min-height: 10px;
  transition: height 0.2s ease;
}

.history-legend {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .entry-row {
    grid-template-columns: 1fr;
  }

  .entry-row button {
    width: 100%;
  }
}
