:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --input-line: #d0d5dd;
  --bg: #f3f4f6;
  --side: #0b1220;
  --side-hover: #1e293b;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

button, input, textarea, select { font: inherit; }

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(160deg, #0b1220, #14532d);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card img { display: block; height: 56px; margin: 0 auto 12px; }
.login-card h2 { text-align: center; margin: 0 0 24px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--side);
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.sidebar-brand img { height: 36px; }
.sidebar-brand strong { font-size: 19px; display: block; }
.sidebar-brand small { color: #94a3b8; font-size: 12px; }

.side-group { color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: 1.1px; padding: 14px 10px 6px; }

.side-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  background: transparent;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.side-btn:hover { background: var(--side-hover); color: #fff; }
.side-btn.active { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--green); }

.badge-count { background: var(--green); color: #052e16; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; }

.side-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 16px; display: grid; gap: 8px; }

.main { flex: 1; min-width: 0; padding: 28px; }

.topbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.topbar .eyebrow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; }
.topbar h1 { margin: 6px 0 0; font-size: 26px; }

/* ---------- Componentes ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--green); color: #052e16; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--green-dark); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--input-line); }
.btn-light:hover:not(:disabled) { background: #f9fafb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-small { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-warn { background: #fff7ed; color: #9a5b00; border-color: #fed7aa; }
.alert-error { background: #fee2e2; color: var(--danger); }
.alert-ok { background: #dcfce7; color: #15803d; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.panel + .panel { margin-top: 16px; }
.panel h3 { margin: 0 0 16px; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
.field .hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.input:focus { outline: 2px solid rgba(34, 197, 94, 0.35); border-color: var(--green); }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.5; }

.image-field { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.image-field .preview {
  width: 160px;
  height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb center/contain no-repeat;
  flex-shrink: 0;
}
.image-field .controls { flex: 1; min-width: 200px; display: grid; gap: 8px; }

.tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tab {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--input-line);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.tab.active { border: 2px solid var(--green); background: #f0fdf4; font-weight: 700; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 28px 0 14px; padding-top: 20px; border-top: 1px solid var(--line); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.item-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; background: #fcfcfd; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.item-head strong { font-size: 14px; }
.item-actions { display: flex; gap: 6px; }

.save-bar {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  padding: 14px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .tab { padding: 8px 14px; }

.contact-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 12px; }
.contact-card.is-new { border-left: 4px solid var(--green); }
.contact-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.contact-top h4 { margin: 0; font-size: 16px; }
.contact-top .date { color: var(--muted); font-size: 12px; margin-top: 4px; }
.contact-meta { display: flex; gap: 8px 18px; flex-wrap: wrap; color: #374151; font-size: 13px; margin-bottom: 10px; }
.contact-meta a { color: var(--green-dark); text-decoration: none; font-weight: 600; }
.contact-message { white-space: pre-wrap; background: #f9fafb; border-radius: 8px; padding: 12px; margin: 0 0 12px; line-height: 1.5; }
.contact-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status-pill { border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.status-novo { background: #dcfce7; color: #166534; }
.status-em_tratamento { background: #fef3c7; color: #92400e; }
.status-concluido { background: #e5e7eb; color: #374151; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .sidebar-brand { padding: 0 8px 0 0; width: 100%; }
  .side-group { display: none; }
  .side-btn { width: auto; flex: 1 1 auto; justify-content: center; gap: 8px; padding: 10px 12px; font-size: 14px; }
  .side-footer { display: none; }
  .main { padding: 16px; }
  .panel { padding: 16px; }
  .topbar h1 { font-size: 22px; }
}
