:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1e1f24;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f8fafc;
  color: inherit;
}

.app-header {
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  font-weight: 700;
}

nav {
  display: flex;
  gap: 0.5rem;
}

.tab-button {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.tab-button.active {
  border-color: rgba(59, 130, 246, 0.6);
  color: #2563eb;
}

.tab-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

main {
  flex: 1;
  padding: clamp(1rem, 4vw, 3rem);
  display: grid;
  place-items: start center;
}

.tab {
  display: none;
  width: min(720px, 100%);
  gap: 1rem;
}

.tab.active {
  display: flex;
  flex-direction: column;
}

.card {
  width: 100%;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: 20px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card h2, .card h3 {
  margin: 0;
}

.card.muted {
  opacity: 0.6;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 500;
}

textarea,
input[type="date"] {
  resize: vertical;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #f8fafc;
  color: inherit;
  font: inherit;
  min-height: 3rem;
}

input[type="date"] {
  min-height: unset;
  line-height: 1.4;
  resize: none;
}

textarea:focus,
input[type="date"]:focus {
  outline: 2px solid rgba(14, 116, 144, 0.5);
  outline-offset: 2px;
  background: #fff;
}

.helper-text {
  font-size: 0.85rem;
  color: #64748b;
  display: block;
}

.record-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

.action-buttons {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(120deg, #3b82f6, #1d4ed8);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(37, 99, 235, 0.35);
}

.secondary {
  padding: 0.75rem 1.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  background: #fff;
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary:not(:disabled):hover {
  border-color: rgba(37, 99, 235, 0.4);
}

.status {
  font-size: 0.95rem;
  opacity: 0.8;
}

.upload-status {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.08);
  color: #1d4ed8;
}

.upload-status.error {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(248, 113, 113, 0.1);
  color: #991b1b;
}

.hidden {
  display: none;
}

.result-block {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
  overflow-x: auto;
}

@media (max-width: 600px) {
  .record-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .status {
    text-align: center;
  }
}

.lead {
  margin: 0;
  font-size: 1rem;
  opacity: 0.85;
}

.info-block {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(248, 250, 252, 0.9);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.info-block h3 {
  margin: 0;
  font-size: 1.05rem;
}

.field-list {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
  list-style: disc;
}

.field-list li {
  line-height: 1.4;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.muted-text {
  font-size: 0.9rem;
  color: #8c7aa6;
}

.info-banner {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #fff;
  color: #475569;
  font-size: 0.95rem;
}

.info-banner.error {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(254, 226, 226, 0.5);
  color: #b91c1c;
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #fff;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.chart-body {
  position: relative;
}

.chart {
  width: 100%;
  height: 220px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(191, 219, 254, 0.5), rgba(248, 250, 252, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.chart .chart-label {
  font-size: 12px;
  fill: rgba(71, 85, 105, 0.85);
}

.chart-grid line {
  shape-rendering: crispEdges;
}

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

.stat-card {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.7;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
}

.stat-footnote {
  font-size: 0.85rem;
  opacity: 0.65;
}

.insights-panels {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel h3, .panel h4 {
  margin: 0;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

 .chip {
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: #eef2ff;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chip strong {
  font-weight: 600;
}

.distribution-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.93rem;
}

.distribution-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  opacity: 0.85;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-notes {
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0.85;
}

.recent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.88rem;
  opacity: 0.8;
}

 .badge {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid rgba(249, 115, 22, 0.35);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .stat-value {
    font-size: 1.5rem;
  }
}
