:root {
  --bg: #eef5f3;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
  --radius: 24px;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(
      circle at top left,
      rgba(20, 184, 166, 0.2),
      transparent 36rem
    ),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
}
body.has-modal,
body.is-admin-open {
  overflow: hidden;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
img {
  max-width: 100%;
  display: block;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  position: relative;
  overflow: hidden;
  padding-bottom: 24px;
}
.site-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 260px;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 55%, #67e8f9 100%);
  z-index: -1;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.03em;
  font-size: clamp(1rem, 3vw, 1.2rem);
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.32);
}
.hero {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 320px);
  gap: 24px;
  align-items: end;
  padding: 40px 0 20px;
  color: #fff;
}
.eyebrow {
  margin: 0 0 10px;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero .eyebrow {
  color: #ccfbf1;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 8vw, 4.7rem);
  line-height: 0.93;
  letter-spacing: -0.08em;
}
.hero__copy {
  max-width: 660px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 2vw, 1.15rem);
}
.hero__stats {
  display: grid;
  gap: 8px;
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.hero__stats strong {
  font-size: 2rem;
}
.hero__stats span {
  color: rgba(255, 255, 255, 0.8);
}

.main-layout {
  padding: 8px 0 112px;
}
.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 0 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.search-box input,
.admin-filters input,
.admin-filters select,
.add-form input,
.add-form select,
.form-grid input,
.table-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}
.search-box input {
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
}
input:focus,
select:focus,
.table-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}
.status-summary {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}
.user-list {
  display: grid;
  gap: 14px;
}
.user-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 18px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  text-align: left;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
.user-card:hover,
.user-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.12);
}
.user-card__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  padding: 7px;
  background: var(--primary-soft);
}
.user-card__content {
  display: grid;
  gap: 8px;
}
.user-card__content strong {
  font-size: clamp(1rem, 2vw, 1.12rem);
}
.user-card__amount {
  color: var(--muted);
  font-weight: 800;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.status-pill.is-paid {
  color: var(--success);
  background: var(--success-soft);
}
.status-pill.is-debt {
  color: var(--danger);
  background: var(--danger-soft);
}
.empty-state {
  margin: 0;
  padding: 28px;
  border-radius: 18px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.floating-total {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  gap: 4px;
  width: min(360px, calc(100% - 32px));
  padding: 18px 20px;
  border: 1px solid rgba(20, 184, 166, 0.28);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.floating-total span {
  color: var(--muted);
  font-size: 0.88rem;
}
.floating-total strong {
  color: var(--primary-dark);
  font-size: 1.45rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn--small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
}
.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 20px rgba(15, 118, 110, 0.22);
}
.btn--primary:hover {
  background: var(--primary-dark);
}
.btn--secondary {
  background: #e0f2fe;
  color: #0369a1;
}
.btn--ghost {
  background: rgba(255, 255, 255, 0.72);
  color: var(--primary-dark);
  border-color: rgba(15, 118, 110, 0.18);
}
.btn--success {
  background: var(--success);
  color: #fff;
}
.btn--danger {
  background: var(--danger);
  color: #fff;
}

.modal,
.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.is-hidden {
  display: none !important;
}
.modal {
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(6px);
}
.modal__card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: popIn 0.22s ease-out;
}
.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 1.35rem;
}
.detail-card,
.message-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 34px 26px 26px;
  text-align: center;
}
.detail-card__image {
  width: 138px;
  height: 138px;
  object-fit: contain;
  border-radius: 32px;
  background: #f8fafc;
  padding: 16px;
}
.detail-card h2 {
  margin: 0;
  font-size: 1.45rem;
}
.detail-card__amount {
  margin: 0;
  color: var(--primary-dark);
  font-size: 2rem;
  font-weight: 900;
}
.detail-card__text {
  color: var(--muted);
  line-height: 1.6;
}
.detail-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.message-card__icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: var(--primary-soft);
  font-size: 2rem;
}
.message-card p {
  color: var(--muted);
  line-height: 1.6;
}

.admin-panel {
  overflow: auto;
  background: #f8fafc;
}
.admin-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 60px;
}
.admin-panel__back {
  margin-bottom: 18px;
}
.login-card,
.dashboard,
.admin-section {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}
.login-card {
  width: min(480px, 100%);
  margin: 8vh auto;
  padding: 30px;
}
.login-card h2,
.dashboard h2 {
  margin-bottom: 10px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}
.form-grid,
.add-form {
  display: grid;
  gap: 14px;
}
.form-grid label,
.add-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}
.form-grid input,
.add-form input,
.add-form select,
.admin-filters input,
.admin-filters select,
.table-input {
  min-height: 44px;
  padding: 0 12px;
}
.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}
.dashboard {
  padding: 24px;
}
.dashboard__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.dashboard__header p {
  color: var(--muted);
}
.dashboard__actions,
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.admin-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.admin-cards article {
  padding: 18px;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}
.admin-cards span {
  color: var(--muted);
  font-size: 0.86rem;
}
.admin-cards strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}
.admin-section {
  padding: 20px;
  margin-top: 18px;
  box-shadow: none;
}
.admin-section__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.add-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
}
.table-wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.admin-table th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.row-actions {
  display: flex;
  gap: 8px;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 840px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 28px;
  }
  .toolbar,
  .dashboard__header,
  .admin-section__top {
    align-items: stretch;
    flex-direction: column;
  }
  .status-summary {
    white-space: normal;
  }
  .admin-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .add-form {
    grid-template-columns: 1fr 1fr;
  }
  .add-form .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 22px, 1120px);
  }
  .topbar {
    align-items: flex-start;
  }
  .brand__mark {
    width: 38px;
    height: 38px;
  }
  .hero__stats {
    padding: 18px;
  }
  .toolbar {
    position: static;
  }
  .user-card {
    grid-template-columns: 54px 1fr;
    gap: 12px;
    padding: 14px;
  }
  .user-card__avatar {
    width: 54px;
    height: 54px;
  }
  .user-card__amount {
    grid-column: 2;
  }
  .floating-total {
    right: 11px;
    bottom: 11px;
    padding: 14px 16px;
  }
  .detail-card__actions .btn {
    width: 100%;
  }
  .admin-cards,
  .add-form {
    grid-template-columns: 1fr;
  }
  .dashboard {
    padding: 16px;
  }
  .login-card {
    padding: 22px;
  }
}
