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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #0d904f;
  --danger: #d93025;
  --warning: #f9ab00;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f1f1f;
  --text-light: #5f6368;
  --border: #dadce0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* === HEADER === */
.header {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.header h1 { font-size: 1.1rem; font-weight: 600; }
.header-info { font-size: 0.8rem; opacity: 0.9; }
.header-actions { display: flex; gap: 8px; }

/* === SCREENS === */
.screen { display: none; padding: 16px; max-width: 900px; margin: 0 auto; }
.screen.active { display: block; }

/* === CARDS === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

/* === FORM ELEMENTS === */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
}
.form-group .hint {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 400;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

/* === FORM ROW (side by side) === */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* === TOGGLE BUTTONS (SIM/NAO) === */
.toggle-group {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  flex: 1;
  padding: 14px 8px;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.toggle-btn:active { transform: scale(0.97); }
.toggle-btn.selected-sim {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.toggle-btn.selected-nao {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.toggle-btn.selected-neutral {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* === STEPPER (numeric +/-) === */
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.stepper-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.stepper-btn:active { background: var(--bg); }
.stepper-btn.minus { color: var(--danger); }
.stepper-btn.plus { color: var(--success); }
.stepper input {
  width: 56px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 4px;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-lg {
  width: 100%;
  padding: 18px;
  font-size: 1.15rem;
}
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-header {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  cursor: pointer;
}
.btn-header:hover { background: rgba(255,255,255,0.3); }

/* === RISCO BADGE === */
.risco-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
}
.risco-A { background: #0d904f; }
.risco-B { background: #34a853; }
.risco-C { background: #f9ab00; }
.risco-D { background: #e37400; }
.risco-E { background: #ea4335; }
.risco-F { background: #c5221f; }
.risco-G { background: #7b1fa2; }

/* === STUDENT LIST === */
.student-list { list-style: none; }
.student-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
}
.student-item:active { background: #e8f0fe; }
.student-item .name { font-weight: 600; font-size: 0.95rem; }
.student-item .info { font-size: 0.8rem; color: var(--text-light); }

/* === RECORDS TABLE === */
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.records-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
}
.records-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.records-table tr:hover td { background: #e8f0fe; }

/* === CARIE GRID === */
.carie-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.carie-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.carie-item label {
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 30px;
  margin-bottom: 0;
}
.carie-item .hint {
  font-size: 0.7rem;
  color: var(--text-light);
  flex: 1;
}
.carie-item-a {
  grid-column: 1 / -1;
  background: #e8f5e9;
  border: 2px solid var(--success);
}

/* === PERIODONTAL GRID === */
.perio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.perio-item {
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.perio-item label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

/* === SECTION ACCORDION === */
.section-toggle {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: none;
  border-bottom: 2px solid var(--primary);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius) var(--radius) 0 0;
}
.section-toggle::after {
  content: '\25BC';
  font-size: 0.8rem;
  transition: transform 0.2s;
}
.section-toggle.collapsed::after { transform: rotate(-90deg); }
.section-content {
  padding: 16px;
  background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.section-content.hidden { display: none; }

/* === STATS === */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* === SEARCH === */
.search-bar {
  position: relative;
  margin-bottom: 12px;
}
.search-bar input {
  padding-left: 40px;
}
.search-bar::before {
  content: '\1F50D';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
}

/* === ALERT === */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}
.alert-info { background: #e8f0fe; color: #1a73e8; }
.alert-success { background: #e6f4ea; color: #0d904f; }
.alert-warning { background: #fef7e0; color: #b06000; }

/* === PATIENT HEADER === */
.patient-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.patient-header .name { font-size: 1.1rem; font-weight: 700; }
.patient-header .details { font-size: 0.85rem; opacity: 0.9; }

/* === FOOTER ACTIONS === */
.footer-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .carie-grid { grid-template-columns: 1fr; }
  .perio-grid { grid-template-columns: 1fr; }
  .stats-row { flex-wrap: wrap; }
  .stat-card { min-width: calc(50% - 6px); }
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* === SCROLLABLE TABLE === */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === FILE UPLOAD === */
.file-upload {
  border: 3px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.file-upload:hover, .file-upload.dragover {
  border-color: var(--primary);
  background: #e8f0fe;
}
.file-upload input { display: none; }
