:root {
  --safe-top-raw: env(safe-area-inset-top);
  --safe-top: max(0px, calc(var(--safe-top-raw) - 14px)); /* reduced safe top */
  --safe-bottom: env(safe-area-inset-bottom);

  --bd: #e5e7eb;
  --ink: #0f172a;
  --ink-sub: #334155;
  --panel: #fff;
  --ring: rgba(59,130,246,.12);
}

/* === Unified Header (Categories, matching Contacts) ===================== */
/* Top App Bar */
.appbar {
  padding-top: var(--safe-top);

  background: #F3F4F6;
  border-bottom: 1px solid var(--bd);
  position: sticky;
  top: 0;
  z-index: 10;
}

.status {
  display: none;
}

/* Keep "primary" button visually neutral in header */



.page-title-sm {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Screens */
.screen {
  margin: 0 auto;
  max-width: 960px;
}

.screen.hidden {
  display: none;
}

/* Search */

/* List */
.list {
  list-style: none;
  margin: 2px 0 64px;
  padding: 0;
}

.li {
  align-items: center;
  border-bottom: 1px solid var(--bd);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  padding: 14px 8px 14px 16px;
}

.li:first-child {
  border-top: 1px solid var(--bd);
}

.avatar {
  background: #f8fafc;
  border-radius: 50%;
  color: #475569;
  display: grid;
  font-size: 12px;
  font-weight: 700;
  height: 28px;
  letter-spacing: .2px;
  place-items: center;
  width: 28px;
}

.name {
  font-size: 11px;
  font-weight: 450;
  color: var(--ink-sub);
}

/* Subbar + actions (mirror Contacts) */
.subbar {
  padding-top: var(--safe-top);

  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--bd);
  display: grid;
  gap: 6px;
  grid-template-columns: auto 1fr auto;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 9;
}

.title-lg {
  font-size: 15px;
  font-weight: 600;
}

.subtitle {
  color: var(--ink-sub);
  font-size: 15px;
}
/* Form chips */
.form {
  padding: 10px;
}


/* === Typography normalization (match Contacts) === */
body, .toolbar h1, .subbar .title-lg, .subbar .subtitle,
#search, .li .name, .chip, .chip-label, .chip-field,

/* === Type chips exactly like Contacts === */
:root {
  --blue: #2563eb;
}

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Pills (contacts-like) */
.pill {
  background: #ffffff;
  border: 0;
  border-radius: 14px;
  color: #334155;
  cursor: pointer;
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  padding: 8px 14px;
}

.pill:hover {
  background: #f3f4f6;
}

.pill.on {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* + Add Type pill (dashed) */
.pill.add {
  background: transparent;
  border: 2px dashed #cbd5e1;
  color: #475569;
  padding: 10px 16px;
}

.pill.add:hover {
  background: #eef2f7;
}


/* === Type chips grid & sizes (Contacts) === */
#typePicker {
  align-items: stretch;
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(4, minmax(0,1fr));
}


/* Tiny screens: micro type */
@media (max-width: 400px){
#categoryTxns .two-line .line1 {
  font-size: .76rem;
}

#categoryTxns .two-line .line2 {
  font-size: .68rem;
}
}

/* Tiny screens: micro type */
@media (max-width: 400px){
#categoryTxns .two-line .line1 {
  font-size: .86rem;
}

#categoryTxns .two-line .line2 {
  font-size: .80rem;
}
}

/* "+ Add Type" button identical to chips but dashed */
#addTypeBtn {
  align-items: center;
  background: #fff;
  border: 1px dashed #9ca3af;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  display: inline-flex;
  font-size: 10px;
  height: 23px;
  justify-content: center;
  line-height: 1;
  margin-top: 3px;
  padding: 0 12px;
  white-space: nowrap;
}

#addTypeBtn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* === Footer filter (self-contained, fixed) === */

#list {
  margin-bottom: 64px;
}


main {
  padding-bottom: var(--footer-h);
  padding-top: var(--appbar-h);
}

/* Remove the extra top/bottom padding from main,
   since the screens are already positioned with top/bottom */
main {
  padding-bottom: 0 !important;
  padding-top: 0 !important;
}

/* === FINAL OVERRIDE: Search right-border fix (do not remove) === */
.search-wrap .search-container,

.search-wrap .search-container .search-input,
#listScreen .search-wrap .search-container .search-input,
.search-wrap input[type="search"],

/* === END FINAL OVERRIDE === */

#search:focus,

/* === Unified search field (container draws the border) === */

#search {
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-sizing: border-box;
  color: var(--ink);
  flex: 1 1 auto;
  font-size: 12px;
  min-width: 0;
  outline: 0;
  padding: 8px 10px;
}

/* === CANONICAL: unified search control (container owns the border) === */

