:root {
  --quids-tech-blue: #0059B1;
  --quids-burnt-rose: #904E55;
  --quids-sand: #BFB48F;
  --quids-parchment: #F2EFE9;
  --quids-ink: #04080F;

  --bs-primary: var(--quids-tech-blue);
  --bs-primary-rgb: 0, 89, 177;
  --bs-link-color: var(--quids-tech-blue);
  --bs-link-color-rgb: 0, 89, 177;
  --bs-link-hover-color: #00417f;
  --bs-danger: var(--quids-burnt-rose);
  --bs-danger-rgb: 144, 78, 85;
  --bs-body-bg: var(--quids-parchment);
  --bs-body-color: var(--quids-ink);

  /* A distinct surface colour for cards/tables/panels so they visually separate from the
     page background instead of blending into it, previously both used --bs-body-bg, so
     there was nothing for the (barely-tinted) Parchment page to contrast against. */
  --quids-surface: #faf8f3;
  --bs-border-color: rgba(4, 8, 15, 0.18);
  --bs-border-color-translucent: rgba(4, 8, 15, 0.18);

  /* Sharp corners throughout, pills included (circular avatars/icon buttons still use 50%,
     that's a shape, not a corner radius, so it's untouched). */
  --bs-border-radius: 4px;
  --bs-border-radius-sm: 4px;
  --bs-border-radius-lg: 4px;
  --bs-border-radius-xl: 4px;
  --bs-border-radius-xxl: 4px;
  --bs-border-radius-2xl: 4px;
  --bs-border-radius-pill: 4px; /* Bootstrap's own .rounded-pill/.badge utility */

  font-size: 14px;
}

[data-bs-theme="dark"] {
  --bs-primary: #4d8fd6;
  --bs-primary-rgb: 77, 143, 214;
  --bs-link-color: #7fb1e6;
  --bs-link-color-rgb: 127, 177, 230;
  --bs-link-hover-color: #a4c8ef;
  --bs-danger: #c47b83;
  --bs-danger-rgb: 196, 123, 131;
  --bs-body-bg: var(--quids-ink);
  --bs-body-color: var(--quids-parchment);

  --quids-surface: #10161f;
  --bs-border-color: rgba(242, 239, 233, 0.18);
  --bs-border-color-translucent: rgba(242, 239, 233, 0.18);
}

@media (min-width: 768px) {
  :root {
    font-size: 16px;
  }
}

body {
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin-bottom: 60px;
  /* Digits line up in columns almost everywhere in Quids (tables, stat cards, charts), so this
     is set broadly rather than scoped to individual number-bearing elements. */
  font-variant-numeric: tabular-nums;
}

/* Lighter, smaller currency symbol ahead of every amount, wraps just the "&pound;" so the
   figure itself keeps its own weight/size/colour. */
.quids-currency-symbol {
  font-weight: 400;
  font-size: 0.8em;
  opacity: 0.65;
}

/* Bootstrap's own .container caps at 1320px even on very wide monitors, leaving a lot of unused
   margin either side, the data tables (particularly the Tags column) benefit from the extra
   room, so give it more at the widest breakpoint. Every narrower breakpoint is untouched. */
@media (min-width: 1400px) {
  .container {
    max-width: 1600px;
  }
}

/* .navbar-brand is in this list for any text that isn't the nav logo itself, the logo's own
   <text> element (Pages/Shared/_Layout.cshtml, and the standalone files under wwwroot/images/Quids
   Logo/) sets its own font-family directly as an SVG presentation attribute, which always wins
   over this rule regardless of what it says, so the two are kept in sync by hand, not by this
   selector, if this ever changes again without the logo files changing too, that's fine, they'll
   just diverge on purpose rather than silently. */
h1, h2, h3, h4, h5, h6, .navbar-brand {
  font-family: "Unbounded", "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--bs-body-bg), 0 0 0 0.25rem var(--quids-tech-blue);
}

