/* ===== Planner grid ====================================================== */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; padding-bottom: 4px; }
.input--search { width: auto; flex: 1 1 200px; min-height: 40px; padding: 6px 12px; }

.pgrid-wrap {
  position: relative;
  overflow: auto;
  max-height: min(72vh, 900px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(to right, var(--surface), var(--surface)) left / 0 100% no-repeat;
  overscroll-behavior-x: contain;
}
.pgrid-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pgrid-wrap::after {
  content: ""; position: sticky; display: block; right: 0; bottom: 0;
}
.pgrid-wrap.has-right { box-shadow: inset -14px 0 12px -12px rgba(17, 17, 16, 0.18); }
.pgrid-wrap.has-left.has-right { box-shadow: inset -14px 0 12px -12px rgba(17, 17, 16, 0.18); }

.pgrid {
  border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  min-width: 100%;
}
.pgrid th, .pgrid td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  height: 40px;
  background: var(--surface);
}
.pgrid thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  font-weight: 600; color: var(--ink-2);
  height: 44px;
}
.pgrid .pgrid__cat {
  position: sticky; left: 0; z-index: 2;
  min-width: 184px; max-width: 220px;
  padding: 0 10px;
  text-align: left; font-weight: 600; font-size: var(--fs-sm); color: var(--ink);
  box-shadow: 1px 0 0 var(--line-strong);
}
.pgrid thead .pgrid__cat { z-index: 4; font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.pgrid__catname { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pgrid__catname a { color: inherit; }
.pgrid__catname svg { flex: none; }
.pgrid .is-child .pgrid__cat { font-weight: 500; font-size: var(--fs-xs); padding-left: 26px; color: var(--ink-2); }
.pgrid .is-child td { background: var(--surface-2); }
.pgrid .is-archived .pgrid__cat { color: var(--ink-3); font-style: italic; }

.pgrid__budget { min-width: 88px; padding: 2px 8px !important; text-align: right; line-height: 1.25; }
.pgrid__budget span { display: block; font-weight: 600; }
.pgrid__budget small { display: block; font-size: 10.5px; }
.pgrid__budget .is-over { color: var(--over); font-weight: 700; }

.pgrid__day { min-width: 66px; text-align: center; line-height: 1.1; }
.pgrid__dnum { display: block; font-size: var(--fs-sm); color: var(--ink); }
.pgrid__dname { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 500; }
.pgrid .is-weekend { background: var(--surface-sunken); }
.pgrid thead .is-weekend { background: var(--surface-sunken); }
.pgrid thead .is-today { background: var(--accent); }
.pgrid thead .is-today .pgrid__dnum, .pgrid thead .is-today .pgrid__dname { color: #fff; }
.pgrid td.is-today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }

.pgrid__cell { text-align: right; }
.pgrid__link {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 1px;
  width: 100%; height: 100%; min-height: 40px;
  padding: 3px 7px;
  color: var(--ink); text-decoration: none;
  position: relative;
}
.pgrid__link:hover { background: var(--accent-soft); }
.pgrid__link:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 0; background: var(--accent-soft); }
.pgrid__link:empty::after, .pgrid__link:not(:has(span))::after { content: "+"; color: transparent; font-size: 14px; }
.pgrid__link:hover:not(:has(span))::after { color: var(--accent-ink); }

.pgrid__plan { color: var(--ink); white-space: nowrap; }
.pgrid__fact { color: var(--fact); white-space: nowrap; font-weight: 600; }
.pgrid__tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; margin-right: 2px; opacity: 0.8; }
.pgrid--both .pgrid__plan { color: var(--plan); }
/* Overspending is a monthly signal of the category, shown with the row total – never in a day cell. */
.pgrid__over { color: var(--over); font-size: 11px; font-weight: 700; white-space: nowrap; }
.pgrid__flag {
  position: absolute; left: 4px; bottom: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--pending-mark); color: #3a2600;
  font-size: 10px; font-weight: 800; line-height: 13px; text-align: center;
}
.pgrid__muted { color: var(--ink-3); font-size: 10px; }
.is-neg { color: var(--over) !important; }

.pgrid__total {
  position: sticky; right: 0; z-index: 1;
  min-width: 108px; padding: 2px 10px !important;
  text-align: right; font-weight: 700;
  background: var(--surface-2) !important;
  box-shadow: -1px 0 0 var(--line-strong);
}
.pgrid__total > span { display: block; }
.pgrid thead .pgrid__total { z-index: 4; }

.pgrid__section th {
  height: 28px !important;
  background: var(--surface-sunken) !important;
  text-align: left; padding: 0 !important;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
}
.pgrid__section th span { position: sticky; left: 0; display: inline-block; padding: 0 10px; }

.pgrid tfoot th, .pgrid tfoot td { background: var(--surface-2); font-weight: 700; }
.pgrid tfoot .pgrid__cell { padding: 3px 7px; }
.pgrid tfoot .pgrid__cell > span { display: block; }
.pgrid__summary--net th, .pgrid__summary--net td { border-top: 2px solid var(--line-strong); }

.pgrid__legend { margin: 10px 0 0; line-height: 1.8; }
.pgrid__flag-inline { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: var(--pending-mark); color: #3a2600; font-size: 10px; font-weight: 800; line-height: 13px; text-align: center; }
.is-over-sample { color: var(--over); font-weight: 600; }

/* ===== Day cards (narrow screens) ======================================= */
.daycards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.daycard { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.daycard.is-weekend { background: var(--surface-2); }
.daycard.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.daycard__head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; min-height: 44px; }
.daycard__date { margin-right: auto; font-size: var(--fs-sm); color: var(--ink-2); }
.daycard__date strong { font-size: var(--fs-md); color: var(--ink); margin-right: 4px; }
.daycard__sum { font-size: var(--fs-sm); font-weight: 600; }
.daycard.is-empty .daycard__head { min-height: 40px; }
.daycard__list { list-style: none; margin: 0; padding: 0 12px 8px; display: grid; gap: 2px; }
.daycard__entry { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 0; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); }
.daycard__title { margin-right: auto; min-width: 0; display: grid; font-size: var(--fs-sm); font-weight: 600; }
.daycard__title small { font-weight: 400; color: var(--ink-3); font-size: var(--fs-xs); }
.is-income { color: var(--fact); }

/* Table on wide screens, day cards on phones and tablets: below 1024 px the
   table shows about five days and scrolls sideways (audit M-13). */
.planner-view--days { display: none; }
@media (max-width: 1023px) {
  .planner-view--table { display: none; }
  .planner-view--days { display: block; }
}

.pay-form { display: inline-block; }
.pay-form[open] { display: block; flex-basis: 100%; }
.pay-form > summary { list-style: none; }
.pay-form > summary::-webkit-details-marker { display: none; }
.pay-form[open] > summary { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.pay-form__body { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.entry__actions { align-items: flex-start; }
.drawer__titles { margin-right: auto; min-width: 0; }
.drawer__titles p { margin: 0; }
