:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: rgba(22, 25, 34, .92);
  --panel-strong: #191c25;
  --panel-soft: #11141b;
  --border: rgba(255, 255, 255, .075);
  --text: #f5f6f8;
  --muted: #9298a7;
  --muted-2: #686e7b;
  --accent: #66dfd3;
  --accent-2: #2daea5;
  --accent-soft: rgba(102, 223, 211, .14);
  --danger: #ff667d;
  --warning: #ffb64d;
  --success: #62d4a5;
  --shadow: 0 24px 60px rgba(0, 0, 0, .34);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, Montserrat, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(1px);
  opacity: .75;
}

.ambient-one {
  width: 280px;
  height: 280px;
  right: -150px;
  top: -110px;
  background: radial-gradient(circle, rgba(102, 223, 211, .18), transparent 70%);
}

.ambient-two {
  width: 240px;
  height: 240px;
  left: -160px;
  top: 380px;
  background: radial-gradient(circle, rgba(89, 105, 145, .12), transparent 70%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(110px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 2px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.topbar h1, .sheet-header h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-weight: 600;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 15px;
  background: linear-gradient(145deg, #303541, #171a22);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 10px 24px rgba(0, 0, 0, .24);
}

.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 146px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 27px;
  background:
    radial-gradient(circle at 92% 5%, rgba(102, 223, 211, .2), transparent 38%),
    linear-gradient(145deg, rgba(36, 40, 51, .96), rgba(18, 20, 28, .98));
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, .05);
}

.hero::after {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  right: -40px;
  top: -55px;
  border: 1px solid rgba(255, 255, 255, .055);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(255, 255, 255, .018), 0 0 0 48px rgba(255, 255, 255, .012);
}

.hero-copy { position: relative; z-index: 1; }
.hero-kicker { color: #d5d7de; font-size: 12px; font-weight: 500; }
.hero h2 { margin: 17px 0 6px; font-size: 24px; line-height: 1.16; letter-spacing: -.025em; font-weight: 600; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.hero-add {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  margin-left: 16px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(145deg, #70e7dc, #35b7ae);
  color: #071924;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(45, 174, 165, .3), inset 0 1px rgba(255, 255, 255, .25);
}

.hero-add span { margin-top: -3px; font-size: 33px; font-weight: 300; }
.hero-add:active, .floating-add:active { transform: scale(.96); }

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.summary-card {
  min-width: 0;
  padding: 15px 14px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: rgba(20, 23, 31, .82);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.summary-card:active { background: #1c202a; }
.summary-card strong { display: block; margin-top: 8px; font-size: 24px; line-height: 1; font-weight: 600; }
.summary-label { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
.summary-card.danger strong { color: var(--danger); }
.summary-card.today strong { color: var(--warning); }

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 25px 0 18px;
}

.filter {
  grid-column: span 2;
  width: 100%;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.filter-row-two { grid-column: span 3; }

.filter.active {
  border-color: rgba(102, 223, 211, .42);
  background: var(--accent-soft);
  color: #aaf5ee;
}

.report-filter { color: #91cbc6; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 12px;
}

.section-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; font-weight: 600; }
.clear-scope { border: 0; background: transparent; color: #79dcd3; font-size: 12px; cursor: pointer; }

.items { display: grid; gap: 10px; }
.group-label { margin: 9px 2px 1px; color: var(--muted-2); font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }

.item-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .13);
}

.item-card.overdue { border-color: rgba(255, 102, 125, .2); }
.item-card.completed { opacity: .62; }
.item-card.completed .item-title { text-decoration: line-through; }

.item-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: rgba(117, 129, 158, .12);
  color: #cbd1df;
  font-size: 17px;
  font-weight: 600;
}

.item-card.payment .item-icon { background: var(--accent-soft); color: #8ee9e0; }
.item-card.birthday { border-color: rgba(255, 182, 77, .16); }
.item-card.birthday .item-icon { background: rgba(255, 182, 77, .1); color: var(--warning); }
.item-main { min-width: 0; }
.item-title { margin: 0; overflow: hidden; font-size: 15px; font-weight: 600; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: flex; flex-wrap: wrap; gap: 5px 9px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.item-meta .overdue-text { color: var(--danger); }
.item-amount { margin-top: 7px; color: #e9eaf0; font-size: 14px; font-weight: 600; }
.repeat-badge { color: #80bbb7; }

.item-actions { display: flex; align-items: center; gap: 7px; }
.done-button, .edit-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  cursor: pointer;
}

.done-button { border: 1px solid rgba(98, 212, 165, .25); background: rgba(98, 212, 165, .08); color: var(--success); font-size: 16px; }
.edit-button { border: 0; background: rgba(255, 255, 255, .035); color: var(--muted); font-size: 20px; }

.empty { padding: 42px 18px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 15px; border-radius: 20px; background: rgba(98, 212, 165, .1); color: var(--success); font-size: 24px; }
.empty h3 { margin: 0 0 7px; font-size: 17px; }
.empty p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.floating-add {
  position: fixed;
  z-index: 15;
  right: max(20px, calc((100vw - 680px) / 2 + 20px));
  bottom: calc(20px + var(--safe-bottom));
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0 0 5px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(145deg, #70e7dc, #35b7ae);
  color: #071924;
  font-size: 34px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(45, 174, 165, .34);
}

.sheet-backdrop { position: fixed; z-index: 40; inset: 0; background: rgba(0, 0, 0, .68); backdrop-filter: blur(5px); }

.sheet {
  position: fixed;
  z-index: 41;
  left: 50%;
  bottom: 0;
  width: min(100%, 680px);
  max-height: 94vh;
  padding: 9px 20px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: #12151c;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, .45);
  transform: translateX(-50%);
  animation: sheetIn .22s ease-out;
}

@keyframes sheetIn { from { transform: translate(-50%, 30px); opacity: 0; } }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 15px; border-radius: 99px; background: #3f444f; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 19px; }
.icon-button { width: 38px; height: 38px; padding: 0 0 3px; border: 0; border-radius: 13px; background: #20232c; color: #d9dbe2; font-size: 26px; cursor: pointer; }

.type-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 18px; padding: 5px; border-radius: 17px; background: #0d1016; }
.type-option { min-width: 0; padding: 10px 5px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.2; cursor: pointer; }
.type-option span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 5px; border-radius: 8px; background: rgba(255, 255, 255, .05); }
.type-option.active { background: #232631; color: #fff; box-shadow: 0 5px 15px rgba(0, 0, 0, .18); }
.type-option[data-kind="payment"].active span { background: var(--accent-soft); color: #8ee9e0; }
.type-option[data-kind="birthday"].active span { background: rgba(255, 182, 77, .12); }

.field { display: grid; gap: 8px; min-width: 0; margin-bottom: 15px; }
.field > span { padding-left: 2px; color: #b3b7c2; font-size: 12px; font-weight: 500; }
.field em { color: var(--muted-2); font-style: normal; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 15px;
  outline: none;
  background: #1a1d25;
  color: #f4f5f7;
}

input, select { height: 49px; padding: 0 13px; }
textarea { min-height: 84px; padding: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(102, 223, 211, .55); box-shadow: 0 0 0 3px rgba(102, 223, 211, .08); }
input::placeholder, textarea::placeholder { color: #626774; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #767c89 50%), linear-gradient(135deg, #767c89 50%, transparent 50%); background-position: calc(100% - 17px) 21px, calc(100% - 12px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.amount-wrap { position: relative; }
.amount-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 8px; }
.amount-wrap input { padding-right: 13px; }
.amount-wrap .currency-select { padding: 0 25px 0 12px; background-color: #1a1d25; }

.form-actions { display: flex; gap: 10px; margin-top: 7px; }
.primary-button, .secondary-button, .delete-button { min-height: 49px; border-radius: 15px; font-weight: 600; cursor: pointer; }
.primary-button { flex: 1; border: 0; background: linear-gradient(145deg, #70e7dc, #35b7ae); color: #071924; box-shadow: 0 12px 24px rgba(45, 174, 165, .24); }
.secondary-button { padding: 0 18px; border: 1px solid var(--border); background: #1b1e27; color: #e9eaf0; }
.delete-button { padding: 0 16px; border: 1px solid rgba(255, 102, 125, .2); background: rgba(255, 102, 125, .07); color: var(--danger); }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(88px + var(--safe-bottom)); width: max-content; max-width: calc(100% - 38px); padding: 12px 16px; border: 1px solid var(--border); border-radius: 14px; background: #242731; color: #fff; font-size: 13px; text-align: center; box-shadow: var(--shadow); transform: translateX(-50%); animation: toastIn .18s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

.loading { position: fixed; z-index: 90; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); font-size: 13px; }
.spinner { width: 34px; height: 34px; border: 3px solid #242833; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
body.sheet-open { overflow: hidden; }

.report-section { padding-bottom: 14px; }
.report-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 2px 2px 18px; }
.report-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.month-control { display: grid; gap: 6px; width: 148px; }
.month-control > span { color: var(--muted); font-size: 11px; }
.month-control input { height: 42px; padding: 0 10px; font-size: 13px; }
.report-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 18px; }
.report-card { padding: 15px; border: 1px solid var(--border); border-radius: 18px; background: var(--panel); }
.report-card.completed { border-color: rgba(98, 212, 165, .2); background: rgba(98, 212, 165, .055); }
.report-card.pending { border-color: rgba(255, 182, 77, .18); background: rgba(255, 182, 77, .045); }
.report-card.overdue { border-color: rgba(255, 102, 125, .2); background: rgba(255, 102, 125, .05); }
.report-card span { display: block; color: var(--muted); font-size: 11px; }
.report-card strong { display: block; margin-top: 8px; font-size: 18px; font-weight: 600; }
.report-card small { display: block; margin-top: 5px; color: #b9bdc7; font-size: 12px; }
.report-list { display: grid; gap: 8px; }
.report-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 15px; border: 1px solid var(--border); border-radius: 17px; background: var(--panel); }
.report-row h3 { margin: 0; font-size: 14px; font-weight: 600; }
.report-row-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.report-row-side { text-align: right; }
.report-row-amount { font-size: 14px; font-weight: 600; white-space: nowrap; }
.status-chip { display: inline-block; margin-top: 6px; padding: 4px 8px; border-radius: 999px; color: #cdd1d9; background: rgba(255, 255, 255, .055); font-size: 10px; white-space: nowrap; }
.status-chip.completed { color: var(--success); background: rgba(98, 212, 165, .1); }
.status-chip.pending { color: var(--warning); background: rgba(255, 182, 77, .09); }
.status-chip.overdue { color: var(--danger); background: rgba(255, 102, 125, .09); }
.export-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 18px; }
.export-button { min-height: 51px; }

@media (max-width: 380px) {
  .report-head { align-items: stretch; flex-direction: column; }
  .month-control { width: 100%; }
}

@media (min-width: 720px) {
  .app-shell { padding-top: 30px; }
  .sheet { bottom: 24px; max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 28px; }
  .floating-add { right: calc((100vw - 680px) / 2 + 22px); }
}

@media (max-width: 380px) {
  .app-shell { padding-inline: 13px; }
  .hero { padding: 20px; }
  .summary-card { padding-inline: 10px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .item-card { gap: 10px; padding: 14px; }
}
