/* Talaan · V2.0.1 · Budget summary mascots */
/* Phase 5.1 compatibility repair: load the canonical Dashboard interaction core.
   dashboard-interactions.css still points at a retired versioned filename. */
@import url("./dashboard-interactions-core.css");
@import url("./ui-radius.css?v=2.5.0-ui-37fc672009f7");

/* Phase 5.1 · customization controls must never leak into normal Dashboard view. */
.dashboard-drag-handle,
.dashboard-resize-handle {
  display: none !important;
}
#dashboard.dashboard-customizing .dashboard-drag-handle {
  display: grid !important;
}
#dashboard.dashboard-customizing .dashboard-resize-handle {
  display: inline-flex !important;
}
@media (max-width: 700px) {
  #dashboard.dashboard-customizing .dashboard-resize-handle {
    display: none !important;
  }
}

/* Prevent a page-level horizontal scrollbar/separator from appearing when a
   wide child temporarily exceeds the viewport. Purpose-built inner scrollers remain unaffected. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}
.app,
.main,
.content,
.page {
  min-width: 0;
  max-width: 100%;
}

/* Phase 5.2 · the medium-desktop Finance card rail intentionally remains
   horizontally swipeable, but it must not reserve or paint a bottom scrollbar
   gutter. That gutter is the empty strip visible below the transaction totals
   on Retina/zoomed desktop layouts. */
.app,
.main,
.content,
.page {
  overflow-x: clip !important;
}
@media (min-width: 851px) and (max-width: 1099px) {
  html body #money .section-stack {
    scrollbar-gutter: auto !important;
    scrollbar-width: none !important;
  }
  html body #money .section-stack::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
  }
}

/* Phase 5.3 · present Budget & Expenses filters and view controls as one
   deliberate workspace toolbar instead of two unrelated rows. */
@media (min-width: 851px) {
  html body #money #expenseFiltersPanel {
    margin: 10px 0 0 !important;
    padding: 10px 10px 8px !important;
    border: 1px solid var(--line) !important;
    border-bottom: 0 !important;
    border-radius: var(--talaan-card-radius) var(--talaan-card-radius) 0 0 !important;
    background: var(--surface-soft) !important;
  }

  html body #money #expenseFiltersPanel > .expense-toolbar-single-line {
    grid-template-columns: minmax(170px,.62fr) minmax(240px,1.4fr) minmax(160px,.7fr) minmax(180px,.9fr) auto minmax(0,auto) !important;
    gap: 6px !important;
    align-items: center !important;
  }

  html body #money #expenseFiltersPanel .bulk-expense-inline {
    box-sizing: border-box !important;
    min-height: 35px !important;
    height: 35px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 0 10px !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--talaan-control-radius) !important;
    background: var(--surface) !important;
  }

  html body #money #expenseFiltersPanel :is(.input,.select,.button),
  html body #money #transactionToolbar-expense :is(.select,.button) {
    box-sizing: border-box !important;
    min-height: 35px !important;
    height: 35px !important;
    border-radius: var(--talaan-control-radius) !important;
  }

  html body #money #transactionToolbar-expense {
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 54px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    margin: 0 0 10px !important;
    padding: 8px 10px 10px !important;
    border: 1px solid var(--line) !important;
    border-top-color: color-mix(in srgb,var(--line) 72%,transparent) !important;
    border-radius: 0 0 var(--talaan-card-radius) var(--talaan-card-radius) !important;
    background: var(--surface-soft) !important;
  }

  html body #money #transactionToolbar-expense .transaction-view-group {
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    gap: 2px !important;
    padding: 2px !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--talaan-control-radius) !important;
    background: var(--surface) !important;
  }

  html body #money #transactionToolbar-expense .transaction-view-group .button {
    min-height: 29px !important;
    height: 29px !important;
    padding-inline: 12px !important;
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html body #money #transactionToolbar-expense .transaction-view-group .button[aria-pressed="true"] {
    border-color: color-mix(in srgb,var(--primary) 20%,var(--line)) !important;
    background: var(--surface) !important;
    color: var(--primary) !important;
    box-shadow: 0 0 0 1px color-mix(in srgb,var(--primary) 24%,transparent) !important;
  }

  html body #money #transactionToolbar-expense > label {
    display: block !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
  }

  html body #money #transactionToolbar-expense > label:first-of-type .select {
    width: 150px !important;
  }

  html body #money #transactionToolbar-expense > label:nth-of-type(2) .select {
    width: 158px !important;
  }

  html body #money #transactionToolbar-expense > label:nth-of-type(3) .select {
    width: 126px !important;
  }

  html body #money #transactionToolbar-expense [data-open-transaction-columns] {
    margin-right: auto !important;
  }
}

