:root {
  --background: #F4F1EB;
  --surface: #FFFFFF;
  --ink: #0E1B2E;
  --accent: #B3122F;
  --blush: #F6E7EC;
  --line: #E6E1D8;
  --muted: #5A6473;
  --ink2: #3B4658;
  --green: #146C43;
  --gold: #C9A24A;
  --gold2: #F3E7C7;
  --red: #C0392B;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--background);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; }
button, input, select { font-family: inherit; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr-only:focus {
  position: absolute; width: auto; height: auto; margin: 0; padding: 0.5rem 0.75rem;
  clip: auto; overflow: visible; background: var(--accent); color: #fff; z-index: 50;
  border-radius: 0.5rem; top: 0.5rem; left: 0.5rem;
}

.badge-demo {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.gate-card {
  width: 100%;
  max-width: 28rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 2rem;
  text-align: center;
}
.gate-card img { height: 3rem; width: auto; margin: 0 auto 1rem; }
.gate-card h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
.gate-card p { color: var(--ink2); margin: 0 0 1.5rem; }
.gate-actions { display: flex; flex-direction: column; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  border: 0;
  font-weight: 600;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-red { background: var(--surface); color: var(--red); border: 1px solid var(--red); }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 768px) { .shell { flex-direction: row; } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
}
@media (min-width: 768px) { .topbar { display: none; } }
.topbar img { height: 1.75rem; filter: brightness(0) invert(1); }
.topbar .btn-ghost {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}

.side {
  display: none;
  width: 16rem;
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--ink);
  color: #fff;
  padding: 1.5rem;
  flex-direction: column;
}
@media (min-width: 768px) { .side { display: flex; } }
.side img { height: 2rem; width: auto; filter: brightness(0) invert(1); }
.side .meta { color: rgba(255,255,255,0.8); font-size: 0.75rem; margin: 0.4rem 0 1.5rem; }
.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav button.navlink {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: 0;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  min-height: 2.75rem;
  font-weight: 500;
  cursor: pointer;
}
.nav button.navlink.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav button.navlink:focus-visible { outline: 2px solid #fff; }

.side-foot {
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.side-user { padding: 0.5rem 1rem; font-size: 0.875rem; }
.side-user .name { font-weight: 600; }
.side-user .email { color: rgba(255,255,255,0.8); font-size: 0.75rem; }

.signout {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  min-height: 2.75rem;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 0;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.signout:hover,
.signout:focus-visible {
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.signout:focus-visible { outline: 2px solid #fff; }

.main { flex: 1; padding: 1rem 1rem 6rem; min-width: 0; }
@media (min-width: 768px) { .main { padding: 2rem; } }
.main h1 { font-size: 1.875rem; margin: 0 0 0.25rem; }
.lede { color: var(--muted); margin: 0 0 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.5rem;
}
.card + .card { margin-top: 1rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; }
table { width: 100%; min-width: 40rem; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1rem;
  background: var(--background);
}
td { padding: 0.85rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
tr.selected { background: rgba(243, 231, 199, 0.35); }
tr.clickable { cursor: pointer; }
.right { text-align: right; }
.accent { color: var(--accent); font-weight: 700; }
.ink { color: var(--ink); font-weight: 600; }
.total-row { background: var(--background); border-top: 2px solid var(--ink); font-weight: 700; }

.pill {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--ink);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}
.pill-soft { background: var(--background); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.pill-upside { background: rgba(179, 18, 47, 0.1); color: var(--accent); }
.pill-classic { background: rgba(14, 27, 46, 0.1); color: var(--ink); }
.pill-gold { background: var(--gold2); color: var(--ink); }
.pill-watch { background: var(--gold2); color: var(--ink); }

.kpis { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.5rem; }
@media (min-width: 768px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 1.5rem; }
.kpi.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi .label { font-size: 0.875rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; }
.kpi.dark .label { color: rgba(255,255,255,0.7); }
.kpi .value { font-size: 1.875rem; font-weight: 700; }
.kpi .hint { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }
.kpi.dark .hint { color: #bbf7d0; }

.bar-track { height: 2rem; background: var(--background); border-radius: 0.5rem; overflow: hidden; }
.bar { height: 100%; background: var(--gold); border-radius: 0.5rem; }
.bar.now { background: var(--accent); }
.thin-track { height: 0.5rem; background: var(--background); border-radius: 999px; overflow: hidden; }
.thin-bar { height: 100%; border-radius: 999px; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  min-height: 2.75rem;
  font-weight: 600;
  cursor: pointer;
}
.filters button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.5rem;
  position: sticky;
  top: 2rem;
}
.split { display: flex; flex-direction: column; gap: 1.5rem; }
@media (min-width: 1024px) {
  .split { flex-direction: row; align-items: flex-start; }
  .split .grow { flex: 1; min-width: 0; }
  .drawer { width: 24rem; flex-shrink: 0; }
}
.field-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.25rem; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; }

.bottom {
  display: flex;
  justify-content: space-around;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0.4rem 0.2rem;
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  z-index: 30;
}
@media (min-width: 768px) { .bottom { display: none; } }
.bottom button {
  background: none;
  border: 0;
  color: var(--ink2);
  font-size: 0.65rem;
  font-weight: 700;
  min-height: 2.75rem;
  min-width: 3.4rem;
  cursor: pointer;
}
.bottom button.active { color: var(--accent); }

.toast {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  z-index: 40;
}
@media (min-width: 768px) { .toast { bottom: 1.5rem; } }

.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.small { font-size: 0.75rem; color: var(--muted); }
.mobile-nav { display: none; background: var(--ink); color: #fff; padding: 0.75rem 1rem 1rem; }
.mobile-nav.open { display: block; }
@media (min-width: 768px) { .mobile-nav { display: none !important; } }
.mobile-nav .navlink,
.mobile-nav .signout {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.9);
  border: 0;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  min-height: 2.75rem;
  cursor: pointer;
}
.mobile-nav .navlink.active { background: rgba(255,255,255,0.1); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; min-width: 32rem; }
.cal .hd { font-size: 0.7rem; color: var(--muted); text-align: center; font-weight: 700; text-transform: uppercase; padding: 0.5rem 0; }
.cal .day {
  min-height: 6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.5rem;
  background: var(--background);
}
.cal .day.today { border-color: var(--accent); background: rgba(179, 18, 47, 0.05); }
.cal .day.empty { background: transparent; border-color: transparent; }
.cal .chip { display: block; font-size: 0.65rem; background: var(--blush); color: var(--ink); border-radius: 0.25rem; padding: 0.1rem 0.35rem; margin-top: 0.25rem; font-weight: 600; }

.dropzone {
  background: var(--gold2);
  border: 1px solid var(--gold);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.cols-6 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .cols-6 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .cols-6 { grid-template-columns: repeat(6, 1fr); } }
.pipe-card { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.pipe-card.hot { border-color: rgba(179, 18, 47, 0.2); }
.pipe-item { background: var(--background); border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.75rem; margin-top: 0.5rem; }
.empty-col { text-align: center; color: var(--muted); font-size: 0.75rem; padding: 1rem 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-gold { padding: 0.25rem 0.75rem; background: var(--gold2); color: var(--ink); border-radius: 999px; font-size: 0.875rem; }
.chip-soft { padding: 0.25rem 0.75rem; background: var(--background); border: 1px solid var(--line); border-radius: 0.5rem; }
.chip-avoid { padding: 0.25rem 0.75rem; background: rgba(192, 57, 43, 0.1); color: var(--red); border-radius: 999px; font-size: 0.875rem; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
label.block { display: block; }
input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  min-height: 2.75rem;
}
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; }
.avatar {
  width: 3rem; height: 3rem; border-radius: 999px;
  background: var(--gold); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.online { color: var(--green); font-size: 0.875rem; display: flex; align-items: center; gap: 0.35rem; }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--green); }
.composer { display: flex; gap: 0.5rem; }
.composer input { flex: 1; padding: 0.75rem 1rem; border-radius: 0.75rem; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 1024px) { .two-col { grid-template-columns: 2fr 1fr; } }

.leave-card { border-color: rgba(192, 57, 43, 0.2); }
.leave-card h3 { color: var(--red); }

.convo { display: flex; flex-direction: column; gap: 1rem; max-height: 24rem; overflow: auto; margin-bottom: 1.5rem; }
.bubble { max-width: 80%; padding: 0.75rem; border-radius: 1rem; }
.bubble.in { background: var(--background); color: var(--ink); border-bottom-left-radius: 0.25rem; }
.bubble.out { margin-left: auto; background: var(--ink); color: #fff; border-bottom-right-radius: 0.25rem; }
.log-list button {
  display: block; width: 100%; text-align: left; background: transparent;
  border: 0; border-bottom: 1px solid var(--line); padding: 1rem; cursor: pointer;
}
.log-list button.on { background: var(--blush); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
