:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --border: #e0dbd3;
  --accent: #2d6a9f;
  --accent-light: #e8f1f9;
  --text: #1a1a1a;
  --muted: #7a7670;
  --danger: #c0392b;
  --success: #27ae60;
  --radius: 12px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: 80px;
  min-height: 100vh;
}

header {
  background: var(--accent);
  color: white;
  padding: 20px 20px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

header .label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 4px;
}

header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
}

header .date {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.7;
}

.sections {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-row label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 90px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.field-group label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: white;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button { display: none; }

.inline-fields {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.inline-fields .field-group {
  flex: 1;
}

.unit-tag {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 10px;
  white-space: nowrap;
}

/* Toggle group */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-group label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.options-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.option-btn {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.extra-field {
  display: none;
  margin-top: 6px;
}

.extra-field.visible {
  display: block;
}

textarea {
  resize: none;
  min-height: 72px;
  line-height: 1.5;
}

/* PM section with liquido options */
.pm-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.pm-row .field-group:first-child { flex: 0 0 80px; }
.pm-row .field-group:last-child { flex: 1; }

/* Checkboxes visuais para orifício */
.check-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

.check-item.checked {
  border-color: var(--accent);
  background: var(--accent-light);
}

.check-item .check-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.check-item.checked .check-box {
  background: var(--accent);
  border-color: var(--accent);
}

.check-item.checked .check-box::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}

.check-item span {
  font-size: 13px;
  color: var(--text);
}

/* Submit area */
.submit-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.preview-btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.preview-btn:active { opacity: 0.85; }

/* Modal de preview */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px 20px 32px;
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 4px;
}

.modal .subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.preview-text {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  flex: 1;
  padding: 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.btn-primary {
  flex: 2;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Collapsible cards ── */
.card-toggle {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.card-body.collapsed {
  display: none;
}

.collapse-arrow {
  margin-left: auto;
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
  transition: transform 0.2s;
  transform: rotate(90deg);
}

.collapse-arrow.open {
  transform: rotate(-90deg);
}

.collapse-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* quando há badge, a arrow não precisa do margin-left auto */
.card-header:has(.collapse-badge) .collapse-arrow {
  margin-left: 6px;
}
