:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --panel: rgba(18, 26, 43, 0.65);
  --panel-solid: #111a2c;
  --border: rgba(43, 59, 90, 0.4);
  --border-focus: #10b981;
  --text: #f1f5f9;
  --muted: #64748b;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-secondary: #38bdf8;
  --error: #ef4444;
  --font: 'Outfit', sans-serif;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius: 16px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.05) 0px, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

header {
  margin-bottom: 32px;
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

header p {
  color: var(--muted);
  font-size: 1.05rem;
}

/* Cards / Glassmorphism */
.upload-card, .review-panel, .summary-card, .laudo-card, .modal-card, .auth-card, .chart-card, .relatorios-section {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

/* Auth Panel */
.auth-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  border-color: rgba(56, 189, 248, 0.2);
}

.auth-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-tab {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  padding: 12px;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-tab:hover {
  border-color: var(--accent-secondary);
}

.auth-tab.active {
  background: var(--accent-secondary);
  color: #0b0f19;
  border-color: var(--accent-secondary);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.auth-message {
  margin-top: 16px;
  min-height: 1.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  text-align: center;
}

.auth-message.success { color: var(--accent); }
.auth-message.error { color: var(--error); }

/* Header Actions */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
}

.user-box span {
  font-weight: 500;
  color: #e2e8f0;
}

#logout-button {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

#logout-button:hover {
  background: var(--error);
  color: #ffffff;
  border-color: var(--error);
}

#toggle-relatorios {
  background: transparent;
  border: 1px solid var(--border);
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 999px;
  transition: all 0.2s;
}

#toggle-relatorios:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-secondary);
}

/* Upload Card */
.upload-card {
  text-align: center;
  border-style: dashed;
  border-width: 2px;
  padding: 40px 24px;
}

.upload-button {
  display: inline-block;
  padding: 12px 28px;
  background: var(--accent);
  color: #0c1524;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.upload-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px 0 rgba(16, 185, 129, 0.4);
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 12px;
}

/* Form Fields & Grid */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: #cbd5e1;
  font-weight: 500;
}

input, select, textarea {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

textarea {
  resize: vertical;
}

button[type="submit"] {
  padding: 12px 24px;
  background: var(--accent);
  color: #0b0f19;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

/* Summary Metrics */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  text-align: center;
  padding: 20px 16px;
  margin-bottom: 0;
  transition: transform 0.2s;
}

.summary-card:hover {
  transform: translateY(-2px);
}

.summary-card strong {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-secondary);
  margin-bottom: 4px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Cards List */
.laudos-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.laudo-card {
  margin-bottom: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.laudo-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-secondary);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.laudo-card .header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.laudo-card strong {
  font-size: 1.15rem;
  color: #ffffff;
}

.laudo-card .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.laudo-card .badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.laudo-card button {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.laudo-card button:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-card {
  width: min(780px, 100%);
  margin-bottom: 0;
  max-height: 90vh;
  overflow-y: auto;
  border-color: var(--accent-secondary);
}

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

.modal-header h3 {
  font-size: 1.35rem;
  font-weight: 600;
}

.modal-header button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.8rem;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-header button:hover {
  color: var(--error);
}

/* Relatórios */
.relatorios-section {
  margin-top: 32px;
}

.relatorios-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.relatorios-filters button {
  padding: 12px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-secondary);
  border: 1px solid rgba(56, 189, 248, 0.2);
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.2s;
}

.relatorios-filters button:hover {
  background: var(--accent-secondary);
  color: #0b0f19;
}

/* Charts Container */
.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  padding: 20px;
  margin-bottom: 0;
}

.chart-card h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 16px;
}

.chart-wrapper {
  position: relative;
  height: 240px;
  width: 100%;
}

.relatorio-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
  font-size: 0.95rem;
}

.relatorio-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--accent-secondary);
  color: var(--accent-secondary);
}

.relatorio-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  color: #e2e8f0;
}

.relatorio-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.relatorios-resultado h3 {
  margin-top: 32px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-secondary);
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: #111a2e;
  border-left: 4px solid var(--accent);
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  color: #f1f5f9;
  min-width: 280px;
  max-width: 420px;
  font-weight: 500;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toast.error {
  border-left-color: var(--error);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive grid changes */
@media (max-width: 850px) {
  .charts-container {
    grid-template-columns: 1fr;
  }
  .summary {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .summary {
    grid-template-columns: 1fr;
  }
  .header-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

.hidden {
  display: none !important;
}

/* Pagination */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  margin-bottom: 8px;
}

.pagination-button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.pagination-button:hover {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
  background: rgba(56, 189, 248, 0.05);
}

.pagination-button.active {
  background: var(--accent-secondary);
  color: #0b0f19;
  border-color: var(--accent-secondary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}