html {
  position: relative;
  min-height: 100%;
  /* Bootstrap hides the scrollbar while a modal is open, which widens the page and shifts it sideways. Reserving the gutter up front stops that. */
  scrollbar-gutter: stable;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ---- Bootstrap button-color overrides ----
   Bootstrap's compiled CSS hardcodes each .btn-* variant's colors as its own
   --bs-btn-* custom properties (e.g. .btn-primary sets --bs-btn-bg: #0d6efd
   directly) rather than deriving them from the root --bs-primary/--bs-danger
   variables above, so those root overrides alone never reach real buttons,
   every variant needs its own override here. .btn-success is deliberately left
   at Bootstrap's default green, "paid/confirmed" reads as a status colour
   (green = good, like the win/loss accent this table styling is modelled on),
   not a brand action colour, so it stays outside the 5-colour brand palette. */

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--quids-tech-blue);
  --bs-btn-border-color: var(--quids-tech-blue);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #00417f;
  --bs-btn-hover-border-color: #00417f;
  --bs-btn-focus-shadow-rgb: 0, 89, 177;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #003666;
  --bs-btn-active-border-color: #003666;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--quids-tech-blue);
  --bs-btn-disabled-border-color: var(--quids-tech-blue);
}

.btn-outline-primary {
  --bs-btn-color: var(--quids-tech-blue);
  --bs-btn-border-color: var(--quids-tech-blue);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--quids-tech-blue);
  --bs-btn-hover-border-color: var(--quids-tech-blue);
  --bs-btn-focus-shadow-rgb: 0, 89, 177;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--quids-tech-blue);
  --bs-btn-active-border-color: var(--quids-tech-blue);
  --bs-btn-disabled-color: var(--quids-tech-blue);
  --bs-btn-disabled-border-color: var(--quids-tech-blue);
}

.btn-danger, .btn-outline-danger {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--quids-burnt-rose);
  --bs-btn-border-color: var(--quids-burnt-rose);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #7a4248;
  --bs-btn-hover-border-color: #7a4248;
  --bs-btn-focus-shadow-rgb: 144, 78, 85;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #6c3b40;
  --bs-btn-active-border-color: #6c3b40;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--quids-burnt-rose);
  --bs-btn-disabled-border-color: var(--quids-burnt-rose);
}
.btn-outline-danger {
  --bs-btn-color: var(--quids-burnt-rose);
  --bs-btn-bg: transparent;
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-color: var(--quids-burnt-rose);
}

.form-check-input:checked {
  background-color: var(--quids-tech-blue);
  border-color: var(--quids-tech-blue);
}
.form-check-input:focus {
  border-color: var(--quids-tech-blue);
  box-shadow: 0 0 0 0.25rem rgba(0, 89, 177, 0.25);
}

/* ---- Quids-specific components ---- */

.quids-auth-wrap {
  display: flex;
  justify-content: center;
  padding: 4rem 1rem;
}

.quids-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--quids-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.quids-auth-logo {
  display: block;
  margin: 0 auto 1.5rem;
  max-width: 160px;
  height: auto;
}

.quids-form {
  max-width: 480px;
}

.quids-alert-warning {
  background-color: rgba(191, 180, 143, 0.25);
  border: 1px solid var(--quids-sand);
  color: var(--bs-body-color);
}

/* Small inline info-icon tooltip trigger, e.g. next to a checkbox label needing a short explainer. */
.quids-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0;
  margin-left: 0.35rem;
  color: var(--bs-secondary-color);
  cursor: help;
  vertical-align: middle;
}
.quids-info-icon:hover,
.quids-info-icon:focus {
  color: var(--bs-body-color);
}

/* ---- Nav layout: left-aligned links (right after the logo), actions pinned far right ----
   .quids-navbar-collapse already spans the full remaining row at sm+ (Bootstrap's base
   .navbar-collapse rule sets flex-grow: 1, the expand-breakpoint override only touches
   flex-basis), so margin-left: auto on the actions group is enough to reach the real right
   edge without fighting Bootstrap's own flex layout. */