#search {
  background: transparent;
  border: 0;
  box-sizing: border-box;
  color: var(--ink);
  flex: 1 1 auto;
  font-size: 14px;
  min-width: 0;
  outline: 0;
  padding: 8px 10px;
}

/* === FINAL OVERRIDE: Footer background same as header === */
nav#catSegments.segmented,
body.app

/* === ULTIMATE HEADER LOCK (covers #title and any element) ================= */

header.appbar .toolbar > #title,
header.appbar .toolbar > h1,



/* === CATEGORY LIST FONT TWEAK ========================================== */
#list .li .name {
  font-size: 14px !important;
  font-weight: 400 !important;
  color: var(--ink) !important;
}

/* === FINAL CONSOLIDATED: Unified Search Bar (single source of truth) ====== */
.search-wrap {
  background: #fff !important;
  padding: 8px !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 5 !important;
}

.search-container {
  align-items: center !important;
  background: #fff !important;
  border: 0 !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  display: flex !important;
  overflow: hidden !important;
}

.search-ic {
  color: var(--ink-sub) !important;
  font-size: 16px !important;
  margin-left: 10px !important;
  position: static !important;
  transform: none !important;
}

#search,
.search-input,
.search-wrap input[type="search"],

#search:focus {
  box-shadow: 0 0 0 4px var(--ring) !important;
  outline: 0 !important;
}

/* === FINAL VARS (single source of truth) =================================== */
:root {
  --appbar-h: 48px;
  --bd: #e5e7eb;
  --footer-h: 40px;
  --ink: #0f172a;
  --ink-sub: #334155;
  --panel: #fff;
  --ring: rgba(59,130,246,.12);
  --search-h: 48px;
}

/* === FINAL TYPOGRAPHY NORMALIZATION ======================================= */
body, .toolbar h1, .subbar .title-lg, .subbar .subtitle,
#search, .li .name, .chip, .chip-label, .chip-field,
.save-cta, .hbtn, .header-actions .hbtn {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               system-ui, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* === FINAL HEADER / APP BAR =============================================== */
header.appbar {
  padding-top: var(--safe-top);

  background: #f3f4f6 !important;
  border-bottom: 1px solid var(--bd) !important;
  display: flex !important;
  flex-direction: column !important;
  height: var(--appbar-h) !important;
  justify-content: center !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
}

header.appbar .toolbar {
  display: grid !important;
  grid-template-columns: minmax(0,auto) 1fr minmax(0,auto) !important;
  align-items: center !important;
  gap: 8px !important;
  height: var(--appbar-h) !important;
  padding: 6px 12px !important;
  white-space: nowrap !important;
}

header.appbar .toolbar h1 {
  color: var(--ink-sub) !important;
  font-size: 18px !important;       /* increased by 1px */
  font-weight: 600 !important;
  line-height: 1.3 !important;      /* gives space for descenders like g, y, p */
  margin: 0 !important;
  justify-self: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  padding-bottom: 1px !important;   /* ensures bottom of letters never clip */
}

header.appbar .icon {
  background: transparent !important;
  border: 0 !important;
  border-radius: 10px !important;
  color: var(--ink) !important;
  cursor: pointer !important;
  padding: 4px !important;
}

header.appbar .icon.round {
  background: #F3F4F6 !important;
  border: 1px solid var(--bd) !important;
  display: grid !important;
  height: 32px !important;
  place-items: center !important;
  width: 32px !important;
}

header.appbar .icon.primary {
  background: #F3F4F6 !important;
  border: 1px solid var(--bd) !important;
  color: var(--ink) !important;
}

header.appbar .material-icons {
  display: inline-block !important;
  font-size: 21px !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}

/* === FINAL HEADER ACTIONS ================================================== */
.header-actions {
  align-items: center;
  background: #f3f4f6;
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  gap: 0;
  padding: 1px;
}

.header-actions .hbtn {
  appearance: none;
  background: #f3f4f6;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  color: var(--ink);
  cursor: pointer;
  font: 600 14px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  height: 22px;
  padding: 2px 7px;
  position: relative;
}

.header-actions .hbtn:hover {
  background: #e9ecef;
}

.header-actions .hbtn + .hbtn::before {
  background: var(--bd);
  content: "";
  height: .9em;
  left: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
}

.header-actions .hbtn[aria-pressed="true"] {
  background: #e9ecef;
}

/* === FINAL VIEWPORT & SCREENS ============================================= */
body.app {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#listScreen, #editScreen {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  overflow: visible;
}


main {
  padding-bottom: 0 !important;
  padding-top: 0 !important;
}

#list {
  margin-bottom: var(--footer-h);
}

/* === FINAL CONSOLIDATED FOOTER FILTER PILLS =============================== */
nav#catSegments.segmented {
  padding-bottom: var(--safe-bottom);

  -webkit-overflow-scrolling: touch !important;
  background: #f3f4f6 !important;
  border-top: 1px solid #e5e7eb !important;
  bottom: 0;
  display: flex;
  height: var(--footer-h) !important;
  left: 0;
  overflow-x: auto !important;
  position: fixed !important;
  right: 0;
  white-space: nowrap !important;
  z-index: 1100 !important;
}

