:root {
  --bg: #faf6f1;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-text: #8a7f79;
  --sidebar-text-active: #221c1a;
  /* Laranja (mais fechado/queimado, menos vibrante) e verde-árvore. */
  --accent: #c1670f;
  --accent-dark: #94500c;
  --accent-soft: #f6e6d3;
  --tree-green: #006400;
  --tree-green-soft: #e3f0e3;
  --text: #221c1a;
  --text-muted: #8a7f79;
  --border: #ece3dc;
  --success-bg: #e3f0e3;
  --success-text: #0f5c2e;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30, 20, 15, 0.06), 0 1px 2px rgba(30, 20, 15, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14100e;
    --card-bg: #1f1a17;
    --sidebar-bg: #1f1a17;
    --sidebar-text: #9c8f88;
    --sidebar-text-active: #f1ebe7;
    --text: #f1ebe7;
    --text-muted: #9c8f88;
    --border: #322922;
    --accent-soft: #3a2a14;
    --tree-green-soft: #16341c;
    --success-bg: #16341c;
    --success-text: #5fd38a;
  }
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-right: 1px solid var(--border);
}

.sidebar .brand {
  color: var(--sidebar-text-active);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0 10px 26px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-group-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tree-green);
  opacity: 0.75;
  padding: 18px 12px 8px;
}
.sidebar-group-label:first-of-type { padding-top: 4px; }

.sidebar a {
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--sidebar-text);
  opacity: 1;
  transition: background 0.15s, color 0.15s;
}
.sidebar a svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.8; }

.sidebar a:hover { background: var(--bg); }

.sidebar a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.sidebar a.active svg { opacity: 1; }

.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 14px 12px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.sidebar .sidebar-footer button {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--sidebar-text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.86rem;
  cursor: pointer;
}

/* Main content */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

.page-header h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-header p {
  color: var(--text-muted);
  margin: 0 0 22px;
  font-size: 0.92rem;
}

/* Tab pills */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tabs a {
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tabs a.active {
  background: var(--accent);
  color: white;
}

/* Stat cards */
.stats-row {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  min-width: 130px;
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cards / lists */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

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

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name { font-weight: 600; font-size: 0.95rem; }
.list-item .info .name .tag-status {
  font-weight: 500; font-size: 0.78rem; color: var(--text-muted); margin-left: 4px;
}
.list-item .info .meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }
.list-item .info .meta .kw { color: var(--accent); font-weight: 600; }
.list-item .info .meta a { color: var(--text-muted); text-decoration: underline; }

.list-item .actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Buttons */
.btn {
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text); padding: 6px 10px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger-outline { background: transparent; border: 1px solid #e4b3ae; color: #b0392f; }
.btn-danger-outline:hover { background: #fdeceb; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* Badges */
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 2px 7px; font-size: 0.78rem; font-weight: 600; }
.badge-yes { background: var(--success-bg); color: var(--success-text); }
.badge-no { color: var(--text-muted); }

.chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 2px 3px 2px 0;
}

/* Table */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
tr:last-child td { border-bottom: none; }

.search-bar {
  margin-bottom: 16px;
}
.search-bar input {
  width: 100%;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* Forms */
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin: 14px 0 5px; }
label:first-child { margin-top: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
  resize: vertical;
}
textarea { min-height: 70px; }
.field-hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 3px; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.err { background: #b0392f; color: white; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 14, 11, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 480px; box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 16px; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Menu mobile: botão hambúrguer no topo, sidebar vira painel deslizante */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text-active);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.mobile-topbar button {
  background: none;
  border: 1px solid var(--border);
  color: var(--sidebar-text-active);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-topbar-brand { font-weight: 700; font-size: 1rem; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 11, 0.5);
  z-index: 40;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    padding: 20px 14px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px; }
  .list-item { flex-wrap: wrap; }
}
