:root {
  --bg: #fbf9fc;
  --raise: #ffffff;
  --ink: #1c1218;
  --muted: #5f5f5f;
  --line: rgba(81, 28, 122, 0.16);
  --purple: #511c7a;
  --purple-deep: #3a1259;
  --gold: #c1a067;
  --on-purple: #ffffff;
  --display: "Bebas Neue", Unbounded, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --grad-purple: linear-gradient(135deg, #5f2290 0%, #511c7a 48%, #3a1259 100%);
  --shadow-sm: 0 1px 2px rgba(28, 18, 24, 0.05), 0 2px 8px rgba(81, 28, 122, 0.06);
  --shadow-md: 0 6px 18px rgba(81, 28, 122, 0.1), 0 2px 6px rgba(28, 18, 24, 0.05);
  --shadow-purple: 0 10px 24px rgba(81, 28, 122, 0.3);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  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.6rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.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;
  box-shadow: 1px 0 0 rgba(81, 28, 122, 0.04), 8px 0 24px rgba(81, 28, 122, 0.04);
}

.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.6rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.nav a:hover {
  color: var(--purple);
  background: rgba(81, 28, 122, 0.06);
}

.nav a.is-current {
  color: var(--purple);
  font-weight: 460;
  background: rgba(81, 28, 122, 0.1);
  box-shadow: inset 3px 0 0 var(--purple);
}

.badge {
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  background: var(--grad-purple);
  color: var(--on-purple);
  border-radius: 999px;
  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 {
  position: relative;
  padding: 1rem 1.1rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gold);
}

.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat span { display: block; color: var(--muted); font-size: 0.85rem; }
.stat strong {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--display);
  font-size: 2.1rem;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--purple);
  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: 1.1rem 1.2rem 1.25rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.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;
}

tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: rgba(81, 28, 122, 0.035); }

.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.9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 580;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}

.btn-primary { background: var(--grad-purple); color: var(--on-purple); box-shadow: var(--shadow-sm); }
.btn-primary:hover, .btn-primary:focus-visible { transform: translateY(-1px); box-shadow: var(--shadow-purple); }
.btn-ghost, .chip { border-color: var(--line); color: var(--purple); background: var(--raise); }
.btn-ghost:hover, .chip:hover { border-color: var(--purple); box-shadow: var(--shadow-sm); }
.chip.is-on { background: var(--grad-purple); color: var(--on-purple); border-color: var(--purple); }
.btn-danger { color: #8d2f3a; border-color: rgba(141, 47, 58, 0.35); background: var(--raise); }
.btn-danger:hover { background: rgba(141, 47, 58, 0.08); border-color: rgba(141, 47, 58, 0.55); }
.btn-tiny { min-height: 2rem; padding: 0.2rem 0.7rem; font-size: 0.88rem; }

.pill {
  display: inline-block;
  padding: 0.14rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 460;
}
.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.75rem 0.9rem;
  background: rgba(193, 160, 103, 0.2);
  color: #5c4316;
  border-radius: var(--radius-sm);
}
.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.8rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  padding: 1.4rem;
  background: var(--raise);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px rgba(28, 18, 24, 0.4);
}
dialog::backdrop { background: rgba(16, 8, 22, 0.72); backdrop-filter: blur(2px); }
dialog form, dialog .roster { display: grid; gap: 0.8rem; }
dialog input[readonly] { user-select: text; }
dialog .actions { justify-content: flex-start; }

.field { display: grid; gap: 0.3rem; }
.field span { color: var(--muted); font-size: 0.85rem; }
.field input, .field select, .search {
  width: 100%;
  min-height: 2.7rem;
}
input, select {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
input:hover, select:hover { border-color: rgba(81, 28, 122, 0.35); }

.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;
}

.who {
  display: grid;
  gap: 0.1rem;
  margin: 0;
}
.who span { color: var(--muted); font-size: 0.82rem; }

