:root {
  --bg: #f7f1e3;
  --panel: #fffdf8;
  --ink: #1d1e2c;
  --muted: #575a6f;
  --accent: #00897b;
  --accent-deep: #00695c;
  --warn: #c64f2d;
  --line: #e7dece;
  --good: #198754;
  --bad: #b42318;
  --shadow: 0 14px 30px rgba(29, 30, 44, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--ink);
  background: var(--bg);
  position: relative;
}

.background-layer {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 15%, rgba(0, 137, 123, 0.15), transparent 36%),
    radial-gradient(circle at 88% 10%, rgba(230, 120, 48, 0.18), transparent 34%),
    linear-gradient(180deg, #f9f5ea, #f4ebd8);
  z-index: -1;
}

h1,
h2,
h3 {
  font-family: "Fraunces", Georgia, serif;
  margin: 0;
}

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.25rem 1rem 1rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  line-height: 1.05;
  margin-top: 0.25rem;
}

.subtitle {
  margin-top: 0.5rem;
  max-width: 62ch;
  color: var(--muted);
}

.save-status {
  margin-top: 0.8rem;
  font-size: 0.86rem;
  color: var(--accent-deep);
  font-weight: 600;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, #ffffff 8%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel-header h2 {
  font-size: 1.18rem;
}

.input-grid {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.five-up {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid #d7d0c2;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fffcf4;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 54%, transparent);
  outline-offset: 1px;
}

button {
  border: 1px solid var(--accent);
  color: white;
  background: linear-gradient(125deg, var(--accent), var(--accent-deep));
  border-radius: 11px;
  padding: 0.62rem 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.04);
}

button.danger {
  border-color: #a93716;
  background: linear-gradient(120deg, #ca4a27, #9f2809);
}

button.small {
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.inline-form > label {
  min-width: 190px;
  flex: 1 1 190px;
}

.manual-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 0.6rem;
}

.manual-form button {
  height: 2.35rem;
}

.hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf0;
  padding: 0.7rem;
}

.metric p {
  margin: 0;
}

.metric .label {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.metric .value {
  margin-top: 0.18rem;
  font-size: 1.06rem;
  font-weight: 700;
}

.metric .good {
  color: var(--good);
}

.metric .bad {
  color: var(--bad);
}

.account-list {
  display: grid;
  gap: 0.65rem;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: #fffbf3;
}

.account-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.account-title {
  font-size: 1.04rem;
}

.type-badge {
  border-radius: 999px;
  background: #ece7da;
  padding: 0.2rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #4d4f5f;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.72rem;
}

.file-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  color: var(--accent-deep);
  background: #e3f4f1;
  border-radius: 10px;
  padding: 0.43rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.flip-check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.8rem;
}

.flip-check input {
  margin: 0;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  border: 1px solid #d6c8ae;
  background: #fff9ea;
  padding: 0.35rem 0.62rem;
  font-size: 0.8rem;
}

.pill-kind {
  border-radius: 999px;
  border: 1px solid #d7ceb9;
  background: #f2ecdf;
  padding: 0.14rem 0.42rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #4f5268;
}

.pill button {
  border: 0;
  padding: 0.05rem 0.3rem;
  border-radius: 999px;
  background: #dbdfeb;
  color: #27293b;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf7;
}

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

thead th {
  text-align: left;
  background: #f3ebd9;
  color: #404256;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

th,
td {
  border-bottom: 1px solid #eee4d0;
  padding: 0.55rem 0.65rem;
  font-size: 0.83rem;
}

tbody tr:hover {
  background: #fcf4de;
}

.duplicate-row {
  background: #fff3ea;
}

.duplicate-row:hover {
  background: #fee7da;
}

.right {
  text-align: right;
}

.amount-positive {
  color: #1f743c;
  font-weight: 700;
}

.amount-negative {
  color: #9f2809;
  font-weight: 700;
}

.table-action {
  border: 1px solid #be5834;
  background: #fff1ec;
  color: #942a0c;
  border-radius: 8px;
  padding: 0.26rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.table-action:hover {
  background: #ffe6dd;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.duplicate-chip {
  border-radius: 999px;
  border: 1px solid #d26b45;
  background: #fff2eb;
  color: #9f310f;
  padding: 0.14rem 0.42rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tag {
  font-size: 0.78rem;
  border: 1px solid #ccc1aa;
  border-radius: 999px;
  padding: 0.18rem 0.58rem;
  background: #fff8e8;
}

.hint-box {
  border: 1px dashed #cfbea0;
  border-radius: 11px;
  color: var(--muted);
  padding: 0.55rem;
  font-size: 0.8rem;
  background: #fff8e5;
}

.duplicate-warning {
  margin-bottom: 0.7rem;
  border: 1px dashed #d88461;
  border-radius: 11px;
  background: #fff2e9;
  padding: 0.65rem 0.72rem;
}

.duplicate-warning p {
  margin: 0;
  font-size: 0.82rem;
  color: #6e3014;
}

.duplicate-list {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.34rem;
}

.duplicate-item {
  font-size: 0.78rem;
  color: #7a3b1d;
}

.budget-input {
  width: 130px;
}

.budget-over {
  color: #9f2809;
  font-weight: 700;
}

.budget-under {
  color: #1f743c;
  font-weight: 700;
}

.budget-neutral {
  color: #4f5268;
  font-weight: 700;
}

.budget-status {
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.budget-status-alert {
  background: #fff1ea;
  border-color: #dd7b53;
  color: #9d3412;
}

.budget-status-over {
  background: #ffecec;
  border-color: #dc6a6a;
  color: #a52121;
}

.budget-status-ok {
  background: #eaf7ef;
  border-color: #7db98f;
  color: #22693f;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.viz-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffcf4;
  padding: 0.8rem;
}

.viz-card h3 {
  margin-bottom: 0.7rem;
  font-size: 1rem;
}

#category-donut {
  min-height: 200px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
}

.donut-shape {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
}

.donut-shape::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: inset 0 0 0 1px #f0e3ca;
}

.donut-legend {
  display: grid;
  gap: 0.45rem;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.legend-left {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 0.66rem;
  height: 0.66rem;
  border-radius: 50%;
  display: inline-block;
}

.bar-rows {
  display: grid;
  gap: 0.5rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 98px;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8rem;
}

.bar-track {
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #e7dbc2;
  background: #f7efde;
  height: 0.7rem;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #009688, #f08a24);
}

.trend-bars {
  display: grid;
  gap: 0.5rem;
}

.trend-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.transfer-rows {
  display: grid;
  gap: 0.45rem;
}

.transfer-head,
.transfer-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 120px;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.79rem;
}

.transfer-head {
  color: #5c5f74;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.net-positive {
  color: #1f743c;
  font-weight: 700;
}

.net-negative {
  color: #9f2809;
  font-weight: 700;
}

.net-zero {
  color: #4f5268;
  font-weight: 700;
}

.hidden {
  display: none;
}

.empty {
  border: 1px dashed #ceb997;
  border-radius: 10px;
  padding: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: #fff8e5;
}

@media (max-width: 1100px) {
  .five-up {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .three-up,
  .five-up,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #category-donut {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .bar-row {
    grid-template-columns: 120px minmax(0, 1fr) 80px;
  }

  .transfer-head,
  .transfer-row {
    grid-template-columns: minmax(110px, 1fr) 90px;
  }

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

@media (max-width: 640px) {
  .hero {
    padding-top: 1.35rem;
  }

  .three-up,
  .five-up,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form > label,
  .inline-form > button {
    width: 100%;
  }

  .manual-form {
    grid-template-columns: 1fr;
  }
}
