/* ---------- theme variables: light by default, dark when chosen or when the device is dark ---------- */
:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #1d2433; --muted: #6b7486; --line: #e3e7ef;
  --brand: #1e3c6e; --brand-text: #ffffff; --accent: #2f6fdb;
  --expense: #c93a3a; --income: #1e9650; --saving: #7a42d6; --out: #d8821f;
  --ok-bg: #e3f6ea; --ok-text: #14602f; --err-bg: #fde8e8; --err-text: #8d1f1f;
  --radius: 12px; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #11151c; --card: #1a202b; --text: #e8ecf3; --muted: #93a0b5; --line: #2a3242;
  --brand: #7aa2f0; --brand-text: #11151c; --accent: #7aa2f0;
  --expense: #ef6b6b; --income: #4cc380; --saving: #b794f6; --out: #f0a24a;
  --ok-bg: #16372a; --ok-text: #a8e8c3; --err-bg: #402124; --err-text: #f4b4b4; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --card: #1a202b; --text: #e8ecf3; --muted: #93a0b5; --line: #2a3242;
    --brand: #7aa2f0; --brand-text: #11151c; --accent: #7aa2f0;
    --expense: #ef6b6b; --income: #4cc380; --saving: #b794f6; --out: #f0a24a;
    --ok-bg: #16372a; --ok-text: #a8e8c3; --err-bg: #402124; --err-text: #f4b4b4; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 1.2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .7rem; }
h1.expense, h2.expense { color: var(--expense); }
h1.income, h2.income { color: var(--income); }
h1.saving, h2.saving { color: var(--saving); }
h2.ch { margin: 0 0 .5rem; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .9em; }
.pad { padding: 1rem; }
.expense { --c: var(--expense); }
.income { --c: var(--income); }
.saving { --c: var(--saving); }
td.expense, .num.expense { color: var(--expense); }
td.income, .num.income { color: var(--income); }
td.saving, .num.saving { color: var(--saving); }
.bad { color: var(--expense); } .good { color: var(--income); } .sv { color: var(--saving); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px;
       background: var(--bg); color: var(--muted); border: 1px solid var(--line); margin-right: .3rem; }
.tag.in { color: var(--income); border-color: var(--income); }      /* paid in */
.tag.out { color: var(--expense); border-color: var(--expense); }   /* taken out */
.tag.move { color: var(--out); border-color: var(--out); }          /* moved between savings */

/* ---------- top bar + responsive menu ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem; padding: .6rem 1.2rem;
          background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--brand); }
.brand:hover { text-decoration: none; }
.brand .duck { font-size: 1.3rem; }
.bar-right { order: 3; margin-left: auto; display: flex; gap: .4rem; }
.topbar nav { order: 2; display: flex; flex-wrap: wrap; gap: .2rem .3rem; }
.topbar nav a { padding: .4rem .8rem; border-radius: 8px; color: var(--text); }
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.on { background: var(--brand); color: var(--brand-text); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
            color: var(--text); font-size: 1.25rem; line-height: 1; cursor: pointer; display: inline-flex;
            align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg); }
.menu-toggle { display: none; }
.menu-toggle .bars, .menu-toggle .bars::before, .menu-toggle .bars::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: ""; }
.menu-toggle .bars::before { position: absolute; top: -6px; }
.menu-toggle .bars::after { position: absolute; top: 6px; }

@media (max-width: 720px) {
  .topbar { padding: .5rem .9rem; }
  .menu-toggle { display: inline-flex; }
  .topbar nav { display: none; order: 4; width: 100%; flex-direction: column; gap: .2rem; padding-top: .4rem;
                border-top: 1px solid var(--line); }
  .topbar nav.open { display: flex; }
  .topbar nav a { padding: .75rem .8rem; font-size: 1.05rem; }
}

/* ---------- layout ---------- */
.container { max-width: 1050px; margin: 0 auto; padding: 0 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1rem; margin-bottom: 1rem; }
.tablewrap { padding: 0; overflow-x: auto; }

