:root {
  --ink: #14231c;
  --ink-soft: #3d5248;
  --muted: #6b7f74;
  --line: rgba(20, 35, 28, 0.1);
  --line-strong: rgba(20, 35, 28, 0.16);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #f7faf7;
  --panel: #ffffff;
  --bg: #eef3ef;
  --accent: #0f7a5a;
  --accent-2: #1a9b72;
  --accent-soft: rgba(15, 122, 90, 0.1);
  --warn: #b86a12;
  --warn-soft: rgba(184, 106, 18, 0.12);
  --danger: #c23b3b;
  --ok: #1f7a4d;
  --shadow: 0 20px 50px rgba(20, 35, 28, 0.08);
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 0% -10%, rgba(26, 155, 114, 0.16), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(20, 35, 28, 0.06), transparent 50%),
    linear-gradient(180deg, #f4f8f5 0%, #e8efe9 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(20, 35, 28, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 28, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand {
  font-family: var(--display);
  font-size: 1.45rem;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-decoration: none;
  font-weight: 600;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.topbar {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 250, 247, 0.92);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0 1rem 0.75rem;
}
.top-nav a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
}
.top-nav a:hover,
.top-nav a.active {
  color: var(--ink);
  background: var(--accent-soft);
  text-decoration: none;
}
.nav-logout { margin: 0; }
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 28, 0.35);
  z-index: 30;
}
.bottom-nav { display: none; }
.mobile-cards { display: none; }
.debt-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  box-shadow: 0 8px 22px rgba(20, 35, 28, 0.05);
}
.debt-card + .debt-card { margin-top: 0.7rem; }
.debt-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.debt-card-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}
.debt-card-name:hover { text-decoration: none; color: var(--accent); }
.debt-card-amount {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 550;
  white-space: nowrap;
}
.debt-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}
.debt-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.debt-card-actions .btn,
.debt-card-actions .inline-adjust input {
  min-height: 42px;
}
.debt-card-actions .inline-adjust {
  flex: 1 1 100%;
}
.debt-card-actions .inline-adjust input {
  flex: 1;
  width: auto;
  min-width: 0;
}

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.6rem auto 3rem;
  position: relative;
  z-index: 1;
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.site-foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0 1rem 2.5rem;
}

h1 {
  font-family: var(--display);
  font-weight: 550;
  font-size: clamp(1.85rem, 3.6vw, 2.55rem);
  margin: 0.1rem 0 0.45rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.lede, .muted { color: var(--muted); }
.lede { margin: 0 0 1.25rem; line-height: 1.55; max-width: 38rem; }

.mega {
  font-family: var(--display);
  font-size: clamp(2.6rem, 6.5vw, 4rem);
  margin: 0.15rem 0;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.dash-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.1rem;
  margin-bottom: 1.35rem;
}

.hero-main {
  padding: 1.7rem 1.8rem;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(15, 122, 90, 0.08), transparent 45%),
    var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-main::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 122, 90, 0.18), transparent 70%);
  animation: pulse 4.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 1; }
}

.hero-side {
  display: grid;
  gap: 0.75rem;
}

.stat-tile {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: 0 8px 24px rgba(20, 35, 28, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-tile .label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-tile .value {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 550;
  letter-spacing: -0.02em;
}
.stat-tile.warn .value { color: var(--warn); }
.stat-tile.ok .value { color: var(--accent); }

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

.section { margin-top: 1.6rem; }
.section-head, .page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}
.page-head { margin-bottom: 1.35rem; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(20, 35, 28, 0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th, td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 700;
  background: rgba(238, 243, 239, 0.85);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(15, 122, 90, 0.035); }
.row-paid td { opacity: 0.58; }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.inline { display: inline; margin: 0; }
.inline-adjust {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0;
}
.inline-adjust input {
  width: 5.5rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(20, 35, 28, 0.08);
}
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.04); color: #fff; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.84rem; }
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
}

.linkish {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}
.linkish:hover { color: var(--ink); text-decoration: underline; }
.linkish.danger { color: var(--danger); }

.flash {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  animation: rise 0.3s ease both;
}
.flash-ok {
  background: rgba(31, 122, 77, 0.1);
  border-color: rgba(31, 122, 77, 0.25);
  color: var(--ok);
}
.flash-error {
  background: rgba(194, 59, 59, 0.08);
  border-color: rgba(194, 59, 59, 0.25);
  color: var(--danger);
}

.auth-stage {
  min-height: calc(100vh - 5rem);
  display: grid;
  place-items: center;
}

.auth-panel, .form-panel {
  width: min(460px, 100%);
}