nav#catSegments.segmented > button.seg {
  align-items: center;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  border-right: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
  cursor: pointer;
  display: flex;
  flex: 0 0 auto !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  height: var(--footer-h) !important;
  justify-content: center;
  padding: 0 10px !important;
}

nav#catSegments.segmented > button.seg:hover {
  background: rgba(0,0,0,0.04) !important;
}

nav#catSegments.segmented > button.seg.on {
  background: #f3f4f6 !important;
  font-weight: 500 !important;
}

nav#catSegments.segmented > button.seg .seg-label {
  font-size: inherit !important;
  font-weight: inherit !important;
  white-space: nowrap !important;
}

/* === FINAL CATEGORY TRANSACTIONS PANEL (#categoryTxns) ==================== */
#categoryTxns {
  margin-top: .25rem;
}

#categoryTxns .txn-head {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--bd);
  border-top: 1px solid var(--bd);
  display: flex;
  flex-wrap: nowrap;
  gap: .5rem;
  justify-content: space-between;
  margin-top: 8px;
  padding: 6px 8px;
}

#categoryTxns .txn-head .title {
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: .02em;
}

#categoryTxns .header-actions {
  align-items: center;
  display: inline-flex;
  gap: 0;
}

#categoryTxns .txn-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#categoryTxns .two-line {
  border-bottom: 1px solid #f2f2f2;
  padding: 6px 8px;
}

#categoryTxns .two-line .line1 {
  align-items: center;
  display: flex;
  font-size: .85rem;
  gap: 8px;
  justify-content: space-between;
  line-height: 1.2;
  white-space: nowrap;
}

#categoryTxns .two-line .line1 .contact,
#categoryTxns .two-line .line1 .category {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#categoryTxns .two-line .line1 .amounts {
  display: flex;
  gap: 6px;                 /* slightly closer spacing between $ and LL */
  justify-content: flex-end;/* align both amounts to the right edge */
  flex: 0 0 120px;          /* fixed right column width for perfect alignment */
}

#categoryTxns .two-line .line1 .amount {
  flex: 1;
  text-align: right;        /* keep numbers aligned right */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}


#categoryTxns .two-line .line1 .amount:not(.neg) {
  color: #b42318;
  font-weight: 600;

}

#categoryTxns .two-line .line1 .amount.neg {
  color: #3f5ba3;
  font-weight: 600;

}

#categoryTxns .two-line .line2 {
  align-items: center;
  color: #444;
  display: flex;
  font-size: .88rem;
  gap: 8px;
  line-height: 1.2;
}

#categoryTxns .two-line .line2 .date {
  opacity: .95;
}

#categoryTxns .two-line .line2 .memo {
  color: #000000;
  flex: 1;
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* === FINAL ICONS & CHEVRON ================================================= */
.material-icons {
  display: inline-block;
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
}

.chev {
  color: #94a3b8;
}

/* === CATEGORY LIST FONT TWEAK ============================================= */
#list .li .name {
  font-size: 14px !important;
  font-weight: 400 !important;
  color: var(--ink) !important;
}
/* === CENTERED SEARCH BAR + VERTICALLY CENTERED TEXT ====================== */
/* === CENTERED SEARCH BAR – FIXED LEFT PADDING ============================ */
.search-wrap {
  display: flex !important;
  justify-content: center !important;
  padding: 12px 0 !important;
  background: #fff !important;
}

.search-wrap .search-container {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 90% !important;
  max-width: 460px !important;
  background: #fff !important;
  border: 1px solid var(--bd) !important;
  border-radius: 10px !important;
  box-shadow: 0 0 0 4px rgba(59,130,246,.05);
  padding: 8px 14px !important;
}

/* icon spacing */
.search-wrap .search-ic {
  font-size: 20px !important;
  color: var(--ink-sub) !important;
  margin-right: 14px !important;
  margin-left: -5px !important;
  flex-shrink: 0 !important;
}

/* input now has internal left padding to offset text from border */
.search-wrap input[type="search"],
#search,
.search-input {
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
  font-size: 15px !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  color: var(--ink) !important;
  padding: 6px 4px 6px 4px !important;   /* new internal horizontal spacing */
  line-height: 1.4 !important;
  text-indent: 2px !important;           /* extra nudge so text is not flush */
}

/* placeholder smaller for contrast */
.search-wrap input[type="search"]::placeholder,
#search::placeholder {
  font-size: 14px !important;
  color: var(--ink-sub) !important;
  opacity: .8;
}
/* === END CENTERED SEARCH BAR ============================================ */
/* === Categories → Type chips (reduced radius, Contacts look) === */
#typePicker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

