body {
  align-items: flex-start;
  padding: 20px 14px 60px;
}

.fin-app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* ===== Шапка ===== */
.fin-header {
  background: #fff;
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.fin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}

.fin-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fin-user strong { display: block; color: #1e1b3a; font-size: 15px; }
.fin-user small { color: #7a7899; font-size: 12px; }

.fin-tabs {
  display: flex;
  gap: 6px;
  background: #f1f0fa;
  padding: 5px;
  border-radius: 14px;
  flex: 1;
  justify-content: center;
}

.tab {
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #7a7899;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { color: #4a4770; }
.tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.fin-exit {
  color: #e5484d;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  transition: background 0.2s;
}
.fin-exit:hover { background: #ffe9ea; }

/* ===== Панели ===== */
.panel { display: none; }
.panel.active { display: block; animation: pop 0.3s ease; }

.panel .card { margin-bottom: 16px; }
.card h2 { margin-bottom: 6px; }
.card h3 { margin-bottom: 14px; text-align: left; color: #1e1b3a; }

/* ===== Ввод дня ===== */
#form-day { text-align: left; }

#day-date {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e4e2f2;
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 4px;
  font-family: inherit;
}
#day-date:focus { outline: none; border-color: #667eea; }

.streak {
  background: #fff4e5;
  color: #b25b00;
  border-radius: 12px;
  padding: 10px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
}

.today-summary {
  margin-top: 14px;
  padding: 12px;
  background: #eafaf0;
  border-radius: 12px;
  color: #0a7a3d;
  font-weight: 700;
  font-size: 14px;
  display: none;
}
.today-summary.show { display: block; }

/* ===== Быстрая статистика ===== */
.tiny {
  font-size: 12px;
  margin-bottom: 0 !important;
  text-align: left;
}

.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.qs {
  border-radius: 16px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qs span {
  font-size: 19px;
  font-weight: 800;
  color: #1e1b3a;
  line-height: 1.15;
}

.qs small {
  font-size: 11px;
  font-weight: 700;
  color: #4a4770;
}

.qs em {
  font-style: normal;
  font-size: 11px;
  color: #7a7899;
}

.qs.green  { background: #e6f9ee; }
.qs.green span  { color: #0a7a3d; }
.qs.red    { background: #ffe9ea; }
.qs.red span    { color: #e5484d; }
.qs.gold   { background: #fff4d6; }
.qs.gold span   { color: #b25b00; }
.qs.gold2  { background: #ece8ff; }
.qs.gold2 span  { color: #5b3df5; }

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

/* Линия среднего на дневных диаграммах */
.day-chart { position: relative; height: 210px; }

.avg-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed #5b3df5;
  pointer-events: none;
  z-index: 6;
}

.avg-tag {
  position: absolute;
  top: -9px;
  right: 0;
  background: #5b3df5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ===== Сравнение по дням ===== */
.compare {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 130px;
  padding-top: 6px;
  overflow-x: auto;
  overflow-y: hidden;
}

.cmp-col {
  flex: 1;
  min-width: 26px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  position: relative;
}

.cmp-stack {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  border-bottom: 2px solid #d9d6ef;
}

.cmp-bar {
  width: 70%;
  min-height: 3px;
  border-radius: 4px;
  position: relative;
  transition: filter 0.15s;
}

.cmp-bar:hover { filter: brightness(1.2); }

.cmp-bar.inc { background: linear-gradient(180deg, #3ddc84, #0a7a3d); }
.cmp-bar.exp { background: linear-gradient(180deg, #ff8787, #e5484d); }

.cmp-bar::after {
  content: attr(data-v);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b3a;
  color: #fff;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 9;
}

.cmp-bar:hover::after { opacity: 1; }

.cmp-label {
  font-size: 9px;
  font-weight: 700;
  color: #7a7899;
  white-space: nowrap;
}

.cmp-label.best { color: #0a7a3d; }

/* ===== История ===== */
.history {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.history li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #f7f6fd;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}

.history .h-date { font-weight: 700; color: #4a4770; white-space: nowrap; }
.history .h-note { color: #7a7899; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-inc { color: #0a7a3d; font-weight: 700; white-space: nowrap; }
.history .h-exp { color: #e5484d; font-weight: 700; white-space: nowrap; }
.history .h-empty { color: #7a7899; font-style: italic; justify-content: center; }

/* ===== Статистика ===== */
.stat-row {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.s {
  flex: 1;
  background: #f7f6fd;
  border-radius: 14px;
  padding: 14px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.s span { font-size: 16px; font-weight: 800; color: #1e1b3a; word-break: break-all; }
.s small { font-size: 10.5px; color: #7a7899; }
.s.green span { color: #0a7a3d; }
.s.red span { color: #e5484d; }
.s.blue span { color: #3d5afe; }

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.month-nav h2 { font-size: 20px; }
.month-nav button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #f1f0fa;
  font-size: 22px;
  font-weight: 800;
  color: #4a4770;
  cursor: pointer;
  transition: all 0.15s;
}
.month-nav button:hover { background: #667eea; color: #fff; }

.progress-wrap {
  height: 14px;
  background: #ffe3e4;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress {
  height: 100%;
  background: linear-gradient(90deg, #0a7a3d, #3ddc84);
  border-radius: 10px;
  transition: width 0.5s ease;
  min-width: 2px;
}

/* ===== Календарь месяца ===== */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-head {
  font-size: 11px;
  font-weight: 700;
  color: #7a7899;
  text-align: center;
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: #f1f0fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #4a4770;
  position: relative;
  gap: 1px;
}
.cal-day .d-num { font-weight: 700; }
.cal-day .d-bal { font-size: 9px; font-weight: 700; }
.cal-day.has .d-bal.pos { color: #0a7a3d; }
.cal-day.has .d-bal.neg { color: #e5484d; }
.cal-day.empty { background: transparent; }
.cal-day.today { outline: 3px solid #667eea; }
.cal-day.has { background: #e9e7fb; }
.cal-day.miss { opacity: 0.55; }

/* ===== График ===== */
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chart-head h3 { margin: 0; }

.legend { display: flex; gap: 12px; }
.lg { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.lg::before { content: ""; width: 12px; height: 12px; border-radius: 3px; display: block; }
.lg.green::before { background: #3ddc84; }
.lg.red::before { background: #ff6b6b; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 220px;
  padding-top: 10px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
  min-width: 0;
}

.bars { display: flex; gap: 3px; align-items: flex-end; height: 170px; width: 100%; justify-content: center; }

.bar {
  width: 45%;
  max-width: 18px;
  border-radius: 5px 5px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}
.bar.inc { background: linear-gradient(180deg, #3ddc84, #0a7a3d); }
.bar.exp { background: linear-gradient(180deg, #ff8787, #e5484d); }

.bar:hover { filter: brightness(1.15); }
.bar::after {
  content: attr(data-v);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b3a;
  color: #fff;
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 5;
}
.bar:hover::after { opacity: 1; }

.chart-label {
  font-size: 10px;
  font-weight: 700;
  color: #7a7899;
  white-space: nowrap;
}

/* ===== Таблица ===== */
.table-scroll { overflow-x: auto; }

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fin-table th {
  background: #f1f0fa;
  color: #4a4770;
  padding: 10px 8px;
  text-align: left;
  font-size: 12px;
}

.fin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #eeecf9;
  color: #1e1b3a;
}

.fin-table tr.total td {
  font-weight: 800;
  background: #eef1ff;
}

.fin-table .pos { color: #0a7a3d; font-weight: 700; }
.fin-table .neg { color: #e5484d; font-weight: 700; }

/* ===== Мобильные ===== */
@media (max-width: 640px) {
  .fin-header { flex-direction: column; align-items: stretch; }
  .fin-user { justify-content: center; }
  .fin-tabs { width: 100%; }
  .tab { flex: 1; padding: 9px 6px; font-size: 13px; }
  .fin-exit { text-align: center; }
  .stat-row { flex-direction: column; }
  .chart { height: 180px; }
  .bars { height: 130px; }
}