@media (min-width: 576px) {
  .quids-navbar-actions {
    margin-left: auto;
  }
}

/* Current-page indicator: a Tech Blue underline, not a background/colour change, so it reads
   as "you are here" without competing with the active-widget/active-tab treatment used
   elsewhere. var(--quids-tech-blue) directly (not --bs-primary), same reasoning as the
   initials badge, this should stay the true brand blue in both themes. */
.quids-navbar-links .nav-link.active {
  position: relative;
  color: var(--bs-body-color);
}
.quids-navbar-links .nav-link.active::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: -0.15rem;
  height: 2px;
  background: var(--quids-tech-blue);
  border-radius: 2px;
}

/* ---- Live password requirements checklist ---- */

.quids-password-requirements [data-rule] {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--bs-secondary-color);
  transition: color 0.15s ease;
}

.quids-req-icon {
  display: inline-flex;
  width: 1em;
  justify-content: center;
}
.quids-req-icon::before {
  content: "\2022"; /* bullet, unmet */
}

.quids-password-requirements [data-rule].quids-req-met {
  color: var(--bs-success);
}
.quids-password-requirements [data-rule].quids-req-met .quids-req-icon::before {
  content: "\2713"; /* checkmark, met */
}

/* Sits above the FAB's resting position (1.5rem + 56px + breathing room) so a toast
   never stacks on top of the quick-add button, both live bottom-right. */
.quids-toast-container {
  bottom: 6.5rem;
}

/* ---- Nav username menu ----
   Given its own background/border/text colour rather than relying on the navbar's own
   light/dark theming, which wasn't tracking the page theme toggle correctly and read as
   low-contrast in dark mode. */
.quids-user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem 0.25rem 0.25rem; /* tighter now it wraps a circular badge, not a name */
  border-radius: 4px;
  border: 1px solid var(--bs-border-color);
  background-color: rgba(127, 127, 127, 0.1);
  color: var(--bs-body-color) !important;
}
.quids-user-menu-toggle:hover,
.quids-user-menu-toggle:focus {
  background-color: rgba(127, 127, 127, 0.18);
  color: var(--bs-body-color) !important;
}

/* Initials avatar, replaces the plain display-name text in the nav. */
.quids-user-initials-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  /* Always the true brand Tech Blue, not --bs-primary (which lightens in dark mode for button/
     link contrast), the nav logo next to it hardcodes the same #0059B1 regardless of theme, so
     this stays locked to it rather than drifting apart in dark mode. */
  background: var(--quids-tech-blue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* ---- Hold-to-delete button (site.js initHoldToDelete) ----
   The progress "fill" is a separate absolutely-positioned child (.quids-hold-delete-fill),
   not the button's own background, a previous attempt at this exact pattern had the fill
   done via the button's background-color, and Bootstrap's/this stylesheet's own :hover/:active/
   :focus rules kept repainting that background mid-hold, killing the animation. Locking every
   interactive state's background/border/color to the same fixed values (via !important) means
   nothing but JS explicitly setting the fill element's width can ever change how this looks. */
.quids-hold-delete {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--quids-burnt-rose);
  background: var(--quids-burnt-rose);
  color: #fff;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.quids-hold-delete,
.quids-hold-delete:hover,
.quids-hold-delete:focus,
.quids-hold-delete:focus-visible,
.quids-hold-delete:active {
  background: var(--quids-burnt-rose) !important;
  border-color: var(--quids-burnt-rose) !important;
  color: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}
.quids-hold-delete-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.35);
  z-index: 0;
  pointer-events: none;
}
.quids-hold-delete-label {
  position: relative;
  z-index: 1;
}

/* ---- Settings: sections instead of boxed cards ----
   Plain full-width sections separated by a divider, rather than narrow max-width cards that
   clump to the left of the page on wide viewports. */
.quids-settings-section {
  padding: 1.5rem 0;
}
.quids-settings-section:first-child {
  padding-top: 0;
}
.quids-settings-section + .quids-settings-section {
  border-top: 1px solid var(--bs-border-color);
}
.quids-settings-section .quids-form,
.quids-settings-section form {
  max-width: 480px;
}

