.dashboard-week {
  container-type: inline-size;
  container-name: dashboard-week;
  margin: 14px 0 4px;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}
.dashboard-week-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dashboard-week-head h2 {
  margin: 2px 0 0;
  font: 800 22px Manrope, sans-serif;
}
.dashboard-week-range {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.dashboard-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.dashboard-week-nav-btn,
.dashboard-week-open {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.dashboard-week-nav-btn {
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
}
.dashboard-week-open {
  height: 36px;
  padding: 0 12px;
}
.dashboard-week-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.dashboard-week-day {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 132px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 55%, var(--card));
}
.dashboard-week-day.is-today {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}
.dashboard-week-day-btn {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.dashboard-week-dow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.dashboard-week-date {
  font: 800 18px Manrope, sans-serif;
}
.dashboard-week-day.is-today .dashboard-week-date {
  color: var(--green);
}
.dashboard-week-items {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}
.dashboard-week-item.event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 4px 6px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.dashboard-week-item .event-name {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  text-overflow: ellipsis;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.dashboard-week-state {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
#dashboardWeek .dashboard-week-item .dashboard-week-state,
#dashboardWeek .dashboard-week-item.predicted .dashboard-week-state {
  display: none;
}
.dashboard-week-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
}
.dashboard-week-key-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.dashboard-week-key i {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.dashboard-week-key .income-key {
  background: #c9ecd6;
  border: 1px solid #62a980;
  box-shadow: inset 3px 0 #08704c;
}
.dashboard-week-key .expense-key {
  background: #f7d1c7;
  border: 1px solid #d98974;
  box-shadow: inset 3px 0 #d6553d;
}
.dashboard-week-key .posted-key {
  border: 1px solid currentColor;
  background: color-mix(in srgb, var(--muted) 20%, var(--card));
}
.dashboard-week-key .predicted-key {
  border: 1px dashed currentColor;
  background: var(--card);
}
.dashboard-week-item.expense .dashboard-week-state {
  color: #7a3b35;
}
.dashboard-week-item.income .dashboard-week-state {
  color: #14543d;
}
body[data-theme="midnight"] .dashboard-week-item.expense .dashboard-week-state {
  color: #7a3b35;
}
body[data-theme="midnight"] .dashboard-week-item.income .dashboard-week-state {
  color: #14543d;
}
.dashboard-week-nav-btn:focus-visible,
.dashboard-week-open:focus-visible,
.dashboard-week-day-btn:focus-visible,
.dashboard-week-item:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 55%, var(--ink));
  outline-offset: 2px;
}
#dashboardWeek .dashboard-week-grid:focus-visible{outline:3px solid color-mix(in srgb,var(--green) 55%,var(--ink));outline-offset:-3px;-webkit-mask-image:none;mask-image:none}
.dashboard-week-item .event-amount {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 12px;
}
@media (min-width: 721px) {
  .dashboard-week-item.event {
    gap: 2px;
    padding: 3px 4px;
  }
  .dashboard-week-item .event-amount {
    font-size: 9px;
  }
}
.dashboard-week-empty {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}
body[data-theme="midnight"] .dashboard-week-day {
  background: #0d1222;
}
/*
  Compact 7-column grid when the week card is too narrow for the
  desktop columns (container ≤ 1080) but the viewport is wider than
  a phone. 1080 is the existing wide/medium split: 1440 expanded is
  ~1137px and stays on the default 7-col grid. Phones stay on the
  stacked @media (max-width: 720px) layout and do not use this block.
*/
@media (min-width: 721px) {
  @container dashboard-week (max-width: 1080px) {
    .dashboard-week-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      gap: 3px;
      overflow: visible;
      overflow-x: visible;
      scroll-snap-type: none;
      padding-bottom: 0;
    }
    .dashboard-week-day {
      flex: none;
      width: auto;
      max-width: none;
      min-width: 0;
      min-height: 0;
      padding: 5px 2px 4px;
      gap: 3px;
      overflow: hidden;
    }
    .dashboard-week-dow {
      font-size: 11px;
    }
    .dashboard-week-date {
      font-size: 12px;
    }
    .dashboard-week-day-btn {
      gap: 4px;
    }
    .dashboard-week-items {
      gap: 2px;
      min-width: 0;
      overflow: hidden;
    }
    .dashboard-week-items > * {
      min-width: 0;
      max-width: 100%;
      overflow: hidden;
    }
    .dashboard-week-item.event {
      display: flex;
      flex-direction: column;
      flex-wrap: nowrap;
      align-items: stretch;
      justify-content: flex-start;
      gap: 1px;
      width: 100%;
      max-width: 100%;
      min-width: 0;
      padding: 2px 2px 2px 7px;
      overflow: hidden;
      box-sizing: border-box;
      box-shadow: none;
      border-width: 1.5px;
      border-color: var(--ink);
    }
    .dashboard-week-item.event.posted {
      border-style: solid;
    }
    .dashboard-week-item.event.predicted {
      border-style: dashed;
      box-shadow: none;
    }
    /*
      Option (b): 3px compact stripe + shared 7px start (stripe + 4px
      clearance). Beats option (a)'s 4+6=10px pad so 721 keeps more
      text. #dashboardWeek beats theme .event.posted.* 4px shadows.
    */
    #dashboardWeek .dashboard-week-item.event.posted.expense {
      box-shadow: inset 3px 0 0 #cf432e;
    }
    #dashboardWeek .dashboard-week-item.event.posted.income {
      box-shadow: inset 3px 0 0 #0b8a62;
    }
    #dashboardWeek .dashboard-week-item.event.predicted {
      box-shadow: none;
    }
    /*
      decorateCalendarV11 injects .mini-bank + .event-visual into every
      [data-event] after renderCalendar() (e.g. after crossing 720px).
      Those two rows grow a compact chip from ~29px to ~63px in a
      7-column grid. Hide them only in this compact block. Phones and
      wide 1440 keep the default accounts-v11 rules.
    */
    #dashboardWeek .dashboard-week-item .mini-bank,
    #dashboardWeek .dashboard-week-item .event-visual {
      display: none;
    }
    /*
      Global chip/day outline is 3px / offset 2px and is clipped by
      overflow:hidden on the day, the list, the li, and the chip.
      Keep the ring fully inside those clippers. Day headers use a
      2px outline at offset 0 so it sits in the card's 2px side
      padding instead of covering the W or the date digit. Chips
      drop the overflowing outline and paint an inset ::after ring
      that starts after the 3px stripe so it does not cover the
      stripe or the first merchant/amount glyph.
    */
    .dashboard-week-day-btn:focus-visible {
      outline-width: 2px;
      outline-offset: 0;
    }
    #dashboardWeek .dashboard-week-item.event:focus-visible {
      outline: none;
      position: relative;
    }
    #dashboardWeek .dashboard-week-item.event:focus-visible::after {
      content: "";
      position: absolute;
      inset: 0 0 0 4px;
      border: 2px solid color-mix(in srgb, var(--green) 55%, var(--ink));
      border-radius: 6px;
      pointer-events: none;
      box-sizing: border-box;
    }
    #dashboardWeek .dashboard-week-item.event.predicted:focus-visible::after {
      inset: 0;
    }
    /*
      Light navy on the pale chip fills. The default green/ink mix
      becomes ~#c1a9ff in midnight and is only 1.43:1 on posted
      expense #f7d1c7. Geometry stays the same.
    */
    body[data-theme="midnight"] #dashboardWeek .dashboard-week-item.event:focus-visible::after {
      border-color: #1d3e9f;
    }
    .dashboard-week-item .event-name {
      flex: 0 0 auto;
      min-width: 0;
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: block;
      -webkit-box-orient: initial;
      -webkit-line-clamp: unset;
      line-clamp: unset;
      font-size: 9px;
      line-height: 1.2;
    }
    .dashboard-week-state {
      display: none;
    }
    .dashboard-week-item .event-amount {
      flex: none;
      width: 100%;
      min-width: 0;
      overflow: hidden;
      white-space: nowrap;
      font-size: 10px;
      font-variant-numeric: lining-nums;
      letter-spacing: -0.02em;
    }
    .dashboard-week-empty {
      font-size: 9px;
      margin: 2px 0 0;
    }
  }
}
@media (min-width: 1280px) {
  #dashboardWeek .dashboard-week-item.event {
    gap: 2px;
    padding: 3px 4px;
  }
  #dashboardWeek .dashboard-week-item.event.posted {
    padding-left: 7px;
  }
  #dashboardWeek .dashboard-week-item .event-amount {
    font-size: 9px;
  }
}
@media (max-width: 720px) {
  .dashboard-week {
    padding-top: 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .dashboard-week-head {
    align-items: flex-start;
    margin-bottom: 8px;
  }
  .dashboard-week-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .dashboard-week-grid {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    overflow: visible;
    scroll-snap-type: none;
    flex-wrap: nowrap;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
    gap: 6px;
  }
  .dashboard-week-day {
    min-height: 0;
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
    min-width: 260px;
    scroll-snap-align: start;
    overflow: hidden;
    padding: 6px 8px;
    gap: 4px;
  }
  .dashboard-week-items {
    gap: 3px;
  }
  .dashboard-week-item.event {
    overflow: hidden;
    max-width: 100%;
    min-height: 0;
    padding: 3px 6px;
  }
  .dashboard-week-item .event-name {
    min-width: 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
    line-height: 1.2;
  }
  .dashboard-week-empty {
    margin: 6px 0 0;
  }
}

/*
  Experimental phone carousel. The script adds .is-week-carousel at
  max-width 720px. This block does not apply to foldable, tablet, or
  desktop widths. Predicted "Expected" stays hidden, matching the
  current Dashboard week cards.
*/
@media (max-width: 720px) {
  .dashboard-week.is-week-carousel {
    padding-top: 8px;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 8px;
    overflow: hidden;
  }
  .dashboard-week.is-week-carousel .dashboard-week-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title nav"
      "range range"
      "key key";
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
    flex-wrap: nowrap;
    min-width: 0;
    margin-bottom: 2px;
    padding-inline: 12px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-title {
    grid-area: title;
    min-width: 0;
  }
  .dashboard-week.is-week-carousel .dashboard-week-head h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.15;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-nav {
    grid-area: nav;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-range {
    grid-area: range;
    margin: 0;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-key {
    grid-area: key;
    margin: 4px 0 0;
  }
  .dashboard-week.is-week-carousel .section-kicker {
    display: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-nav-btn,
  .dashboard-week.is-week-carousel .dashboard-week-open {
    min-width: 44px;
    min-height: 44px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-nav-btn {
    width: 44px;
    height: 44px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-open {
    height: 44px;
    padding: 0 12px;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-open-short {
    display: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-grid {
    --cw-carousel-card: 80%;
    --cw-carousel-gap: 1px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--cw-carousel-gap);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 10px;
    margin: 0;
    grid-template-columns: none;
    scroll-padding-inline: 0;
  }
  .dashboard-week.is-week-carousel .dashboard-week-grid::-webkit-scrollbar {
    display: none;
    height: 0;
  }
  .dashboard-week.is-week-carousel .dashboard-week-grid::before,
  .dashboard-week.is-week-carousel .dashboard-week-grid::after {
    content: "";
    flex: 0 0 calc((100% - var(--cw-carousel-card)) / 2 - var(--cw-carousel-gap));
    width: calc((100% - var(--cw-carousel-card)) / 2 - var(--cw-carousel-gap));
    scroll-snap-align: none;
    pointer-events: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-day {
    position: relative;
    flex: 0 0 var(--cw-carousel-card);
    width: var(--cw-carousel-card);
    max-width: var(--cw-carousel-card);
    min-width: 0;
    height: 284px;
    min-height: 284px;
    max-height: 284px;
    align-self: stretch;
    overflow: hidden;
    padding: 12px 12px 10px;
    box-sizing: border-box;
    gap: 0;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
    background: var(--card);
    box-shadow: none;
    scroll-snap-align: center;
    scroll-snap-stop: normal;
    transform: scale(0.92);
    transform-origin: center bottom;
    opacity: 0.72;
    transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  }
  .dashboard-week.is-week-carousel .dashboard-week-day.is-active {
    z-index: 1;
    transform: scale(1);
    opacity: 1;
    border-color: color-mix(in srgb, var(--green) 62%, var(--line));
    box-shadow: 0 14px 32px rgba(23, 35, 31, 0.16), inset 0 0 0 1px color-mix(in srgb, var(--green) 28%, transparent);
  }
  body[data-theme="midnight"] .dashboard-week.is-week-carousel .dashboard-week-day {
    background: #12182a;
  }
  body[data-theme="midnight"] .dashboard-week.is-week-carousel .dashboard-week-day.is-active {
    background: #18233a;
    border-color: color-mix(in srgb, var(--green) 70%, #8fb9ff);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42), inset 0 0 0 1px color-mix(in srgb, #8fb9ff 35%, transparent);
  }
  .dashboard-week.is-week-carousel .dashboard-week-day-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    box-sizing: border-box;
    padding: 0;
    border-radius: 12px;
    text-align: left;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .dashboard-week.is-week-carousel .dashboard-week-day-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--green) 55%, var(--ink));
    outline-offset: -3px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-day-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
  }
  .dashboard-week.is-week-carousel .dashboard-week-dow {
    flex: 0 0 auto;
    font-size: 12px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-today {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--green);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-date {
    flex: 0 0 auto;
    margin-left: auto;
    font: 800 22px/1 Manrope, sans-serif;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-summary,
  .dashboard-week.is-week-carousel .dashboard-week-more {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
  }
  .dashboard-week.is-week-carousel .dashboard-week-day.is-active .dashboard-week-summary,
  .dashboard-week.is-week-carousel .dashboard-week-day:not(.is-active) .dashboard-week-items,
  .dashboard-week.is-week-carousel .dashboard-week-day:not(.is-active) .dashboard-week-more {
    display: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-items {
    display: grid;
    gap: 5px;
    min-width: 0;
    min-height: 0;
    align-content: start;
  }
  .dashboard-week.is-week-carousel .dashboard-week-item.event {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name amount";
    align-items: center;
    gap: 2px 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 4px 8px;
    overflow: hidden;
    pointer-events: none;
    cursor: inherit;
    box-sizing: border-box;
  }
  .dashboard-week.is-week-carousel .dashboard-week-item .event-name {
    grid-area: name;
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    line-clamp: unset;
    line-height: 1.25;
    font-size: 13px;
    font-weight: 700;
  }
  .dashboard-week.is-week-carousel .dashboard-week-state {
    grid-area: state;
    font-size: 11px;
    font-weight: 700;
  }
  #dashboardWeek.is-week-carousel .dashboard-week-item.predicted .dashboard-week-state {
    display: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-item .event-amount {
    grid-area: amount;
    justify-self: end;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-net {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    font-size: 15px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .dashboard-week.is-week-carousel .dashboard-week-net.is-positive { color: #14543d; }
  .dashboard-week.is-week-carousel .dashboard-week-net.is-negative { color: #7a3b35; }
  body[data-theme="midnight"] .dashboard-week.is-week-carousel .dashboard-week-net.is-positive { color: #b7f0d4; }
  body[data-theme="midnight"] .dashboard-week.is-week-carousel .dashboard-week-net.is-negative { color: #ffc7bc; }
  .dashboard-week.is-week-carousel .dashboard-week-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    margin: 0;
    min-height: 0;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
  }
}
@media (max-width: 360px) {
  .dashboard-week.is-week-carousel .dashboard-week-head h2 {
    font-size: 18px;
  }
  .dashboard-week.is-week-carousel .dashboard-week-open-full {
    display: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-open-short {
    display: inline;
  }
}
@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .dashboard-week.is-week-carousel .dashboard-week-day {
    transition: none;
  }
  .dashboard-week.is-week-carousel .dashboard-week-grid {
    scroll-behavior: auto;
  }
}
