:root {
  --bg: #f5efe6;
  --bg-strong: #ebe0d0;
  --surface: rgba(255, 250, 244, 0.92);
  --surface-solid: #fffaf4;
  --surface-dark: #1f3130;
  --text: #1e1f1d;
  --muted: #6e6258;
  --line: #d8c9b6;
  --line-strong: #baa48f;
  --primary: #aa5b2a;
  --primary-dark: #8e471d;
  --accent: #27574c;
  --accent-soft: #d8ebe6;
  --warning: #d17c15;
  --danger: #b4372d;
  --danger-soft: #fde8e3;
  --shadow: 0 18px 40px rgba(71, 45, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(170, 91, 42, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(39, 87, 76, 0.18), transparent 26%),
    linear-gradient(180deg, #f8f2ea 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}

.sidebar,
.card,
.login-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(186, 164, 143, 0.5);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.sidebar-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logout-link {
  background: transparent;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
  transition: color 0.15s;
}

.logout-link:hover {
  color: var(--danger);
}

.sidebar {
  padding: 26px;
  display: grid;
  gap: 24px;
  align-self: start;
  position: sticky;
  top: 20px;
}

.content {
  display: grid;
  gap: 16px;
}

.topbar,
.filters,
.stats-grid,
.charts-grid,
.section-head,
.form-actions,
.topbar-actions,
.nav-tabs {
  display: flex;
  gap: 12px;
}

.topbar,
.filters,
.section-head {
  justify-content: space-between;
  align-items: center;
}

.filters {
  flex-wrap: wrap;
  padding: 16px 18px;
}

.filters label,
.expense-form label,
.login-form label {
  display: grid;
  gap: 8px;
}

.filters label {
  flex: 1 1 0;
  min-width: 0;
}

.search-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}

.search-field {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.02;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.12rem;
}

.muted,
.login-copy,
.telegram-hint p,
.table-description small {
  color: var(--muted);
}

.nav-tabs {
  flex-direction: column;
}

.nav-tab,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.nav-tab {
  text-align: left;
  background: rgba(255, 250, 244, 0.7);
  color: var(--text);
  border: 1px solid transparent;
}

.nav-tab.active {
  background: var(--surface-dark);
  color: #fef7ef;
  border-color: rgba(255, 255, 255, 0.08);
}

.primary-button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: rgba(39, 87, 76, 0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.filters input,
.filters select {
  height: 46px;
  min-height: 0;
}

.filters input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(170, 91, 42, 0.12);
}

label span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.98), rgba(246, 234, 221, 0.9));
  border: 1px solid rgba(186, 164, 143, 0.45);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: 1.7rem;
  line-height: 1.1;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-card,
.recent-card,
.form-card,
.table-shell,
.filters,
.topbar {
  padding: 18px;
}

.card {
  padding: 18px;
}

canvas {
  width: 100%;
  min-height: 320px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.8), rgba(242, 231, 218, 0.9));
}

.recent-list,
.table-body {
  display: grid;
  gap: 12px;
}

.recent-item,
.table-row,
.table-head {
  display: grid;
  grid-template-columns: 100px minmax(0, 1.6fr) 160px 110px 120px 120px;
  gap: 12px;
  align-items: center;
}

.table-head {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.table-row,
.recent-item {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 250, 244, 0.84);
  border: 1px solid rgba(216, 201, 182, 0.8);
}

.table-description {
  display: grid;
  gap: 4px;
}

.text-button {
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-weight: 700;
}

.danger-text {
  color: var(--danger);
}

.expense-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.expense-form .full-width {
  grid-column: 1 / -1;
}

.budget-alert {
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(209, 124, 21, 0.35);
  background: rgba(209, 124, 21, 0.12);
  color: #7c4300;
  font-weight: 700;
}

.budget-alert.danger {
  border-color: rgba(180, 55, 45, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
}

.telegram-hint {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(39, 87, 76, 0.14), rgba(39, 87, 76, 0.04));
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(460px, 100%);
}

.login-card {
  padding: 28px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.form-error {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(180, 55, 45, 0.2);
  color: var(--danger);
}

.table-origin,
.table-category {
  font-weight: 700;
}

code {
  background: rgba(30, 31, 29, 0.08);
  padding: 2px 6px;
  border-radius: 8px;
}

.budget-summary-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.budget-summary-strip article {
  flex: 1;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 250, 244, 0.84);
  border: 1px solid rgba(216, 201, 182, 0.8);
}

.budget-summary-strip span {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.budget-summary-strip strong {
  font-size: 1.2rem;
}

.contributions-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.contribution-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 250, 244, 0.84);
  border: 1px solid rgba(216, 201, 182, 0.8);
}

.contribution-info {
  display: grid;
  gap: 3px;
}

.contribution-amount {
  font-weight: 700;
  color: var(--accent);
}

.contribution-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .expense-form,
  .recent-item,
  .table-row,
  .table-head {
    grid-template-columns: 1fr;
  }

  .topbar,
  .topbar-actions,
  .filters,
  .budget-summary-strip {
    flex-direction: column;
    align-items: stretch;
  }
}