/* ---- Settings: section list on the left, the chosen section on the right ----
   Below md the page is only the list (each link opens its own screen), so the chevron shows there
   and nothing is marked active. */
.quids-settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem;
}
.quids-settings-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  color: var(--bs-body-color);
  text-decoration: none;
}
.quids-settings-nav-icon {
  width: 1.1rem;
  text-align: center;
  color: var(--bs-secondary-color);
}
.quids-settings-nav-chev {
  margin-left: auto;
  color: var(--bs-secondary-color);
}
@media (min-width: 768px) {
  .quids-settings-nav-chev {
    display: none;
  }
  .quids-settings-nav a.active {
    background: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
    font-weight: 600;
  }
  .quids-settings-nav a.active .quids-settings-nav-icon {
    color: var(--bs-primary);
  }
}
.quids-settings-back {
  display: inline-block;
  margin-bottom: 0.75rem;
  text-decoration: none;
}
.quids-settings-body {
  max-width: 640px;
}

/* ---- Admin > Users ---- */
.quids-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}
.quids-badge-free,
.quids-badge-quiet {
  border: 1px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
}
.quids-badge-premium {
  background: rgba(var(--bs-primary-rgb), 0.14);
  color: var(--bs-primary);
}
.quids-badge-comp {
  background: var(--quids-sand);
  color: var(--quids-ink);
}
.quids-badge-alert {
  background: var(--quids-burnt-rose);
  color: #fff;
}
.quids-admin-user {
  align-items: flex-start;
}
.quids-admin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.quids-admin-menu-toggle {
  color: var(--bs-secondary-color);
}
.quids-admin-facts dt {
  color: var(--bs-secondary-color);
  font-weight: 400;
}
@media (min-width: 992px) {
  .quids-admin-user {
    cursor: pointer;
  }
  .quids-admin-user.is-selected {
    background: rgba(var(--bs-primary-rgb), 0.1);
    box-shadow: inset 3px 0 0 var(--bs-primary);
  }
}

/* ---- Admin > Households: a card each on a phone, only the chosen one beside the list on a PC ---- */
@media (min-width: 992px) {
  .quids-admin-household-detail:not(.is-selected) {
    display: none;
  }
}

/* ---- Admin > Logs ---- */
.quids-logs-table td,
.quids-logs-table th {
  padding: 0.45rem 0.75rem;
  white-space: nowrap;
}
.quids-logs-table td.quids-log-summary {
  white-space: normal;
  min-width: 14rem;
}
.quids-log-id {
  font-family: var(--bs-font-monospace);
  font-size: 0.8rem;
}
.quids-code-block {
  background: var(--quids-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  padding: 0.75rem;
  margin: 0;
  max-height: 16rem;
  overflow: auto;
  font-size: 0.8rem;
}

/* ---- Global loading overlay (site.js quidsShowLoading/quidsHideLoading) ----
   Above modals (Bootstrap's .modal is 1055) and toasts, so it can block the whole screen even
   mid-modal (e.g. a hold-to-delete button inside one). The three arcs share the exact three
   colours the Q in the navbar logo is built from, the same brand mark, just spun into a
   loading indicator instead of the static wordmark. */
.quids-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 15, 0.5);
  z-index: 1090;
}
.quids-loading-overlay.quids-loading-visible {
  display: flex;
}
.quids-loading-spinner {
  width: 64px;
  height: 64px;
  animation: quids-spin 1s linear infinite;
}
@keyframes quids-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Muted helper text, section intros, empty states, card sub-labels, inline "Currently £X"
   lines. One class so there's a single place to tune it and one thing to grep for. */