#typePicker .chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 400;
  border-radius: 6px; /* reduced from 9999px */
  background: #f3f4f6;
  color: #0f172a;
  border: 1px solid #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

#typePicker .chip.on {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* long-press delete badge */
#typePicker .chip .chip-del {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
#typePicker .chip.show-del .chip-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* “+ Add Type” button styled like a chip */
#addTypeBtn {
  height: 24px;
  padding: 3px 8px;
  border-radius: 8px; /* reduced to match chips */
  border: 1px dashed #d1d5db;
  background: #fff;
  color: #111827;
  font-size: 13px;
  cursor: pointer;
}
#addTypeBtn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* inline rename editor */
#typePicker .chip.editing {
  padding: 0;
  height: 24px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px; /* match new style */
}
#typePicker .chip.editing input {
  width: 100%;
  height: 22px;
  padding: 0 10px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
}
#typePicker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 10px; /* ← adds vertical space between the title and the chips */
}


/* Contact | Account separator on line1 (parity with Contacts) */
#categoryTxns .two-line .line1 .contact { 
  display: inline-block;
  max-width: calc(100% - 140px); /* leave room for amounts */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#categoryTxns .two-line .line1 .sep { 
  opacity: .6; 
  margin: 0 6px; 
}
#categoryTxns .two-line .line1 .account { 
  opacity: .9;
}
/* === Remove background from back arrow in Edit screen === */
#editScreen #backBtn.icon {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
/* === Tiny chip menu (Rename | Delete), parity with Contacts === */
.chip-menu{
  position:absolute;
  z-index:9999;
  background:#fff;
  border:1px solid var(--bd);
  border-radius:8px;
  box-shadow:0 6px 18px rgba(0,0,0,.12);
  padding:4px;
  min-width:120px;
}
.chip-menu .chip-menu-item{
  display:block;
  width:100%;
  border:0;
  background:transparent;
  padding:8px 10px;
  text-align:left;
  font-size:14px;
  cursor:pointer;
}
.chip-menu .chip-menu-item:hover{ background:#f3f4f6; }
.chip-menu .chip-menu-item.delete{ color:#b91c1c; }

/* ========= IMAGE 2 EXACT LOOK (Contacts parity) ========================== */
/* Lock layout: popover never pushes content, no horizontal scroll */
html, body, #listScreen, #editScreen {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  overflow: visible;
}


/* Header actions = Contacts pill group */
.header-actions{
  display:inline-flex; align-items:center; gap:0;
  background:#f3f4f6; border:1px solid #e5e7eb; border-radius:6px; padding:1px;
}
.header-actions .hbtn{
  appearance:none; border:0; background:#f3f4f6; color:#0f172a;
  font:600 14px/1 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  height:22px; padding:2px 8px; border-radius:6px; cursor:pointer; position:relative;
}
.header-actions .hbtn + .hbtn::before{
  content:""; position:absolute; left:0; top:50%; width:1px; height:.9em;
  transform:translateY(-50%); background:#e5e7eb;
}
.header-actions .hbtn:hover{ background:#e9ecef; }
.header-actions .hbtn:focus{ outline:0 !important; box-shadow:none !important; }
/* selected is neutral (no blue fill) */
.txn-filter .hbtn.on{ background:#f3f4f6 !important; color:#0f172a !important; }

/* Month popover: compact card with large soft shadow, rounded corners */
.mini-month-picker{ position:fixed !important; z-index:2000; inset:auto auto auto auto; }
.mini-month-picker .mmp-card{
  width: 320px !important; min-width:320px !important; max-width:320px !important;
  background:#fff; border:1px solid #e5e7eb; border-radius:14px; overflow:hidden;
  /* big ambient drop shadow + faint floor bloom, as in screenshot */
  box-shadow:
    0 32px 80px rgba(15,23,42,.18),
    0 10px 28px rgba(15,23,42,.12);
}

/* Header strip */
.mini-month-picker .mmp-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; background:#f3f6fb; /* subtle cool tint */
  border-bottom:1px solid #e9edf2; color:#0f172a; font-weight:700;
}
.mini-month-picker .mmp-head .mmp-close{
  appearance:none; border:0; background:transparent; color:#0f172a;
  font-size:18px; line-height:1; padding:2px 6px; border-radius:8px; cursor:pointer;
}
.mini-month-picker .mmp-head .mmp-close:hover{ background:rgba(0,0,0,.06); }

/* Body & field */
.mini-month-picker .mmp-body{ position:relative; padding:16px; }
.mini-month-picker #mmpInput{
  width:100%; box-sizing:border-box; font-size:16px; color:#0f172a;
  background:#fff; border:1px solid #e5e7eb; border-radius:12px;
  padding:12px 44px 12px 14px; outline:none;
}
.mini-month-picker #mmpInput:focus{ border-color:#cbd5e1; box-shadow:none; }
.mini-month-picker .mmp-body::after{ content:none !important; }  /* no decorative icon */

/* Actions: gray “This Month” + outlined blue “Apply” */
.mini-month-picker .mmp-actions{ display:flex; gap:12px; padding-top:14px; }
.mini-month-picker .mmp-actions button{
  appearance:none; border:1px solid #e5e7eb; background:#fff; color:#0f172a;
  border-radius:999px; padding:9px 16px; font-size:14px; cursor:pointer;
}
.mini-month-picker .mmp-actions button:hover{ background:#f3f4f6; }
.mini-month-picker .mmp-actions .primary{
  border-color:#2563eb; color:#2563eb; background:#fff;
}
.mini-month-picker .mmp-actions .primary:hover{ background:rgba(37,99,235,.06); }

/* Zebra striping, subtle like Contacts */
#categoryTxns .txn-list li.two-line{ border-bottom:1px solid #eaeaea; }
#categoryTxns .txn-list li.two-line:not(.total-row):nth-child(odd){ background:#fafafa; }
#categoryTxns .txn-list li.two-line:not(.total-row):nth-child(even){ background:#ffffff; }
/* === Month popover layout refinements =================================== */
:root { --month-popover-w: 260px; }   /* smaller container */

.mini-month-picker { position: fixed !important; z-index: 2000; }

/* Smaller card, and nudge it 12px left so it’s not flush with the viewport edge */
.mini-month-picker .mmp-card{
  width: var(--month-popover-w) !important;
  min-width: var(--month-popover-w) !important;
  max-width: var(--month-popover-w) !important;
  transform: translateX(-12px); /* soft inset from screen-right */
}

/* Center the date pill; right-align the action pills */
.mini-month-picker .mmp-body{
  display: flex;
  flex-direction: column;
  align-items: center;   /* centers the input */
  padding: 14px 14px 16px;
}

.mini-month-picker #mmpInput{
  margin: 0 auto;                    /* center */
  max-width: calc(var(--month-popover-w) - 40px);  /* breathe inside */
  width: 100%;
}

/* Actions push to the right edge of the card */
.mini-month-picker .mmp-actions{
  align-self: stretch;               /* take full width */
  display: flex;
  justify-content: flex-end;         /* right align buttons */
  gap: 10px;
  padding-top: 12px;
}

/* Keep layout rock-solid: no horizontal scrollbars */
html, body, #listScreen, #editScreen {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  overflow: visible;
}

