:root {
  --background: #f7f9fb;
  --foreground: #131c2e;
  --card: #ffffff;
  --primary: #028036;
  --primary-hover: #016b2d;
  --muted: #edf1f6;
  --muted-foreground: #4d5a6d;
  --accent: #f3a530;
  --accent-hover: #e6971f;
  --accent-foreground: #131c2e;
  --border: #dde3eb;
  --danger: #9d2c2c;
  --ok: #176b45;
  --radius: 0.75rem;
  --font-heading: 'Archivo', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--foreground);
  background: var(--background);
  line-height: 1.5;
}

h1, h2, p { margin: 0; }

a { color: inherit; }

img { max-width: 100%; display: block; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner, .wrap {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  min-height: 4rem;
  padding: 0.75rem 0;
}

.brand {
  font-family: var(--font-heading);
  font-weight: 800;
  text-decoration: none;
}

.brand span, .menu a.is-active {
  color: var(--primary);
}

.menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
}

.menu a, .linkish {
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

.menu a:hover, .linkish:hover { color: var(--primary); }

.wrap { padding: 1.5rem 0 3rem; }

.wrap h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.lead, .muted { color: var(--muted-foreground); }

.lead { margin-bottom: 1rem; max-width: 42rem; }

.notice {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.notice-ok { background: #e7f6ee; color: var(--ok); }
.notice-erro { background: #fdecec; color: var(--danger); }
.notice-aviso { background: #fff4df; color: #8a4b08; }
.notice a { font-weight: 700; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
}

a.stat { text-decoration: none; display: block; }
a.stat:hover { border-color: var(--primary); }

.stat-label { font-weight: 700; }
.stat-number {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  line-height: 1.1;
  margin: 0.25rem 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 0.7rem;
  border: 2px solid transparent;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  padding: 0.65rem 1rem;
  cursor: pointer;
}

.btn-accent { background: var(--accent); color: var(--accent-foreground); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: #fff; color: var(--foreground); border-color: var(--border); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c8c8; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.82rem; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 1rem; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th { font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted-foreground); }

tr:last-child td { border-bottom: 0; }

.actions, .actions form { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-on { background: #e7f6ee; color: var(--ok); }
.badge-off { background: var(--muted); color: var(--muted-foreground); }

.thumb, .preview {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 0.4rem;
  margin-bottom: 0.25rem;
}

.preview { width: 96px; height: 96px; margin-top: 0.5rem; }
.preview-wide { width: min(100%, 420px); height: auto; aspect-ratio: 1024 / 778; object-fit: cover; }

.empty { padding: 1rem; background: #fff; border: 1px dashed var(--border); border-radius: 1rem; }

.form { display: grid; gap: 0.9rem; max-width: 760px; }

.fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.field { display: grid; gap: 0.35rem; font-weight: 600; }
.field small, .field em { font-weight: 500; color: var(--muted-foreground); font-style: normal; }

input[type="text"], input[type="password"], input:not([type]), textarea, input[type="file"], select {
  width: 100%;
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
}

input[type="checkbox"] { width: 1.1rem; height: 1.1rem; justify-self: start; }

.checkline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
}

textarea { resize: vertical; }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--primary);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
}

.login-card h1 {
  font-family: var(--font-heading);
  margin: 0.35rem 0 0.5rem;
}

.login-card .muted { margin-bottom: 1rem; }

@media (min-width: 800px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  thead { display: none; }
  tr { display: block; padding: 0.4rem 0; }
  td { display: block; border-bottom: 0; padding: 0.25rem 0.9rem; }
  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted-foreground);
  }
  tr + tr { border-top: 1px solid var(--border); }
}
