:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #262337;
  background: #f7f7fb;
  font-synthesis: none;
  --muted: #6b687b;
  --purple: #574298;
  --border: #e1dfe8;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #9678d5; outline-offset: 3px; }
.symbols { display: none; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: min(1152px, calc(100% - 64px)); margin-inline: auto; }
header { background: white; border-bottom: 1px solid var(--border); }
.topbar, .intro, .brand, .local, .today, .stat-title, .panel-title, .history-top, .primary, footer, .row, .dialog-actions { display: flex; align-items: center; }
.topbar { justify-content: space-between; height: 72px; }
.brand { color: #2d2246; text-decoration: none; font-size: 1.85rem; font-weight: 760; letter-spacing: -1.6px; }
.brand-icon, .tile, .title-icon { display: inline-grid; place-items: center; flex: none; }
.brand-icon { background: var(--purple); border-radius: 11px; width: 39px; height: 39px; margin-right: 10px; color: white; transform: rotate(-5deg); }
.brand-icon .icon { width: 25px; height: 25px; }
.brand-dot { color: #8c73c4; }
.local, .today { gap: 8px; font-size: .87rem; }
.local { color: #575162; background: #f5f4f8; padding: 7px 12px; border-radius: 30px; }
.local .icon, .today .icon, footer .icon { width: 16px; height: 16px; }
.intro { margin: 36px 0 24px; justify-content: space-between; gap: 16px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 3.3vw, 2.5rem); letter-spacing: -.055em; line-height: 1.18; }
.intro p { margin-top: 8px; color: var(--muted); }
.today { border: 1px solid var(--border); border-radius: 9px; padding: 9px 13px; background: white; color: #534e63; }
.summary { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 16px; }
.stat, .panel { border-radius: 18px; background: white; border: 1px solid var(--border); }
.stat { padding: 21px 24px; position: relative; min-width: 0; overflow: hidden; }
.stat-title { gap: 10px; font-size: .92rem; font-weight: 550; color: #5b5569; }
.tile { width: 33px; height: 33px; border-radius: 10px; }
.stat strong { display: block; position: relative; z-index: 1; margin-top: 13px; font-size: clamp(1.55rem, 3vw, 2.2rem); line-height: 1.2; letter-spacing: -.055em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.balance { color: white; background: linear-gradient(115deg,#493784,#624ba6); border-color: transparent; }
.balance .stat-title { position: relative; z-index: 1; color: #f8f4ff; }
.balance .tile { background: #ffffff25; }
.waves { position: absolute; color: #c3b4ef; opacity: .41; right: -22px; bottom: -26px; height: 165px; width: 165px; }
.in { background: #ddf5ea; color: #167959; }
.out { background: #ffebe4; color: #ad5135; }
.panels { display: grid; grid-template-columns: minmax(0, 1.48fr) minmax(0, 1fr); grid-template-areas: "history entry"; gap: 20px; margin-top: 24px; align-items: start; }
.panel { padding: 23px; }
.entry { grid-area: entry; }
.history { grid-area: history; }
.panel-title { gap: 10px; }
.title-icon { width: 32px; height: 32px; border-radius: 9px; color: var(--purple); background: #f0ecfa; }
h2 { font-size: 1.22rem; line-height: 1.24; letter-spacing: -.04em; }
.history-top { justify-content: space-between; gap: 6px; }
#count { font-size: .8rem; color: var(--muted); }
.filters { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.filters button { border: 1px solid transparent; background: transparent; color: #655f70; border-radius: 20px; font-size: .875rem; padding: 7px 13px; }
.filters button:hover { background: #f7f5fb; }
.filters button[aria-pressed=true] { background: #eee9fa; color: #55418a; font-weight: 650; border-color: #e0d7f2; }
.empty { margin-top: 18px; min-height: 287px; padding: 32px 15px; text-align: center; display: grid; align-content: center; justify-items: center; background: radial-gradient(#e6e1ef .8px,transparent .9px) 0 0/12px 12px, #faf9fd; border: 1px dashed #dfd9e9; border-radius: 12px; }
.receipt { width: 148px; height: auto; margin-bottom: 10px; }
.empty h3 { font-size: 1.05rem; letter-spacing: -.025em; }
.empty p { margin-top: 6px; font-size: .875rem; color: var(--muted); }
#entry-form { display: grid; gap: 15px; margin-top: 20px; }
fieldset { padding: 0; margin: 0; border: none; min-width: 0; }
.field, legend { font-weight: 600; font-size: .875rem; }
legend { padding: 0; margin-bottom: 6px; }
.field { display: grid; gap: 6px; }
.field small { font-size: .81rem; color: var(--muted); font-weight: 400; }
.switch { display: grid; grid-template-columns: 1fr 1fr; border-radius: 10px; padding: 4px; background: #f4f3f7; }
.switch label { position: relative; min-width: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: flex; justify-content: center; align-items: center; gap: 5px; border: 1px solid transparent; padding: 7px 2px; border-radius: 7px; font-size: .86rem; font-weight: 550; color: #696575; }
.switch .icon { width: 16px; height: 16px; }
.switch input:focus-visible + span { outline: 2px solid #9678d5; }
.switch input:checked + span { background: white; border-color: #dfdbe6; color: #40344f; box-shadow: 0 1px 3px #29203210; }
.switch input[value=expense]:checked + span .icon { color: #b95739; }
.switch input[value=income]:checked + span .icon { color: #197956; }
.field input, .money { width: 100%; min-width: 0; height: 43px; border: 1px solid #dcd9e4; border-radius: 9px; padding: 0 12px; background: white; color: #302b3b; font-size: 1rem; font-weight: 400; }
.field input:focus, .money:focus-within { outline: 2px solid #9e88c9; outline-offset: 1px; }
.money { display: flex; align-items: center; gap: 10px; }
.money span { font-size: .92rem; font-weight: 600; color: #5a5367; border-right: 1px solid var(--border); padding-right: 10px; }
.money input { height: 100%; border: 0; padding: 0; }
.money input:focus { outline: 0; }
.primary { justify-content: center; gap: 8px; width: 100%; min-height: 45px; margin-top: 3px; background: var(--purple); color: white; border: none; border-radius: 9px; font-weight: 620; }
.primary:hover { background: #47347d; }
button:disabled { opacity: .55; cursor: wait; }
#records { list-style: none; padding: 0; margin: 0; }
.row { gap: 11px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border: 0; }
.row-info { min-width: 0; flex: 1; }
.row-info strong, .row-info small { display: block; overflow-wrap: anywhere; }
.row-info strong, .row-amount { font-size: .93rem; }
.row-info small { color: var(--muted); margin-top: 3px; }
.row-amount { font-weight: 650; max-width: 44%; overflow-wrap: anywhere; text-align: right; }
.positive { color: #16734f; }
.negative { color: #a34e35; }
.remove { display: grid; place-items: center; background: transparent; border: none; color: #746d80; width: 36px; min-height: 42px; }
.remove .icon { width: 16px; }
.remove:hover { background: #fff0ec; border-radius: 8px; color: #a34e35; }
footer { justify-content: center; color: var(--muted); gap: 7px; font-size: .81rem; padding: 23px 0 30px; }
dialog { width: min(390px, calc(100% - 32px)); border: 1px solid var(--border); border-radius: 16px; padding: 24px; color: inherit; }
dialog::backdrop { background: #21182d75; }
dialog h2 { margin: 14px 0 8px; }
dialog p { color: var(--muted); overflow-wrap: anywhere; }
.dialog-actions { gap: 8px; justify-content: end; margin-top: 22px; }
.dialog-actions button { border: 1px solid var(--border); border-radius: 8px; min-height: 42px; padding: 8px 14px; background: white; }
.dialog-actions .danger { background: #993c30; color: white; border-color: transparent; }
#toast, #error { position: fixed; z-index: 2; bottom: 16px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; padding: 10px 16px; border-radius: 10px; background: #30283e; color: white; font-size: .9rem; }
#error { background: #83362e; }
[hidden], #toast:empty { display: none; }
@media (max-width: 840px) {
  .wrap { width: calc(100% - 36px); }
  .panels { grid-template-columns: 1.1fr 1fr; gap: 14px; }
  .panel, .stat { padding: 17px; }
}
@media (max-width: 700px) {
  .topbar { height: 60px; }
  .intro { margin: 24px 0 18px; display: grid; gap: 10px; }
  .intro p { font-size: .93rem; }
  .today { border: 0; padding: 0; background: transparent; color: var(--muted); }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .balance { grid-column: 1/-1; }
  .stat { padding: 14px; border-radius: 14px; }
  .stat-title { gap: 6px; font-size: .84rem; }
  .tile { width: 27px; height: 27px; border-radius: 8px; }
  .tile .icon { width: 17px; height: 17px; }
  .balance strong { font-size: 2rem; }
  .stat strong { margin-top: 8px; }
  .panels { grid-template-areas: "entry" "history"; grid-template-columns: minmax(0,1fr); margin-top: 16px; }
  .empty { min-height: 225px; }
  .local { font-size: .8rem; }
  .row { gap: 6px; }
  footer { align-items: start; }
}
@media (max-width: 360px) {
  .wrap { width: calc(100% - 24px); }
  .stat:not(.balance) .stat-title { align-items: start; flex-direction: column; }
}
