:root {
  /* Tomorrow Night Blue inspired palette */
  --bg: #002451;
  --surface: #001b3a;
  --surface-elevated: #00152b;
  --border: #00346e;
  --text: #f8f8f8;
  --text-soft: #b4c9ff;
  --muted: #7081a3;
  --accent: #bbdaff;
  --accent-hover: #99c1ff;
  --accent-subtle: rgba(153, 193, 255, 0.16);
  --success: #d1f1a9;
  --success-soft: rgba(209, 241, 169, 0.12);
  --warn: #ffc58f;
  --warn-soft: rgba(255, 197, 143, 0.16);
  --error: #ff9da4;
  --error-soft: rgba(255, 157, 164, 0.16);
  --limit-low: #d1f1a9;
  --limit-mid: #ffc58f;
  --limit-high: #ff9da4;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 1.5rem;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  margin-bottom: 2rem;
  text-align: center;
}

header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  letter-spacing: 0.02em;
}

header p {
  color: var(--text-soft);
  margin: 0;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 2rem;
}

@media (min-width: 1024px) {
  main {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
    grid-template-rows: auto auto;
    gap: 1.5rem;
    grid-template-areas:
      "upload training"
      "budget budget";
  }

  #upload-section {
    grid-area: upload;
  }

  #training-section {
    grid-area: training;
  }

  #budget-section {
    grid-area: budget;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  color: var(--muted);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

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

.drop-zone .drop-zone-hint {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--accent);
}

.upload-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0 0;
}

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

.upload-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.upload-item i {
  color: var(--muted);
  font-size: 1rem;
  width: 1.1em;
}

.upload-item i.fa-file-pdf {
  color: #e74c3c;
}

.upload-item i.fa-file-lines {
  color: var(--success);
}

.upload-list li:last-child {
  border-bottom: none;
}

.btn {
  cursor: pointer;
  font: inherit;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  margin-top: 1rem;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin: 0 0 1rem 0;
  font-weight: 500;
}

.status.running {
  color: var(--accent);
}

.status.done {
  color: var(--success);
}

.status.failed {
  color: var(--error);
}

.chart-container {
  position: relative;
  height: 220px;
}

.budget-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .budget-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 2rem;
  }
}

.budget-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.budget-block {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.budget-block:first-child {
  padding-top: 0;
  border-top: none;
}

.budget-block h3 {
  margin-top: 0;
}

.budget-block--alerts {
  padding-bottom: 0.25rem;
}

.budget-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.budget-sidebar .chart-container--bar {
  height: 320px;
  min-height: 240px;
}

.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.grid-search {
  flex: 1;
  min-width: 120px;
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.grid-search::placeholder {
  color: var(--muted);
}

.grid-filter,
.grid-sort {
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.transactions-list {
  max-height: none;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.list-box {
  max-height: none;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.25rem;
}

.list-box:empty {
  min-height: 2.5rem;
}

.tx-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  align-items: center;
}

.tx-row:last-child {
  border-bottom: none;
}

.tx-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.amount-credit {
  color: var(--success);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.amount-debit {
  color: var(--error);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.pagination:empty {
  margin-top: 0;
}

.pagination button {
  padding: 0.25rem 0.5rem;
  font: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}

.pagination button:hover:not(:disabled) {
  background: var(--border);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination .page-info {
  color: var(--muted);
  margin-left: 0.25rem;
}

.filtered-total {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  border: 1px solid var(--border);
}

.filtered-total.amount-credit {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}

.filtered-total.amount-debit {
  background: var(--error-soft);
  color: var(--error);
  border-color: var(--error);
}

.filtered-total.amount-zero {
  background: var(--surface-elevated);
  color: var(--muted);
}

/* Multi-select category dropdown */
.category-multiselect {
  position: relative;
  min-width: 140px;
}

.category-multiselect-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.category-multiselect-trigger:hover {
  border-color: var(--accent);
}

.category-multiselect-trigger i {
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 0.15s;
}

.category-multiselect.open .category-multiselect-trigger i {
  transform: rotate(180deg);
}

.category-multiselect-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  max-height: 220px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.category-multiselect.open .category-multiselect-dropdown {
  display: flex;
  flex-direction: column;
}

.category-multiselect-search {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px 8px 0 0;
}

.category-multiselect-search::placeholder {
  color: var(--muted);
}

.category-multiselect-list {
  overflow-y: auto;
  padding: 0.25rem;
  max-height: 180px;
}

.category-multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
}

.category-multiselect-option:hover {
  background: var(--accent-subtle);
}

.category-multiselect-option input {
  margin: 0;
  accent-color: var(--accent);
}

/* Suggested limits value coloring */
.limit-value {
  font-weight: 600;
  text-align: right;
}

.limit-value.limit-low {
  color: var(--limit-low);
}

.limit-value.limit-mid {
  color: var(--limit-mid);
}

.limit-value.limit-high {
  color: var(--limit-high);
}

.budget-content h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.by-category,
.suggested-limits {
  display: grid;
  gap: 0;
}

.by-category .row,
.suggested-limits .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.by-category .row:last-child,
.suggested-limits .row:last-child {
  border-bottom: none;
}

.data-quality-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.data-quality-warning i {
  color: var(--warn);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.data-quality-warning:last-child {
  margin-bottom: 0;
}

.alerts .alert {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.alerts .alert:last-child {
  margin-bottom: 0;
}

.alerts .alert .category {
  font-weight: 600;
}

.alerts .alert .message {
  color: var(--muted);
  font-size: 0.9rem;
}

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

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