/* Light grey background for the Type picker block */
.chip.picker {
  background: #f5f6f8;          /* soft light grey */
  border-radius: 10px;          /* smooth rounded corners */
  padding: 8px 10px;            /* some inner spacing */
}

/* Optional: space out the inner chips neatly */
.chip.picker .chip-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}


/* === Mini Category Picker (bulk change) ================================ */
.mini-cat-picker { position: fixed; z-index: 2100; }
.mini-cat-picker .mcp-card{
  width: 320px; max-width: calc(100vw - 24px);
  background:#fff; border:1px solid #e5e7eb; border-radius:12px;
  box-shadow: 0 28px 60px rgba(15,23,42,.16), 0 8px 24px rgba(15,23,42,.10);
  overflow:hidden;
}
.mini-cat-picker .mcp-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:#f8fafc; border-bottom:1px solid #eaeaea;
  font-weight:700; color:#0f172a;
}
.mini-cat-picker .mcp-head .mcp-close{
  appearance:none; border:0; background:transparent; cursor:pointer;
  font-size:18px; line-height:1; color:#0f172a; border-radius:8px; padding:2px 6px;
}
.mini-cat-picker .mcp-head .mcp-close:hover{ background:rgba(0,0,0,.06); }
.mini-cat-picker .mcp-body{ padding:10px 10px 8px; }
.mini-cat-picker .mcp-list{ list-style:none; margin:6px 0 6px; padding:0; max-height:320px; overflow:auto; }
.mini-cat-picker .mcp-item{
  display:flex; align-items:center; gap:10px; padding:8px 10px;
  border-radius:8px; cursor:pointer;
}
.mini-cat-picker .mcp-item:hover{ background:#f3f4f6; }
.mini-cat-picker .mcp-item .avatar{ width:24px; height:24px; display:grid; place-items:center; border-radius:999px; background:#eef2ff; }
.mini-cat-picker .mcp-item .name{ font-size:14px; color:#0f172a; flex:1; }
.mini-cat-picker .mcp-item .meta{ font-size:12px; color:#64748b; }
/* One-line header actions for the Transactions header */
#categoryTxns .txn-head{ overflow:hidden; }
#categoryTxns .txn-head .header-actions{
  display:inline-flex; align-items:center; gap:0;
  flex-wrap:nowrap; white-space:nowrap; max-width:100%;
}
#categoryTxns .txn-head .txn-filter{ display:inline-flex; flex-wrap:nowrap; white-space:nowrap; }
#categoryTxns .txn-head .header-actions .hbtn,
#categoryTxns .txn-head .txn-filter .hbtn{
  flex:0 0 auto; white-space:nowrap; min-width:0; line-height:1;
  height:22px; padding-left:8px; padding-right:8px;
}
/* Keep header pills and buttons all on one line */
#categoryTxns .txn-head .header-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 4px;
  overflow: hidden;
}
#categoryTxns .txn-head .header-actions .hbtn {
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1;
  height: 24px;
  padding: 0 8px;
}
#categoryTxns .txn-head .txn-filter {
  display: inline-flex;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.icon-btn {
  background: none;
  border: none;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn .material-icons {
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
}
/* === Mini Category Picker: lighter title, narrower card, lighter rows === */
.mini-cat-picker .mcp-card{
  width: 280px !important;         /* was ~320 — make a little narrower */
  min-width: 280px !important;
  max-width: 280px !important;
}

.mini-cat-picker .mcp-head{
  font-weight: 600 !important;     /* reduce from heavy bold */
}

.mini-cat-picker .mcp-item .name{
  font-weight: 500 !important;     /* lighter text for category names */
}

.mini-cat-picker .mcp-item .avatar .material-icons{
  font-weight: normal !important;                  /* avoid bold-looking icon */
  font-variation-settings: "wght" 400 !important; /* for variable icon font */
}

/* Search field: darker border + slightly rounded */
.mini-cat-picker .mcp-search{
  border: 1px solid #9ca3af !important;  /* dark grey */
  border-radius: 8px !important;         /* a little rounded */
  padding: 8px 10px;
}
.mini-cat-picker .mcp-search:focus{
  border-color: #6b7280 !important;      /* darker on focus */
  box-shadow: none;
}



/* === List bulk edit bar (Categories list) ================================= */
.list-bulk-bar{
  position: sticky; top: 0;
  z-index: 8;
  display:flex; align-items:center; justify-content:space-between;
  padding: 6px 10px; background:#fff; border-bottom:1px solid var(--bd);
}
.list-bulk-bar .bulk-right{ display:inline-flex; gap:6px; }

/* Checkboxes column in list rows */
#list .li.editing{ grid-template-columns: auto auto 1fr auto; }
#list .li .chk-wrap{ display:inline-flex; align-items:center; justify-content:center; width:24px; }

/* Mini Type Picker */
.mini-type-picker{ position:fixed !important; z-index:2100; }
.mini-type-picker .mtp-card{
  width: 260px !important; min-width:260px !important; max-width:260px !important;
  background:#fff; border:1px solid #e5e7eb; border-radius:12px;
  box-shadow: 0 28px 60px rgba(15,23,42,.16), 0 8px 24px rgba(15,23,42,.10);
  overflow:hidden;
}
.mini-type-picker .mtp-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:#f8fafc; border-bottom:1px solid #eaeaea;
  font-weight:700; color:#0f172a;
}
.mini-type-picker .mtp-head .mtp-close{
  appearance:none; border:0; background:transparent; cursor:pointer;
  font-size:18px; line-height:1; color:#0f172a; border-radius:8px; padding:2px 6px;
}
.mini-type-picker .mtp-body{ padding:10px; }
.mini-type-picker .mtp-list{ list-style:none; margin:0; padding:0; max-height:300px; overflow:auto; }
.mini-type-picker .mtp-item{ padding:8px 10px; border-radius:8px; cursor:pointer; }
.mini-type-picker .mtp-item:hover{ background:#f3f4f6; }


/* Right actions group keeps buttons together on one side */
.actions-right{ display:inline-flex !important; align-items:center !important; gap:6px !important; }
.actions-right .icon.round{ margin:0 !important; }

/* Prevent toolbar from creating implicit second rows */
header.appbar .toolbar > * { min-width: 0 !important; }

/* Unified Header (Categories) — Contacts parity */
header.appbar .toolbar{
  display: grid !important;
  grid-template-columns: auto auto 1fr auto !important; /* home | org | title | actions */
  align-items: center !important;
  padding: 6px 12px !important;
  justify-content: initial !important;

  column-gap: 0px !important;
  grid-auto-flow: column !important;
  white-space: nowrap !important;
}

header.appbar .toolbar h1,
header.appbar .toolbar #title{
  margin: 0 !important;
  justify-self: center !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  color: var(--ink-sub) !important;
  position: static !important;
  left: auto !important;
  transform: none !important;
}

