:root {
  --green: #1b4d3e;
  --green-dark: #123529;
  --green-light: #e6f0ec;
  --accent: #c47a1a;
  --bg: #f6f7f6;
  --surface: #ffffff;
  --text: #1f2a26;
  --muted: #6b7a74;
  --line: #dde3e0;
  --danger: #a3392f;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--green); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; color: var(--green-dark); }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
code { background: var(--green-light); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); font-weight: normal; font-size: .92em; }
.nowrap { white-space: nowrap; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--danger); }

/* topo */
.topbar { background: var(--green); color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand span { font-weight: 400; opacity: .8; margin-left: .3rem; }
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a {
  color: #fff; text-decoration: none; padding: .35rem .7rem; border-radius: var(--radius); opacity: .85;
}
.nav a:hover, .nav a.active { background: var(--green-dark); opacity: 1; }
.nav .btn-ghost { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.4); }

.container { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.period { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }

/* flash */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-color: #9cc9b3; background: var(--green-light); color: var(--green-dark); }
.flash-warn { border-color: #e2c38f; background: #fff6e6; color: #6b4a0f; }
.flash-error { border-color: #e0a9a3; background: #fdecea; color: var(--danger); }
.flash ul { margin: .3rem 0 0 1.2rem; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.card-value { font-size: 1.6rem; font-weight: 700; color: var(--green); }
.card-label { color: var(--muted); font-size: .85rem; }

/* gráficos */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1rem 0; }
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem 1rem; }
.chart-box h2 { margin-top: .2rem; }
.chart-box canvas { max-height: 240px; }

/* tabelas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--green-light); color: var(--green-dark); font-weight: 600; white-space: nowrap; }
table.zebra tbody tr:nth-child(even) { background: #f3f6f4; }
table.zebra tbody tr:hover { background: #e9f1ed; }
tr.inactive-row td { color: var(--muted); }
table.kv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.kv th { width: 40%; color: var(--muted); font-weight: 500; }

/* badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: #e3e7e5; color: var(--text); white-space: nowrap; }
.badge-active { background: var(--green-light); color: var(--green-dark); }
.badge-pending { background: #fff3dc; color: #6b4a0f; }
.badge-inactive { background: #e9ecea; color: var(--muted); }
.badge-declined { background: #fdecea; color: var(--danger); }

/* botões e formulários */
.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; font: inherit; font-size: .92rem;
}
.btn:hover { border-color: var(--green); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { color: var(--danger); border-color: #e0a9a3; }
.btn-danger:hover { background: #fdecea; }
form.inline { display: inline; }
.actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 1rem; }
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .7rem; border-radius: var(--radius); text-decoration: none; color: var(--green-dark); }
.tabs a.active { background: var(--green); color: #fff; }
.form { max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field small { display: block; color: var(--muted); margin-top: .2rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.checks label { display: inline-block; font-weight: 500; margin-right: 1.2rem; }
input[type=text], input[type=search], input[type=url], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: #fff;
}
input[readonly] { background: #f0f2f1; color: var(--muted); }
input[type=search] { max-width: 320px; }
.form-inline { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.form-inline label { font-size: .9rem; }
.form-inline input { width: 130px; display: block; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* fotos */
.photos { display: flex; gap: .75rem; flex-wrap: wrap; }
.photos figure { margin: 0; text-align: center; }
.photos img { width: 160px; height: 220px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.photo-missing { width: 160px; height: 220px; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); font-size: .85rem; }
.photos figcaption { font-size: .85rem; color: var(--muted); }

/* login */
.login-box { max-width: 380px; margin: 3rem auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.login-box label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
.login-box .btn { margin-top: 1rem; width: 100%; }

@media (max-width: 720px) {
  .grid-2, .field-row { grid-template-columns: 1fr; }
  html { font-size: 15px; }
}
