:root {
  --bg: #fbf9fc;
  --raise: #ffffff;
  --ink: #1c1218;
  --muted: #5f5f5f;
  --line: rgba(81, 28, 122, 0.16);
  --purple: #511c7a;
  --gold: #c1a067;
  --on-purple: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(81, 28, 122, 0.08), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-weight: 340;
  line-height: 1.45;
}

button, input, select { font: inherit; color: inherit; }

a { color: inherit; }

h1, h2, .brand {
  font-family: Unbounded, sans-serif;
  letter-spacing: -0.04em;
}

h1, h2 { color: var(--purple); }

.login-logo {
  width: min(16rem, 100%);
  height: auto;
  justify-self: center;
}

h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); margin: 0; }
h2 { font-size: 1.25rem; margin: 0; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(26rem, 100%);
  display: grid;
  gap: 0.9rem;
  padding: 1.4rem;
  background: var(--raise);
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0;
  color: var(--purple);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.muted { color: var(--muted); }
.login-card .muted { margin: 0; }

.shell {
  display: grid;
  grid-template-columns: 15.5rem 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  padding: 1.2rem 1rem;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-size: 0.95rem;
}

.brand {
  color: var(--purple);
}

.brand-mark {
  width: 2.4rem;
  height: auto;
}

.nav { display: grid; gap: 0.2rem; overflow: auto; }

.nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  text-decoration: none;
  color: var(--muted);
}

.nav a.is-current {
  color: var(--purple);
  background: rgba(81, 28, 122, 0.08);
  box-shadow: inset 3px 0 0 var(--purple);
}

.badge {
  min-width: 1.4rem;
  padding: 0.05rem 0.35rem;
  background: var(--purple);
  color: var(--on-purple);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 580;
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 0.45rem;
}

.side-foot button, .side-foot a {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.content { padding: 1.5rem 1.4rem 4rem; min-width: 0; }

.page-head, .actions, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
}

.page-head { margin-bottom: 1.2rem; }
.page-head p { margin: 0.35rem 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}

.stat {
  padding: 0.9rem;
  background: var(--raise);
  border: 1px solid var(--line);
}

.stat span { display: block; color: var(--muted); font-size: 0.85rem; }
.stat strong {
  display: block;
  margin-top: 0.25rem;
  font-family: Outfit, sans-serif;
  font-size: 1.45rem;
  font-weight: 580;
  font-variant-numeric: tabular-nums;
}

.block { margin-top: 1.6rem; }
.block h2 { margin-bottom: 0.7rem; }

.guide {
  display: grid;
  gap: 0.75rem;
}

.guide article {
  padding: 1rem 1.1rem 1.15rem;
  background: var(--raise);
  border: 1px solid var(--line);
}

.guide h2 { margin-bottom: 0.45rem; }

.guide p { margin: 0.4rem 0 0; }

.guide ol,
.guide ul {
  margin: 0.45rem 0 0;
  padding-left: 1.15rem;
}

.guide li + li { margin-top: 0.28rem; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.75rem 0.45rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 460;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.btn, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 580;
}

.btn-primary { background: var(--purple); color: var(--on-purple); }
.btn-ghost, .chip { border-color: var(--line); color: var(--purple); }
.chip.is-on { background: var(--purple); color: var(--on-purple); border-color: var(--purple); }
.btn-danger { color: #8d2f3a; border-color: rgba(141, 47, 58, 0.35); }
.btn-tiny { min-height: 2rem; padding: 0.2rem 0.55rem; font-size: 0.88rem; }

.pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--line);
  font-size: 0.82rem;
}
.pill-activa { background: var(--purple); color: var(--on-purple); border-color: var(--purple); }
.pill-por_vencer { color: #8a6a32; border-color: rgba(193, 160, 103, 0.7); }
.pill-vencida { color: #8d2f3a; border-color: rgba(141, 47, 58, 0.35); }

.banner, .form-error {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.8rem;
  background: rgba(193, 160, 103, 0.2);
  color: #5c4316;
}
.banner.is-error, .form-error:not(:empty) {
  background: rgba(141, 47, 58, 0.1);
  color: #8d2f3a;
}
.form-error:empty { display: none; }

.filters { justify-content: flex-start; margin-bottom: 0.8rem; }
.filters input, .search {
  min-height: 2.4rem;
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--line);
}

dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  padding: 1.2rem;
  background: var(--raise);
  color: var(--ink);
  border: 1px solid var(--line);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
dialog form { display: grid; gap: 0.8rem; }
dialog .actions { justify-content: flex-start; }

.field { display: grid; gap: 0.3rem; }
.field span { color: var(--muted); font-size: 0.85rem; }
input, select {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--line);
}

.empty { color: var(--muted); padding: 1rem 0; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 3;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { display: flex; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .side-foot { display: flex; gap: 1rem; margin-top: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
}