/* Categories header org pill sizing (same as Contacts) */
#categoriesHeaderOrgPill{
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px; /* spacing from home */
  border-radius: 6px;
}
/* === OVERRIDE: Bulk bar button group (Change Type + X) ===================== */
/* Group the two buttons in one rounded capsule with a divider */
.list-bulk-bar .bulk-right{
  display: inline-flex !important;
  align-items: center !important;
  gap: 0 !important;
  background: #f8fafc !important;
  border: 1px solid var(--bd) !important;
  border-radius: 10px !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.list-bulk-bar .bulk-right .hbtn{
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 6px 10px !important;
  height: 26px !important;
  line-height: 1 !important;
}

.list-bulk-bar .bulk-right .hbtn + .hbtn{
  border-left: 1px solid var(--bd) !important; /* thin separator */
}

.list-bulk-bar .bulk-right .icon-btn{
  padding: 0 8px !important; /* tighter icon area */
}



/* === EDIT SCREEN HEADER TWEAKS ============================================= */
/* Add breathing room above the edit header (the white bar with back + title + buttons) */
#editScreen .subbar {
  margin-top: 6px !important;                 /* increase upper margin */
}

/* Softer "Edit: …" title */
#editScreen #editTitle {
  font-weight: 500 !important;                 /* reduce intensity */
  color: var(--ink-sub) !important;            /* slightly softer color */
}