.quids-muted {
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

/* Modal forms (.quids-form) read the field's own `required` attribute; other forms need `is-required` on the label. */
.form-label.is-required::after,
.form-check-label.is-required::after,
.quids-form .form-label:has(+ input[required], + select[required], + textarea[required])::after {
  content: " *";
  color: var(--bs-danger);
}

/* ---- Templates page: panels, badge and the add-item row ---- */
.quids-panel {
  background: var(--quids-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1rem;
}
.quids-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.quids-panel-body {
  padding: 1rem;
}

.quids-add-row {
  background: rgba(127, 127, 127, 0.1);
}
.quids-due-input {
  width: 6rem;
}
.quids-amount-input {
  width: 8rem;
}
/* A form that sits in a full-width panel rather than a narrow card, so it should use the panel's width. */
.quids-form.quids-form-wide {
  max-width: none;
}

/* Cells that can be edited in place: a pencil marks them, and a click swaps in an input. */
.quids-edit-cell {
  cursor: text;
}
.quids-edit-cell:hover,
.quids-edit-cell:focus-visible {
  background: rgba(127, 127, 127, 0.08);
}
.quids-edit-icon {
  font-size: 0.7rem;
  margin-left: 0.4rem;
  color: var(--bs-secondary-color);
  opacity: 0.6;
}
.quids-edit-cell:hover .quids-edit-icon {
  opacity: 1;
}
.quids-edit-cell.is-editing {
  cursor: auto;
  background: transparent;
}

/* ---- Create Budget: the tick-list ---- */
.quids-create-budget {
  max-width: 900px;
}
.quids-tick-group {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  padding: 0.5rem 1rem;
  background: rgba(127, 127, 127, 0.08);
  border-bottom: 1px solid var(--bs-border-color);
}
.quids-tick-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.quids-tick-row:last-child {
  border-bottom: 0;
}
.quids-tick-row .form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex-shrink: 0;
}
.quids-tick-row label {
  cursor: pointer;
  min-width: 0;
}
.quids-tick-overdue {
  box-shadow: inset 3px 0 0 var(--quids-burnt-rose);
}

.quids-edit-text {
  position: relative;
  display: inline-block;
}
.quids-edit-extras {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  margin-left: 0.4rem;
}
.quids-edit-extras .quids-edit-icon {
  margin-left: 0;
}

/* The template editor's item list: the same rows as the Budget list, with its own column widths. The pencil hangs
   off the right of a value, so right-aligned columns leave room for it. */
.quids-tpl-due {
  width: 6.5rem;
  flex-shrink: 0;
  color: var(--bs-secondary-color);
}
.quids-tpl-amount {
  width: 8.5rem;
  flex-shrink: 0;
  padding-right: 1.4rem;
  text-align: right;
}
.quids-tpl-override {
  width: 14rem;
  flex-shrink: 0;
  padding-right: 3rem;
  text-align: right;
}
.quids-item-head .quids-tpl-override {
  white-space: nowrap;
}
.quids-tpl-actions {
  width: 2.5rem;
  flex-shrink: 0;
  text-align: right;
}
/* Boxes fill their column, so the add row and the in-place editors line up with the headings and never run into the
   next column. The generic .quids-due-input and .quids-amount-input widths are for other pages. */
.quids-tpl-due .form-control,
.quids-tpl-amount .form-control,
.quids-tpl-override .form-control {
  width: 100%;
  min-width: 0;
}
.quids-item-main > .quids-edit-cell {
  display: inline-block;
  max-width: 100%;
}
.quids-item-main > .quids-edit-cell.is-editing {
  display: block;
}
/* Below the medium width the due day and override take a line of their own under the row, two equal cells each with a
   small heading above its value, so they have the whole width instead of squeezing beside the name. */
@media (max-width: 767.98px) {
  .quids-tpl-row {
    flex-wrap: wrap;
  }
}
.quids-tpl-small {
  display: flex;
  flex: 1 1 100%;
  gap: 0.75rem;
  font-size: 0.85rem;
}
@media (max-width: 575.98px) {
  .quids-tpl-small {
    gap: 0.5rem;
  }
}
.quids-tpl-small::after {
  content: "";
  flex: 0 0 2.5rem; /* the width of the delete column above, so Override lines up under the amount */
}
.quids-tpl-small-cell {
  flex: 1 1 0;
  min-width: 0;
}
.quids-tpl-small-override {
  flex: 0 0 7rem; /* the width of the amount column above */
  text-align: right;
}
.quids-tpl-small-override > .quids-muted {
  padding-right: 1.5rem;
}
/* A small heading above each value, like the labels on the Budget page's cards. */
.quids-tpl-small-cell > .quids-muted {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quids-tpl-small-cell .quids-edit-cell:not(.is-editing) {
  display: inline-block;
  margin-right: 1.5rem; /* room for the pencil that hangs off the value */
  color: var(--bs-body-color);
}
.quids-tpl-small-cell .form-control {
  display: inline-block;
  width: 6.5rem;
}
.quids-add-row .quids-tpl-amount,
.quids-add-row .quids-tpl-due {
  padding-right: 0;
}
.quids-add-row .quids-tpl-actions {
  text-align: right;
}

/* ---- Budget page: balance and Disposable Income cards, item rows, pills ---- */
.quids-card-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.4rem;
}
.quids-big {
  font-family: "Unbounded", "Instrument Sans", sans-serif;
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--bs-primary);
}
.quids-big.quids-big-neg {
  color: var(--quids-burnt-rose);
}
.quids-balance-group {
  max-width: 24rem;
}

