/* Ledger — design tokens */
:root {
  --bg: #0a0c10;
  --bg-glow:
    radial-gradient(
      circle at 15% -10%,
      rgba(240, 180, 41, 0.08),
      transparent 45%
    ),
    radial-gradient(circle at 85% 0%, rgba(62, 207, 142, 0.06), transparent 40%);
  --surface: #12151b;
  --surface-2: #191d25;
  --surface-3: #20242d;
  --border: #262b35;
  --border-soft: #1c2028;

  --text: #e7e9ee;
  --text-muted: #8790a0;
  --text-faint: #565c68;

  --positive: #3ecf8e;
  --positive-soft: rgba(62, 207, 142, 0.12);
  --negative: #f0685c;
  --negative-soft: rgba(240, 104, 92, 0.12);
  --gold: #f0b429;
  --gold-soft: rgba(240, 180, 41, 0.14);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --shadow-card: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
}

/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

::selection {
  background: var(--gold-soft);
  color: var(--gold);
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
*::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 8px;
}

/* Shell & header */
.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.app-header {
  margin-bottom: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 28px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid rgba(240, 180, 41, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  align-items: start;
  gap: 24px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* Balance card */
.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 24px;
}

.balance-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 20px;
}

.balance-icon {
  font-size: 26px;
  color: var(--gold);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 10px;
}

.balance-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.balance-display {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  letter-spacing: -0.02em;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.stat-pill .material-symbols-outlined {
  font-size: 20px;
  border-radius: 8px;
  padding: 6px;
}

.stat-pill p {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.stat-pill span:not(.material-symbols-outlined) {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
}

.stat-pill--income .material-symbols-outlined {
  color: var(--positive);
  background: var(--positive-soft);
}
.stat-pill--income .income-display {
  color: var(--positive);
}

.stat-pill--expense .material-symbols-outlined {
  color: var(--negative);
  background: var(--negative-soft);
}
.stat-pill--expense .expense-display {
  color: var(--negative);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 14px;
}

.section-divider span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  white-space: nowrap;
}

.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* category chips (generated by JS as <p> tags) */
.percentage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 4px;
}

.percentage p {
  margin: 0;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.percentage p::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.percentage p:nth-child(6n + 2)::before {
  background: var(--positive);
}
.percentage p:nth-child(6n + 3)::before {
  background: var(--negative);
}
.percentage p:nth-child(6n + 4)::before {
  background: #4ea1f3;
}
.percentage p:nth-child(6n + 5)::before {
  background: #b084f0;
}
.percentage p:nth-child(6n + 0)::before {
  background: #34d0c6;
}

/* Entry form */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

input,
select {
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

input::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238790a0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

input[type="date"] {
  color-scheme: dark;
}

.add-button {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gold);
  color: #191305;
  font-weight: 600;
  font-size: 0.92rem;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.add-button:hover {
  background: #f7c34c;
  box-shadow: 0 8px 20px -8px rgba(240, 180, 41, 0.55);
  transform: translateY(-1px);
}

.add-button:active {
  transform: translateY(0);
}

.add-button .material-symbols-outlined {
  font-size: 20px;
}

/* Table card */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  max-height: 640px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  min-width: 640px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
}

.table-initial-info {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.col-no,
.col-actions {
  text-align: center;
  width: 60px;
}

td,
th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88rem;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

td.item-no,
td:first-child {
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

td:nth-child(3) {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

td:nth-child(4) {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.82rem;
}

td:nth-child(5) {
  color: var(--text-muted);
}

td:last-child {
  text-align: center;
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 6px;
  font-size: 20px;
  line-height: 1;
  transition:
    color 120ms ease,
    background 120ms ease;
}

.delete-btn:hover {
  color: var(--negative);
  background: var(--negative-soft);
}

.bg-\[\#331414\] {
  background: linear-gradient(90deg, var(--negative-soft), transparent 60%);
}

.bg-\[\#0d2d0b\] {
  background: linear-gradient(90deg, var(--positive-soft), transparent 60%);
}

/* Responsive */
@media (max-width: 640px) {
  .app-shell {
    padding: 24px 14px 60px;
  }

  .balance-card {
    position: static;
  }

  .balance-display {
    font-size: 1.6rem;
  }
}
