:root {
  --bg-soft: #ecf6f2;
  --bg-warm: #fff3e2;
  --ink: #16282e;
  --muted: #5f7078;
  --brand: #0d9488;
  --brand-strong: #0f766e;
  --brand-deep: #134e4a;
  --accent: #f97316;
  --accent-soft: #fff1e4;
  --gold: #f59e0b;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(19, 78, 74, 0.12);
  --shadow: 0 1px 2px rgba(19, 60, 56, 0.06), 0 14px 34px rgba(19, 60, 56, 0.1);
  --shadow-lg: 0 2px 4px rgba(19, 60, 56, 0.08), 0 26px 54px rgba(19, 60, 56, 0.16);
  --radius-xl: 22px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at 6% 10%, rgba(13, 148, 136, 0.2), transparent 40%),
    radial-gradient(circle at 92% 16%, rgba(249, 115, 22, 0.16), transparent 44%),
    radial-gradient(circle at 50% 110%, rgba(245, 158, 11, 0.12), transparent 52%),
    linear-gradient(150deg, var(--bg-soft) 0%, #f8fbf7 46%, var(--bg-warm) 100%);
  min-height: 100vh;
}

::selection {
  background: rgba(13, 148, 136, 0.24);
}

.bg-shape {
  position: fixed;
  border-radius: 42% 58% 53% 47% / 46% 36% 64% 54%;
  filter: blur(46px);
  z-index: -1;
  pointer-events: none;
}

.shape-1 {
  width: 380px;
  height: 380px;
  left: -130px;
  top: 26vh;
  background: rgba(16, 185, 129, 0.22);
  animation: float 16s ease-in-out infinite;
}

.shape-2 {
  width: 420px;
  height: 420px;
  right: -160px;
  top: 4vh;
  background: rgba(251, 146, 60, 0.2);
  animation: float 13s ease-in-out infinite reverse;
}

.shape-3 {
  width: 300px;
  height: 300px;
  left: 52%;
  bottom: -140px;
  background: rgba(56, 189, 248, 0.16);
  animation: float 18s ease-in-out infinite;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(19, 78, 74, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 78, 74, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 16%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 16%, #000 0%, transparent 72%);
}

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 38px 18px 48px;
}

/* ---------- hero ---------- */

.hero {
  margin-bottom: 18px;
}

.hero-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.eyebrow {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-strong);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

h1 {
  margin-top: 12px;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.08;
  letter-spacing: 0.01em;
}

.grad-text {
  background: linear-gradient(115deg, var(--brand-deep) 10%, var(--brand) 45%, var(--accent) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.7;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pill {
  font-size: 12.5px;
  color: var(--brand-deep);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: 999px;
  padding: 5px 12px;
  backdrop-filter: blur(4px);
}

/* ---------- cards ---------- */

.card {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.section-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
}

.sec-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-strong), #2dd4bf);
  box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sub-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--brand-deep);
}

.sub-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
}

.dot-teal { background: #0d9488; }
.dot-amber { background: #f59e0b; }
.dot-blue { background: #0284c7; }
.dot-rose { background: #f43f5e; }

/* ---------- forms ---------- */

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input::placeholder {
  color: #9aa8ae;
}

input:hover,
select:hover {
  border-color: rgba(13, 148, 136, 0.35);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(13, 148, 136, 0.55);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.16);
}

#participant-name {
  max-width: 260px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.tiny-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.14s ease;
}

.primary-btn {
  padding: 10px 16px;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-strong), #0d9488 55%, #2dd4bf);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.35);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.ghost-btn {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-deep);
  border: 1px solid rgba(13, 148, 136, 0.28);
}

.ghost-btn:hover {
  background: #fff;
}

.danger-btn {
  padding: 10px 14px;
  color: #fff;
  background: linear-gradient(120deg, #dc2626, #f97316);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.28);
}

.tiny-btn {
  padding: 6px 11px;
  font-size: 13px;
  color: var(--brand-strong);
  background: rgba(13, 148, 136, 0.12);
  border: 1px solid rgba(13, 148, 136, 0.18);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

label {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--brand-deep);
}

.split-block {
  margin: 14px 0;
  padding: 12px;
  border: 1px dashed rgba(13, 148, 136, 0.4);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(240, 253, 250, 0.75), rgba(255, 251, 235, 0.5));
}

.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
  color: var(--brand-deep);
}

.split-actions {
  display: flex;
  gap: 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.checkbox-item:has(input:checked) {
  border-color: rgba(13, 148, 136, 0.55);
  background: rgba(204, 251, 241, 0.5);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.14);
}

.checkbox-item input {
  width: auto;
  margin: 0;
  accent-color: var(--brand-strong);
}

.empty-hint {
  margin: 12px 0 0;
  color: var(--muted);
}

/* ---------- chips ---------- */

.chip-list {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent-soft), #fff7ed);
  color: #9a3412;
  border: 1px solid rgba(249, 115, 22, 0.3);
  padding: 6px 8px 6px 13px;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.12);
}

.chip button {
  border: 0;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  line-height: 1;
  color: #9a3412;
  background: rgba(249, 115, 22, 0.18);
  cursor: pointer;
  transition: background 0.15s ease;
}