.quids-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
/* Column headings for the row's controls, so a phone user can tell what each icon is for. The cells reuse the row's own
   classes, so their widths line up with the rows below. */
.quids-oneoff-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--quids-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.quids-oneoff-form .js-oneoff-name {
  flex: 1 1 12rem;
  width: auto;
}
.quids-oneoff-form .quids-oneoff-amount {
  width: 9rem;
}
.quids-oneoff-form .quids-oneoff-date {
  width: 10rem;
}
.quids-oneoff-modal-form .quids-oneoff-amount,
.quids-oneoff-modal-form .quids-oneoff-date {
  width: 100%;
}
.quids-oneoff-target .btn {
  white-space: nowrap;
}

/* The pool of one-offs waiting for the next budget: the name, amount and delete icon on a line, the date under the name,
   because the side column is too narrow for all of them side by side. */
.quids-pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "name amount delete"
    "date date date";
  align-items: center;
  column-gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.quids-pool-row:last-child {
  border-bottom: 0;
}
.quids-pool-name {
  grid-area: name;
  min-width: 0;
  padding-right: 1.4rem; /* room for the pencil that hangs off the value */
}
.quids-pool-date {
  grid-area: date;
  justify-self: start;
  padding-right: 1.4rem;
  color: var(--bs-secondary-color);
  font-size: 0.85rem;
}
.quids-pool-amount {
  grid-area: amount;
  padding-right: 1.4rem;
  text-align: right;
}
.quids-pool-row .js-pool-delete {
  grid-area: delete;
}
.quids-pool-name.is-editing,
.quids-pool-date.is-editing,
.quids-pool-amount.is-editing {
  padding-right: 0;
}
.quids-pool-amount.is-editing {
  width: 7rem;
}

.quids-item-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
}
.quids-item-head .quids-item-due {
  font-size: inherit;
}

/* Search box, sortable headings and page controls shared by the item lists. */
.quids-list-tools {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.quids-list-search {
  max-width: 18rem;
}
.quids-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.quids-sort i {
  font-size: 0.8em;
  opacity: 0.45;
}
.quids-sort.is-sorted i {
  opacity: 1;
}
.quids-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--bs-border-color);
}
.quids-pager:empty {
  display: none;
}
.quids-pager-size {
  width: auto;
}
@media (max-width: 575.98px) {
  .quids-item-head {
    gap: 0.5rem;
  }
}

.quids-item-row:last-child {
  border-bottom: 0;
}
.quids-item-main {
  flex: 1;
  min-width: 0;
}
.quids-item-name {
  margin-right: 0.25rem;
}
.quids-item-due {
  width: 4.5rem;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}
