:root {
  --bg: #0b1220;
  --bg-soft: #101a2c;
  --panel: rgba(17, 24, 39, 0.92);
  --panel-2: rgba(20, 30, 50, 0.88);
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #22c55e;
  --green-dark: #16a34a;
  --blue: #38bdf8;
  --blue-dark: #0ea5e9;
  --red: #ef4444;
  --gold: #f59e0b;
  --shadow: 0 20px 50px rgba(0,0,0,.35);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56,189,248,.12), transparent 28%),
    radial-gradient(circle at top right, rgba(34,197,94,.10), transparent 26%),
    linear-gradient(180deg, #08111d 0%, #0b1220 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

select {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

select:focus {
  background: #0b1220;
  color: #fff;
}

select option {
  background: #0b1220;
  color: #ffffff;
}

.container {
  width: min(1380px, calc(100% - 32px));
  margin: 28px auto 40px;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(470px, 100%);
  padding: 30px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 820px;
  font-size: 15px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 20px;
}

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

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

@media (max-width: 920px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.stat {
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.stat .label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 600;
}

.stat .value {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.card {
  padding: 20px;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 28px;
  line-height: 1.1;
}

.form-group {
  margin-bottom: 14px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.045);
  color: var(--text);
  padding: 13px 14px;
  border-radius: 14px;
  outline: none;
  transition: .2s ease;
}

input::placeholder,
textarea::placeholder {
  color: #7f8ea7;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(56,189,248,.75);
  box-shadow: 0 0 0 4px rgba(56,189,248,.14);
  background: rgba(255,255,255,.06);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  transition: .2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,.09);
}

.btn.primary {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border: none;
  color: #052e16;
}

.btn.info {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border: none;
  color: #082f49;
}

.btn.danger {
  background: linear-gradient(135deg, #f87171, var(--red));
  border: none;
  color: #fff;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.2fr .8fr .8fr .8fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

th,
td {
  text-align: left;
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #13203a;
  color: #d8e2f0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}

tbody tr {
  transition: .18s ease;
}

tbody tr:hover {
  background: rgba(255,255,255,.035);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
  margin-top: 6px;
}

.pill.kzt {
  background: rgba(34,197,94,.14);
  color: #86efac;
}

.pill.usd {
  background: rgba(56,189,248,.14);
  color: #7dd3fc;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: .18s ease;
}

.mini-btn:hover {
  background: rgba(255,255,255,.1);
}

.mini-btn.delete {
  color: #fecaca;
  border-color: rgba(239,68,68,.28);
  background: rgba(239,68,68,.12);
}

.alert {
  padding: 13px 15px;
  border-radius: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}

.alert.error {
  background: rgba(239,68,68,.12);
  color: #fecaca;
}

.alert.success {
  background: rgba(34,197,94,.12);
  color: #bbf7d0;
}

.hint,
.footer-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.chart-header h2 {
  margin: 0;
}

.chart-switch {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,.04);
  padding: 4px;
  border-radius: 12px;
}

.chart-switch a {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: #94a3b8;
  text-decoration: none;
  transition: .2s;
}

.chart-switch a:hover {
  color: #fff;
}

.chart-switch a.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}

.pill.usd {
  background: rgba(56,189,248,.14);
  color: #7dd3fc;
}

.pill.kzt {
  background: rgba(34,197,94,.14);
  color: #86efac;
}

/* ===== Mobile optimization ===== */
@media (max-width: 768px) {
  .container {
    width: min(100%, calc(100% - 18px));
    margin: 14px auto 24px;
  }

.chart-header {
    align-items: flex-start;
  }

  .chart-switch {
    width: 100%;
    justify-content: space-between;
  }

  .chart-switch a {
    flex: 1;
    text-align: center;
  }
  .hero {
    gap: 12px;
    margin-bottom: 14px;
  }

  .hero h1 {
    font-size: 32px;
    line-height: 1.05;
    margin-bottom: 8px;
  }

  .subtitle {
    font-size: 14px;
    line-height: 1.45;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .btn {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .stat {
    padding: 14px;
    border-radius: 16px;
  }

  .stat .label {
    font-size: 12px;
  }

  .stat .value {
    font-size: 26px;
  }

  .card {
    padding: 14px;
    border-radius: 18px;
  }

  .card h2 {
    font-size: 26px;
    margin-bottom: 14px;
  }

  .filter-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .filter-bar input,
  .filter-bar select,
  .filter-bar button,
  .btn {
    min-height: 54px;
    border-radius: 16px;
    font-size: 16px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
  }

  table {
    min-width: 920px;
  }

  th,
  td {
    padding: 12px 10px;
    font-size: 13px;
  }

  th {
    font-size: 11px;
    letter-spacing: .05em;
  }

  .pill {
    font-size: 11px;
    padding: 6px 9px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .mini-btn {
    width: 100%;
    text-align: center;
  }

  canvas#expensesChart {
    width: 100% !important;
    height: 260px !important;
  }
}

@media (max-width: 480px) {
  .container {
    width: min(100%, calc(100% - 14px));
    margin: 10px auto 18px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .card h2 {
    font-size: 22px;
  }

  .subtitle {
    font-size: 13px;
  }

  .stat .value {
    font-size: 22px;
  }

  .card {
    padding: 12px;
  }

  th,
  td {
    padding: 10px 9px;
  }

  canvas#expensesChart {
    height: 220px !important;
  }
}