.chip button:hover {
  background: rgba(249, 115, 22, 0.35);
  transform: none;
}

/* ---------- tables ---------- */

.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(19, 78, 74, 0.22);
  border-radius: 99px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.compact table {
  min-width: 520px;
}

th,
td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid rgba(19, 78, 74, 0.08);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--brand-strong);
  background: linear-gradient(180deg, #f0faf7, #f6fbf9);
  border-bottom: 1px solid rgba(13, 148, 136, 0.18);
  z-index: 1;
}

td {
  font-size: 14px;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: rgba(240, 253, 250, 0.35);
}

tbody tr:hover {
  background: rgba(13, 148, 136, 0.07);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.row-action-btn {
  border: 0;
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.85);
  cursor: pointer;
  transition: background 0.15s ease;
}

.row-action-btn:hover {
  background: #fecaca;
  transform: none;
}

/* ---------- results ---------- */

.report-capture {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.report-capture .card {
  margin-top: 0;
}

.result-grid,
.analytics-grid {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 16px;
}

.transfer-list,
.tag-summary-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.transfer-list li,
.tag-summary-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.tag-summary-list li {
  display: block;
}

.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.tag-bar {
  height: 7px;
  border-radius: 99px;
  background: rgba(19, 78, 74, 0.08);
  overflow: hidden;
}

.tag-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

.expense-amount {
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  font-weight: 700;
  color: var(--brand-deep);
}

.tag-badge {
  display: inline-block;
  font-size: 12.5px;
  color: var(--brand-strong);
  background: rgba(13, 148, 136, 0.1);
  border: 1px solid rgba(13, 148, 136, 0.18);
  border-radius: 999px;
  padding: 2px 9px;
}

.transfer-list li:hover,
.tag-summary-list li:hover {
  border-color: rgba(13, 148, 136, 0.35);
  box-shadow: 0 6px 16px rgba(19, 60, 56, 0.09);
  transform: translateY(-1px);
}

.transfer-who {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.transfer-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-style: normal;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-strong), #14b8a6);
  box-shadow: 0 3px 8px rgba(13, 148, 136, 0.3);
}

.transfer-list li strong,
.tag-summary-list li strong {
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  font-size: 14.5px;
  color: var(--brand-deep);
  background: rgba(13, 148, 136, 0.09);
  border-radius: 9px;
  padding: 3px 9px;
}

.tag-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.amount-positive {
  color: #047857;
  font-weight: 700;
}

.amount-negative {
  color: #be123c;
  font-weight: 700;
}

.amount-neutral {
  color: #374151;
  font-weight: 700;
}

/* ---------- chart ---------- */

.chart-panel {
  min-width: 0;
}

.chart-box {
  position: relative;
  height: 320px;
  border: 1px solid rgba(13, 148, 136, 0.16);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 42%, rgba(204, 251, 241, 0.45), transparent 65%),
    rgba(255, 255, 255, 0.94);
  padding: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 10px 26px rgba(19, 60, 56, 0.07);
}

/* ---------- utility ---------- */

.utility-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.footer-note {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- animation ---------- */

.reveal {
  animation: riseIn 0.58s ease both;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-14px) rotate(6deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-shape,
  .reveal {
    animation: none;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 920px) {
  .result-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 22px 12px calc(34px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 14px;
    border-radius: 18px;
  }

  .hero-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .section-head {
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .section-head p {
    font-size: 13px;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .inline-form {
    flex-direction: column;
  }

  #participant-name {
    max-width: none;
  }

  .inline-form .primary-btn {
    width: 100%;
  }

  .split-head {
    align-items: flex-start;
  }

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

  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
    box-shadow: none;
  }

  #expenses-table,
  #balances-table {
    min-width: 0;
    width: 100%;
  }

  #expenses-table thead,
  #balances-table thead {
    display: none;
  }

  #expenses-table tbody,
  #balances-table tbody {
    display: grid;
    gap: 10px;
  }

  #expenses-table tr,
  #balances-table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    padding: 2px 0;
    box-shadow: 0 4px 12px rgba(19, 60, 56, 0.06);
  }

  #expenses-table td,
  #balances-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    white-space: normal;
    padding: 8px 12px;
    border-bottom: 1px dashed rgba(19, 78, 74, 0.1);
  }

  #expenses-table td::before,
  #balances-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 76px;
  }

  #expenses-table td:last-child,
  #balances-table td:last-child {
    border-bottom: 0;
  }

  #expenses-table td[colspan],
  #balances-table td[colspan] {
    display: block;
    text-align: center;
    border-bottom: 0;
  }

  #expenses-table td[colspan]::before,
  #balances-table td[colspan]::before {
    content: none;
  }

  .row-action-btn {
    width: 100%;
    padding: 8px 10px;
  }

  .chart-box {
    height: 280px;
  }

  .utility-row {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-lg);
    z-index: 8;
  }

  .utility-row .primary-btn,
  .utility-row .ghost-btn,
  .utility-row .danger-btn {
    width: 100%;
  }
}

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