.flash { padding: .75rem 1rem; border-radius: 10px; margin: 1rem 0 0; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1rem 0; }
.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; overflow-wrap: anywhere; }
.stat.expense .value { color: var(--expense); }
.stat.income .value { color: var(--income); }
.stat.saving .value { color: var(--saving); }
.stat .sub { font-size: .8rem; margin-top: .2rem; }
.stat.diff { border-left: 6px solid var(--muted); }
.stat.diff.good { border-left-color: var(--income); }
.stat.diff.bad { border-left-color: var(--expense); }
.stat.diff .value { font-size: 2rem; }
.stat.diff.good .value { color: var(--income); }
.stat.diff.bad .value { color: var(--expense); }
.stat.diff .sub { color: var(--muted); font-size: .9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tfoot td { font-weight: 700; border-bottom: 0; }
td:first-child { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
         color: #fff; background: var(--c); }
:root[data-theme="dark"] .badge { color: #11151c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge { color: #11151c; } }
.barcol { width: 32%; min-width: 120px; }
.bar { height: 14px; border-radius: 7px; background: var(--c); min-width: 3px; }

/* ---------- forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: flex-end; }
.filters label, .form label, .quick label, .quick .field, .form .field { display: flex; flex-direction: column; gap: .25rem;
  font-size: .85rem; color: var(--muted); }
.custom-dates { display: flex; gap: 1rem; flex-wrap: wrap; }
.custom-dates[hidden] { display: none; }
input[type=text], input[type=date], input[type=search], select {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form { max-width: 560px; display: grid; gap: 1rem; }
.form input, .form select { width: 100%; font-size: 1.05rem; }
.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.money-input span { padding-left: .8rem; color: var(--muted); font-size: 1.05rem; }
.money-input input { border: 0; background: transparent; width: 100%; font-size: 1.05rem; }
.money-input input:focus { outline: none; }
.money-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn { display: inline-block; font: inherit; padding: .55rem 1rem; border-radius: 8px; cursor: pointer;
       background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--c, var(--brand)); border-color: transparent; color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn.primary { color: #11151c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #11151c; } }
.btn.danger { color: var(--expense); border-color: var(--expense); }
.btn.small { padding: .3rem .7rem; font-size: .9rem; }
.actions { display: flex; gap: .7rem; }
.toolbar { margin: 0 0 1rem; }
.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--accent); }
.link.danger { color: var(--expense); }
form.inline { display: inline; margin-left: .6rem; }
.inline-delete { margin: -.2rem 0 1.2rem; }

/* segmented switches (type, savings action, category tabs) */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
       background: var(--bg); min-height: 44px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; align-items: center; justify-content: center; text-align: center; margin: 0; padding: .35rem .4rem;
             cursor: pointer; font-size: .95rem; font-weight: 600; color: var(--muted); user-select: none; }
.seg input:checked + label { background: var(--c); color: #fff; }
:root[data-theme="dark"] .seg input:checked + label { color: #11151c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg input:checked + label { color: #11151c; } }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabs { margin-bottom: 1rem; max-width: 520px; }
.cat-section[hidden] { display: none; }

/* ---------- home: quick add ---------- */
.quick h1 { margin: 0 0 1rem; font-size: 1.4rem; }
.quick form { display: grid; gap: 1rem; }
.qa-row { display: grid; gap: 1rem; }
.qa-row.three { grid-template-columns: 1fr 1fr 1.5fr; }
.qa-row.two { grid-template-columns: 1fr 1fr; }
.qa-row[hidden], #qa-action-row[hidden], .qa-hint[hidden], .qa-tip[hidden] { display: none; }
.quick input[type=date], .quick select, .quick input[type=text] { width: 100%; font-size: 1.05rem; }
.quick .lbl { font-size: .85rem; color: var(--muted); }
.qa-tip { margin: -.4rem 0 0; }
.qa-hint { margin: -.3rem 0 0; padding: .5rem .8rem; border-radius: 8px; background: var(--bg); border-left: 4px solid var(--saving);
           font-size: .9rem; }
.quick label.check { flex-direction: row; align-items: center; gap: .6rem; font-size: 1rem; color: var(--text); cursor: pointer; }
.quick label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
#qa-desc-wrap[hidden] { display: none; }
.quick .save { justify-self: start; font-size: 1.05rem; padding: .7rem 1.6rem; }
#quick-add[data-type="expense"] .save { background: var(--expense); }
#quick-add[data-type="income"] .save { background: var(--income); }
#quick-add[data-type="saving"] .save { background: var(--saving); }
#quick-add[data-type="expense"] { border-top: 4px solid var(--expense); }
#quick-add[data-type="income"] { border-top: 4px solid var(--income); }
#quick-add[data-type="saving"] { border-top: 4px solid var(--saving); }

/* ---------- home: calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.cal-title { display: flex; flex-direction: column; align-items: center; text-align: center; font-size: 1.1rem; }
.cal-nav-right { display: flex; gap: .4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: .2rem 0; }
.day { min-height: 88px; border-radius: 8px; padding: .3rem .35rem; display: flex; flex-direction: column; gap: 1px;
       background: var(--bg); border: 1px solid transparent; color: var(--text); overflow: hidden; }
a.day:hover { text-decoration: none; border-color: var(--accent); }
.day.out { background: transparent; }
.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day .n { font-size: .8rem; font-weight: 600; color: var(--muted); }
.day.today .n { color: var(--accent); }
.day .e, .day .i, .day .s { font-size: .78rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day .e { color: var(--expense); } .day .i { color: var(--income); } .day .s { color: var(--saving); }
.cal-hint { margin: .8rem 0 0; }

/* ---------- reports / charts ---------- */
.legend { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); margin: 0 .3rem 0 .6rem; }
.legend .sw:first-child { margin-left: 0; }
.chart { overflow-x: auto; }
.chart svg text { fill: var(--muted); font-size: 11px; }
.chart svg .grid { stroke: var(--line); stroke-width: 1; }
.chart svg .zero { stroke: var(--muted); stroke-width: 1.5; }
.chart svg rect:hover { opacity: .8; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.two-col > .card, .three-col > .card { margin-bottom: 0; }
.two-col, .three-col { margin-bottom: 1rem; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.rank-top { display: flex; justify-content: space-between; gap: .6rem; margin-bottom: .25rem; }
.rank-name { font-weight: 600; }
.rank-val { font-variant-numeric: tabular-nums; text-align: right; }
.rank-val.expense { color: var(--expense); } .rank-val.income { color: var(--income); } .rank-val.saving { color: var(--saving); }
.balance-total { margin: 1rem 0 0; }
.pie-result { margin: .6rem 0 0; font-size: 1.1rem; }

.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut { width: 180px; height: 180px; flex: none; }
.donut text { fill: var(--text); }
.donut .donut-total-l { fill: var(--muted); font-size: 10px; }
.donut .donut-total { font-size: 15px; font-weight: 700; }
.donut-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; flex: 1; min-width: 160px; }
.donut-legend li { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.donut-legend .sw { margin: 0; flex: none; }
.dl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-val { font-variant-numeric: tabular-nums; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .8rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px; cursor: pointer;
        border: 1px solid var(--line); background: var(--bg); font-size: .9rem; color: var(--text); }
.chip.expense { border-left: 4px solid var(--expense); }
.chip.income { border-left: 4px solid var(--income); }
.chip.saving { border-left: 4px solid var(--saving); }
.chip input { accent-color: var(--accent); }
form + .chart { margin-top: 1rem; }

/* ---------- categories ---------- */
.addrow, .row { display: flex; gap: .5rem; }
.addrow input, .row input { flex: 1; min-width: 0; }
.cat, .cat form { min-width: 0; }
.cat summary { cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.cat[open] summary { margin-bottom: .8rem; }
.subs { list-style: none; padding: 0; margin: .8rem 0; display: grid; gap: .4rem; }
.subs li { display: flex; align-items: center; gap: .5rem; }
.subs li .row { flex: 1; }
.cat .row { margin-bottom: .5rem; }

/* ---------- tablets and phones ---------- */
@media (max-width: 900px) {
  .cards.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .qa-row.three { grid-template-columns: 1fr 1fr; }
  .qa-row.three .field { grid-column: 1 / -1; }
  .qa-row.two { grid-template-columns: 1fr; }
  .quick .save { justify-self: stretch; }
  .seg label { font-size: .85rem; }
  th, td { padding: .5rem; }
  .day { min-height: 66px; padding: .2rem; }
  .day .e, .day .i, .day .s { font-size: .58rem; }
  .day .n { font-size: .7rem; }
  .cal-grid { gap: 2px; }
  .cal-title { font-size: 1rem; }
  .stat .value { font-size: 1.3rem; }
  .stat.diff .value { font-size: 1.7rem; }
}

.quick { margin-top: 1rem; }

/* ---------- savings actions: add = green, take out = red, move = orange ---------- */
.seg .act-in { --c: var(--income); color: var(--income); }
.seg .act-out { --c: var(--expense); color: var(--expense); }
.seg .act-move { --c: var(--out); color: var(--out); }
#quick-add[data-action="deposit"] .qa-hint { border-left-color: var(--income); }
#quick-add[data-action="withdraw"] .qa-hint { border-left-color: var(--expense); }
#quick-add[data-action="transfer"] .qa-hint { border-left-color: var(--out); }

/* ---------- logo, account menu, sign-in ---------- */
:root { --logo-green: #1c9552; --logo-purple: #6d3d8d; }
:root[data-theme="dark"] { --logo-green: #3fbf7f; --logo-purple: #a77bd1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo-green: #3fbf7f; --logo-purple: #a77bd1; } }
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.logo-mark { display: block; width: 45px; height: 36px; }
.logo-word { display: block; width: 132px; height: 22px; }
@media (max-width: 380px) { .logo-word { width: 110px; height: 18px; } .logo-mark { width: 38px; height: 31px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; height: 40px;
                    padding: 0 .6rem 0 .3rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--bg); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--income); color: #fff; font-weight: 700;
          display: inline-flex; align-items: center; justify-content: center; }
:root[data-theme="dark"] .avatar { color: #11151c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: #11151c; } }
.uname { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 20; background: var(--card);
            border: 1px solid var(--line); border-radius: 12px; padding: .4rem; box-shadow: 0 8px 24px rgba(0,0,0,.18);
            display: grid; gap: 2px; }
.menu-pop .who { display: grid; padding: .5rem .7rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .2rem; overflow-wrap: anywhere; }
.menu-pop a, .menu-pop .link-btn { display: block; width: 100%; text-align: left; padding: .55rem .7rem; border-radius: 8px;
                                   color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-pop a:hover, .menu-pop .link-btn:hover { background: var(--bg); text-decoration: none; }
.menu-pop form { margin: 0; }
.topbar nav a.admin-link { border: 1px dashed var(--line); }
.topbar nav a.admin-link.on { border-style: solid; border-color: transparent; }
.narrow { max-width: 560px; }
.small { font-size: .85rem; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 .35rem; font-size: .9em; }
.login { max-width: 420px; margin: 2rem auto; text-align: center; }
.login .form { text-align: left; margin: 1.6rem auto .4rem; }
.login-mark { display: block; width: 150px; height: 121px; margin: .6rem auto 0; }
.login-word { display: block; width: 240px; height: 40px; margin: .9rem auto 0; }
.form input[type=password] { font: inherit; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
@media (max-width: 720px) { .uname { display: none; } .usermenu summary { padding: 0 .3rem; } .menu-pop { right: -48px; } }

/* amount typed as a negative (money taken out of savings) */
.money-input.neg input, .money-input.neg span { color: var(--expense); }
.money-input.neg input::placeholder { color: var(--expense); opacity: .5; }


/* ---------- phone: collapsible add-entry form ---------- */
.qa-toggle { display: flex; align-items: center; gap: .6rem; width: 100%; background: none; border: 0; padding: 0; font: inherit;
  font-size: 1.2rem; font-weight: 700; color: inherit; cursor: pointer; text-align: left; }
.qa-toggle[hidden] { display: none; }
.qa-toggle .plus { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.4rem; line-height: 1; }
.quick.collapsible .qa-title { display: none; }
.quick.collapsible.open .qa-body { margin-top: .8rem; }
.quick.collapsible:not(.open) .qa-body { display: none; }

/* ---------- calendar zoom: week and year ---------- */
.cal-zoom { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: .8rem; }
.zbtn { min-width: 2.2rem; text-align: center; font-weight: 700; }
.zbtn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.cal-seg { min-width: 14rem; }
.cal-seg a { display: flex; align-items: center; justify-content: center; padding: .35rem .5rem; text-decoration: none; color: inherit; }
.cal-seg a.on { background: var(--accent); color: #fff; }
.week-list { display: grid; gap: .6rem; }
.wday { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.wday.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.wd-head { display: flex; justify-content: space-between; gap: .6rem; text-decoration: none; color: inherit; flex-wrap: wrap; }
.wd-tot { display: flex; gap: .6rem; font-variant-numeric: tabular-nums; }
.wd-item { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--line); margin-top: .3rem; }
.wd-item .wd-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.wd-empty { margin: .3rem 0 0; font-size: .85rem; }
.wd-ico { display: inline-flex; vertical-align: middle; }
.year-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.ymonth { display: flex; flex-direction: column; gap: .15rem; border: 1px solid var(--line); border-radius: 10px; padding: .6rem;
  text-decoration: none; color: inherit; font-size: .85rem; font-variant-numeric: tabular-nums; }
.ymonth.today { border-color: var(--accent); }
.ymonth .e { color: var(--expense); } .ymonth .i { color: var(--income); } .ymonth .s { color: var(--saving); }
@media (max-width: 700px) { .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cal-seg { min-width: 0; flex: 1; } }

/* ---------- category icons ---------- */
.ico { width: 1.25em; height: 1.25em; vertical-align: -.28em; flex: none; fill: currentColor; }
.ico.t-expense { color: var(--expense); } .ico.t-income { color: var(--income); } .ico.t-saving { color: var(--saving); }
.cu { display: inline-flex; width: 1.25em; height: 1.25em; vertical-align: -.28em; flex: none; }
.cu svg, .cu img { width: 100%; height: 100%; }

.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 96px; height: 96px; font-size: 2.4rem; flex: none; }
.photo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.photo-form { flex: 1; min-width: 220px; }

/* ---------- icon picker ---------- */
.ipwrap { display: inline-flex; flex: none; }
.icon-pick { width: 2.6rem; min-height: 2.6rem; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.icon-pick:hover { border-color: var(--accent); }
.ipv { display: inline-flex; }
.cat > summary .ico, .cat > summary .cu { margin-right: .3rem; }
.icon-dialog { width: min(36rem, 94vw); max-height: 88vh; padding: 1rem; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--text, inherit); }
.icon-dialog::backdrop { background: rgba(0,0,0,.5); }
.icd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.icd-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: .6rem; }
.icd-tabs button { padding: .4rem; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.icd-tabs button.on { background: var(--accent); color: #fff; }
.icd-colors { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; align-items: center; }
.swc { width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swc.none { background: var(--card); border-color: var(--line); font-size: .75rem; color: var(--muted); }
.swc.sel { border-color: var(--text, #000); outline: 2px solid var(--accent); outline-offset: 1px; }
.swc-pick { width: 1.9rem; height: 1.9rem; padding: 0; border: 0; background: none; cursor: pointer; }
.icd-panel { max-height: 40vh; overflow-y: auto; }
.icd-panel input[type="search"] { width: 100%; margin-bottom: .5rem; }
.icg h4 { margin: .6rem 0 .3rem; font-size: .8rem; color: var(--muted); text-transform: uppercase; }
.icg-box, #icd-custom { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: .3rem; }
.ic { height: 2.6rem; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text, inherit); cursor: pointer; font-size: 1.2rem; padding: 0; }
.ic.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ic[hidden], .icg[hidden] { display: none; }
.cwrap { position: relative; }
.cwrap .ic { width: 100%; }
.cdel { position: absolute; top: -6px; right: -6px; width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 0; background: var(--expense);
  color: #fff; font-size: .9rem; line-height: 1; cursor: pointer; padding: 0; }
.icd-foot { margin-top: .6rem; }
.icd-panel[hidden] { display: none; }

/* ---------- your data ---------- */
.data-card { margin-bottom: 1rem; }
.data-card h3 { margin-top: 0; }
.data-card h4 { margin: 1rem 0 .4rem; }
.notice { padding: .7rem .9rem; border-radius: 10px; margin: .5rem 0; }
.notice.warn { background: var(--err-bg); color: var(--err-text); }
.notice.error { background: var(--err-bg); color: var(--err-text); }
.reveal { margin: .6rem 0; }
.reveal > summary { display: inline-block; cursor: pointer; list-style: none; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal .form { margin-top: .6rem; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: .6rem; max-width: 26rem; }
.danger-zone { border-color: var(--expense); }
