:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647184;
  --line: #dce2ea;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #067647;
  --soft: #eef3f7;
  --shadow: 0 12px 28px rgba(23, 32, 51, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

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

a:hover {
  text-decoration: underline;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: #eef2f7;
  padding: 24px 18px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 24px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  border-radius: 8px;
  color: #cbd5e1;
  padding: 10px 12px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.topbar h1 {
  font-size: 28px;
  letter-spacing: 0;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

.card {
  min-height: 104px;
  padding: 16px;
}

.metric {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar h2,
.panel h2 {
  font-size: 18px;
  letter-spacing: 0;
  margin: 0 0 12px;
}

.toolbar h2 {
  margin: 0;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-cell {
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

button,
.button {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 750;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
  text-decoration: none;
}

.button.secondary,
button.secondary {
  background: #e7edf4;
  color: var(--ink);
}

.button.danger,
button.danger {
  background: var(--danger);
}

.button.whatsapp,
button.whatsapp {
  background: #128c7e;
}

.button.whatsapp:hover,
button.whatsapp:hover {
  background: #0d756a;
}

.button.small,
button.small {
  font-size: 13px;
  min-height: 32px;
  padding: 6px 9px;
}

.button.link,
button.link {
  background: transparent;
  color: var(--brand);
  min-height: auto;
  padding: 0 4px;
}

button.link.danger {
  color: var(--danger);
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  min-width: 0;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

label {
  color: #35445c;
  display: grid;
  font-size: 14px;
  font-weight: 700;
  gap: 6px;
}

.check {
  align-items: center;
  display: flex;
  gap: 9px;
}

.check input {
  width: auto;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #41516b;
  font-size: 13px;
}

.amount {
  text-align: right;
  white-space: nowrap;
}

.positive {
  color: var(--ok);
  font-weight: 800;
}

.negative {
  color: var(--danger);
  font-weight: 800;
}

.neutral {
  color: var(--muted);
}

.notice {
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice.error {
  background: #fee4e2;
  color: var(--danger);
}

.notice.success {
  background: #dcfce7;
  color: var(--ok);
}

.auth-wrap {
  display: grid;
  min-height: 100vh;
  padding: 22px;
  place-items: center;
}

.auth-panel {
  width: min(460px, 100%);
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 14px;
}

.legal-copy {
  color: #35445c;
  display: grid;
  font-size: 14px;
  gap: 10px;
  line-height: 1.55;
  max-height: 56vh;
  overflow-y: auto;
}

.legal-checks {
  display: grid;
  gap: 10px;
}

.legal-checks label {
  align-items: start;
  display: grid;
  font-weight: 600;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  line-height: 1.35;
}

.legal-checks input {
  margin-top: 3px;
  width: auto;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  align-items: center;
  background: var(--soft);
  border: 1px solid #dce5ee;
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 12px;
}

.list-item:hover {
  text-decoration: none;
}

.list-item small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.group-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.member-chips span {
  background: #ecfdf3;
  border: 1px solid #b7e4c7;
  border-radius: 999px;
  color: #075e3f;
  font-size: 13px;
  font-weight: 750;
  padding: 6px 9px;
}

.member-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.member-row {
  align-items: center;
  background: var(--soft);
  border: 1px solid #dce5ee;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.member-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.settle-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.split-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.segmented {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  overflow: hidden;
}

.segmented label {
  align-items: center;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 8px 10px;
}

.segmented label:last-child {
  border-right: 0;
}

.segmented input,
.split-row input[type="checkbox"] {
  width: auto;
}

.split-grid {
  display: grid;
  gap: 8px;
}

.split-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(150px, 1fr) 160px;
}

.print-only {
  display: none;
}

.chatbot {
  bottom: 20px;
  position: fixed;
  right: 20px;
  z-index: 50;
}

.chatbot-toggle {
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.28);
  gap: 8px;
  min-width: 58px;
}

.chatbot-toggle span:first-child {
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  display: inline-flex;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.chatbot-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  bottom: 58px;
  box-shadow: 0 18px 46px rgba(23, 32, 51, 0.18);
  display: none;
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(360px, calc(100vw - 32px));
}

.chatbot.open .chatbot-panel {
  display: block;
}

.chatbot-header {
  align-items: center;
  background: #111827;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.chatbot-header span {
  color: #cbd5e1;
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.chatbot-close {
  background: transparent;
  color: #fff;
  min-height: 30px;
  padding: 4px 8px;
}

.chatbot-messages {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 12px;
}

.chatbot-message {
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  padding: 9px 10px;
}

.chatbot-message.bot {
  background: #eef7f5;
  color: #193c38;
  justify-self: start;
}

.chatbot-message.user {
  background: #172033;
  color: #fff;
  justify-self: end;
}

.chatbot-suggestions {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
}

.chatbot-suggestions button {
  background: #e8eef7;
  color: var(--ink);
  font-size: 12px;
  min-height: 30px;
  padding: 6px 9px;
}

.chatbot-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }

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

  .cards,
  .two,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

  .group-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 660px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .panel {
    overflow-x: auto;
    padding: 14px;
  }

  .split-row {
    grid-template-columns: 1fr;
  }

  .member-row,
  .settle-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .member-row .button,
  .settle-actions .button {
    width: 100%;
  }

  .chatbot {
    bottom: 14px;
    right: 14px;
  }

  .chatbot-toggle-label {
    display: none;
  }
}

@media print {
  .sidebar,
  .topbar .actions,
  .no-print,
  .button,
  button {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel,
  .card {
    border-color: #cbd5e1;
    box-shadow: none;
  }

  .print-only {
    display: block;
  }
}