.quids-item-due-small {
  display: block;
  font-size: 0.8rem;
}
.quids-item-due.is-editing,
.quids-item-due-small.is-editing {
  width: auto;
}
.quids-due-input {
  width: 9.5rem;
}
.quids-item-amount {
  min-width: 5.5rem;
  padding-right: 1.4rem; /* room for the pencil that hangs off the right of the figure */
  text-align: right;
}
.quids-item-tick {
  min-width: 2.25rem; /* the Paid button, or the undo that replaces it, so every row lines up */
  text-align: right;
  flex-shrink: 0;
}
.quids-item-action {
  min-width: 5rem; /* room for the Partial and Skip icon buttons, so a row with fewer still lines up */
  text-align: center; /* the heading sits over the middle of the icons */
  flex-shrink: 0;
  white-space: nowrap;
}

/* Linked budgets: the chip on a parent line, the strip on a linked budget's page, and the third row action. */
.quids-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.6rem;
  border: 1px solid var(--bs-primary-border-subtle);
  border-radius: 999px;
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  vertical-align: middle;
}
.quids-item-chip {
  display: none;
}
.quids-item-row[data-linked-budget] .quids-item-chip {
  display: inline-flex;
}
.quids-link-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}
.quids-link-bar {
  flex: 1 1 8rem;
  min-width: 6rem;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bs-secondary-bg);
}
.quids-link-bar > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--bs-success);
}
.quids-link-figure {
  color: var(--bs-body-color);
}
a.quids-chip:hover {
  border-color: var(--bs-primary);
  color: var(--bs-primary-text-emphasis);
  text-decoration: underline;
}
.quids-link-note {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bs-primary-border-subtle);
  border-radius: 4px;
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}
.quids-switch-linked {
  padding-left: 1.75rem;
}
.js-item-link {
  display: none;
}
.quids-can-link .js-item-link {
  display: inline-block;
}
.quids-can-link .quids-item-action {
  min-width: 7.5rem; /* the third icon button, so every row and the heading still line up */
}
.quids-can-link .js-item-skip {
  margin-right: 0.25rem;
}

/* The prompt that offers the next budget once nothing is left unpaid. */
.quids-next-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bs-success-border-subtle);
  border-radius: 4px;
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}
.quids-next-banner.d-none {
  display: none;
}
.quids-next-banner-text {
  flex: 1 1 14rem;
}

/* History: the closed budgets list and one closed budget's items. */
.quids-hist-account {
  width: 9rem;
  flex-shrink: 0;
  color: var(--bs-secondary-color);
}
.quids-hist-date {
  width: 6.5rem;
  flex-shrink: 0;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}
.quids-hist-num {
  width: 3.5rem;
  flex-shrink: 0;
  text-align: right;
}
.quids-hist-chev {
  width: 1.5rem;
  flex-shrink: 0;
  text-align: right;
  color: var(--bs-secondary-color);
}
.quids-hist-status {
  width: 8.5rem;
  flex-shrink: 0;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}
.quids-item-head .quids-hist-date,
.quids-item-head .quids-hist-status {
  font-size: inherit;
}
@media (max-width: 575.98px) {
  .quids-hist-status {
    width: 5.5rem;
  }
}

/* Everything that depends on an item's state is driven by data-state on the row, so ticking only has to change that. */
/* Burnt rose in the light theme; --bs-danger is its lighter dark-theme twin, so it stays readable. */
.quids-still-to-pay {
  color: var(--bs-danger);
  font-size: 1.35rem;
  font-weight: 600;
}

