/* ======================================================================
   Perisso v12: calm layout, green and gold.
   Loaded after app.css and overrides it. Light ("ivory" id): a soft green-white with deep emerald and gold.
   Dark ("luxe" id): deep emerald with gold. Text colours were picked for WCAG AA contrast on their backgrounds.
   ====================================================================== */
:root, :root[data-theme="ivory"] {
  --bg: #F2F7F5; --panel: #FFFFFF; --panel2: #E9F1EE; --text: #0B241F; --muted: #4F6A63; --faint: #8DA19B; --line: #DCE7E3;
  --accent: #19443C; --accent-ink: #FFFFFF; --accent-soft: #E1EDE9; --emerald: #19443C; --emerald-deep: #0B241F; --sel: #19443C; --sel-ink: #FFFFFF;
  --gold: #A77E01; --gold-text: #876600; --gold-soft: #E9D9A6; --gold-deep: #A77E01; --gold-hi: #C9A33A;
  --neg: #A3333D; --neg-soft: #F8E6E7; --pos: #1C7550; --hi: #1C7550; --lo: #A3333D; --today: #A77E01;
  --tint: #E6F0EC; --tint2: #D7E7E1; --strip: #E6F0EC;
  --shadow: 0 1px 2px rgba(11,36,31,.05), 0 6px 22px rgba(11,36,31,.06);
  --r: 16px; --serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  color-scheme: light;
}
:root[data-theme="luxe"] {
  --bg: #0A1D19; --panel: #102823; --panel2: #16332D; --text: #EDF4F1; --muted: #A3BAB3; --faint: #6F8C84; --line: #234139;
  --accent: #D4B25C; --accent-ink: #0B241F; --accent-soft: #1D3A2F; --emerald: #2E6B5C; --emerald-deep: #0B241F; --sel: #2F7564; --sel-ink: #FFFFFF;
  --gold: #D4B25C; --gold-text: #D9BA68; --gold-soft: #5A4B22; --gold-deep: #B8963E; --gold-hi: #E8CF8A;
  --neg: #F1A1A6; --neg-soft: #3A2226; --pos: #82D2AA; --hi: #82D2AA; --lo: #F1A1A6; --today: #D4B25C;
  --tint: #143029; --tint2: #1B3B33; --strip: #143029;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}
body { -webkit-font-smoothing: antialiased; }

/* ---------- header (all sizes): fewer boxes, quieter icons ---------- */
.topbar { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); }
.topbar::after { display: none !important; }
.brand { color: var(--emerald); }
:root[data-theme="luxe"] .brand { color: var(--gold); }
.iconbtn { border-color: transparent; background: transparent; color: var(--muted); }
.iconbtn:not(:disabled):hover { color: var(--text); }
.hdrline, #dailyLine { display: none !important; }      /* the line of the day now sits at the top of the Menu */
.hdrcal { display: none; }
.btn { border-radius: 12px; background: var(--panel); }
.btn.primary { background: var(--emerald); border-color: var(--emerald); color: #fff; }
:root[data-theme="luxe"] .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--emerald-deep); }
.calbtn { background: transparent; border-color: transparent; color: var(--muted); }
.calbtn.active, .calbtn:hover { color: var(--text); border-color: var(--line); }
.menubtn { background: transparent; border-color: transparent; }
.badge { background: var(--neg); color: #fff; }

/* Menu: the line of the day at the top, quiet items */
.navpanel { border-radius: 18px; border-color: var(--line); box-shadow: var(--shadow); }
.menuquote { margin: 4px 8px 6px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--emerald); display: flex; gap: 6px; align-items: flex-start; }
:root[data-theme="luxe"] .menuquote { color: var(--gold-text); }
.menuquote .qtext { flex: 1; }
.navpanel button:disabled { opacity: .45; cursor: default; }