@media (min-width: 851px) and (max-width: 1180px) {
  html body #money #expenseFiltersPanel > .expense-toolbar-single-line {
    grid-template-columns: minmax(170px,.72fr) minmax(230px,1.35fr) minmax(150px,.72fr) minmax(170px,.9fr) auto auto !important;
  }

  html body #money #transactionToolbar-expense {
    flex-wrap: wrap !important;
  }

  html body #money #transactionToolbar-expense [data-open-transaction-columns] {
    margin-right: 0 !important;
  }

  html body #money #transactionToolbar-expense > label:nth-of-type(2) {
    margin-left: auto !important;
  }
}

/* The older completion layer still keeps its amount in data-* attributes.
   Never show its heart-smile artwork in Budget & Expenses; this layer owns the visual. */
#money img[data-first-half-complete-icon],
#money img[data-other-expenses-complete-icon] {
  display: none !important;
}

/* Phone keeps a numeric fallback even when the legacy completion layer has moved
   the number into its stored data attribute. */
@media (max-width: 850px) {
  #money [data-first-half-original-text]:not(.summary-mascot-slot)::after {
    content: attr(data-first-half-original-text);
    display: inline;
    color: inherit;
    font: inherit;
    line-height: inherit;
    white-space: nowrap;
  }

  #money [data-other-expenses-original-text]:not(.summary-mascot-slot)::after {
    content: attr(data-other-expenses-original-text);
    display: inline;
    color: inherit;
    font: inherit;
    line-height: inherit;
    white-space: nowrap;
  }
}

@media (min-width: 851px) {
  #money .summary-mascot-slot {
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
  }

  #money .summary-mascot-slot::after {
    content: "";
    box-sizing: border-box;
    display: block;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    max-width: 30px;
    max-height: 30px;
    margin: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
  }

  #money .summary-mascot-slot[data-summary-mascot="red"]::after {
    background-image: url("./assets/mascots/mascot-red.png?v=2.5.0-talaan1");
  }

  #money .summary-mascot-slot[data-summary-mascot="green"]::after {
    background-image: url("./assets/mascots/mascot-green.png?v=2.5.0-talaan1");
  }

  #money .summary-mascot-slot[data-summary-mascot="blue"]::after {
    background-image: url("./assets/mascots/mascot-blue.png?v=2.5.0-talaan1");
  }

  #money .summary-mascot-slot[data-summary-mascot="orange"]::after {
    background-image: url("./assets/mascots/mascot-orange.png?v=2.5.0-talaan1");
  }

  #money .legend-item.summary-card,
  #moneySummary .summary-card {
    position: relative !important;
  }

  #money .legend-item.summary-card.has-summary-mascot,
  #moneySummary .summary-card.has-summary-mascot {
    padding-right: 60px !important;
  }

  #money .legend-total.summary-mascot-slot,
  #moneySummary .summary-card-value.summary-mascot-slot {
    position: absolute !important;
    /* 19px from the positioning edge + the card's 1px border = 20px visual inset. */
    right: 19px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    box-sizing: border-box !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
  }

  #money .period-card .collapse-actions.has-period-mascot {
    gap: 10px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
  }

  #money .period-card .period-total.summary-mascot-slot {
    box-sizing: border-box !important;
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    align-self: center !important;
    /* Optical correction: align the supplied PNG's visible center with the 20px collapse control. */
    transform: translateY(-16px) !important;
  }

  #money .period-card .period-total.summary-mascot-slot::after {
    align-self: center !important;
    justify-self: center !important;
  }

  /* The compact disclosure remains 20×20 and 10px from the right edge. */
  #money .period-card .period-header {
    padding-right: 10px !important;
  }
}