.quids-pill {
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.quids-pill-overdue {
  background: var(--quids-burnt-rose);
  color: #fff;
}
.quids-pill-soon,
.quids-pill-today {
  background: var(--quids-sand);
  color: var(--quids-ink);
}
.quids-pill-skipped {
  background: var(--bs-secondary);
  color: #fff;
}
.quids-item-row[data-state="1"][data-overdue="1"] .quids-pill-overdue,
.quids-item-row[data-state="1"][data-soon="1"]:not([data-today="1"]) .quids-pill-soon,
.quids-item-row[data-state="1"][data-today="1"] .quids-pill-today,
.quids-item-row[data-state="3"] .quids-pill-skipped {
  display: inline-block;
}
.quids-item-row[data-state="1"][data-overdue="1"] {
  box-shadow: inset 3px 0 0 var(--quids-burnt-rose);
}
.quids-item-row[data-state="1"][data-soon="1"] {
  box-shadow: inset 3px 0 0 var(--quids-sand);
}
.quids-item-row[data-state="2"] {
  box-shadow: inset 3px 0 0 var(--bs-success);
}
.quids-item-row[data-state="3"] {
  box-shadow: inset 3px 0 0 var(--bs-secondary);
}
.quids-item-row .js-item-partial {
  margin-right: 0.25rem;
}
.quids-pill-partial {
  background: var(--quids-tech-blue);
  color: #fff;
}
.quids-item-row[data-partial="1"] .quids-pill-partial {
  display: inline-block;
}
.quids-partial-summary > div {
  padding-left: 0;
  padding-right: 0;
}
.quids-item-row[data-state="2"] .quids-item-name,
.quids-item-row[data-state="2"] .quids-item-amount {
  color: var(--bs-secondary-color);
  text-decoration: line-through;
}
.quids-item-row[data-state="3"] .quids-item-name,
.quids-item-row[data-state="3"] .quids-item-amount {
  color: var(--bs-secondary-color);
  font-style: italic;
}

/* The phone layout: the due date moves under the name, and the icon button stays to the right of the amount. */
@media (max-width: 575.98px) {
  .quids-item-row {
    gap: 0.5rem;
  }
}

.quids-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 1rem;
}
.quids-summary dt {
  font-weight: 400;
  color: var(--bs-secondary-color);
}
.quids-summary dd {
  margin: 0;
}

/* Rows of the Templates list open the template when clicked. */
.quids-list-row {
  cursor: pointer;
}
.quids-list-num,
.quids-list-money {
  width: 8.5rem;
  flex-shrink: 0;
}
.quids-list-money {
  text-align: right;
}
.quids-list-actions {
  width: 6.5rem;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}
.quids-list-row:hover {
  background: var(--bs-tertiary-bg);
}

/* ---- Phones (iPhone 16 Pro Max is 440 CSS pixels wide) ---- */

/* The theme toggle and the user's initials sit side by side in the menu, not stacked. */
.quids-navbar-actions > .navbar-nav {
  flex-direction: row;
  align-items: center;
}
.quids-navbar-actions .dropdown-menu {
  position: absolute;
}

/* A row of action buttons wraps rather than running past the edge of the screen. */
.quids-action-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 767.98px) {
  /* The add row wraps: the name takes a line to itself, then the day, the amount and the button share the next. */
  .quids-add-row {
    flex-wrap: wrap;
  }
  .quids-add-row .quids-item-main {
    flex: 1 1 100%;
  }
  .quids-add-row .quids-tpl-due,
  .quids-add-row .quids-tpl-amount {
    flex: 1 1 0;
    width: auto;
  }
  .quids-add-row .quids-due-input,
  .quids-add-row .quids-amount-input {
    width: 100%;
    min-width: 0;
  }
  .quids-tpl-amount {
    width: 7rem;
  }
}

/* A safety net: nothing may make the page wider than the screen, which on a phone makes the whole
   page zoom out and slide sideways. */
html,
body {
  overflow-x: clip;
}

/* In the collapsed menu, the theme toggle and initials sit apart from the links above them. */
@media (max-width: 575.98px) {
  .quids-navbar-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
  }
}

/* In the collapsed menu the initials sit at the left, so the user menu opens rightwards from them;
   Bootstrap's right-aligned menu would run off the left edge of the screen. */
@media (max-width: 575.98px) {
  .quids-navbar-actions .dropdown-menu-end[data-bs-popper] {
    left: 0;
    right: auto;
  }
}
