:root {
  --yellow: #fff000;
  --black: #0a0a0a;
  --black-soft: #141414;
  --black-muted: #1c1c1c;
  --black-elevated: #222222;
  --text: #f2f2f2;
  --text-muted: rgba(242, 242, 242, 0.58);
  --white: #ffffff;
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent-soft: rgba(255, 240, 0, 0.14);
  --primary: #fff000;
  --primary-hover: #e6d800;
  --income: #fff000;
  --expense: #ffffff;
  --transfer: rgba(242, 242, 242, 0.82);
  --ignore: rgba(242, 242, 242, 0.38);
  --warning: #fff000;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Inclusive Sans", sans-serif;
  --font-display: ClashDisplay, "Inclusive Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
.panel__header h2,
.modal__header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  color: var(--text);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -20px 28px;
  padding: 22px 20px;
  flex-wrap: wrap;
  background: var(--black);
  color: var(--text);
  border-bottom: 2px solid var(--yellow);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  flex-shrink: 0;
  color: var(--yellow);
}

.header h1 {
  margin: 0;
  font-size: 2rem;
  color: var(--white);
}

.header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.header__eyebrow {
  margin: 0 0 2px;
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

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

.upload {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}

.upload:hover,
.upload.dragover {
  border-color: var(--yellow);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  transform: translateY(-1px);
}

.upload__icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.upload__title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.upload__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card__label {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 8px;
}

.card__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.card--income .card__value { color: var(--income); }
.card--expense .card__value { color: var(--expense); }
.card--result .card__value { color: var(--white); }
.card--pending .card__value { color: var(--yellow); }

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel--wide {
  min-width: 0;
}

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

.panel__header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.chart__row--clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -6px -8px;
  transition: background 0.15s;
}

.chart__row--clickable:hover {
  background: var(--accent-soft);
}

.chart__row--active {
  background: var(--accent-soft);
}

.chart__row--active .chart__label {
  color: var(--yellow);
  font-weight: 700;
}

.chart__label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart__bar-wrap {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--black-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.chart__bar {
  height: 100%;
  border-radius: 999px;
  background: var(--yellow);
  transition: width 0.4s ease;
}

.chart__value {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--white);
}

.chart__empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 24px 0;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

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

.table th {
  background: var(--black-muted);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  position: sticky;
  top: 0;
}

.table tbody tr:hover {
  background: var(--accent-soft);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.desc-cell {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.amount--income { color: var(--income); font-weight: 700; }
.amount--expense { color: var(--expense); font-weight: 700; }
.amount--transfer { color: var(--transfer); font-weight: 700; }
.amount--ignore { color: var(--ignore); }

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}

.btn--primary {
  background: var(--yellow);
  color: var(--black);
  border: 2px solid var(--yellow);
}

.btn--primary:hover {
  background: transparent;
  color: var(--yellow);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border-strong);
}

.btn--ghost:hover {
  background: var(--black-elevated);
  color: var(--white);
  border-color: var(--white);
}

.btn--danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border-strong);
}

.btn--danger-ghost:hover {
  background: var(--black-elevated);
  color: var(--white);
  border-color: var(--white);
}

.header .btn--ghost {
  color: var(--text);
  border-color: var(--border-strong);
}

.header .btn--ghost:hover {
  background: var(--yellow);
  color: var(--black);
  border-color: var(--yellow);
}

.header .btn--danger-ghost {
  color: var(--text-muted);
  border-color: var(--border-strong);
}

.header .btn--danger-ghost:hover {
  background: var(--black-elevated);
  color: var(--white);
  border-color: var(--white);
}

.btn--icon {
  padding: 6px 10px;
  min-width: 32px;
  border-radius: 8px;
}

.input,
.select {
  appearance: none;
  background: var(--black-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 9px 12px;
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(255, 240, 0, 0.25);
  outline-offset: 1px;
  border-color: var(--yellow);
}

.select--sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.select--category {
  min-width: 180px;
  max-width: 220px;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge--expense { background: rgba(255, 255, 255, 0.08); color: var(--white); }
.badge--income { background: var(--accent-soft); color: var(--yellow); }
.badge--transfer { background: rgba(255, 255, 255, 0.08); color: var(--transfer); }
.badge--ignore { background: rgba(255, 255, 255, 0.05); color: var(--ignore); }
.badge--uncategorized { background: var(--accent-soft); color: var(--yellow); }

.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 720px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal__content {
  padding: 24px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal__header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal__hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
}

.modal__hint code {
  background: var(--black-muted);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--yellow);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.rule-form {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
}

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

.rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.rules-list__item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.rules-list__item:last-child {
  border-bottom: none;
}

.rules-list__pattern {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--yellow);
}

.rules-list__arrow {
  color: var(--text-muted);
}

.rules-list__category {
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--black-muted);
  color: var(--yellow);
  border: 1px solid var(--yellow);
  border-radius: 999px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
  z-index: 100;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