/* ---------- account tabs: plain text with a gold underline ---------- */
.tabs.acctabs { gap: 20px; padding: 4px 18px 0; border-bottom: 1px solid var(--line); }
.tabs.acctabs button { min-width: 0; flex-direction: column; align-items: flex-start; gap: 0; background: transparent; border: 0; border-radius: 0; padding: 8px 0 9px; box-shadow: none; position: relative; color: var(--muted); }
.tabs.acctabs button .n { font-size: 14px; color: inherit; letter-spacing: 0; }
.tabs.acctabs button .sw { display: none; }
.tabs.acctabs button .b { font-size: 12px; font-weight: 500; color: var(--faint); margin-top: 1px; }
.tabs.acctabs button.active { color: var(--text); background: transparent; box-shadow: none; }
.tabs.acctabs button.active .n { font-weight: 650; color: var(--text); }
.tabs.acctabs button.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--gold); }
.tabs.acctabs button:hover:not(.active) { background: transparent; color: var(--text); }
.tabs.acctabs .reorderbtn { border: 0; background: transparent; color: var(--faint); align-self: center; margin-left: -8px; }
.envtabs button { border-radius: 999px; }

/* ---------- the summary strip ---------- */
.v12strip { display: flex; align-items: center; gap: 12px; width: 100%; margin: 10px 0 6px; padding: 10px 14px; border: 0; border-radius: 14px; background: var(--strip); color: var(--text); text-align: left; cursor: pointer; position: relative; font: inherit; }
.v12strip:hover { background: var(--tint2); }
.v12strip > span { display: flex; flex-direction: column; min-width: 0; }
.v12strip .v12k { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.v12strip .v12v { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.v12strip .v12sts b { font-size: 19px; font-weight: 650; color: var(--emerald); letter-spacing: -.01em; }
:root[data-theme="luxe"] .v12strip .v12sts b { color: var(--gold-text); }
.v12strip .v12sts b.neg, :root[data-theme="luxe"] .v12strip .v12sts b.neg { color: var(--neg); }
.v12strip .v12u { font-size: 12px; color: var(--muted); }
.v12strip .v12sep { align-self: stretch; width: 1px; flex: none; background: var(--line); margin: 2px 2px; }
.v12strip .v12bal b { font-size: 15px; font-weight: 550; }
.v12strip .v12chev { margin-left: auto; color: var(--muted); flex: none; }
.v12strip .v12flag { position: absolute; top: 9px; right: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--neg); }
.safeline, .typehint { display: none !important; }
.modal .typehint { display: block !important; }
.ovsts { margin: 4px 0 12px; }
.ovk { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.ovbig { font-size: 32px; font-weight: 650; color: var(--emerald); letter-spacing: -.01em; margin: 2px 0 6px; }
:root[data-theme="luxe"] .ovbig { color: var(--gold-text); }
.ovbig.neg { color: var(--neg) !important; }
.ovh { margin: 14px 0 6px; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 21px; color: var(--text); }
.ovacc .sw { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
#ovStsAcc { border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 4px; }

/* ---------- calendar (all sizes): no grid lines, calm cells ---------- */
.calnav h2 { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 28px; color: var(--emerald); line-height: 1; }
:root[data-theme="luxe"] .calnav h2 { color: var(--gold-text); }
.calnav .btn { background: transparent; }
.calnav .btn[data-nav] { border-color: transparent; color: var(--muted); }
.calnav .btn[data-today] { border-color: transparent; color: var(--gold-text); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; font-size: 12.5px; }
.grid, body.calfit .grid { background: transparent; gap: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
.grid .dow { background: transparent; color: var(--faint); font-size: 10.5px; letter-spacing: .1em; text-align: center; border-bottom: 1px solid var(--line); }
.day, body.calfit .day { background: transparent; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.day:hover { background: var(--tint); }
.day.other { background: transparent; opacity: 1; }
.day.other .dn span { color: var(--faint); opacity: .7; }
.day.today .dn span { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--gold); border-radius: 999px; }
.day.sel .dn span, .day.sel.today .dn span { background: var(--sel); color: var(--sel-ink); box-shadow: none; border-radius: 999px; }
.day.sel, .day.sel.hiday, .day.sel.loday, .day.hiday, .day.loday, .day.negday.loday { box-shadow: none !important; background: transparent; }
.day.negday { background: transparent; }
.day .bal { color: var(--muted); font-weight: 450; }
.day.negday .bal { color: var(--neg); }
.day.loday .bal { color: var(--neg); font-weight: 650; }
.day.payday .bal { color: var(--pos); font-weight: 650; }
.cellmark { display: none !important; }
.edot { display: none; }

/* ---------- day panel ---------- */
.dp .dphd { display: flex; align-items: baseline; gap: 10px; }
.dp .dphd h3.dptitle { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 22px; line-height: 1.1; color: var(--text); margin: 0; }
.dp .dpbal { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dp .dpbal b { color: var(--text); font-weight: 650; margin-left: 3px; }
.dp .row { border-bottom: 1px solid var(--line); }
.dp .row .num.neg { color: var(--text); }
.dp .row .num.pos { color: var(--pos); }
.dp .row .pill { background: transparent; border: 0; color: var(--faint); padding: 0 2px; }
.dp .row .bin { opacity: 0; transition: opacity .12s; filter: grayscale(1); }
.dp .row:hover .bin, .dp .row .bin:focus-visible { opacity: .75; }
.dp .row input[data-done] { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; margin: 0; flex: none; cursor: pointer; }
.dp .row input[data-done]:checked { background: var(--emerald); border-color: var(--emerald); box-shadow: inset 0 0 0 3px var(--panel); }
.dp .v11pbtns .btn { background: transparent; }
.v12hint { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 6px; padding: 8px 10px; border-radius: 12px; background: var(--tint); color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.v12hint span { flex: 1; }
.v12hint .x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; }
.dpagain { display: none; }
@media (hover: hover) and (pointer: fine) { .v12hint { display: none; } }

/* swipe feedback */
.dp .row { position: relative; touch-action: pan-y; }
.dp .row.swiping > * { transform: translateX(var(--dx, 0)); transition: none; }
.dp .row.swiping.swl { background: var(--neg-soft); }
.dp .row.swiping.swr { background: color-mix(in srgb, var(--pos) 14%, var(--panel)); }
.dp .row.swiping::after { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12.5px; font-weight: 650; letter-spacing: .04em; }
.dp .row.swiping.swl::after { content: 'Delete'; right: 12px; color: var(--neg); }
.dp .row.swiping.swr::after { content: 'Done'; left: 12px; color: var(--pos); }

/* ---------- the + (desktop quick categories button) and toast ---------- */
.fab { background: var(--emerald); color: var(--gold-hi); border: 1.5px solid var(--gold-soft); box-shadow: 0 6px 18px rgba(11,36,31,.25); }
.toast { background: var(--emerald-deep); color: #fff; border-radius: 14px; }
:root[data-theme="luxe"] .toast { background: #EDF4F1; color: var(--emerald-deep); }
.toast .toastbtn { color: var(--gold-hi); }
:root[data-theme="luxe"] .toast .toastbtn { color: var(--gold-deep); }

/* login: emerald glow instead of brown */
.login { background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--emerald) 22%, var(--bg)) 0%, var(--bg) 62%); }
.loginname { color: var(--emerald); }
:root[data-theme="luxe"] .loginname { color: var(--gold); }

/* ======================================================================
   Phones and the installed app (up to 700px)
   ====================================================================== */
@media (max-width: 700px) {
  /* header: menu, month, arrows, TODAY */
  .topbar { min-height: 54px; padding: calc(8px + env(safe-area-inset-top)) 14px 4px 10px; gap: 4px; border-bottom: 0; background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  #undoBtn, #redoBtn, #helpBtn, #searchBtn, #themeBtn, #calBtn, #invBtn, #pageHelpBtn, #pageSearchBtn, .v11qtop { display: none !important; }
  body[data-view="investments"] #calBtn { display: none !important; }
  .menubtn { width: 38px; height: 38px; border-radius: 12px; color: var(--text); }
  .navwrap { order: -1; }
  .menubtn .badge { position: absolute; top: 2px; right: 0; min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
  .menubtn { position: relative; }
  body[data-view="calendar"] .brand:not(.v12keep) { display: none; }
  body[data-view="calendar"] .hdrcal:not([hidden]) { display: flex; }
  .brand { position: static; transform: none; margin-left: 4px; gap: 8px; }
  .brand img { width: 28px; height: 28px; box-shadow: none; }
  .brand > span { display: inline !important; font-size: 24px; }
  .hdrcal { flex: 1; min-width: 0; align-items: center; gap: 2px; }
  .hcmonth { flex: 1 1 auto; min-width: 0; text-align: left; border: 0; background: transparent; padding: 0 0 2px 4px; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 29px; line-height: 1.05; color: var(--emerald); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
  :root[data-theme="luxe"] .hcmonth { color: var(--gold-text); }
  .hcmonth .mshort { display: none; }
  .hcnav { display: flex; flex: none; }
  .hcbtn { width: 32px; height: 36px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
  .hctoday { flex: none; border: 0; background: transparent; color: var(--gold-text); font-size: 12.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; padding: 8px 0 8px 8px; }
  .navpanel { top: calc(56px + env(safe-area-inset-top)); left: 10px; right: auto; width: min(300px, calc(100vw - 20px)); max-height: calc(100vh - 150px); overflow-y: auto; }
  body.navfrommore .navpanel { top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); left: auto; right: 10px; position: fixed; }

  /* account tabs */
  .tabs.acctabs { gap: 20px; padding: 2px 16px 0; }
  .tabs.acctabs button { padding: 7px 0 9px; }
  .tabs.acctabs button .n { font-size: 14px; }
  .tabs.acctabs button .b, .tabs.acctabs .reorderbtn { display: none; }
  .envtabs { padding-top: 8px; }

  /* the month bar moves into the header on phones */
  #view-calendar .calnav { display: none !important; }
  .v12strip { margin: 10px 0 4px; }
  main { padding: 0 10px calc(84px + env(safe-area-inset-bottom)); }
  html.phonecal main { padding-bottom: 0; }

  /* calendar cells: date, a small dot, a muted balance */
  .grid .dow { padding: 6px 0 3px; border-bottom: 0; }
  .day, body.calfit .day { height: var(--rowh, 52px); padding: 4px 0 0; align-items: center; gap: 0; border-bottom: 0; overflow: visible; }
  .day:hover { background: transparent; }
  .day .dn, body.calfit .day .dn { padding: 0; justify-content: center; font-size: 15px; line-height: 1; font-weight: 500; width: 100%; }
  .day .dn span, .day.today .dn span { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; }
  .day.sel .dn span { font-weight: 650; }
  .day .bm { position: absolute; top: 2px; right: 3px; font-size: 9px; color: var(--gold); }
  .day .it, .day .more, .day .dots { display: none !important; }
  .edot { display: block; position: absolute; left: 50%; top: calc(4px + 28px + 1px); width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
  .day.payday .edot { background: var(--pos); }
  .day .bal, body.calfit .day .bal { position: static; margin-top: 7px; font-size: 10.5px; line-height: 1; letter-spacing: .01em; text-align: center; width: 100%; }
  .grid.tight .day .dn span { width: 25px; height: 25px; }
  .grid.tight .edot { top: calc(4px + 25px + 1px); }
  .grid.tight .day .bal { margin-top: 6px; }

  /* the day sheet below the calendar */
  html.phonecal .side#dayPanel { margin: 8px -10px 0; border: 0; border-radius: 22px 22px 0 0; background: var(--panel); box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(11,36,31,.05); }
  html.phonecal .dp .dphd { margin: 0 -14px 2px; padding: 14px 18px 8px; border-bottom: 0; background: var(--panel); }
  .dp .dphd h3.dptitle { font-size: 22px; }
  #dayPanel .card.dp { padding-left: 18px; padding-right: 18px; }
  .dp .row { padding: 10px 0; gap: 10px; }
  .dp .row input[data-done], .dp .row .bin { display: none !important; }
  .dp .row .ttl { font-size: 15px; font-weight: 500; }
  .dp .row .meta { font-size: 12.5px; color: var(--muted); }
  .dp .row .num { font-size: 15px; font-weight: 500; }
  .dp .row.picked { background: var(--tint); }
  .dp .row input[data-cpick], .dp .row input[data-pick] { accent-color: var(--emerald); }
  #dpSelect { display: none !important; }
  .dp .schedrow:has(.schedhd.none) { display: block; }
  .dp .schedhd.none { color: var(--muted); font-weight: 400; font-size: 14px; margin: 8px 0; }
  .dpagain { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; overflow-x: auto; scrollbar-width: none; }
  .dpagain::-webkit-scrollbar { display: none; }
  .dpagain .qalab { flex: none; font-size: 12px; color: var(--muted); }
  .dpagain .qachips { display: flex; gap: 8px; flex-wrap: nowrap; }
  .dpagain .chip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 13px; white-space: nowrap; }
  .dp .bmk { font-size: 13px; margin: 12px 0 8px; }

  /* bottom bar: Calendar, Envelopes, +, Investments, More */
  .bottomnav { display: flex !important; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 4px env(safe-area-inset-bottom); align-items: flex-start; justify-content: space-around;
    background: color-mix(in srgb, var(--panel) 94%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: none; }
  .bottomnav button { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--faint); font-size: 10.5px; padding: 4px 0 0; min-width: 0; position: relative; }
  .bottomnav button.active, #moreBtn.active, #moreBtn[aria-expanded="true"] { color: var(--emerald); font-weight: 650; }
  :root[data-theme="luxe"] .bottomnav button.active, :root[data-theme="luxe"] #moreBtn.active, :root[data-theme="luxe"] #moreBtn[aria-expanded="true"] { color: var(--gold-text); }
  .bottomnav button.bnadd { flex: 0 0 auto; width: 52px; height: 52px; margin: -20px 6px 0; border-radius: 50%; background: var(--emerald); color: var(--gold-hi); box-shadow: 0 6px 16px rgba(11,36,31,.28), inset 0 0 0 1.5px var(--gold-soft); justify-content: center; padding: 0; }
  .bottomnav button.bnadd svg { width: 26px; height: 26px; stroke-width: 2; }
  .bottomnav .dot { position: absolute; top: 2px; right: calc(50% - 15px); width: 7px; height: 7px; border-radius: 50%; background: var(--neg); }
  .morepanel { display: none !important; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .calsel { bottom: calc(72px + env(safe-area-inset-bottom)) !important; }
  body.loginopen .bottomnav { display: none !important; }
}

/* ======================================================================
   Wide screens: same palette, roomier, no bottom bar
   ====================================================================== */
@media (min-width: 701px) {
  .bottomnav, .morepanel { display: none !important; }
  .navpanel .v12mi { display: none; }   /* wide screens keep Search, Undo, ? and the theme as header icons */
  .day .bal, body.calfit .day .bal { font-size: 12px; }
  .day .dn span { display: inline-block; min-width: 24px; text-align: center; padding: 1px 6px; }
  .day.sel { background: var(--tint); }
  .day .it { border-radius: 6px; }
  .edot { display: none !important; }
  .dp { border: 0; box-shadow: var(--shadow); }
  .card { border-color: var(--line); }
  .v12strip { max-width: none; }
}

/* v12 fixes over older rules */
#dailyLine:not([hidden]), .hdrline:not([hidden]) { display: none !important; }
.card h3 { color: var(--gold-text); }
.dp .dphd h3.dptitle { text-transform: none; letter-spacing: 0; }
.dp .row .cdot { width: 7px; height: 7px; box-shadow: none; margin-right: 8px; vertical-align: 2px; }
@media (max-width: 700px) {
  .bottomnav button span.bl { font-size: 10.5px; line-height: 1.2; }
  .bottomnav button svg { width: 22px; height: 22px; }
}

.navpanel { padding-top: 6px; }
.menubtn.active { border-color: transparent; color: var(--text); }
#view-accounts .envhd h3 { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 21px; letter-spacing: 0; text-transform: none; color: var(--text); }
.dpagain .qalab { text-transform: none; letter-spacing: 0; font-weight: 500; }
@media (min-width: 701px) {
  .calnav h2, body.calfit .calnav h2 { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 30px; line-height: 1.1; color: var(--emerald); min-width: 230px; text-align: center; }
  :root[data-theme="luxe"] .calnav h2, :root[data-theme="luxe"] body.calfit .calnav h2 { color: var(--gold-text); }
  .calnav .caret { font-size: 12px; color: var(--faint); font-family: var(--font); font-style: normal; vertical-align: 4px; }
  .calnav .btn[data-nav] { font-size: 18px; }
}

.navpanel > * { flex-shrink: 0; }