/* Buttons on the right: lighter weight, +1px size */
#editScreen .subbar .header-actions .hbtn {
  font-weight: 450 !important;                 /* reduce intensity */
  font-size: 14px !important;                  /* +1px vs the 14px base */
}



/* === OVERRIDE: Align USD and LL columns in #categoryTxns =================== */
/* Force a two-column grid for the amount pair so both align on the right edge */
#categoryTxns .two-line .line1 .amounts{
  display: grid !important;
  grid-template-columns: 84px 100px !important;  /* USD | LL widths */
  justify-content: end !important;
  align-items: center !important;
  column-gap: 12px !important;                   /* space between $ and LL */
  flex: 0 0 196px !important;                    /* reserve consistent right column */
}

#categoryTxns .two-line .line1 .amounts .amount{
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  white-space: nowrap !important;
}

/* === FORCE CONTACTS-BLUE FOR PILLS (kept at EOF for highest precedence) === */
:root {
  --blue: #3a78e0; /* match Contacts */
}
/* Categories pills */
.pill.on, #typePicker .pill.on {
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  color: #fff !important;
}
/* If any chip class is used interchangeably */
.chip.on {
  background: var(--blue) !important;
  color: #fff !important;
}

/* === HARD OVERRIDES: unify Categories pills & footer filter to Contacts blue === */
:root { --blue: #3a78e0; } /* keep in sync with Contacts */

/* Type chips / pills (multiple selectors + important) */
.pill.on,
button.pill.on,
#typePicker .pill.on,
.type-chips .pill.on,
.chip.on,
button.chip.on {
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  color: #fff !important;
}

/* Footer segmented filter: active = blue like Contacts chips */
nav#catSegments.segmented > button.seg.on,
nav#catSegments.segmented > .seg.on {
  background: var(--blue) !important;
  color: #fff !important;
  font-weight: 600 !important;
  border-right-color: rgba(255,255,255,.25) !important;
}
nav#catSegments.segmented > button.seg.on .seg-label,
nav#catSegments.segmented > .seg.on .seg-label {
  color: #fff !important;
}

/* === Editable chips (parity with Contacts) === */
.chip.editable{
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border: none;
  border-bottom: 1px solid var(--bd);
  background: #fff !important;
  border-radius: 0 !important;
  cursor: text;
}

.chip.editable::before{
  content: attr(data-ic);
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 19px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  color: var(--ink-sub);
  opacity: .9;
}

.chip.editable .chip-label{ 
  display: none !important;
}

.chip.editable .chip-field{
  min-height: 20px;
  outline: none;
  display: inline-block;
  width: 100%;
  white-space: nowrap; /* prevent per-letter wrapping */
}

.chip.editable .chip-field:empty:before{
  content: attr(data-placeholder);
  color: var(--ink-sub);
  opacity: .25;
}
/* Perfect full-width divider below Name in Edit Category */
.edit-divider {
  border: 0;
  border-top: 1px solid var(--bd);
  margin: 4px 0 10px 0;
  width: calc(100% + 20px);
  transform: translateX(-10px);
}
#editScreen .chip.editable {
  border-bottom: none !important;
}
/* Contact | Account separator on line1 (parity with Contacts) */
#categoryTxns .two-line .line1 .contact {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#categoryTxns .two-line .line1 .sep {
  opacity: .6;
  margin: 0 6px;
  flex: 0 0 auto;
}
#categoryTxns .two-line .line1 .account {
  flex: 0 0 auto;
  max-width: 18ch;      /* show up to ~12 chars */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.mode-edit #editListBtn { display: none !important; }

/* Patch appended: 2025-11-02T00:57:08.965240 */
/* === FINAL APPEND: Footer Segmented Control (Contacts parity, blue active) === */
:root { --blue: #3a78e0; } /* keep identical to Contacts */

nav#catSegments.segmented {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; gap: 0; justify-content: stretch;
  z-index: 15;
  background: #fff;
  border-top: 1px solid var(--bd);
  height: var(--footer-h);
}

