:root {
  --black: #161616;
  --graphite: #2b2b2f;
  --graphite-soft: #f1f1f1;
  --ink: #101012;
  --muted: #5f6065;
  --line: #dedede;
  --paper: #ffffff;
  --bg: #f5f5f5;
  --red: #9f1f2e;
  --red-dark: #731620;
  --red-deep: #4a1017;
  --red-soft: #fbebed;
  --orange: #f68b19;
  --shadow: 0 18px 50px rgba(20, 20, 20, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 95% 0%, rgba(159, 31, 46, .18), transparent 26rem),
    radial-gradient(circle at 8% 0%, rgba(0, 0, 0, .05), transparent 26rem),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select { font: inherit; }
.finance-shell { min-height: 100vh; padding: 0 clamp(18px, 4vw, 64px) 70px; }
.loading-card {
  width: min(420px, 100%);
  margin: 20vh auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 20px 60px rgba(20, 20, 20, .09);
}
.loading-card strong, .loading-card span { display: block; }
.loading-card span { margin-top: 8px; color: var(--muted); }
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(244, 243, 237, .55);
  backdrop-filter: blur(2px);
}
.loading-overlay > div {
  width: min(360px, calc(100% - 36px));
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 20px 60px rgba(20, 20, 20, .12);
}
.loading-overlay strong,
.loading-overlay span {
  display: block;
}
.loading-overlay span {
  margin-top: 6px;
  color: var(--muted);
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  margin: 0 calc(clamp(18px, 4vw, 64px) * -1) 26px;
  padding: 16px clamp(18px, 4vw, 64px);
  color: var(--red-dark);
  background:
    radial-gradient(circle at 96% 0%, rgba(159,31,46,.12), transparent 20rem),
    linear-gradient(180deg, #ffffff 0%, #f3f3f4 100%);
  border-bottom: 1px solid #e1dadd;
  box-shadow: 0 8px 28px rgba(20, 20, 20, .08);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-logo {
  width: 210px;
  height: 58px;
  object-fit: contain;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.brand h1 {
  margin: 0;
  color: var(--red-dark);
  font: 800 clamp(24px, 3.2vw, 38px)/1.05 Georgia, serif;
  letter-spacing: -.02em;
}
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800;
  color: white; background: linear-gradient(135deg, var(--red), #c33a48); transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(159, 31, 46, .22); }
.btn.secondary { color: var(--black); background: var(--graphite-soft); }
.btn.danger { background: linear-gradient(135deg, var(--red-dark), var(--red)); }
.btn.white { color: var(--red-dark); background: #fff; border: 1px solid #edcdd1; }

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}
.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px auto;
  gap: 10px;
  align-items: center;
}
select, input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: white;
  outline: none;
}
select:focus, input:focus { border-color: #c7a2a6; box-shadow: 0 0 0 3px rgba(167, 43, 53, .09); }
.meta-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 14px; color: var(--muted); font-size: 13px;
}
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 999px; background: #eeeeef;
}
.pill.warn { color: #8a5b14; background: #fff3d9; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0; }
.tab {
  height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); background: white; cursor: pointer; font-weight: 800;
}
.tab.active { color: white; border-color: var(--red); background: linear-gradient(135deg, var(--red), #c33a48); box-shadow: 0 10px 24px rgba(159,31,46,.18); }
.section { display: none; }
.section.active { display: block; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 26px 0 24px; }
.summary-card {
  padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper);
  box-shadow: 0 10px 28px rgba(20,20,20,.04);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.summary-card:hover {
  transform: translateY(-2px);
  border-color: #edcdd1;
  box-shadow: 0 14px 34px rgba(159,31,46,.12);
}
.summary-card.active {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(159,31,46,.08), 0 14px 34px rgba(159,31,46,.12);
}
.summary-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.summary-card strong { display: block; margin-top: 8px; font: 600 28px/1.1 Inter, "Segoe UI", Arial, sans-serif; letter-spacing: -.02em; }
.summary-card-own,
.summary-card-purchased,
.summary-card-other { border-color: var(--line); background: var(--paper); }
.summary-card-action strong { font: 850 22px Inter, "Segoe UI", Arial, sans-serif; }

.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin: 26px 0 14px; }
.section-head h2 { margin: 0; font: 750 30px Georgia, serif; }
.section-head p { margin: 5px 0 0; color: var(--muted); }
.spoiler {
  margin-bottom: 18px;
}
.spoiler-head {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 254, 250, .86);
  cursor: pointer;
  text-align: left;
}
.spoiler-head span {
  font-weight: 900;
}
.spoiler-head strong {
  font: 750 22px Georgia, serif;
  white-space: nowrap;
}
.spoiler-head em {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--red-dark);
  background: var(--red-soft);
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}
.exclude-box { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tag { padding: 8px 10px; border-radius: 10px; background: var(--graphite-soft); font-weight: 750; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.table-wrap.collapsed { display: none; }
.date-spoiler .table-wrap { margin-top: 10px; }
.day-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.day-list.collapsed { display: none; }
.day-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  overflow: hidden;
}
.day-group.open {
  box-shadow: 0 12px 30px rgba(20, 20, 20, .06);
}
.day-head {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 120px auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 0;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
  text-align: left;
}
.day-head:hover {
  background: #fff7f8;
}
.day-head span,
.day-head strong {
  font-weight: 900;
}
.day-head small {
  color: var(--muted);
  font-weight: 800;
}
.day-head em {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--red-dark);
  background: var(--red-soft);
  font-style: normal;
  font-weight: 850;
}
.day-details {
  padding: 0 10px 10px;
}
.day-details .table-wrap {
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th {
  position: sticky; top: 0; z-index: 1;
  padding: 13px 14px;
  color: #4c4d52;
  text-align: left;
  background: #f4f4f5;
  border-bottom: 2px solid #e4c5c9;
}
td { padding: 13px 14px; border-bottom: 1px solid #ededed; vertical-align: top; }
td { color: #151518; font-weight: 500; }
tr:last-child td { border-bottom: 0; }
.money { font-weight: 850; white-space: nowrap; }
.source-kz { background: #fff7d9; }
.muted { color: var(--muted); }
.record-row.has-details {
  cursor: pointer;
}
.record-row.has-details:hover td {
  background: #fff8f8;
}
.record-row.has-details[aria-expanded="true"] td {
  background: #fff4f5;
}
.details-row {
  display: none;
}
.details-row.open {
  display: table-row;
}
.details-row td {
  padding: 0;
  background: #fff8f8;
}
.details-content {
  padding: 12px 16px 14px 72px;
  color: #404044;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  border-top: 1px solid #f2d9dc;
}

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.plan-field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.plan-table td:first-child, .plan-table th:first-child { position: sticky; left: 0; min-width: 180px; background: var(--paper); }
.plan-table th:first-child { background: #f4f4f5; }
.plan-table .total-cell { font-weight: 900; background: #fff1f2; color: var(--red-dark); }

.empty {
  padding: 34px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cccccf;
  border-radius: 16px;
  background: rgba(255,255,255,.5);
}
.error {
  padding: 16px; border-radius: 14px; color: #7b1f28; background: #fdebed;
}
@media (max-width: 820px) {
  .top { grid-template-columns: 1fr; }
  .top-actions { justify-content: flex-start; }
  .brand { align-items: flex-start; flex-direction: column; gap: 10px; }
  .brand-logo { width: 190px; height: 54px; }
  .filters, .summary-grid, .plans { grid-template-columns: 1fr; }
  .day-head { grid-template-columns: 1fr; }
  .finance-shell { padding-inline: 14px; }
}