.inline-form {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 1rem;
  padding: 1.1rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.inline-form h3, .block h3 {
  margin: 0.6rem 0 0;
  font-family: Unbounded, sans-serif;
  color: var(--purple);
  font-size: 1rem;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.log { margin: 0.3rem 0 0.8rem; padding-left: 1.1rem; }

.btn-wa {
  background: #25d366;
  color: #073018;
  border-color: #25d366;
  text-decoration: none;
}

.chart-card, .member-card {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem;
}

.member-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.6rem;
}
.member-card h2, .member-card p { margin: 0.2rem 0; }

.ring {
  width: 7.4rem;
  height: 7.4rem;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--purple) calc(var(--pct) * 1%), rgba(81, 28, 122, 0.14) 0);
}
.ring-hole {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
}
.ring-hole strong { font-family: var(--display); font-size: 2.3rem; line-height: 1; color: var(--purple); }
.ring-hole span { color: var(--muted); font-size: 0.78rem; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; font-family: Outfit, sans-serif; }
.chart-line { fill: none; stroke: var(--purple); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: rgba(81, 28, 122, 0.12); }
.chart-dot { fill: #fff; stroke: var(--purple); stroke-width: 2; cursor: pointer; }
.chart-dot.is-on, .chart-dot:hover { fill: var(--purple); }
.chart-readout { margin: 0.4rem 0 0; }

.vital {
  margin: 0.2rem 0 1.2rem;
  padding: 1.1rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.vital h2 { margin: 0 0 0.7rem; }
.vital dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem 1rem;
  margin: 0;
}
.vital dt { color: var(--muted); font-size: 0.78rem; }
.vital dd { margin: 0.15rem 0 0; }

.bars {
  display: flex;
  align-items: end;
  gap: 0.45rem;
  min-height: 9rem;
  margin-top: 0.8rem;
}
.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 0.35rem;
  min-height: 9rem;
  border: 0;
  background: transparent;
  cursor: default;
  padding: 0;
}
.bar span {
  display: block;
  width: min(2.4rem, 100%);
  background: linear-gradient(#c1a067, var(--purple));
  border-radius: 4px 4px 0 0;
}
.bar em { font-style: normal; color: var(--muted); font-size: 0.75rem; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem;
}
.slot {
  padding: 0.85rem 0.9rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.slot:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.slot.is-mine { border-color: var(--purple); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--purple); }
.slot-top { display: flex; justify-content: space-between; gap: 0.5rem; }
.slot-top span, .slot p { color: var(--muted); font-size: 0.82rem; }
.slot p { margin: 0; }
.fill {
  height: 0.55rem;
  margin: 0.55rem 0 0.35rem;
  background: #efeaf3;
  border-radius: 99px;
  overflow: hidden;
}
.fill span { display: block; height: 100%; background: var(--purple); }
.fill.is-busy span { background: var(--gold); }
.fill.is-full span { background: #8a1f3d; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.55rem; }
.day-block + .day-block { margin-top: 1.15rem; }
.day-block h2 { margin: 0 0 0.6rem; font-size: 1rem; }
.mine-list { margin: 0; padding-left: 1.1rem; }
.mine-list li { margin: 0.35rem 0; }

@media (max-width: 1100px) {
  .content { padding: 1.1rem 1rem 3rem; }
  .stats, .vital dl { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow: visible; border: 0; }
  table, thead, tbody, tr, th, td { display: block; }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  tr {
    margin: 0 0 0.75rem;
    padding: 0.75rem 0.8rem;
    background: var(--raise);
    border: 1px solid var(--line);
  }
  td {
    display: grid;
    grid-template-columns: 7.2rem minmax(0, 1fr);
    gap: 0.35rem 0.6rem;
    align-items: start;
    padding: 0.28rem 0;
    border: 0;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
  }
  td[data-label=""] { grid-template-columns: 1fr; }
  td[data-label=""]::before { content: none; }
  td { overflow-wrap: anywhere; }
}

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    gap: 0.15rem;
    padding: 0.65rem 0.8rem 0.45rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .who { grid-column: 1; }
  .side-foot {
    grid-column: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.85rem;
    margin-top: 0.15rem;
  }
  .nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }
  .nav a {
    white-space: nowrap;
    min-height: 2.5rem;
    box-shadow: none;
  }
  .nav a.is-current { box-shadow: inset 0 -2px 0 var(--purple); }
  .content { padding: 1rem 0.85rem 4.5rem; }
  .split { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; }
  .page-head .btn, .filters { width: 100%; }
  .member-card { align-items: flex-start; }
  .ring { width: 5.6rem; height: 5.6rem; }
  .ring-hole { width: 4.2rem; height: 4.2rem; }
  td { grid-template-columns: 6.4rem minmax(0, 1fr); }
  dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
  }
}
