:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #edf1ea;
  --text: #1f2a23;
  --muted: #56645b;
  --brand: #1d6b4f;
  --brand-strong: #0f4b37;
  --danger: #9b2c2c;
  --warning: #a86111;
  --success: #1f7a46;
  --border: #d4ddd3;
  --radius: 14px;
  --shadow: 0 10px 26px rgba(19, 42, 29, 0.08);
  --space: 1rem;
  --font: "Avenir Next", "Segoe UI Variable", "Trebuchet MS", "Gill Sans", sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1714;
  --surface: #1a2722;
  --surface-soft: #203028;
  --text: #eaf2ec;
  --muted: #b4c2b9;
  --brand: #4fbf8e;
  --brand-strong: #70d9a8;
  --danger: #ef8f8f;
  --warning: #f2c27a;
  --success: #9ed9b3;
  --border: #2b4237;
  --shadow: none;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(circle at top right, #dbe8da 0%, var(--bg) 40%);
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1120px, 92%); margin: 0 auto; }
.main-content { padding: 1.25rem 0 2rem; display: grid; gap: 1rem; }
.site-header, .site-footer { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-footer { border-top: 1px solid var(--border); border-bottom: 0; }
.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 0;
}
.nav-row nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.theme-toggle { background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .75rem; color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.card.subtle { background: var(--surface-soft); box-shadow: none; }
.hero {
  background: linear-gradient(145deg, #1d6b4f 0%, #2d8a5b 100%);
  color: #fff;
}
.hero .btn { margin-top: .4rem; }
.lead { font-size: 1.05rem; max-width: 64ch; }

.grid { display: grid; gap: .8rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

label { display: grid; gap: .35rem; font-weight: 600; }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .58rem .62rem;
  background: #fff;
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: #16211d; color: var(--text); }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: .6rem .9rem;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.btn.alt { background: var(--brand-strong); }
.actions { display: flex; gap: .7rem; margin-top: .9rem; flex-wrap: wrap; }

.toggle { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.toggle input { width: auto; }
.muted { opacity: .6; }
.hint { color: var(--muted); margin: .4rem 0 .9rem; }
.meta-row { margin: .7rem 0; }
.badge { display: inline-block; padding: .3rem .6rem; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--border); font-size: .92rem; }

.result-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.status { padding: .35rem .65rem; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.status.minimum-necessities-not-secured { background: rgba(155,44,44,.15); color: var(--danger); }
.status.basic-level-secured-but-under-pressure { background: rgba(168,97,17,.15); color: var(--warning); }
.status.dignified-level-reached { background: rgba(31,122,70,.15); color: var(--success); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); text-align: left; padding: .55rem .45rem; }
.inline-form, .inline-filter { display: inline; }
.inline-filter { display: flex; gap: .5rem; margin-bottom: .8rem; }
.link-btn { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0; margin-left: .5rem; }

.flash { padding: .7rem .8rem; border-radius: 10px; margin-bottom: .7rem; }
.flash.success { background: rgba(31,122,70,.16); color: var(--success); }
.flash.error { background: rgba(155,44,44,.16); color: var(--danger); }

.kpi { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; padding: .8rem; display: grid; }
.kpi strong { font-size: 1.3rem; }
.kpi span { color: var(--muted); font-size: .9rem; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: min(500px, 100%); }

@media (max-width: 840px) {
  .grid.two, .grid.four { grid-template-columns: 1fr; }
  .result-head { flex-direction: column; align-items: flex-start; }
}

@media print {
  .site-header,
  .site-footer,
  .actions,
  .theme-toggle,
  #copySummaryBtn,
  .admin-head nav { display: none !important; }

  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
