:root {
  color-scheme: dark;
  --bg: #09111f;
  --bg-soft: #0f172a;
  --panel: rgba(15, 23, 42, 0.9);
  --panel-strong: rgba(17, 24, 39, 0.96);
  --panel-soft: #172235;
  --text: #e5eefb;
  --text-soft: #c7d2e5;
  --muted: #8ea2c0;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --info: #93c5fd;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 24%),
    linear-gradient(180deg, #050b15 0%, var(--bg) 100%);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.narrow-container {
  max-width: 680px;
}

.hero {
  margin-bottom: 22px;
}

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2.3vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  margin-top: 10px;
  font-size: 0.95rem;
}

.card,
.panel {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.panel > :first-child,
.card > :first-child {
  margin-top: 0;
}

.panel h2,
.card h2 {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card p {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  font-weight: 700;
  line-height: 1.2;
}

.small-text {
  font-size: 1rem !important;
  line-height: 1.55;
  color: var(--text-soft);
}

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

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-panel {
  margin-bottom: 20px;
}

.filter-form,
.expense-form {
  display: grid;
  gap: 16px;
}

.filter-form {
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px) 1fr;
  align-items: end;
}

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

label span {
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.72);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input::placeholder {
  color: #70819d;
}

input:focus,
select:focus {
  border-color: rgba(147, 197, 253, 0.55);
  box-shadow: 0 0 0 4px rgba(147, 197, 253, 0.12);
}

.filter-actions,
.form-actions,
.admin-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #052e16;
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.back-link,
.admin-link {
  color: var(--info);
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover,
.admin-link:hover {
  text-decoration: underline;
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.category-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: rgba(8, 15, 28, 0.5);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(20, 30, 48, 0.98);
}

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

th {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

tbody tr:hover {
  background: rgba(148, 163, 184, 0.06);
}

code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(23, 34, 53, 0.95);
  border: 1px solid var(--border);
  color: #dbeafe;
  font-size: 0.92rem;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li + li {
  margin-top: 8px;
}

.muted,
.empty {
  color: var(--muted);
}

.form-panel {
  max-width: 780px;
}

.error-box {
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.28);
  color: #fecaca;
  padding: 12px 14px;
}

.delete-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.ocr-box {
  margin: 0;
  padding: 16px;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.72);
  line-height: 1.5;
  color: var(--text-soft);
}

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

  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 18px 14px 32px;
  }

  .hero-row,
  .stats,
  .filter-form {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .grid,
  .admin-grid,
  .dashboard-insight-grid {
    grid-template-columns: 1fr;
  }

  .hero-row {
    display: flex;
    align-items: stretch;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions > * {
    width: 100%;
  }

  .hero-actions .btn,
  .hero-actions button {
    width: 100%;
  }

  .card,
  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .table-wrap {
    border-radius: 14px;
  }

  table {
    min-width: 640px;
  }

  .filter-actions,
  .form-actions {
    width: 100%;
  }

  .filter-actions .btn,
  .form-actions .btn,
  .delete-form .btn {
    width: 100%;
  }
}
a(2, 6, 23, 0.72);
  line-height: 1.5;
  color: var(--text-soft);
}

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

  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 18px 14px 32px;
  }

  .hero-row,
  .grid,
  .admin-grid,
  .stats,
  .filter-form {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-row {
    display: flex;
    align-items: stretch;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions > * {
    width: 100%;
  }

  .hero-actions .btn,
  .hero-actions button {
    width: 100%;
  }

  .card,
  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .table-wrap {
    border-radius: 14px;
  }

  table {
    min-width: 640px;
  }

  .filter-actions,
  .form-actions {
    width: 100%;
  }

  .filter-actions .btn,
  .form-actions .btn,
  .delete-form .btn {
    width: 100%;
  }
}
  .delete-form .btn {
    width: 100%;
  }
}