#catSegments .seg {
  flex: 1 1 0;
  background: #fff;
  color: #0f172a;
  border: none;
  border-right: 1px solid var(--bd);
  border-radius: 0;
  padding: 10px 8px;
  font-weight: 700;
  font-size: 15px;
}

#catSegments .seg.on {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
  border-right-color: rgba(255,255,255,.25);
}

#catSegments .seg:last-child { border-right: none; }
/* === BAKED-IN FONT + HEIGHT REDUCTION PATCH  === */
:root {
  --footer-h: 35px !important; /* reduced from 40px */
}

nav#catSegments.segmented > button.seg {
  font-size: 13px !important; /* reduced from 15px */
}
/* === Header grid column pinning (keeps title centered even when org pill hidden) === */
header.appbar .toolbar > #homeBtn{
  grid-column: 1 !important;
  justify-self: start !important;
}
header.appbar .toolbar > .hdr-org-dot{
  grid-column: 2 !important;
  justify-self: start !important;
}
header.appbar .toolbar > #title,
header.appbar .toolbar > h1#title{
  grid-column: 3 !important;
  justify-self: center !important;
}
header.appbar .toolbar > .actions-right{
  grid-column: 4 !important;
  justify-self: end !important;
}

/* === Org pills in Edit screen (Stage 4) — match Contacts pills === */
#orgPicker { margin-top: 12px; }
#orgPills { display:flex; flex-wrap:wrap; gap:6px; margin-top: 8px;}

.org-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 12px;              /* Contacts .chip */
  border-radius:8px;             /* Contacts .chip radius */
  font-size:16px;                /* Contacts .chip size */
  font-weight:600;
  line-height:2;
  background:#f8fafc;            /* Contacts .chip bg */
  border:none;                   /* Contacts .chip borderless */
  color:var(--ink-sub);
  cursor:pointer;
  user-select:none;
  position:relative;
}

.org-pill.on{
  background:var(--blue);
  color:#fff;
}

.org-pill.off{
  opacity:.40;                   /* Contacts edit org dim */
  text-decoration:none;          /* Contacts uses opacity only */
  border: 1px solid #cbd5e1;
}

.org-pill .lp-badge{
  display:none;
  position:absolute;
  top:-6px; right:-6px;
  width:28px; height:28px; border-radius:50%;
  background:#fff; border:1px solid var(--bd);
  font-size:12px; line-height:16px; text-align:center;
  box-shadow:0 1px 2px rgba(0,0,0,.05);
  color:#111827;
}
.org-pill.show-badge .lp-badge{
  display:inline-flex; align-items:center; justify-content:center;
}

.chip-hint{
  font-size:12px;
  color:var(--ink-sub);
  margin-top:6px;
  opacity:.8;
}


/* === Grouping by Category Type (Accounts-style) === */
.type-group{
  border: 1px solid var(--bd);
  border-radius: 14px;
  margin: 10px 0;
  overflow: hidden;
  background: #fff;
}
.type-header{
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  background: #f8fafc;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.type-avatar{
  font-size: 14px;
  font-weight: 800;
  height: 36px;
  width: 36px;
  background: #f8fafc; /* neutral like other avatars */
  color: #475569;
}
.type-header-text{ display:flex; flex-direction:column; gap:1px; }
.type-name{ font-size: 14px; font-weight: 00; color: var(--ink); }
.type-meta{
  display:flex; gap:4px; font-size:13px; color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  opacity: .8;
}
.type-totals{ display:inline-flex; gap:4px; font-weight:500; }
.type-dot, .bal-dot{ opacity:.6; margin:0 2px; }
.type-chevron{ opacity:.7; }

/* collapsed */
.type-group.collapsed .type-rows{ display:none; }
.type-group.collapsed .type-header{ background:#fff; }

/* nested category rows */
.type-rows{ list-style:none; margin:0; padding:0; }
.type-rows .li{ padding-left: 40px; }

/* Category meta line (parity with Accounts org-meta) */
.name .cat-line1{
  display:flex;
  align-items:center;
  gap:8px;
}

.name .cat-line1 .cat-title{
  font-size: 14px;
  font-weight: 450;
  line-height: 1.2;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Totals move to line 1, right-aligned */
.name .cat-line1 .cat-totals{
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
  text-align: right;
  font-size: 13px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}
.cat-meta{
  display:flex; gap:4px; font-size:13px; color: var(--ink-sub);
  margin-top:2px; font-variant-numeric: tabular-nums;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.cat-totals{ display:inline-flex; gap:4px; }
.cat-dot{ opacity:.6; margin:0 2px; }

/* DR/CR coloring */
.dr{ color: #b42318; font-weight: 600; }
.cr{ color: var(--blue); font-weight: 600; }