.auth-panel {
  padding: 2.1rem;
  border-radius: calc(var(--radius) + 6px);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.settings-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.settings-block {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.35rem 1.45rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(20, 35, 28, 0.04);
}
.settings-block h2 {
  margin-bottom: 0.35rem;
}
.settings-block .hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.narrow { margin: 0 auto; width: min(520px, 100%); }

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
}

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  outline: none;
  width: 100%;
  font-weight: 500;
}
textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.check-row input {
  width: auto;
}

.optional { opacity: 0.7; font-weight: 500; }
.row-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 0.3rem;
  background: rgba(20, 35, 28, 0.05);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  flex-wrap: wrap;
}
.tabs a {
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
}
.tabs a.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(20, 35, 28, 0.06);
}

.pill {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
}
.pill-unpaid {
  background: var(--accent-soft);
  color: var(--accent);
}
.pill-paid {
  background: rgba(107, 127, 116, 0.12);
  color: var(--muted);
}
.pill-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  padding: 2.2rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}

.role-chip {
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
  font-weight: 700;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}
.status-dot i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.status-dot.on i { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.status-dot.off i { background: var(--danger); }

.tiny { font-size: 0.78rem; }
.mega-sm {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 550;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.stat-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 6px 18px rgba(20, 35, 28, 0.03);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--line-strong);
}
.timeline li {
  position: relative;
  padding: 0 0 1.25rem 1.25rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.tl-when {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.tl-what strong { font-weight: 700; }

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 900px) {
  .page-head-actions .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
}

@media (max-width: 900px) {
  .dash-hero { grid-template-columns: 1fr; }
  .hero-side { grid-template-columns: 1fr 1fr; }
  .nav-toggle { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .top-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.5rem 0.85rem 1rem;
    border-top: 1px solid var(--line);
  }
  .top-nav.open { display: flex; }
  .top-nav a {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-size: 1rem;
  }
  .nav-logout {
    padding: 0.5rem 1rem 0;
    border-top: 1px solid var(--line);
    margin-top: 0.35rem;
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 30px rgba(20, 35, 28, 0.06);
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.35rem 0.15rem;
    border-radius: 12px;
    min-height: 52px;
  }
  .bottom-nav a.active { color: var(--accent); background: var(--accent-soft); }
  .bottom-nav .bn-ico { font-size: 1.05rem; line-height: 1; }
  .bottom-nav .bn-add .bn-plus {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.05rem;
    box-shadow: 0 6px 14px rgba(15, 122, 90, 0.28);
  }
  .bottom-nav .bn-add { color: var(--accent); }
  body.has-nav .wrap {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
  body.has-nav .site-foot {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }
  .desktop-table { display: none; }
  .mobile-cards { display: block; }
  .wrap { width: min(1120px, calc(100% - 1rem)); margin: 1rem auto 1.5rem; }
  .mega { font-size: clamp(2.1rem, 11vw, 3rem); }
  h1 { font-size: clamp(1.55rem, 6vw, 2rem); }
  .hero-main {
    min-height: 0;
    padding: 1.25rem 1.15rem;
  }
  .quick-row .btn { flex: 1 1 auto; min-height: 44px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; }
  .auth-panel {
    width: 100%;
    padding: 1.4rem 1.15rem;
    border-radius: 18px;
  }
  .auth-stage {
    min-height: calc(100dvh - 4rem);
    padding: 1rem 0;
    align-items: flex-start;
  }
  .settings-shell { width: 100%; }
  .settings-block { padding: 1.1rem; }
  input, select, textarea, .btn {
    font-size: 16px; /* iOS zoom oldini olish */
  }
  .inline-adjust input { font-size: 16px; }
  .actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .hero-side { grid-template-columns: 1fr 1fr; }
  .stat-tile .value { font-size: 1.35rem; }
}

.faq-hero { margin-bottom: 1.25rem; }
.faq-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 0.65rem;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(20, 35, 28, 0.04);
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--ink);
  position: relative;
  padding-right: 2.5rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
}
.faq-item[open] summary::after { content: "?"; }
.faq-body {
  padding: 0.85rem 1.15rem 1.1rem;
  color: var(--ink-soft);
  line-height: 1.55;
  border-top: 1px solid var(--line);
}
.faq-body ul, .faq-body ol { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.faq-body li { margin: 0.35rem 0; }
.faq-body code {
  background: var(--accent-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  font-size: 0.88em;
}
.faq-author {
  margin-top: 2rem;
  padding: 1.4rem 1.25rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(15, 122, 90, 0.08), transparent 50%),
    var(--panel);
  box-shadow: var(--shadow);
}
.faq-author h2 { margin: 0.2rem 0 0.55rem; }
.site-foot a { color: var(--accent); font-weight: 700; }
