:root {
  color-scheme: light;
  --bg: #f5f0e4;
  --surface: rgba(255, 255, 255, 0.93);
  --field: #ffffff;
  --line: #dde2ea;
  --ink: #141b2b;
  --muted: #667380;
  --blue: #2458df;
  --blue-strong: #1f50dd;
  --blue-soft: #e7f0ff;
  --pink-soft: #f8e8e6;
  --green: #0d7f66;
  --track: #eaedf3;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(25, 31, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.72), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 13px 28px;
}

.budget-card,
.expense-form,
.expense-panel,
.settings-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.budget-card {
  display: grid;
  gap: 14px;
  padding: 18px 16px 16px;
  margin-bottom: 18px;
}

.budget-topline,
.budget-bottomline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.budget-topline strong {
  font-size: clamp(1.33rem, 7vw, 1.7rem);
  line-height: 1.05;
}

.budget-bottomline strong {
  color: var(--muted);
  font-size: clamp(1.05rem, 5.5vw, 1.33rem);
  line-height: 1.1;
}

.budget-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--track);
}

.budget-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.workspace {
  display: grid;
  gap: 12px;
}

.expense-form {
  display: grid;
  gap: 14px;
  padding: 12px 14px 12px;
  overflow: hidden;
}

.quick-strip {
  display: flex;
  gap: 8px;
  margin: 0 -14px;
  padding: 0 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-strip::-webkit-scrollbar {
  display: none;
}

.quick-strip button {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(25, 31, 42, 0.03);
}

.quick-strip strong {
  font-weight: 900;
}

.quick-strip span {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.9fr) minmax(134px, 1.7fr) minmax(98px, 1.15fr);
  gap: 6px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

input {
  padding: 0 12px;
}

select {
  appearance: none;
  padding: 0 34px 0 10px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 88, 223, 0.13);
}

.amount-input {
  min-height: 42px;
  color: #6b6f76;
  font-size: 1.45rem;
}

.select-shell {
  position: relative;
  min-width: 0;
}

.select-shell span {
  position: absolute;
  left: 11px;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  font-size: 1.08rem;
  pointer-events: none;
}

.category-shell select {
  padding-left: 34px;
}

.date-shell select {
  padding-right: 27px;
}

.date-shell svg {
  right: 8px;
}

.select-shell svg {
  position: absolute;
  right: 11px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  pointer-events: none;
}

.note-input {
  min-height: 43px;
  font-size: 1.3rem;
}

.note-input::placeholder,
.amount-input::placeholder {
  color: #777;
}

.more-fields {
  display: grid;
  gap: 10px;
}

.more-fields summary {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.more-fields summary::-webkit-details-marker {
  display: none;
}

.more-fields summary svg {
  width: 14px;
  height: 14px;
}

.more-fields[open] summary svg {
  transform: rotate(180deg);
}

.plus-mark {
  color: var(--muted);
  font-size: 1.85rem;
  line-height: 0;
}

.more-fields label {
  display: grid;
  gap: 6px;
}

.more-fields label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 6px;
  padding-top: 4px;
}

.secondary-button,
.save-button {
  min-height: 48px;
  border-radius: 17px;
  font-size: 1.08rem;
  font-weight: 900;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
}

.save-button {
  background: linear-gradient(135deg, #2f6df0, var(--blue-strong));
  color: #fff;
  box-shadow: 0 10px 18px rgba(36, 88, 223, 0.2);
}

.expense-panel {
  overflow: hidden;
  padding: 14px 14px 12px;
}

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.see-all-button {
  background: transparent;
  color: var(--blue);
  font-size: 1.08rem;
  font-weight: 900;
  padding: 0;
}

.day-picker {
  display: grid;
  grid-template-columns: 34px minmax(104px, auto) 34px;
  align-items: center;
  min-height: 42px;
  padding: 4px;
  border-radius: 22px;
  background: #f6f7fa;
  box-shadow: inset 0 1px 3px rgba(25, 31, 42, 0.08);
}

.day-picker button {
  width: 32px;
  height: 32px;
  border-radius: 13px;
  background: var(--field);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
}

.day-picker strong {
  display: grid;
  justify-items: center;
  font-size: 1rem;
  line-height: 1;
}

.day-picker small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.55fr);
  gap: 7px;
  margin-bottom: 6px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap input {
  min-height: 38px;
  padding-left: 36px;
  border-radius: 13px;
  font-size: 0.92rem;
}

.toolbar select {
  min-height: 38px;
  border-radius: 13px;
  font-size: 0.92rem;
}

.status-line {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.status-line.ok {
  color: var(--green);
}

.expense-list {
  display: grid;
  gap: 8px;
}

.expense-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.expense-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #f5f7fb;
  font-size: 1.2rem;
}

.expense-main {
  min-width: 0;
}

.expense-category,
.expense-note {
  margin: 0;
  overflow-wrap: anywhere;
}

.expense-category {
  color: #202a35;
  font-size: 1.3rem;
  font-weight: 950;
  line-height: 1.05;
}

.expense-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.08;
}

.expense-side {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.amount-cell {
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 950;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 5px;
}

.row-actions button {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: var(--blue-soft);
  font-size: 1rem;
}

.row-actions button[data-action="delete"] {
  background: var(--pink-soft);
}

.empty-state {
  padding: 22px 0;
  color: var(--muted);
  text-align: center;
}

.floating-settings {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.floating-settings svg {
  width: 19px;
  height: 19px;
}

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.38);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-head h2 {
  font-size: 1.2rem;
}

.icon-button,
.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 15px;
}

.icon-button {
  width: 44px;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button,
.ghost-button {
  padding: 0 16px;
  font-weight: 900;
}

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

.ghost-button {
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
}

@media (max-width: 370px) {
  .app-shell {
    padding-left: 9px;
    padding-right: 9px;
  }

  .input-row,
  .form-actions,
  .toolbar,
  .panel-head {
    grid-template-columns: 1fr;
  }

  .day-picker {
    justify-self: stretch;
  }
}
