:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fbff;
  --ink: #111827;
  --muted: #5b6472;
  --line: #d8dfeb;
  --blue: #1d4ed8;
  --blue-soft: #e8f0ff;
  --blue-strong: #0f172a;
  --danger: #b42318;
  --danger-soft: #fff1f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.shell {
  width: min(1040px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 40px;
}

.topbar {
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.topbar-right,
.session-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 1.05rem;
  font-weight: 700;
}

.session-user {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 600;
}

.flash-wrap {
  padding-top: 12px;
  padding-bottom: 0;
}

.flash-message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.flash-error {
  border-color: #efc8c5;
  background: var(--danger-soft);
  color: var(--danger);
}

.flash-info {
  border-color: #bfd2ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.topnav {
  display: inline-flex;
  gap: 8px;
}

.topnav-link {
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
}

.topnav-link.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.hero-card,
.panel,
.card-soft,
.sector-card,
.history-card,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.hero-card,
.panel {
  padding: 20px;
}

.panel {
  margin-top: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.hero-text,
.summary-box span,
.summary-box small,
.helper-text,
.filter-box span,
label span,
dt,
.empty-state p,
.task-copy p,
.sector-card-head p,
.stats-row p,
.entity-card p,
.history-chip span,
.modal-text,
.admin-card-head p,
.task-assign-label span {
  color: var(--muted);
}

.hero-text {
  margin-bottom: 0;
  max-width: 42ch;
  line-height: 1.45;
}

.summary-grid,
.field-grid,
.history-list,
.task-list,
.stats-list,
.admin-overview-grid,
.checklist-toolbar,
.editor-grid,
.admin-grid,
.stats-grid {
  display: grid;
  gap: 12px;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.summary-box,
.card-soft {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
}

.summary-box strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 1.8rem;
}

.summary-box.ingreso {
  border-left: 4px solid var(--blue);
}

.summary-box.egreso {
  border-left: 4px solid var(--blue-strong);
}

.summary-box.neutral {
  border-left: 4px solid #94a3b8;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toggle-group {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
}

.toggle,
.primary-btn,
.secondary-btn,
.modal-close {
  border: 0;
  cursor: pointer;
}

.toggle {
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.toggle.active {
  background: var(--blue);
  color: #fff;
}

label,
.filter-box,
.mini-form,
.compact-form,
.modal-form,
.task-assign-label {
  display: grid;
  gap: 8px;
}

input,
textarea,
select {
  width: 100%;
  padding: 14px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(29, 78, 216, 0.14);
  border-color: var(--blue);
}

textarea {
  resize: vertical;
}

.form-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.primary-btn,
.secondary-btn {
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.primary-btn {
  width: 100%;
  background: var(--blue);
  color: #fff;
}

.secondary-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger-btn {
  border-color: #efc8c5;
  color: var(--danger);
  background: var(--danger-soft);
}

.compact-btn {
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
}

.slim-card {
  padding: 12px;
}

.stack-mobile {
  align-items: stretch;
}

.history-card,
.empty-state,
.sector-card {
  padding: 16px;
}

.history-card {
  border-left: 4px solid var(--blue-soft);
}

.history-card.egreso {
  border-left-color: #c7d2fe;
}

.history-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--blue-soft);
  color: var(--blue);
}

.history-card.egreso .badge {
  background: #e7ecff;
  color: #1e3a8a;
}

.history-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.history-card dl div {
  margin: 0;
}

dt {
  margin-bottom: 4px;
  font-size: 0.8rem;
}

dd {
  margin: 0;
  font-weight: 600;
}

.delete-form {
  margin-top: 14px;
}

.checklist-hero {
  background:
    linear-gradient(135deg, rgba(29, 78, 216, 0.08), rgba(255, 255, 255, 0.96)),
    var(--surface);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 120px);
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.checklist-toolbar {
  margin-top: 18px;
}

.history-filter {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.checklist-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-chips {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.history-chip {
  min-width: 132px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.history-chip strong,
.history-chip span {
  display: block;
}

.history-chip span {
  margin-top: 4px;
  font-size: 0.85rem;
}

.history-chip.active {
  border-color: #bfd2ff;
  background: var(--blue-soft);
}

.history-chip.active strong {
  color: var(--blue);
}

.admin-overview-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-card {
  display: grid;
  gap: 14px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-card-head p {
  margin-bottom: 0;
}

.admin-entity-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.task-entity-list {
  max-height: 420px;
}

.entity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.entity-card p {
  margin-bottom: 0;
}

.entity-actions,
.task-mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-inline {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.sector-grid,
.admin-grid,
.stats-grid,
.editor-grid {
  grid-template-columns: 1fr;
}

.sector-card-head,
.stats-row,
.task-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sector-card-rich {
  display: grid;
  gap: 14px;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.95rem;
}

.sector-progress-wrap {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.progress-bar {
  width: 120px;
  height: 8px;
  border-radius: 999px;
  background: #dbe6ff;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, var(--blue));
}

.task-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
  align-items: center;
}

.task-row.done {
  border-color: #bfd2ff;
  background: linear-gradient(180deg, #f7faff, #eef4ff);
}

.task-status-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  flex: 0 0 auto;
}

.task-status-dot.done {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
}

.grow {
  flex: 1 1 auto;
}

.task-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3ff;
  color: #274690;
  font-size: 0.8rem;
  font-weight: 600;
}

.task-copy strong,
.stats-row strong,
.sector-card-head h3 {
  display: block;
  margin-bottom: 4px;
}

.task-copy p,
.stats-row p,
.sector-card-head p {
  margin-bottom: 0;
}

.task-side-actions {
  display: grid;
  gap: 8px;
  width: min(100%, 220px);
  justify-items: stretch;
}

.task-action {
  width: 100%;
}

.task-complete-form {
  min-width: 0;
  gap: 8px;
}

.task-assign-label {
  min-width: 0;
}

.task-assign-label span {
  font-size: 0.78rem;
  font-weight: 600;
}

.compact-form .primary-btn,
.compact-form .secondary-btn {
  width: 100%;
  min-width: 0;
}

.stats-meta {
  text-align: right;
}

.compact-empty {
  box-shadow: none;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  padding: 20px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
}

.modal-card-danger {
  width: min(100%, 460px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.modal-form {
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.full-width,
.full {
  grid-column: 1 / -1;
}

.empty-state {
  text-align: center;
}

.is-hidden {
  display: none;
}

@media (min-width: 760px) {
  .shell {
    padding-top: 24px;
  }

  .hero-card,
  .panel {
    padding: 24px;
  }

  .field-grid,
  .admin-grid,
  .stats-grid,
  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checklist-toolbar {
    grid-template-columns: minmax(0, 340px) 1fr;
    align-items: end;
  }

  .history-filter {
    flex-direction: row;
    align-items: end;
  }

  .history-filter label {
    flex: 1;
  }

  .admin-overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sector-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-complete-form {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .form-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .primary-btn {
    width: auto;
    min-width: 220px;
  }

  .stack-mobile {
    align-items: end;
  }
}

@media (max-width: 759px) {
  .topbar-inner,
  .topbar-right,
  .session-box,
  .panel-head,
  .history-card header,
  .sector-card-head,
  .stats-row,
  .task-row,
  .admin-card-head,
  .entity-card,
  .modal-head,
  .modal-actions {
    flex-direction: column;
  }

  .topnav {
    width: 100%;
  }

  .topnav-link {
    flex: 1;
    text-align: center;
  }

  .quick-actions,
  .checklist-summary-grid,
  .admin-overview-grid {
    grid-template-columns: 1fr;
  }

  .task-side-actions,
  .task-action,
  .stats-meta,
  .entity-actions,
  .task-mini-actions {
    width: 100%;
    text-align: left;
  }

  .modal-card {
    padding: 18px;
  }
}