:root {
  color-scheme: light;
  --ink: #18242d;
  --muted: #61717f;
  --line: #d7e1e7;
  --surface: #ffffff;
  --wash: #f3f7f8;
  --blue: #2f6175;
  --blue-soft: #dcecf1;
  --green: #24745a;
  --green-soft: #dff1e9;
  --red: #a63b4a;
  --red-soft: #f8dce1;
  --yellow: #87640e;
  --yellow-soft: #fff0bd;
  --focus: #1b6f8f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef5f6 0%, #f8fbfb 38%, #ffffff 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.month-control,
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.month-control {
  min-width: 190px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(27, 111, 143, 0.14);
}

textarea {
  resize: vertical;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

.metric strong {
  font-size: 1.8rem;
  line-height: 1;
  letter-spacing: 0;
}

.metric-income {
  border-left: 6px solid var(--green);
}

.metric-outgoing {
  border-left: 6px solid var(--red);
}

.metric-left {
  border-left: 6px solid var(--yellow);
}

.metric-subscriptions {
  border-left: 6px solid var(--blue);
}

.metric-projected {
  border-left: 6px solid #6f4e9b;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 6px 0 18px;
  overflow-x: auto;
}

.tab-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 11px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.overview-layout,
.work-layout,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.live-panel {
  margin-bottom: 16px;
}

.income-panel {
  margin-bottom: 16px;
}

.bills-summary-panel {
  margin-bottom: 16px;
}

.income-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr) auto;
  align-items: end;
  gap: 14px;
}

.helper-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.income-actions {
  display: flex;
  gap: 8px;
}

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

.bill-total-row {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  align-content: space-between;
}

.bill-total-row span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.bill-total-row strong {
  font-size: 1.5rem;
  letter-spacing: 0;
}

.bill-total-row.income {
  background: var(--green-soft);
}

.bill-total-row.outgoing {
  background: var(--red-soft);
}

.bill-total-row.left {
  background: var(--yellow-soft);
}

.bill-total-row.projected {
  background: var(--blue-soft);
}

.entry-section {
  display: grid;
  gap: 10px;
}

.entry-section + .entry-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 950;
  text-transform: uppercase;
}

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

.running-line {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
  padding: 14px;
  display: grid;
  align-content: space-between;
}

.running-line span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.25;
}

.running-line strong {
  font-size: 1.35rem;
  letter-spacing: 0;
}

.running-line.positive {
  background: var(--green-soft);
}

.running-line.negative {
  background: var(--red-soft);
}

.running-line.result {
  background: var(--yellow-soft);
}

.work-layout {
  grid-template-columns: 380px minmax(0, 1fr);
  align-items: start;
}

.settings-layout {
  align-items: start;
}

.settings-stack {
  display: grid;
  gap: 14px;
}

.panel,
.entry-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px;
}

.entry-panel {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 16px;
}

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

.pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--wash);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.alert {
  border-color: #e8a4ae;
  background: var(--red-soft);
  color: var(--red);
}

.stack,
.item-list,
.bar-list {
  display: grid;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.item-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  margin: 0 0 4px;
  font-weight: 900;
}

.item-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.item-amount {
  text-align: right;
  font-weight: 900;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.small-button,
.ghost-button,
.primary-button {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  font-weight: 900;
  padding: 9px 12px;
}

.small-button,
.ghost-button {
  background: #fff;
  color: var(--blue);
}

.danger-button {
  color: var(--red);
}

.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

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

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--wash);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--blue);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--wash);
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .topbar {
    display: grid;
  }

  .summary-grid,
  .overview-layout,
  .work-layout,
  .settings-layout,
  .running-total,
  .income-form,
  .bill-total-grid {
    grid-template-columns: 1fr;
  }

  .income-actions {
    display: grid;
  }

  .entry-panel {
    position: static;
  }
}

@media (max-width: 520px) {
  .summary-grid {
    gap: 10px;
  }

  .metric {
    min-height: 96px;
  }

  .metric strong {
    font-size: 1.45rem;
  }

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

  .item-topline {
    display: grid;
  }

  .item-amount {
    text-align: left;
  }
}
