:root {
  --bg: #111;
  --panel: #1a1a1a;
  --panel-2: #242424;
  --text: #f8fafc;
  --muted: #d1d5db;
  --green: #4b5563;
  --green-hover: #6b7280;
  --red: #52525b;
  --red-hover: #71717a;
  --border: #3a3a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.container {
  width: min(900px, 92%);
  margin: 24px auto 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1,
h2,
h3 {
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.top-total {
  text-align: center;
  background: linear-gradient(180deg, #202020, #151515);
}

.total-label {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.total-value {
  font-size: clamp(2rem, 4vw, 2.8rem);
  color: #4ade80;
  font-weight: 700;
}

.section-title {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  outline: none;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: #6b7280;
}

button {
  cursor: pointer;
  padding: 10px 14px;
  transition: 0.2s ease;
  color: #fff;
  border: none;
}

.btn-green {
  background: var(--green);
  font-weight: 600;
}

.btn-green:hover {
  background: var(--green-hover);
}

.btn-red {
  background: var(--red);
  font-weight: 600;
}

.btn-red:hover {
  background: var(--red-hover);
}

.category-controls {
  display: flex;
  gap: 8px;
}

.category-controls select {
  flex: 1;
}

.category-action {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.table-card {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #202020;
}

.amount {
  font-weight: 700;
  color: #86efac;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid transparent;
  white-space: nowrap;
}

.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--red);
  border-radius: 8px;
  padding: 0;
}

.delete-btn:hover {
  background: var(--red-hover);
}

.delete-btn svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

.table-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.empty-note {
  color: var(--muted);
  padding: 14px 0 4px;
  text-align: center;
}

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

  .category-controls {
    display: grid;
    grid-template-columns: 1fr auto auto;
  }

  .table-actions {
    justify-content: stretch;
  }

  .table-actions button {
    width: 100%;
  }

  .category-action {
    width: 40px;
    min-width: 40px;
  }
}

@media (max-width: 700px) {
  .table-card {
    overflow-x: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    background: #202020;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed #3f3f3f;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
  }

  .delete-btn {
    margin-left: auto;
  }
}
