/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  padding: 0;
  margin: 0;
  /* A column, so the footer stays at the bottom of the screen on short pages */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* The same 1.5rem on every side: below the header, beside the content and
   above the footer (1rem on tablets and phones, see the media queries) */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* The page's last box keeps no margin of its own, so the space above the
   footer is the container's alone */
.container > :last-child,
.dashboard > :last-child {
  margin-bottom: 0;
}

/* Footer */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.5rem;
  width: 100%;
  max-width: 1440px;
  margin: auto auto 0;
  padding: 1.25rem 1rem 1.5rem;
  border-top: 1px solid #e4e4e4;
  color: #666;
  font-size: 0.85rem;
  text-align: center;
}

.site-footer a {
  color: #5a67d8;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Header */
.header {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  /* The same side space as the page, so the logo lines up with the content */
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Logo plus the signed-in family's name */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

/* The family badge links to My Families. ".header .family-name" outranks the
   generic ".header a" rules (background: none, full width on mobile). */
.header .family-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.75rem 0.35rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  width: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.header .family-name .icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.header .family-name:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* The family switcher: the badge opens a compact card under it, in the
   account menu's style (layouts/_family_switcher) */
.family-switcher {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.header .family-switcher > .family-name {
  list-style: none;
  cursor: pointer;
  color: white;
}

.family-switcher > .family-name::-webkit-details-marker {
  display: none;
}

.header .family-switcher > .family-name .icon {
  transition: transform 0.2s;
}

.header .family-switcher[open] > .family-name {
  background: rgba(255, 255, 255, 0.3);
}

.header .family-switcher[open] > .family-name .icon {
  transform: rotate(180deg);
}

.family-switcher > .family-name:focus-visible {
  outline: 2px solid white;
  outline-offset: 3px;
}

.family-switcher-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 1000;
  width: min(290px, calc(100vw - 24px));
  padding: 0.5rem;
  border: 1px solid #e6e7f1;
  border-radius: 16px;
  background: #f6f7fb;
  color: #1f2340;
  box-shadow: 0 20px 50px rgba(31, 35, 64, 0.2), 0 4px 12px rgba(31, 35, 64, 0.08);
  animation: user-menu-in 0.16s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .family-switcher-panel { animation: none; }
}

.family-switcher-label {
  display: block;
  padding: 0.35rem 0.6rem 0.45rem;
  color: #626982;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.family-switcher-list {
  display: grid;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.family-switcher-form {
  display: block;
}

/* ".header ..." outranks the white header link and button rules */
.header .family-switcher-item,
.header .family-switcher-more {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 11px;
  background: none;
  color: #1f2340;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s;
}

.family-switcher-item .avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.78rem;
}

.family-switcher-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.family-switcher-text strong {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.family-switcher-text small {
  overflow: hidden;
  color: #6b7090;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header .family-switcher-current {
  background: white;
  box-shadow: inset 0 0 0 1px #e3e6f6;
  cursor: default;
}

.family-switcher-check {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
}

.family-switcher-item > .icon,
.family-switcher-more > .icon {
  flex-shrink: 0;
  color: #a3a7bd;
  transition: transform 0.15s, color 0.15s;
}

.header button.family-switcher-item:hover,
.header button.family-switcher-item:focus-visible,
.header .family-switcher-more:hover,
.header .family-switcher-more:focus-visible {
  background-color: white;
  outline: none;
}

.header button.family-switcher-item:focus-visible,
.header .family-switcher-more:focus-visible {
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.45);
}

.header button.family-switcher-item:hover > .icon,
.header .family-switcher-more:hover > .icon {
  color: #5a67d8;
  transform: translateX(2px);
}

.header .family-switcher-more {
  margin-top: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px solid #e6e7f1;
  border-radius: 0 0 11px 11px;
}

.family-switcher-more-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #eceef6;
  border-radius: 10px;
  background: white;
  color: #5a67d8;
}

/* The title doubles as the link to the dashboard */
.header h1 a {
  padding: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 2px 8px rgba(40, 20, 90, 0.25);
}

.brand-logo img {
  display: block;
}

.header h1 a:hover {
  background-color: transparent;
  opacity: 0.85;
}

.header nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.header nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

.header nav a .icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.button_to {
  display: inline;
}

.header a,
.header .nav-button {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  transition: background-color 0.2s;
}

.header a:hover,
.header .nav-button:hover {
  background-color: rgba(255,255,255,0.2);
}

/* The section you're in */
.header nav a.nav-active {
  background-color: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), inset 0 -3px 0 rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

/* Laptops: the links without their icons, so they fit on one row */
@media (min-width: 769px) and (max-width: 1440px) {
  .header nav a .icon {
    display: none;
  }

  .header nav a {
    padding: 0.5rem 0.65rem;
  }
}

/* Tablets: the links on a row of their own under the logo and the avatar */
@media (min-width: 769px) and (max-width: 1100px) {
  .header-content {
    row-gap: 0.6rem;
  }

  .header .header-actions {
    order: 2;
    margin-left: auto;
  }

  .header nav {
    order: 3;
    flex-basis: 100%;
    justify-content: center;
    margin-left: 0;
  }
}

/* Phones only, and only once application.js has set it up */
.nav-toggle {
  display: none;
}

/* Links on the left of the avatar */
.header nav {
  margin-left: auto;
}

/* A person's initials in a coloured circle */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
}

.avatar-large {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.avatar-xl {
  width: 72px;
  height: 72px;
  font-size: 1.6rem;
}

/* The bell and the avatar, at the end of the header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

/* The account menu opened from the avatar */
.user-menu {
  position: relative;
}

/* The avatar with a chevron beside it */
.user-menu-button {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  border-radius: 999px;
  cursor: pointer;
}

.user-menu-button > .avatar {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.user-menu-button > .icon {
  opacity: 0.85;
  transition: transform 0.2s;
}

.user-menu[open] .user-menu-button > .icon {
  transform: rotate(180deg);
}

.user-menu-button::-webkit-details-marker {
  display: none;
}

.user-menu-button:hover > .avatar,
.user-menu[open] .user-menu-button > .avatar {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}

.user-menu-button:focus-visible {
  outline: 2px solid white;
  outline-offset: 3px;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 1000;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  border: 1px solid #e6e7f1;
  border-radius: 18px;
  background: #f6f7fb;
  color: #1f2340;
  box-shadow: 0 24px 60px rgba(31, 35, 64, 0.22), 0 4px 12px rgba(31, 35, 64, 0.08);
  animation: user-menu-in 0.16s ease-out;
}

@keyframes user-menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .user-menu-panel { animation: none; }
}

.avatar-menu {
  width: 60px;
  height: 60px;
  font-size: 1.3rem;
  box-shadow: 0 6px 16px rgba(31, 35, 64, 0.18);
}

.user-menu-person {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.25rem 1.25rem 1rem;
}

.user-menu-names {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.user-menu-names strong,
.user-menu-names small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-names strong {
  color: #1f2340;
  font-size: 1.1rem;
}

.user-menu-names small {
  color: #6b7090;
  font-size: 0.85rem;
}

.user-menu-role {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
  color: #5a67d8;
  font-size: 0.85rem;
  font-weight: 600;
}

/* The family you're working in */
.user-menu-family {
  margin: 0 1rem 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #eceef6;
  border-radius: 12px;
  background: white;
}

.user-menu-family small {
  display: block;
  margin-bottom: 0.3rem;
  color: #626982;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.user-menu-family div {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.user-menu-family div > .icon {
  flex-shrink: 0;
  color: #5a67d8;
}

.user-menu-family strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #1f2340;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-family-check {
  display: inline-flex;
  color: #15803d;
}

.user-menu-section {
  padding: 0.6rem;
  border-top: 1px solid #e6e7f1;
}

.user-menu-form {
  display: block;
}

/* ".header .user-menu-item" outranks the white header link rules */
.header .user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: none;
  border-radius: 12px;
  background: none;
  color: #1f2340;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s;
}

.header .user-menu-item:hover,
.header .user-menu-item:focus-visible {
  background-color: white;
  outline: none;
}

.header .user-menu-item:focus-visible {
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.45);
}

.user-menu-item-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #eceef6;
  border-radius: 11px;
  background: white;
  color: #555b78;
  transition: color 0.15s, background-color 0.15s;
}

.user-menu-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.user-menu-item-title {
  font-weight: 600;
}

.user-menu-item-text small {
  overflow: hidden;
  color: #6b7090;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-item > .icon {
  flex-shrink: 0;
  color: #a3a7bd;
  transition: transform 0.15s, color 0.15s;
}

.header .user-menu-item:hover > .icon {
  color: #5a67d8;
  transform: translateX(2px);
}

.header .user-menu-item:hover .user-menu-item-icon,
.header .user-menu-item-active .user-menu-item-icon {
  border-color: #dfe3fb;
  background: #eef0fd;
  color: #5a67d8;
}

.header .user-menu-item-active .user-menu-item-title {
  color: #5a67d8;
}

.header .user-menu-signout {
  color: #dc2626;
}

.user-menu-signout .user-menu-item-icon {
  border-color: #fbe1e6;
  background: #fdecef;
  color: #dc2626;
}

.header .user-menu-signout:hover {
  background: #fff5f7;
}

.header .user-menu-signout:hover .user-menu-item-icon {
  border-color: #f7c8d0;
  background: #fbdde3;
  color: #b91c1c;
}

/* Phones: a bit more room to tap, the same card under the header */
@media (max-width: 768px) {
  .user-menu-panel {
    width: calc(100vw - 24px);
  }

  .header .user-menu-item {
    padding: 0.65rem 0.6rem;
  }
}

/* Guidance boxes that fold away (details/summary) */
.foldable > summary {
  cursor: pointer;
  list-style: none;
}

.foldable > summary::-webkit-details-marker {
  display: none;
}

/* A chevron: points right when closed, down when open */
.foldable > summary::before {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin: 0 0.65em 0.12em 0.15em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.foldable[open] > summary::before {
  transform: rotate(45deg);
}

.foldable[open] > summary {
  margin-bottom: 0.5rem;
}

/* Forms */
.form-container {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-width: 600px;
  margin: 2rem auto;
}

.form-group {
  margin-bottom: 1.5rem;
}

/* inline-block keeps the required "*" next to its label; the full-width
   field below still starts on its own line */
.form-group label {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  /* Fields don't pick up the page font on their own (dates and notes showed
     in a typewriter font) */
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4f5fc5;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group .required {
  color: #e74c3c;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  /* <button>s (button_to) don't inherit these, so they'd sit shorter than links */
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-success:hover {
  background: #218838;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Table row actions as small icon buttons (view, edit, delete, locked) */
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.row-actions form {
  display: contents;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid #e2e4f0;
  border-radius: 6px;
  background: white;
  color: #5a67d8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: #f2f3fb;
  border-color: #c7cbef;
}

.icon-btn-danger {
  color: #dc3545;
}

.icon-btn-danger:hover,
.icon-btn-danger:focus-visible {
  background: #fdecee;
  border-color: #f3b8bf;
}

.icon-btn-locked,
.icon-btn-locked:hover {
  background: #f7f7f7;
  border-color: #eee;
  color: #999;
  cursor: help;
}

/* Hover text shown at once (application.js, handleTooltips) */
.tooltip {
  position: fixed;
  z-index: 1100;
  max-width: min(320px, calc(100vw - 16px));
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  background: #2d2f45;
  box-shadow: 0 6px 18px rgba(20, 20, 40, 0.25);
  color: white;
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.12s, transform 0.12s;
}

.tooltip-below {
  transform: translateY(-3px);
}

.tooltip-visible {
  opacity: 1;
  transform: none;
}

/* The little arrow pointing at what it describes */
.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--tooltip-arrow-x, 50%);
  border: 5px solid transparent;
  border-top-color: #2d2f45;
  transform: translateX(-50%);
}

.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #2d2f45;
}

@media (prefers-reduced-motion: reduce) {
  .tooltip {
    transition: none;
  }
}

/* A note cut short; hover shows the whole note */
.short-note {
  cursor: help;
  border-bottom: 1px dotted #bbb;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.alert-notice {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-alert {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  color: #666;
  font-size: 0.8rem;
}

/* Login and sign-up pages (the rest is under "Login and sign up" below) */
/* The sign up bot trap: off screen rather than display: none, which some
   bots look for */
.bot-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: #666;
}

.auth-switch a {
  color: #4f5fc5;
  font-weight: 500;
}

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.role-badge-head {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
}

.role-badge-admin {
  background: #e8ebfc;
  color: #4c5bd4;
}

.role-badge-viewer {
  background: #eee;
  color: #555;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge-active {
  background: #e3f6ec;
  color: #1e7b4d;
}

.status-badge-current {
  background: #e8ebfc;
  color: #4c5bd4;
}

.status-badge-revoked {
  background: #fde8ea;
  color: #b0263a;
}

.member-revoked td {
  color: #666;
}

.member-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Keep table action buttons compact on small screens (.btn goes full width there) */
.member-actions .btn {
  width: auto;
  white-space: nowrap;
  font-family: inherit;
  line-height: inherit;
}

.revoked-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
  color: white;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Owner console (/sekret) */
.role-badge-super-admin {
  background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
  color: #5a3d00;
  margin-left: 0.35rem;
}

.status-badge-left {
  background: #eee;
  color: #666;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid #e2e4f0;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.65rem 1.25rem;
  color: #666;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab:hover {
  color: #4f5fc5;
}

.tab-active {
  color: #4f5fc5;
  border-bottom-color: #4f5fc5;
}

.settings-card {
  padding: 0.5rem 1.5rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid #eee;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-text h4 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.setting-text p {
  color: #666;
  font-size: 0.9rem;
}

.setting-text .setting-note {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

.setting-text .setting-locked {
  font-size: 0.8rem;
  color: #b0263a;
  margin-top: 0.25rem;
}

/* On/off switch (a submit button, so it works without JavaScript) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0.25rem;
  white-space: nowrap;
}

.toggle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.toggle-track {
  position: relative;
  width: 3rem;
  height: 1.6rem;
  border-radius: 999px;
  background: #ccc;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.toggle-on .toggle-track {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.toggle-on .toggle-thumb {
  transform: translateX(1.4rem);
}

.toggle-label {
  min-width: 1.75rem;
  font-weight: 600;
  color: #555;
}

.toggle:focus-visible .toggle-track {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 2px;
}

.impersonate-button {
  margin-left: 0.35rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-family: inherit;
}

/* Shown on every page while the Super Admin is impersonating someone */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
  color: #5a3d00;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.impersonation-stop {
  background: #5a3d00;
  color: white;
  font-family: inherit;
  width: auto;
}

.impersonation-stop:hover {
  background: #3d2900;
}

.membership-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.alert-warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

/* Single-line form: fields side by side, wrapping on small screens */
.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: end;
}

.inline-form .form-group {
  margin-bottom: 0;
}

/* Keep the submit button the same height as the inputs beside it */
.inline-form .btn {
  line-height: 1.2;
}

.inline-form-submit .btn {
  width: 100%;
}

.amount-link {
  text-decoration: none;
}

.amount-link:hover {
  text-decoration: underline;
}

.loan-extension-row td {
  background: #fafafa;
  color: #666;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.loan-extension-row td:first-child {
  padding-left: 2rem;
}

/* Table */
.table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  /* Digits of one width, so amounts and dates line up down a column */
  font-variant-numeric: tabular-nums;
}

.stat-box .amount,
.balance-amount {
  font-variant-numeric: tabular-nums;
}

table th,
table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #555;
  position: sticky;
  top: 0;
}

table tr:hover {
  background-color: #f8f9fa;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
}

.badge-credit {
  background-color: #d4edda;
  color: #155724;
}

.badge-debit {
  background-color: #f8d7da;
  color: #721c24;
}

/* Filters */
.filters {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.filter-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border: 1px solid #667eea;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.25;
}

/* Outlined links; overrides .btn-secondary's grey so the text stays readable */
.pagination a {
  background: white;
  color: #4f5fc5;
}

.pagination a:hover {
  background: #667eea;
  color: white;
}

.pagination .current {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  border-color: transparent;
}

/* A list fetching its next page */
[data-ajax-pagination][aria-busy="true"] {
  opacity: 0.6;
  transition: opacity 0.15s;
}

/* Cards and stat boxes (the owner console) */
.report-card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
}

.report-card h3 {
  margin-bottom: 1rem;
  color: #333;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
}

.stat-box h4 {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.stat-box .amount {
  font-size: 2rem;
  font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .header {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header nav {
    width: 100%;
    flex-direction: column;
  }

  .header a {
    width: 100%;
    text-align: center;
  }

  /* With JavaScript: one compact row, the links folded behind Menu */
  .header-js .header-content {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .header-js .brand {
    flex: 1;
  }

  /* Menu, the bell and the avatar stay on the brand's row; the links open below them */
  .header-js .header-actions {
    order: 2;
  }

  .header-js nav {
    order: 3;
    margin-left: 0;
  }

  .header-js .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
  }

  .nav-toggle-icon,
  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
  }

  .nav-toggle-icon {
    position: relative;
  }

  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .nav-toggle-icon::before {
    top: -5px;
  }

  .nav-toggle-icon::after {
    top: 5px;
  }

  .header-js nav {
    display: none;
    gap: 0.25rem;
  }

  .header-js.nav-open nav {
    display: flex;
  }

  .form-container {
    padding: 1.5rem;
    margin: 1rem;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .table-container {
    font-size: 0.875rem;
  }

  table th,
  table td {
    padding: 0.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  /* button_to wraps its button in a form; stretch it like the link buttons */
  .page-actions,
  .page-actions .button_to {
    width: 100%;
  }

  .report-stats {
    grid-template-columns: 1fr;
  }

  /* Keep pagination as a compact row, not full-width .btn blocks */
  .pagination .btn {
    width: auto;
  }

  .stat-box .amount {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }

  .header {
    padding: 0.75rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .form-container {
    padding: 1rem;
  }

  table {
    font-size: 0.875rem;
  }

  table th,
  table td {
    padding: 0.375rem;
  }
}

/* Utility Classes */
.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Confirmation dialog (themed replacement for window.confirm) */
.confirm-dialog {
  /* The global reset zeroes margins; auto margins centre the modal */
  margin: auto;
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  overflow: hidden;
  color: #333;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.confirm-dialog[open] {
  animation: confirm-dialog-in 0.18s ease-out;
}

.confirm-dialog::backdrop {
  background: rgba(40, 32, 80, 0.55);
  backdrop-filter: blur(2px);
}

.confirm-dialog-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  color: white;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
}

.confirm-dialog-danger .confirm-dialog-header {
  background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
}

.confirm-dialog-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.confirm-dialog-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 700;
}

.confirm-dialog-message {
  margin: 0;
  padding: 1.25rem 1.25rem 1.5rem;
  line-height: 1.55;
  color: #555;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0 1.25rem 1.25rem;
}

.confirm-dialog-actions .btn {
  font-family: inherit;
}

.confirm-dialog-actions .btn:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.45);
  outline-offset: 2px;
}

@keyframes confirm-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-dialog[open] {
    animation: none;
  }
}

@media (max-width: 480px) {
  .confirm-dialog-actions {
    flex-direction: column-reverse;
  }

  .confirm-dialog-actions .btn {
    width: 100%;
  }
}

/* Businesses */
.alert-info {
  background-color: #e8f1fd;
  color: #1d4f91;
  border: 1px solid #c9ddf8;
}

.alert-info ul {
  margin: 0.4rem 0 0;
  padding-left: 1.25rem;
}

.payment-progress {
  height: 6px;
  margin-top: 0.5rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.payment-progress span {
  display: block;
  height: 100%;
  background: #fff;
}

/* A number with its unit beside it (asset size, quantity sold) */
.inline-fields {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-fields > input {
  flex: 1 1 0;
  min-width: 0;
}

.inline-fields > .select {
  flex: 1 1 0;
  min-width: 0;
}

.inline-unit {
  color: #666;
  white-space: nowrap;
}

.amount-positive {
  color: #11998e;
}

.amount-negative {
  color: #ee0979;
}

.business-details {
  white-space: pre-line;
  color: #555;
  margin-bottom: 1rem;
}

.form-section-title {
  font-size: 1rem;
  margin: 1.5rem 0 0.75rem;
  color: #333;
}

/* One investor per row: name, amount, remove */
.investor-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.investor-row .form-group {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .investor-row {
    grid-template-columns: 1fr;
  }
}


/* Flash toasts: top-right, closing on their own */
.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 2.4rem 0.95rem 0.9rem;
  border-radius: 8px;
  background: white;
  color: #333;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  border-left: 4px solid #11998e;
  overflow: hidden;
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-alert {
  border-left-color: #dc3545;
}

.toast-leaving {
  opacity: 0;
  transform: translateX(1rem);
}

.toast-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #11998e;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.toast-alert .toast-icon {
  background: #dc3545;
}

.toast-message {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.45;
}

.toast-close {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 10px;
  background: none;
  color: #666;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.toast-close:hover,
.toast-close:focus-visible {
  background: #f0f0f0;
  color: #333;
}

/* Shrinking bar showing how long until the toast closes */
.toast-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.15;
  transform-origin: left;
  animation: toast-timer linear forwards;
  animation-duration: var(--toast-duration, 5s);
  animation-play-state: paused;
}

.toast-running .toast-timer {
  animation-play-state: running;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

@keyframes toast-timer {
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
    transition: none;
  }
}

@media (max-width: 480px) {
  .toast-stack {
    top: 0.75rem;
    right: 1rem;
    left: 1rem;
    width: auto;
  }
}

/* Themed dropdowns. application.js puts a button and option list over each
   <select>; the real select stays in the form (for submitting, validation and
   the field logic) but is shrunk out of sight. */
.select {
  position: relative;
}

.select-native {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px !important;
  height: 1px;
  padding: 0 !important;
  border: 0 !important;
  clip-path: inset(50%);
  pointer-events: none;
}

.select-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: white;
  color: #333;
  font: inherit;
  font-size: 1rem;
  /* Same height as the text inputs beside it */
  line-height: 1.15;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-placeholder .select-value {
  color: #666;
}

/* Chevron */
.select-button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid #667eea;
  border-bottom: 2px solid #667eea;
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s;
}

.select-open .select-button::after {
  transform: translateY(-30%) rotate(-135deg);
}

.select-button:focus-visible,
.select-open .select-button {
  outline: none;
  border-color: #4f5fc5;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.select-button:disabled {
  background: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

.select-button:disabled::after {
  border-color: #bbb;
}

.select-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: white;
  border: 1px solid #e3e6f5;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(40, 40, 90, 0.18);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: select-list-in 0.12s ease-out;
}

.select-list.select-list-up {
  top: auto;
  bottom: calc(100% + 4px);
}

.select-option {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  color: #333;
  line-height: 1.4;
  cursor: pointer;
  /* Long options wrap instead of widening the list past the screen */
  white-space: normal;
  overflow-wrap: anywhere;
}

.select-option-placeholder {
  color: #666;
}

.select-option-active {
  background: #eef0fc;
}

.select-option[aria-selected="true"] {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  font-weight: 500;
}

.select-option[aria-disabled="true"] {
  color: #bbb;
  cursor: default;
}

@keyframes select-list-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .select-list {
    animation: none;
  }
}

/* Page title with its buttons; stacked on phones */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
}

/* iPhone Safari draws date fields with its own grey, centred control that
   collapses to a thin line while empty (it shows no dd/mm/yyyy placeholder).
   Use the app's input look and keep the same height as the other inputs. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  height: 2.75rem;
  background-color: white;
  color: #333;
  line-height: 1.2;
  text-align: left;
}

input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

/* Form with the Guide panel beside it (desktop); the guide is hidden on
   phones and tablets, where the form looks as before */
.with-guide {
  display: grid;
  grid-template-columns: minmax(0, 600px) 340px;
  justify-content: center;
  align-items: start;
  gap: 2rem;
  margin: 2rem 0;
}

.with-guide .form-container {
  max-width: none;
  margin: 0;
}

.form-guide {
  position: sticky;
  top: 1rem;
  padding: 1.5rem;
  background: white;
  border-radius: 8px;
  border-top: 4px solid #667eea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-guide h3 {
  margin-bottom: 1rem;
  color: #4f5fc5;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-section + .guide-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.guide-section h4 {
  margin-bottom: 0.35rem;
  color: #333;
  font-size: 1rem;
}

.guide-section p {
  color: #555;
  font-size: 0.92rem;
  line-height: 1.5;
}

.guide-new {
  margin-top: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: #eef0fc;
  color: #4c5bd4 !important;
}

.guide-preview dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.guide-preview dt {
  color: #555;
}

.guide-preview dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.guide-warning {
  margin-top: 0.6rem;
  color: #b0263a !important;
  font-weight: 500;
}

/* Two fields side by side in a form (the loan form); one a row on phones */
.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* The guide says the same as these hints, so they show only without it */
@media (min-width: 901px) {
  .guide-duplicate {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .with-guide {
    display: block;
    margin: 0;
  }

  .with-guide .form-container {
    max-width: 600px;
    margin: 2rem auto;
  }

  .form-guide {
    display: none;
  }
}

@media (max-width: 768px) {
  .with-guide .form-container {
    margin: 1rem;
  }
}

/* The record form (Add and Edit): the form in a card, with the Guide and
   Record Preview beside it */
.record-form-layout {
  grid-template-columns: minmax(0, 1fr) 380px;
  justify-content: stretch;
  gap: 1.5rem;
  margin: 0;
}

.record-form-layout .form-container {
  padding: 1.75rem;
  border: 1px solid #eceef6;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.form-side {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-side .form-guide {
  position: static;
}

.record-form-layout .form-guide,
.record-preview {
  padding: 1.5rem;
  border: 1px solid #eceef6;
  border-top: 1px solid #eceef6;
  border-radius: 14px;
  background: white;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.record-form-layout .form-guide h3,
.record-preview h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f0f1f7;
  color: #1f2340;
  font-size: 1.1rem;
  letter-spacing: 0;
  text-transform: none;
}

.record-form-layout .form-guide h3::before {
  content: "";
  width: 22px;
  height: 22px;
  background: #5a67d8;
  /* An open book, as a mask so it takes the theme colour */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.record-preview h3 .icon {
  color: #5a67d8;
}

.record-form-layout .guide-section h4 {
  color: #1f2340;
}

.record-form-layout .guide-choice {
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 10px;
  background: #eef0fd;
}

.record-form-layout .guide-choice h4 {
  color: #4c51bf;
  font-size: 0.92rem;
}

.record-form-layout .guide-choice p {
  color: #4c5bd4;
}

/* Credit and Debit as two cards */
.type-cards {
  min-width: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  border: none;
}

.type-cards legend {
  margin-bottom: 0.6rem;
  padding: 0;
  color: #1f2340;
  font-weight: 600;
}

.type-cards-row:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.type-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border: 1.5px solid #e3e6f0;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.type-card:hover {
  border-color: #c7cbef;
}

/* The radio stays for the keyboard and screen readers, out of sight */
.type-card-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-card-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
}

.type-card-credit .type-card-icon {
  background: #e8f7ee;
  color: #15803d;
}

.type-card-debit .type-card-icon {
  background: #fdecef;
  color: #e11d48;
}

.type-card-text {
  flex: 1;
  min-width: 0;
}

.type-card-text strong {
  display: block;
  color: #1f2340;
  font-size: 0.95rem;
}

.type-card-text small {
  display: block;
  color: #626982;
  font-size: 0.8rem;
}

.type-card-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid #c9ccdb;
  border-radius: 50%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.type-card-credit:has(:checked) {
  border-color: #22c55e;
  background: #f3fbf6;
}

.type-card-debit:has(:checked) {
  border-color: #f43f5e;
  background: #fff5f7;
}

.type-card-credit:has(:checked) .type-card-check {
  border-color: #15803d;
  box-shadow: inset 0 0 0 3px white, inset 0 0 0 10px #15803d;
}

.type-card-debit:has(:checked) .type-card-check {
  border-color: #e11d48;
  box-shadow: inset 0 0 0 3px white, inset 0 0 0 10px #e11d48;
}

.type-card:has(:focus-visible) {
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

/* A category that allows only one: the other can't be picked */
.type-card-locked {
  cursor: default;
}

.type-card-locked:not(:has(:checked)) {
  opacity: 0.45;
}

.type-cards .field-hint {
  margin-top: 0.5rem;
}

/* The fields, two to a row */
.record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.25rem;
}

.record-fields > .form-group {
  min-width: 0;
  margin-bottom: 1.25rem;
}

.record-fields > .form-group-wide {
  grid-column: 1 / -1;
}

.record-form label,
.record-form .form-group label {
  color: #1f2340;
  font-weight: 600;
}

.record-form .required {
  color: #e11d48;
}

.record-form .form-group input,
.record-form .form-group textarea,
.record-form .select-button {
  min-height: 48px;
  border: 1px solid #e3e6f0;
  border-radius: 10px;
  color: #1f2340;
}

.record-form .form-group input:focus,
.record-form .form-group textarea:focus {
  outline: none;
  border-color: #4f5fc5;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* A field with its icon at the start */
.field-with-icon {
  position: relative;
}

.field-icon {
  position: absolute;
  top: 50%;
  left: 0.6rem;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4fa;
  color: #5a67d8;
  transform: translateY(-50%);
  pointer-events: none;
}

.field-with-icon-top .field-icon {
  top: 0.6rem;
  transform: none;
}

.record-form .field-with-icon input,
.record-form .field-with-icon textarea,
.record-form .field-with-icon .select-button {
  padding-left: 3.2rem;
}

.record-form .field-with-icon textarea {
  min-height: 110px;
  padding-top: 0.85rem;
}

.record-form-errors {
  margin-bottom: 1.25rem;
}

.record-form .form-actions {
  margin-top: 0.75rem;
}

.btn-outline {
  border-radius: 10px;
}

.record-form .form-actions .btn {
  min-width: 140px;
  border-radius: 10px;
}

/* Record Preview */
.record-preview-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f5f6fb;
}

.record-preview-head.record-credit {
  background: #ecf8f0;
}

.record-preview-head.record-debit {
  background: #fdf0f2;
}

.record-preview-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: white;
}

.record-preview-head:not(.record-credit):not(.record-debit) .record-preview-icon {
  color: #5a67d8;
}

.record-preview-icon:empty {
  display: none;
}

.record-credit .record-preview-icon {
  color: #15803d;
}

.record-debit .record-preview-icon {
  color: #e11d48;
}

.record-preview-head div > span {
  display: block;
  color: #555b78;
  font-size: 0.85rem;
}

.record-preview-head div > strong {
  display: block;
  color: #1f2340;
  font-size: 1.6rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.record-credit strong {
  color: #15803d;
}

.record-debit strong {
  color: #e11d48;
}

.record-preview-rows {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0.75rem 0 0;
}

.record-preview-rows dt,
.record-preview-rows dd {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f1f7;
  font-size: 0.9rem;
}

.record-preview-rows dt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-right: 1rem;
  color: #6b7090;
}

.record-preview-rows dt .icon {
  color: #626982;
}

.record-preview-rows dd {
  margin: 0;
  color: #1f2340;
  font-weight: 600;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .record-form-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

/* Tablets and phones: no Guide or Preview, one field a row on phones */
@media (max-width: 900px) {
  .form-side {
    display: none;
  }

  .record-form-layout .form-container {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .record-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Phones: Credit and Debit as two small cards side by side, the icon on
     top, "Money In" under the name, the check in the corner, no hint */
  .type-cards-row:not([hidden]) {
    gap: 0.6rem;
  }

  .type-card {
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.9rem 0.5rem 0.8rem;
    text-align: center;
  }

  .type-card-icon {
    width: 40px;
    height: 40px;
  }

  .type-card-text strong {
    font-size: 1rem;
  }

  .type-card-direction {
    display: block;
    color: #6b7090;
    font-size: 0.8rem;
    font-weight: 500;
  }

  .type-card-text small {
    display: none;
  }

  .type-card-check {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 18px;
    height: 18px;
  }

  .record-form-layout .form-container {
    padding: 1.25rem;
  }
}

/* The loan form: Money Received as three cards, in the theme colour */
.type-cards-row-3:not([hidden]) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.type-card-choice .type-card-icon {
  background: #eef0fd;
  color: #5a67d8;
}

.type-card-choice:has(:checked) {
  border-color: #4f5fc5;
  background: #f5f6fd;
}

.type-card-choice:has(:checked) .type-card-check {
  border-color: #5a67d8;
  box-shadow: inset 0 0 0 3px white, inset 0 0 0 10px #5a67d8;
}

/* At the bottom of the Loan Preview: nothing can be changed later */
.preview-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #fde7b0;
  border-radius: 12px;
  background: #fff8e6;
}

.preview-notice-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #b45309;
}

.preview-notice strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #92400e;
  font-size: 0.9rem;
}

.preview-notice p {
  color: #7c4a12;
  font-size: 0.85rem;
  line-height: 1.55;
}

.record-preview-rows:empty {
  display: none;
}

/* Laptops: the three cards one a row */
@media (max-width: 1280px) {
  .type-cards-row-3:not([hidden]) {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tablets and phones: the preview (with the notice) under the form, without the Guide */
@media (max-width: 900px) {
  .preview-below-on-phones .form-side {
    display: flex;
    position: static;
    margin-top: 1.25rem;
  }

  .preview-below-on-phones .form-guide {
    display: none;
  }
}

/* Phones: the three cards stay rows, with their hints */
@media (max-width: 600px) {
  .type-cards-row-3 .type-card {
    flex-direction: row;
    padding: 0.85rem 1rem;
    text-align: left;
  }

  .type-cards-row-3 .type-card-text small {
    display: block;
  }

  .type-cards-row-3 .type-card-check {
    position: static;
  }
}

/* The crop form: Quarter as four cards, and Area with its unit beside it */
.record-fields > .type-cards {
  margin-bottom: 1.25rem;
}

/* The cards are labels, but not like a field's label */
.type-cards label.type-card {
  display: flex;
  margin-bottom: 0;
  font-weight: inherit;
}

.type-cards-row-4:not([hidden]) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.type-card-badge {
  font-size: 0.9rem;
  font-weight: 700;
}

/* Compact at every size: the badge on top, the check in the corner */
.type-cards-row-4 label.type-card {
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.9rem 0.5rem 0.8rem;
  text-align: center;
}

.type-cards-row-4 .type-card-icon {
  width: 40px;
  height: 40px;
}

.type-cards-row-4 .type-card-check {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 18px;
  height: 18px;
}

.record-form .inline-fields > .field-with-icon {
  flex: 1 1 0;
  min-width: 0;
}

.record-form .inline-fields > .select {
  flex: 0 0 130px;
}

@media (max-width: 1100px) {
  .type-cards-row-4:not([hidden]) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Phones: two quarters a row, compact, with their months */
@media (max-width: 600px) {
  .type-cards-row-4 .type-card-text small {
    display: block;
  }

  .record-form .inline-fields > .select {
    flex-basis: 110px;
  }
}

/* The business form: Other Investors under the fields */
.investors-section .form-section-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.25rem 0 0.9rem;
  color: #1f2340;
}

.investors-section .form-section-title .icon {
  color: #5a67d8;
}

.investors-section .form-section-title small {
  color: #6b7090;
  font-size: 0.85rem;
  font-weight: 400;
}

.record-form .investor-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px) auto;
  padding: 1rem;
  border: 1px solid #eceef6;
  border-radius: 12px;
  background: #fafbfe;
}

.record-form .investor-remove .btn {
  min-height: 48px;
}

.investors-section #add_investor {
  margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
  .record-form .investor-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Organization Loans: search and filters above the loans; each row opens
   its extensions */
.records-toolbar.loans-toolbar {
  grid-template-columns: minmax(240px, 2.4fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
}

/* Remaining in red while owed, green once paid off */
.loans-table .loan-remaining strong {
  color: inherit;
}

.loans-table td {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.loans-table .loan-total strong,
.loans-table .loan-remaining strong,
.loans-table .loan-paid a {
  font-size: 0.98rem;
  font-weight: 700;
}

.loans-table .loan-paid a {
  text-decoration: none;
}

.loans-table .loan-paid a:hover {
  text-decoration: underline;
}

.loan-icon-received-now { background: #eef0fd; color: #5a67d8; }
.loan-icon-existing-loan { background: #f3edfd; color: #7c3aed; }
.loan-icon-supplier-credit { background: #e6f6f1; color: #0f766e; }

.loan-date {
  white-space: nowrap;
}

/* Active while anything is owed, Paid Off once nothing is */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: #fef3e2;
  color: #b45309;
}

.status-active::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.status-paid-off {
  background: #e8f7ee;
  color: #15803d;
}

.loan-expand {
  width: 1%;
  text-align: right;
}

.expand-btn .icon {
  transition: transform 0.2s;
}

.expand-btn[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

.records-table tbody tr.row-expanded,
.records-table tbody tr.loan-detail-row,
.records-table tbody tr.loan-detail-row:hover {
  background: #fbfbff;
}

.records-table tr.row-expanded td {
  border-bottom: none;
}

.loan-detail-row > td {
  padding: 0 1rem 1rem 4.4rem;
}

.loan-extensions {
  overflow: hidden;
  border: 1px solid #e7e9f5;
  border-radius: 10px;
  background: white;
}

.loan-extensions table th,
.loan-extensions table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #f0f1f7;
  font-size: 0.85rem;
}

.loan-extensions table th {
  position: static;
  background: #f5f6fb;
  color: #555b78;
  font-weight: 600;
}

.loan-extensions table tr:hover {
  background: none;
}

.loan-extensions-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  color: #6b7090;
  font-size: 0.82rem;
}

.loan-extensions .extension-amount {
  color: #15803d;
  font-weight: 600;
}

/* Previous and Next for a loan's extensions, smaller than the list's */
.extension-pages {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.extension-pages .page-step {
  height: 1.9rem;
  padding: 0 0.6rem;
  font-size: 0.8rem;
}

.loan-extensions-page {
  max-width: 900px;
}

.loan-extensions-footer .extension-all {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #5a67d8;
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .records-toolbar.loans-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }

  .records-toolbar.loans-toolbar .toolbar-search {
    grid-column: 1 / -1;
  }
}

/* Phones: each loan a card, its amounts labelled */
@media (max-width: 768px) {
  .records-toolbar.loans-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .loans-table tr[hidden] {
    display: none;
  }

  /* Each extension a two-line item: number, type and amount, then the date
     and note; nothing scrolls sideways */
  .loan-extensions table,
  .loan-extensions tbody {
    display: block;
  }

  .loan-extensions thead {
    display: none;
  }

  .loan-extensions tbody tr {
    display: grid;
    grid-template-columns: 1.6rem auto minmax(0, 1fr) auto;
    grid-template-areas:
      "number type type amount"
      ". date note note";
    gap: 0.15rem 0.5rem;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #f0f1f7;
  }

  .loan-extensions tbody td {
    display: block;
    padding: 0;
    border: none;
    min-width: 0;
  }

  .loan-extensions .extension-number {
    grid-area: number;
    color: #626982;
    font-size: 0.8rem;
  }

  .loan-extensions .extension-type {
    grid-area: type;
    color: #1f2340;
    font-weight: 600;
  }

  .loan-extensions .extension-amount {
    grid-area: amount;
  }

  .loan-extensions .extension-date,
  .loan-extensions .extension-note {
    color: #626982;
    font-size: 0.78rem;
  }

  .loan-extensions .extension-date {
    grid-area: date;
    white-space: nowrap;
  }

  .loan-extensions .extension-note {
    grid-area: note;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .loan-extensions .extension-note::before {
    content: "· ";
  }

  .loan-extensions .extension-note-empty {
    display: none;
  }

  .loan-extensions-footer {
    align-items: center;
  }

  .loan-extensions-footer .extension-all {
    flex-basis: 100%;
  }

  /* The status pill beside the name, then the button */
  .loans-table .loan-name {
    order: 1;
    flex: 1 1 calc(100% - 170px);
    min-width: 0;
  }

  .loans-table .loan-status,
  .loans-table .loan-expand {
    order: 2;
    width: auto;
  }

  .loans-table .loan-total,
  .loans-table .loan-paid,
  .loans-table .loan-remaining,
  .loans-table .loan-date {
    order: 3;
    flex: 1 1 40%;
    text-align: left;
  }

  .loans-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .loans-table tr.loan-detail-row:not([hidden]) {
    display: block;
    padding: 0 0.9rem 0.9rem;
  }

  .loan-detail-row > td {
    padding: 0;
  }
}

/* Reports: Opening and Closing balance above the period's totals, with what
   came in and went out between them */
.balance-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: white;
  border: 1px solid #eceef6;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.balance-figure {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.balance-figure > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.balance-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #eef0fd;
  color: #5a67d8;
}

.balance-icon-closing {
  background: #e8f7ee;
  color: #15803d;
}

.balance-icon-closing.balance-icon-negative {
  background: #fdecef;
  color: #be123c;
}

.balance-label {
  color: #555b78;
  font-size: 0.85rem;
  font-weight: 600;
}

.balance-amount {
  color: #1f2340;
  font-size: 1.25rem;
  font-weight: 700;
}

.balance-figure small {
  color: #6b7090;
  font-size: 0.8rem;
}

.balance-amount.amount-positive {
  color: #15803d;
}

.balance-amount.amount-negative {
  color: #be123c;
}

/* In the middle: what came in and went out during the period */
.balance-flow {
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #6b7090;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.balance-flow-in {
  color: #15803d;
}

.balance-flow-out {
  color: #be123c;
}

.balance-flow-line {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  max-width: 160px;
  color: #a3a8c3;
}

.balance-flow-line::before {
  content: "";
  flex: 1 1 auto;
  border-top: 2px dashed #d5d8ea;
}

/* The takeaway: how much the family has saved by the end of the period */
.balance-closing {
  text-align: right;
}

.balance-closing .balance-amount {
  font-size: 1.6rem;
}

@media (max-width: 768px) {
  .balance-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .balance-closing {
    flex-direction: row-reverse;
    justify-content: flex-end;
    text-align: left;
  }

  .balance-flow {
    flex-basis: auto;
    justify-content: flex-start;
    padding-left: 0.25rem;
  }
}

/* Profile: who you are on the site's gradient, then your details and your
   password side by side */
.profile-summary {
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid #e8eaf6;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 18px rgba(31, 35, 64, 0.06);
}

.profile-summary-banner {
  height: 92px;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
}

.profile-summary-body {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-top: -44px;
  padding: 0 1.75rem;
}

.profile-summary .avatar-xl {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border: 4px solid white;
  box-shadow: 0 6px 16px rgba(31, 35, 64, 0.15);
  font-size: 2rem;
}

/* Below the banner, beside the avatar that overlaps it */
.profile-summary-text {
  min-width: 0;
  padding-top: 54px;
}

.profile-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.profile-name-row h2 {
  margin: 0;
  color: #1f2340;
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

/* Sits beside the name, not pushed away from it */
.profile-name-row .role-badge {
  margin-left: 0;
}

.profile-summary-text p {
  margin: 0;
  color: #6b7090;
  overflow-wrap: anywhere;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 0;
  padding: 1.1rem 1.75rem 1.4rem;
  border-top: 1px solid #eef0f8;
  list-style: none;
}

.profile-facts li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.profile-fact-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #eef0fd;
  color: #5a67d8;
}

.profile-facts small {
  display: block;
  color: #8a8fab;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.profile-facts strong {
  display: block;
  color: #1f2340;
  overflow-wrap: anywhere;
}

.profile-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 1.5rem;
}

.profile-card {
  padding: 1.75rem;
  border: 1px solid #e8eaf6;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 18px rgba(31, 35, 64, 0.06);
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid #eef0f8;
}

.profile-card-header h3 {
  margin: 0;
  color: #1f2340;
  font-size: 1.15rem;
}

.profile-card-header p {
  margin: 0.1rem 0 0;
  color: #6b7090;
  font-size: 0.9rem;
}

.profile-card-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.profile-card-icon-blue { background: #e8ebfc; color: #5a67d8; }
.profile-card-icon-pink { background: #fde8f1; color: #db2777; }

.profile-card .field-with-icon input,
.profile-card .field-with-icon .select-button {
  padding-left: 3.2rem;
}

.profile-card .field-with-icon .select-with-icon .select-button {
  padding-left: 0.6rem;
}

/* The current password, asked for once the email is changed */
.profile-confirm {
  margin-bottom: 1.25rem;
  padding: 1rem 1rem 0.1rem;
  border: 1px solid #e2e6fb;
  border-radius: 12px;
  background: #f6f7fe;
}

.profile-confirm[hidden] {
  display: none;
}

.profile-card .form-actions {
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .profile-forms {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .profile-summary-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0 1.25rem;
  }

  .profile-summary-text {
    padding-top: 0;
  }

  .profile-summary .avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 1.6rem;
  }

  .profile-facts {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 1rem 1.25rem 1.25rem;
  }

  .profile-card {
    padding: 1.25rem;
  }
}

/* Dashboard: search and filters above the records; More Filters opens a
   panel from the right */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.dashboard {
  min-width: 0;
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1.7fr) minmax(190px, 1.1fr) repeat(3, minmax(125px, 1fr)) auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar-search,
.toolbar-field {
  position: relative;
  min-width: 0;
}

.toolbar-search > .icon,
.toolbar-period > .icon {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  z-index: 1;
  transform: translateY(-50%);
  color: #6b7090;
  pointer-events: none;
}

.toolbar-search input {
  width: 100%;
  height: 46px;
  padding: 0 4.5rem 0 2.75rem;
  border: 1px solid #e3e6f0;
  border-radius: 10px;
  background: white;
  color: #1f2340;
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.toolbar-search input::placeholder {
  color: #9296ad;
}

.toolbar-search input:focus {
  outline: none;
  border-color: #4f5fc5;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.search-shortcut {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  transform: translateY(-50%);
  padding: 0.1rem 0.45rem;
  border: 1px solid #e3e6f0;
  border-radius: 6px;
  background: #f7f8fc;
  color: #6b7090;
  font: inherit;
  font-size: 0.75rem;
  pointer-events: none;
}

.toolbar-field .select-button {
  height: 46px;
  padding: 0 2.4rem 0 0.95rem;
  border-color: #e3e6f0;
  border-radius: 10px;
  color: #1f2340;
  font-size: 0.92rem;
  font-weight: 500;
}

.toolbar-period .select-button {
  padding-left: 2.6rem;
}

.toolbar-field .select-list {
  min-width: 190px;
}

.toolbar-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 46px;
  padding: 0 1.1rem;
  border: 1px solid #e3e6f0;
  border-radius: 10px;
  background: white;
  color: #1f2340;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.toolbar-more .icon {
  color: #5a67d8;
}

.toolbar-more:hover,
.toolbar-more:focus-visible,
.filters-open .toolbar-more {
  border-color: #4f5fc5;
  background: #f5f6fd;
  outline: none;
}

.toolbar-more[hidden] {
  display: none;
}

/* A number in a small purple circle: how many filters are chosen */
.filter-count:not(:empty) {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

/* More Filters. Without JavaScript it shows under the row of filters. */
.filter-sidebar {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  background: white;
  border: 1px solid #eceef6;
  border-radius: 14px;
}

.filter-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eef0f6;
}

.filter-sidebar-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto 0 0;
  color: #1f2340;
  font-size: 1.05rem;
}

.filter-clear {
  color: #5a67d8;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.filter-clear:hover {
  text-decoration: underline;
}

.filter-close {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: none;
  color: #6b7090;
  cursor: pointer;
}

.filter-close[hidden] {
  display: none;
}

.filter-close:hover,
.filter-close:focus-visible {
  background: #f2f3fb;
  color: #1f2340;
}

.filter-sidebar-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.25rem 1.25rem 1.25rem;
}

.filter-group {
  /* A fieldset grows to fit its widest option by default; a long crop name
     would widen the panel */
  min-width: 0;
  margin: 0;
  padding: 0.9rem 0 0;
  border: none;
}

.filter-group + .filter-group {
  margin-top: 0.75rem;
  border-top: 1px solid #f0f1f7;
}

.filter-group[hidden] {
  display: none;
}

.filter-group legend {
  float: left;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0;
  color: #626982;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-group legend + * {
  clear: left;
}

.filter-sidebar .form-group {
  margin-bottom: 0.85rem;
}

.filter-sidebar .form-row-2 {
  gap: 0.75rem;
}

.filter-sidebar label {
  font-size: 0.85rem;
}

/* The chosen option is cut short with "..."; the open list shows it in full */
.filter-sidebar select {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.filter-group .field-hint {
  margin-top: -0.35rem;
}

.filter-apply {
  padding: 0 1.25rem 1.25rem;
}

/* With JavaScript, changes apply at once and the panel slides in from the right */
.filters-live .filter-apply {
  display: none;
}

.filters-live .filter-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  width: min(400px, 92vw);
  margin: 0;
  border: none;
  border-radius: 16px 0 0 16px;
  box-shadow: -12px 0 40px rgba(30, 30, 80, 0.18);
  transform: translateX(105%);
  visibility: hidden;
}

/* Slides only once the page is set up, so it doesn't slide away on load */
.filters-ready .filter-sidebar {
  transition: transform 0.22s ease, visibility 0.22s;
}

.filters-live.filters-open .filter-sidebar {
  transform: none;
  visibility: visible;
}

.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(20, 20, 40, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .filters-ready .filter-sidebar {
    transition: none;
  }
}

/* Page title with its icon */
.page-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.page-title-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef0fd 0%, #f3ecfb 100%);
  color: #5a67d8;
  box-shadow: inset 0 0 0 1px #e3e6fa;
}

.page-title h2 {
  color: #1f2340;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-subtitle {
  color: #6b7090;
  font-size: 0.95rem;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 10px;
  padding: 0.75rem 1.3rem;
}

/* The records */
.records-card {
  border: 1px solid #eceef6;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.records-table th {
  padding: 0.85rem 1rem;
  background: #fafbfe;
  border-bottom: 1px solid #eceef6;
  color: #3d4260;
  font-size: 0.85rem;
  white-space: nowrap;
}

.records-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #f0f1f7;
  vertical-align: middle;
}

.records-table tbody tr:hover {
  background: #fafaff;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
}

.sort-link .icon {
  color: #a3a7bd;
}

.sort-link:hover .icon,
.sort-active .icon {
  color: #5a67d8;
}

.sort-active {
  color: #1f2340;
}

.cell-media {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.cell-media > div {
  min-width: 0;
}

.records-table td strong {
  display: block;
  color: #1f2340;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.records-table td small {
  display: block;
  color: #626982;
  font-size: 0.875rem;
  line-height: 1.4;
}

.records-table td strong a {
  color: inherit;
  text-decoration: none;
}

.records-table td strong a:hover {
  color: #5a67d8;
  text-decoration: underline;
}

.record-date {
  white-space: nowrap;
}

.record-date .icon {
  flex-shrink: 0;
  color: #626982;
}

/* A date added days later shows when it was added */
.record-added-late {
  color: #b45309;
  font-weight: 600;
}

.record-details {
  min-width: 240px;
}

.record-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.record-credit .record-icon {
  background: #e8f7ee;
  color: #15803d;
}

.record-debit .record-icon {
  background: #fdecef;
  color: #e11d48;
}

.category-pill,
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.type-credit {
  background: #e8f7ee;
  color: #15803d;
}

.type-debit {
  background: #fdecef;
  color: #be123c;
}

.category-income { background: #e8f7ee; color: #15803d; }
.category-expense { background: #fdecef; color: #be123c; }
.category-business { background: #eef0fd; color: #4c51bf; }
.category-loan { background: #e9edfd; color: #4f63d9; }
.category-assets { background: #fef3e2; color: #b45309; }
.category-agriculture { background: #e6f6f1; color: #0f766e; }
.category-donation { background: #fdeef6; color: #be185d; }
.category-committee { background: #f1ecfe; color: #6d28d9; }
.category-gift { background: #f6edfe; color: #9333ea; }
.category-occasions-and-events { background: #fcebfb; color: #a21caf; }
.category-insurance { background: #e6f3fb; color: #0369a1; }
.category-other { background: #f0f1f5; color: #525a6e; }

.record-amount {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.amount-credit {
  color: #15803d;
}

.amount-debit {
  color: #e11d48;
}

.record-person .avatar {
  flex-shrink: 0;
}

.record-person strong {
  white-space: nowrap;
}

.records-table .row-actions {
  gap: 0.45rem;
}

.records-table .icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  border-color: #e5e7f2;
  border-radius: 8px;
}

/* A row's More menu */
.row-menu {
  position: relative;
}

.row-menu > summary {
  list-style: none;
}

.row-menu > summary::-webkit-details-marker {
  display: none;
}

.row-menu[open] > summary {
  background: #f2f3fb;
  border-color: #c7cbef;
}

.row-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 1000;
  min-width: 210px;
  padding: 0.35rem;
  background: white;
  border: 1px solid #e3e6f5;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(40, 40, 90, 0.18);
}

.row-menu-panel form {
  display: block;
}

.row-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 7px;
  background: none;
  color: #1f2340;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.row-menu-item .icon {
  color: #5a67d8;
}

.row-menu-item:hover,
.row-menu-item:focus-visible {
  background: #f2f3fb;
  outline: none;
}

.row-menu-danger,
.row-menu-danger .icon {
  color: #dc2626;
}

.row-menu-danger:hover,
.row-menu-danger:focus-visible {
  background: #fdecee;
}

.records-empty {
  padding: 2.5rem 1rem;
  color: #626982;
  text-align: center;
}

/* Under the records: the count, and the page buttons */
.records-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
}

.records-count {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #6b7090;
  font-size: 0.85rem;
}

.records-count .icon {
  color: #15803d;
}

.records-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.page-step,
.page-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.15rem;
  height: 2.15rem;
  padding: 0 0.75rem;
  border: 1px solid #e3e6f0;
  border-radius: 8px;
  background: white;
  color: #3d4260;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.page-number {
  padding: 0 0.5rem;
}

a.page-step:hover,
a.page-number:hover {
  border-color: #4f5fc5;
  background: #f5f6fd;
  color: #5a67d8;
}

.page-number.current {
  border-color: transparent;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
}

.page-disabled {
  background: #f7f8fb;
  color: #b5b9cc;
}

.page-gap {
  padding: 0 0.2rem;
  color: #9296ad;
}

/* Narrower screens: search on its own row, and the records closer together */
@media (max-width: 1100px) {
  .records-toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  }

  .toolbar-search {
    grid-column: 1 / -1;
  }

  .records-table th,
  .records-table td {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .record-details {
    min-width: 180px;
  }

  .record-date > .cell-media > .icon,
  .record-details .record-icon,
  .record-person .avatar {
    display: none;
  }

  .records-table .row-actions {
    gap: 0.3rem;
  }
}

/* Phones: two filters a row, and each record as a card */
@media (max-width: 768px) {
  .page-title h2 {
    font-size: 1.4rem;
  }

  .page-title-icon {
    width: 48px;
    height: 48px;
  }

  .records-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .toolbar-more {
    grid-column: 1 / -1;
  }

  .search-shortcut {
    display: none;
  }

  .toolbar-search input {
    padding-right: 1rem;
  }

  .records-table thead {
    display: none;
  }

  .records-table,
  .records-table tbody {
    display: block;
  }

  .records-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.5rem;
    padding: 0.9rem;
    border-bottom: 1px solid #f0f1f7;
  }

  .records-table td {
    display: block;
    padding: 0;
    border: none;
  }

  .record-details {
    order: 1;
    /* With the amount, the whole first line; the pills start the next */
    flex: 1 1 calc(100% - 130px);
    min-width: 0;
  }

  .record-details .record-icon {
    display: grid;
  }

  .record-amount {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .record-category {
    order: 3;
  }

  .record-type {
    order: 4;
  }

  .record-date {
    order: 5;
    margin-left: auto;
  }

  .record-date strong,
  .record-date small {
    display: inline;
  }

  .record-date small::before {
    content: " · ";
  }

  .record-person {
    order: 6;
    flex: 1 1 50%;
    min-width: 0;
  }

  .record-person .avatar {
    display: inline-flex;
  }

  .record-actions {
    order: 7;
  }

  .records-footer {
    justify-content: center;
  }

  .page-step span {
    display: none;
  }
}

/* A record's page: breadcrumb, title and actions, the transaction beside
   its record information, and the edit history below */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: #6b7090;
  font-size: 0.88rem;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #6b7090;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: #5a67d8;
}

.breadcrumb [aria-current] {
  color: #1f2340;
  font-weight: 600;
}

.btn-outline,
.btn-outline-danger {
  border: 1px solid #e3e6f0;
  background: white;
  color: #1f2340;
}

.btn-outline:hover {
  border-color: #4f5fc5;
  background: #f5f6fd;
  color: #5a67d8;
}

.btn-outline-danger {
  color: #dc2626;
}

.btn-outline-danger:hover {
  border-color: #f3b8bf;
  background: #fdecee;
}

.record-actions-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.record-actions-bar .button_to {
  display: block;
}

.edit-record-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.edit-record-action small {
  color: #6b7090;
  font-size: 0.8rem;
}

.record-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.record-card {
  padding: 1.5rem;
  background: white;
  border: 1px solid #eceef6;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.record-card h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #1f2340;
  font-size: 1.1rem;
}

.record-card h3 > .icon {
  color: #5a67d8;
}

.record-amount-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #f0f1f7;
}

.record-amount-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.record-credit .record-amount-icon {
  background: #e8f7ee;
  color: #15803d;
}

.record-debit .record-amount-icon {
  background: #fdecef;
  color: #e11d48;
}

.record-amount-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.record-amount-head .type-pill {
  padding: 0.4rem 1rem;
  font-size: 0.88rem;
}

/* The fields, two to a row with a line between the columns */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-item {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
  padding: 1rem 0.5rem;
  border-bottom: 1px solid #f0f1f7;
}

@media (min-width: 769px) {
  .detail-grid .detail-item:nth-child(odd):not(.detail-item-wide) {
    padding-right: 1.25rem;
    border-right: 1px solid #f0f1f7;
  }

  .detail-grid .detail-item:nth-child(even) {
    padding-left: 1.25rem;
  }
}

.detail-item-wide {
  grid-column: 1 / -1;
}

.detail-grid .detail-item-wide {
  padding-left: 0.5rem;
  border-right: none;
}

.detail-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f3f4fa;
  color: #5a67d8;
}

.detail-item dl {
  min-width: 0;
}

.detail-label {
  display: block;
  color: #6b7090;
  font-size: 0.82rem;
  font-weight: 500;
}

.detail-value {
  margin: 0.15rem 0 0;
  color: #1f2340;
  font-size: 0.98rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-value a {
  color: #5a67d8;
  text-decoration: none;
}

.detail-value a:hover {
  text-decoration: underline;
}

.detail-value small {
  color: #626982;
  font-size: 0.82rem;
  font-weight: 500;
}

.detail-value p {
  margin: 0;
  font-weight: 500;
}

.detail-value p + p {
  margin-top: 0.5rem;
}

/* Record Information */
.record-info h3 {
  padding-bottom: 1rem;
  border-bottom: 1px solid #f0f1f7;
}

.record-info-items .detail-item {
  padding: 0.9rem 0;
  border-bottom: none;
}

.record-info-items {
  padding: 0.25rem 0 0.75rem;
  border-bottom: 1px solid #f0f1f7;
}

.record-info-items .detail-value small {
  display: block;
}

.record-availability {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f5f6fb;
}

.record-availability .detail-icon {
  background: white;
  color: #626982;
}

.record-availability-open {
  background: #eef0fd;
}

.record-availability-open .detail-icon {
  color: #5a67d8;
}

.record-availability h4 {
  margin-bottom: 0.3rem;
  color: #1f2340;
  font-size: 0.95rem;
}

.record-availability p {
  color: #555b78;
  font-size: 0.88rem;
  line-height: 1.6;
}

.record-availability p + p {
  margin-top: 0.4rem;
}

/* Edit History: a timeline, newest first */
.edit-history h3 {
  margin-bottom: 1.1rem;
}

.edit-list {
  position: relative;
  margin: 0;
  padding: 0 0 0 1.5rem;
  list-style: none;
}

/* The line down the left, with a dot for each edit */
.edit-list::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 0.3rem;
  width: 2px;
  background: #e7e9f5;
}

.edit-entry {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.edit-entry::before {
  content: "";
  position: absolute;
  top: 0.85rem;
  left: -1.5rem;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  background: #c7cbef;
  box-shadow: 0 0 0 1px #e3e6f5;
}

.edit-entry:first-child::before {
  background: #667eea;
}

.edit-entry + .edit-entry {
  margin-top: 1rem;
}

.edit-entry > .avatar {
  margin-top: 0.15rem;
}

.edit-body {
  flex: 1;
  min-width: 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid #eceef6;
  border-radius: 12px;
}

.edit-by {
  margin-bottom: 0.4rem;
  color: #6b7090;
  font-size: 0.9rem;
}

.edit-by strong {
  color: #1f2340;
}

.edit-changes th,
.edit-changes td {
  padding: 0.45rem 0.75rem 0.45rem 0;
  border-bottom: 1px solid #f4f5f9;
  background: none;
  font-size: 0.9rem;
  vertical-align: top;
}

.edit-changes tr:last-child th,
.edit-changes tr:last-child td {
  border-bottom: none;
}

.edit-changes th {
  position: static;
  width: 200px;
  color: #6b7090;
  font-weight: 600;
}

.edit-changes tr:hover {
  background: none;
}

.edit-from {
  color: #b91c1c;
  text-decoration: line-through;
  text-decoration-color: rgba(185, 28, 28, 0.45);
}

.edit-to {
  color: #15803d;
  font-weight: 600;
}

.edit-arrow {
  margin: 0 0.4rem;
  color: #9296ad;
}

.edit-empty {
  color: #9296ad;
  font-style: italic;
  font-weight: 400;
}

.edit-none {
  color: #626982;
}

/* Tablets: Record Information under the transaction */
@media (max-width: 1000px) {
  .record-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Phones: one field a row, and the buttons full width */
@media (max-width: 768px) {
  .record-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .edit-record-action {
    align-items: stretch;
    text-align: center;
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-grid .detail-item {
    padding: 0.9rem 0;
  }

  .record-amount-value {
    font-size: 1.6rem;
  }

  .edit-changes th {
    width: auto;
  }
}

/* The dashboard's small mark beside an edited record's date */
.record-edited {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: #eef0fd;
  color: #5a67d8;
  vertical-align: 1px;
  cursor: help;
}

/* Family Members: Delete Family */
.danger-zone {
  border: 1px solid #f5c6cb;
  border-left: 4px solid #dc3545;
}

.danger-zone h3 {
  color: #b02a37;
  margin-bottom: 0.5rem;
}

.danger-zone p {
  color: #555;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.danger-zone .btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Agriculture: the crops and the supplier accounts, each a card with its
   title and toolbar on one line */
.info-guide {
  background: #f4f5fe;
  border-color: #dfe3fb;
  color: #1f2340;
}

.info-guide a {
  color: #5a67d8;
}

.info-guide > summary .icon {
  margin-right: 0.45rem;
  color: #5a67d8;
  vertical-align: -0.2em;
}

.list-section {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem 0.25rem;
  border: 1px solid #eceef6;
  border-radius: 14px;
  background: white;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.list-section .records-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.list-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.9rem;
}

.list-section-header .records-toolbar {
  flex: 1 1 640px;
  max-width: 1000px;
  margin: 0 0 0 auto;
}

/* Without JavaScript the panel is part of the form, under the toolbar */
.list-section-header .filter-sidebar {
  flex-basis: 100%;
}

.list-section-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.list-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  color: #1f2340;
  font-size: 1.15rem;
}

.list-section-subtitle {
  margin: 0.1rem 0 0;
  color: #6b7090;
  font-size: 0.85rem;
}

.list-section-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef0fd;
  color: #5a67d8;
}

/* The site's purple, as on the Add and Edit crop pages */
.crop-icon {
  background: #eef0fd;
  color: #5a67d8;
}

.records-toolbar.crops-toolbar {
  grid-template-columns: minmax(250px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
}

.records-toolbar.suppliers-toolbar {
  grid-template-columns: minmax(220px, 1fr) auto;
  max-width: 560px;
}

.crops-table .crop-name a {
  color: #1f2340;
  text-decoration: none;
}

.crops-table .crop-name a:hover {
  color: #5a67d8;
  text-decoration: underline;
}

.crop-season span,
.crop-season small,
.supplier-name strong,
.supplier-name small {
  display: block;
}

.crop-season small,
.supplier-name small {
  color: #626982;
  font-size: 0.78rem;
}

.crop-season {
  white-space: nowrap;
}

/* Growing (green, with a dot) or closed (grey) */
.status-crop-active {
  background: #e8f7ee;
  color: #15803d;
}

.status-crop-active::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.status-crop-closed {
  background: #f0f1f6;
  color: #5b6080;
}

/* Profit / Loss with an arrow in a tinted circle */
.profit-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.crops-table .profit-cell strong,
.suppliers-table .supplier-owed strong {
  color: inherit;
}

.amount-even {
  color: #6b7090;
}

.profit-arrow {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.amount-credit .profit-arrow {
  background: #e8f7ee;
}

.amount-debit .profit-arrow {
  background: #fdecef;
}

.crop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.crop-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid #e3e6f0;
  border-radius: 999px;
  background: #fafbfe;
  color: #1f2340;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}


.crop-chip .icon {
  color: #5a67d8;
}

a.crop-chip:hover {
  border-color: #4f5fc5;
  color: #5a67d8;
}

.crop-chip-more {
  color: #6b7090;
}

.muted-dash {
  color: #9aa0b8;
}

@media (max-width: 1100px) {
  .list-section-header .records-toolbar {
    flex-basis: 100%;
    max-width: none;
  }

  .records-toolbar.crops-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  }

  .records-toolbar.crops-toolbar .toolbar-search {
    grid-column: 1 / -1;
  }
}

/* Phones: each crop and supplier a card, its amounts labelled */
@media (max-width: 768px) {
  .list-section {
    padding: 0.9rem 0.9rem 0.25rem;
  }

  .records-toolbar.crops-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* More Filters beside Status, and beside the suppliers' search */
  .records-toolbar.crops-toolbar .toolbar-more,
  .records-toolbar.suppliers-toolbar .toolbar-more {
    grid-column: auto;
  }

  .records-toolbar.suppliers-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .records-toolbar.suppliers-toolbar .toolbar-search {
    grid-column: auto;
  }

  /* Just the icon (and count) beside the search; still named for screen readers */
  .records-toolbar.suppliers-toolbar .toolbar-more {
    padding: 0 0.85rem;
  }

  .records-toolbar.suppliers-toolbar .toolbar-more span:not(.filter-count) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .crops-table tr,
  .suppliers-table tr {
    align-items: flex-start;
  }

  .crops-table .total-cardus {
    align-self: center;
  }

  .suppliers-table .supplier-crops-none {
    display: none;
  }

  .crops-table td[data-label]::before,
  .suppliers-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .crops-table .crop-name {
    order: 1;
    flex: 1 1 calc(100% - 110px);
    min-width: 0;
  }

  .crops-table .total-cardus {
    order: 2;
  }

  .crops-table .crop-season,
  .crops-table .crop-cost,
  .crops-table .crop-income,
  .crops-table .crop-profit {
    order: 3;
    flex: 1 1 40%;
    text-align: left;
  }

  .crops-table .profit-cell {
    justify-content: flex-start;
  }

  .crops-table .crop-actions {
    order: 4;
    flex: 1 1 100%;
  }

  .crops-table .profit-arrow {
    width: 22px;
    height: 22px;
  }

  .suppliers-table .supplier-name,
  .suppliers-table .supplier-crops {
    flex: 1 1 100%;
  }

  .suppliers-table .supplier-bought,
  .suppliers-table .supplier-paid,
  .suppliers-table .supplier-owed {
    flex: 1 1 24%;
    text-align: left;
  }

  /* Room for its label on one line */
  .suppliers-table .supplier-bought {
    flex-basis: 38%;
  }
}

.records-empty a:not(.btn) {
  color: #5a67d8;
}

/* A crop's or an asset's page: its totals in tinted cards, the details and records beside
   its information and the guide */
.detail-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.detail-title .status-pill {
  font-size: 0.8rem;
}

.total-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.total-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  min-width: 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid #eceef6;
  border-radius: 14px;
  background: white;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.total-card h3 {
  margin: 0;
  color: #555b78;
  font-size: 0.85rem;
  font-weight: 600;
}

.total-card strong {
  display: block;
  margin: 0.2rem 0 0.3rem;
  font-size: 1.6rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.total-card small {
  color: #6b7090;
  font-size: 0.8rem;
}

.total-card-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.total-card-red {
  border-color: #fbe1e6;
  background: linear-gradient(135deg, #fff5f7 0%, #ffffff 100%);
}

.total-card-red .total-card-icon {
  background: #fdecef;
  color: #be123c;
}

.total-card-red strong,
.total-card-loss strong {
  color: #be123c;
}

.total-card-green {
  border-color: #d8f0e1;
  background: linear-gradient(135deg, #f2fbf5 0%, #ffffff 100%);
}

.total-card-green .total-card-icon {
  background: #e2f5ea;
  color: #15803d;
}

.total-card-green strong,
.total-card-gain strong {
  color: #15803d;
}

.total-card-purple {
  border-color: #e3e6fa;
  background: linear-gradient(135deg, #f5f5fe 0%, #ffffff 100%);
}

.total-card-purple .total-card-icon {
  background: #eef0fd;
  color: #5a67d8;
}

.detail-main,
.detail-side {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
}

.linked-records-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.linked-records-header h3 {
  margin: 0;
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #5a67d8;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.view-all-link:hover {
  text-decoration: underline;
}

.linked-records .records-card {
  box-shadow: none;
}

.linked-record-date {
  white-space: nowrap;
}

.linked-records-table .amount-link {
  font-weight: 700;
  text-decoration: none;
}

.linked-records-table .amount-link:hover {
  text-decoration: underline;
}

.linked-record-note {
  color: #555b78;
}

.guide-card p {
  margin: 0 0 1rem;
  color: #555b78;
  font-size: 0.9rem;
  line-height: 1.6;
}

.guide-card a {
  color: #5a67d8;
}

.guide-more > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e3e6fa;
  border-radius: 10px;
  background: #f4f5fe;
  color: #5a67d8;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.guide-more > summary::-webkit-details-marker {
  display: none;
}

.guide-more > summary .icon:last-child {
  margin-left: auto;
  transition: transform 0.2s;
}

.guide-more[open] > summary .icon:last-child {
  transform: rotate(90deg);
}

.guide-more-text {
  margin-top: 0.85rem;
  color: #3d4260;
  font-size: 0.88rem;
  line-height: 1.6;
}

.guide-more-text ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

@media (max-width: 1100px) {
  .total-cards {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }
}

/* Phones: each record a short card: the date, type and amount on one line,
   the note under them */
@media (max-width: 768px) {
  .total-card {
    padding: 1rem 1.1rem;
  }

  .total-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .total-card strong {
    font-size: 1.35rem;
  }

  .linked-records-table .linked-record-date {
    order: 1;
    color: #6b7090;
    font-size: 0.85rem;
  }

  .linked-records-table .linked-record-type {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
  }

  .linked-records-table .linked-record-amount {
    order: 3;
  }

  .linked-records-table .linked-record-note {
    order: 4;
    flex: 1 1 100%;
    font-size: 0.85rem;
  }
}

/* Assets: two total cards, then the list with an icon and colour for each kind */
.total-cards.total-cards-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.records-toolbar.assets-toolbar {
  grid-template-columns: minmax(250px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
}

.assets-table .asset-name a {
  color: #1f2340;
  text-decoration: none;
}

.assets-table .asset-name a:hover {
  color: #5a67d8;
  text-decoration: underline;
}

.assets-table .asset-value strong,
.assets-table .asset-result strong,
.assets-table .asset-owed strong {
  color: inherit;
}

.assets-table .asset-value strong {
  color: #1f2340;
}

.assets-table .asset-result .amount-credit { color: #15803d; }
.assets-table .asset-result .amount-debit,
.assets-table .asset-owed .amount-debit { color: #e11d48; }
.assets-table .amount-even { color: #6b7090; }

.kind-pill {
  display: inline-flex;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Each kind's colour, on its icon and its Type pill */
.asset-icon-house-property, .asset-kind-house-property { background: #eef0fd; color: #5a67d8; }
.asset-icon-plot-land, .asset-kind-plot-land { background: #e8f7ee; color: #15803d; }
.asset-icon-vehicle, .asset-kind-vehicle { background: #e8f1fd; color: #2563eb; }
.asset-icon-gold-jewellery, .asset-kind-gold-jewellery { background: #fef3e2; color: #b45309; }
.asset-icon-shop-commercial, .asset-kind-shop-commercial { background: #e6f6f1; color: #0f766e; }
.asset-icon-livestock, .asset-kind-livestock { background: #fdeee6; color: #c2410c; }
.asset-icon-other, .asset-kind-other { background: #f0f1f6; color: #5b6080; }

/* Owned (green), partly sold (amber) or sold (grey) */
.status-asset-owned {
  background: #e8f7ee;
  color: #15803d;
}

.status-asset-partly-sold {
  background: #fef3e2;
  color: #b45309;
}

.status-asset-sold {
  background: #f0f1f6;
  color: #5b6080;
}

/* Paying installments (amber) or fully paid (green), on an asset's page */
.status-asset-paying {
  background: #fef3e2;
  color: #b45309;
}

.status-asset-paid {
  background: #e8f7ee;
  color: #15803d;
}

@media (max-width: 1100px) {
  .records-toolbar.assets-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  }

  .records-toolbar.assets-toolbar .toolbar-search {
    grid-column: 1 / -1;
  }
}

/* Phones: each asset a card, its amounts labelled */
@media (max-width: 768px) {
  .total-cards.total-cards-2 {
    grid-template-columns: 1fr;
  }

  .records-toolbar.assets-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-toolbar.assets-toolbar .toolbar-more {
    grid-column: auto;
  }

  .assets-table tr {
    align-items: flex-start;
  }

  .assets-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .assets-table .asset-name {
    order: 1;
    flex: 1 1 calc(100% - 110px);
    min-width: 0;
  }

  .assets-table .asset-status {
    order: 2;
    align-self: center;
  }

  /* The kind is under the name already */
  .assets-table .asset-kind {
    display: none;
  }

  .assets-table .asset-price,
  .assets-table .asset-value,
  .assets-table .asset-result,
  .assets-table .asset-owed {
    order: 3;
    flex: 1 1 40%;
    text-align: left;
  }

  .assets-table .asset-actions {
    order: 4;
    flex: 1 1 100%;
  }
}

/* A value in the site's purple, unless it's a gain or loss */
.total-card-purple:not(.total-card-gain):not(.total-card-loss) strong {
  color: #4c51bf;
}

/* An asset's page: four cards when it's on installments; Still Owed in amber */
.total-cards.total-cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.total-card-amber {
  border-color: #f6e2bf;
  background: linear-gradient(135deg, #fff9ef 0%, #ffffff 100%);
}

.total-card-amber .total-card-icon {
  background: #fef3e2;
  color: #b45309;
}

.total-card-amber strong {
  color: #b45309;
}

.total-card .payment-progress {
  margin-top: 0.5rem;
  background: #f6e2bf;
}

.total-card .payment-progress span {
  background: #b45309;
}

.linked-record-quantity {
  margin-left: 0.35rem;
  color: #6b7090;
}

@media (max-width: 1300px) {
  .total-cards.total-cards-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .total-cards.total-cards-4 {
    grid-template-columns: 1fr;
  }
}

/* Businesses: three total cards, then the list with an icon and colour for
   each ownership */
.records-toolbar.businesses-toolbar {
  grid-template-columns: minmax(250px, 2fr) repeat(2, minmax(140px, 1fr)) auto;
}

.businesses-table .business-name a {
  color: #1f2340;
  text-decoration: none;
}

.businesses-table .business-name a:hover {
  color: #5a67d8;
  text-decoration: underline;
}

.businesses-table .business-investment strong {
  color: #1f2340;
}

.businesses-table .amount-credit { color: #15803d; }
.businesses-table .amount-debit { color: #e11d48; }
.businesses-table .amount-even { color: #6b7090; }

.businesses-table .business-started {
  color: #555b78;
  white-space: nowrap;
}

/* Each ownership's colour, on its icon and its Ownership pill */
.business-icon-self-owned, .business-kind-self-owned { background: #eef0fd; color: #5a67d8; }
.business-icon-partnership, .business-kind-partnership { background: #e6f6f1; color: #0f766e; }
.business-icon-invested-in-other, .business-kind-invested-in-other { background: #f3ecfd; color: #764ba2; }

/* Active (green), paused (amber) or closed (grey) */
.status-business-active {
  background: #e8f7ee;
  color: #15803d;
}

.status-business-paused {
  background: #fef3e2;
  color: #b45309;
}

.status-business-closed {
  background: #f0f1f6;
  color: #5b6080;
}

.investors-table .investor-name {
  color: #1f2340;
  font-weight: 600;
}

.investors-table .investor-share {
  color: #555b78;
}

.investors-table .investor-amount {
  color: #1f2340;
  font-weight: 600;
}

/* Phones: the name, then the labelled amount and share side by side */
@media (max-width: 768px) {
  .investors-table .investor-name {
    flex: 1 1 100%;
  }

  .investors-table .investor-amount,
  .investors-table .investor-share {
    flex: 1 1 40%;
    text-align: left;
  }

  .investors-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }
}

@media (max-width: 1100px) {
  .records-toolbar.businesses-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }

  .records-toolbar.businesses-toolbar .toolbar-search {
    grid-column: 1 / -1;
  }
}

/* Phones: each business a card, its amounts labelled */
@media (max-width: 768px) {
  .records-toolbar.businesses-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-toolbar.businesses-toolbar .toolbar-more {
    grid-column: auto;
  }

  .businesses-table tr {
    align-items: flex-start;
  }

  .businesses-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .businesses-table .business-name {
    order: 1;
    flex: 1 1 calc(100% - 110px);
    min-width: 0;
  }

  .businesses-table .business-status {
    order: 2;
    align-self: center;
  }

  /* The ownership is under the name already */
  .businesses-table .business-ownership {
    display: none;
  }

  .businesses-table .business-investment,
  .businesses-table .business-net,
  .businesses-table .business-result,
  .businesses-table .business-started {
    order: 3;
    flex: 1 1 40%;
    text-align: left;
  }

  .businesses-table .business-actions {
    order: 4;
    flex: 1 1 100%;
  }
}

/* Reports: the date range with quick ranges */
.report-range {
  margin-bottom: 1.5rem;
}

.report-range h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.report-range-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 230px)) 1fr auto;
  align-items: end;
  gap: 1rem;
}

.report-range-form .form-group {
  margin: 0;
}

.range-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.range-choice {
  padding: 0.55rem 0.9rem;
  border: 1px solid #e2e4f0;
  border-radius: 8px;
  background: white;
  color: #3d4260;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.range-choice:hover {
  border-color: #c3c9f3;
  color: #5a67d8;
}

.range-choice-active {
  border-color: #b9c0f5;
  background: #eef0fd;
  color: #4c51bf;
  font-weight: 600;
}

/* "vs previous period" under each total */
.period-change {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: #6b7090;
  font-size: 0.8rem;
}

.period-change strong {
  display: inline;
  margin: 0 0 0 auto;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.total-card .period-change strong {
  font-size: 0.8rem;
}

.period-change-better .icon,
.total-card .period-change-better strong {
  color: #15803d;
}

.period-change-worse .icon,
.total-card .period-change-worse strong {
  color: #be123c;
}

.total-card .period-change-same strong {
  color: #6b7090;
}

.report-totals .total-card > div {
  flex: 1 1 auto;
  min-width: 0;
}

/* Credit vs Debit Ratio: the donut, its legend and what it means */
.ratio-card {
  margin-bottom: 1.5rem;
}

.ratio-card h3 {
  margin: 0;
}

.ratio-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem 2.5rem;
  margin-top: 1.25rem;
}

.ratio-donut {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: conic-gradient(#15803d 0 var(--credit-share), #ec4899 var(--credit-share) 100%);
}

.ratio-donut-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: white;
  text-align: center;
}

.ratio-donut-center span {
  color: #6b7090;
  font-size: 0.8rem;
}

.ratio-donut-center strong {
  color: #1f2340;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.ratio-legend {
  display: grid;
  flex: 1 1 260px;
  gap: 0.75rem;
  margin: 0;
}

.ratio-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f1f7;
}

.ratio-legend dt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #3d4260;
  font-weight: 500;
}

.ratio-legend dd {
  display: flex;
  gap: 1.5rem;
  margin: 0;
}

.ratio-legend dd strong {
  color: #1f2340;
}

.ratio-legend dd span {
  min-width: 3.5rem;
  color: #6b7090;
  text-align: right;
}

.ratio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.ratio-dot-credit { background: #15803d; }
.ratio-dot-debit { background: #ec4899; }

.ratio-note {
  flex: 1 1 220px;
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: #f6f7fd;
  color: #3d4260;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* The four breakdowns, two to a row */
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.report-share h3 {
  margin: 0;
}

.report-share .linked-records-header {
  margin-bottom: 1rem;
}

.report-icon-credit {
  background: #e8f7ee;
  color: #15803d;
}

.report-icon-debit {
  background: #fdecef;
  color: #be123c;
}

.share-table .share-rank {
  width: 2.5rem;
  color: #6b7090;
}

.share-table .share-label a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #1f2340;
  text-decoration: none;
}

.share-table .share-label a:hover {
  color: #5a67d8;
  text-decoration: underline;
}

.share-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.share-table .share-amount {
  color: #1f2340;
  white-space: nowrap;
}

.share-table .share-percent,
.share-table .share-percent-heading {
  width: 38%;
}

.share-table .share-percent {
  white-space: nowrap;
}

.share-value {
  display: inline-block;
  min-width: 3.4rem;
  color: #3d4260;
  font-size: 0.85rem;
}

.share-bar {
  display: inline-block;
  width: calc(100% - 4rem);
  height: 8px;
  border-radius: 999px;
  background: #f0f1f7;
  overflow: hidden;
  vertical-align: middle;
}

.share-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.report-share-credit .share-bar span { background: #22c55e; }
.report-share-debit .share-bar span { background: #ec4899; }

.share-table tfoot th,
.share-table tfoot td {
  padding: 0.85rem 1rem;
  border-top: 1px solid #eceef6;
  background: #fafbfe;
  color: #1f2340;
  text-align: left;
}

.share-table tfoot .share-amount {
  text-align: right;
}

/* Monthly Breakdown: the balance as a bar either side of the middle */
.monthly-breakdown .linked-records-header {
  margin-bottom: 1rem;
}

.monthly-breakdown h3 {
  margin: 0;
}

.monthly-choice {
  display: flex;
  gap: 0.5rem;
  min-width: 180px;
}

.monthly-choice .select {
  flex: 1 1 auto;
}

.monthly-table .monthly-credit { color: #15803d; font-weight: 600; }
.monthly-table .monthly-debit { color: #be123c; font-weight: 600; }
.monthly-table .monthly-balance.amount-credit strong { color: #15803d; }
.monthly-table .monthly-balance.amount-debit strong { color: #be123c; }

.monthly-table .monthly-bar,
.monthly-table .monthly-bar-heading {
  width: 35%;
}

.balance-bar {
  position: relative;
  display: block;
  height: 10px;
  border-radius: 999px;
  background: #f0f1f7;
}

.balance-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
}

.balance-bar-gain {
  left: 50%;
  border-radius: 0 999px 999px 0;
  background: #4ade80;
}

.balance-bar-loss {
  right: 50%;
  border-radius: 999px 0 0 999px;
  background: #f472b6;
}

@media (max-width: 1100px) {
  .report-range-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-choices {
    justify-content: flex-start;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }
}

/* Phones: each row a short card */
@media (max-width: 768px) {
  .report-range-form {
    grid-template-columns: 1fr;
  }

  .range-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-choice {
    text-align: center;
  }

  .ratio-donut {
    margin: 0 auto;
  }

  .share-table .share-rank {
    display: none;
  }

  .share-table .share-label {
    flex: 1 1 auto;
    min-width: 0;
  }

  .share-table .share-percent {
    flex: 1 1 100%;
    width: auto;
  }

  .share-table tfoot {
    display: block;
  }

  .share-table tfoot tr {
    display: flex;
    justify-content: space-between;
    background: #fafbfe;
  }

  .share-table tfoot th,
  .share-table tfoot td {
    padding: 0;
    border: none;
  }

  .share-table tfoot .share-percent {
    display: none;
  }

  .monthly-choice {
    min-width: 0;
  }

  .monthly-table .monthly-month {
    flex: 1 1 100%;
    color: #1f2340;
    font-weight: 600;
  }

  .monthly-table td[data-label] {
    flex: 1 1 28%;
    text-align: left;
  }

  .monthly-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .monthly-table .monthly-bar {
    flex: 1 1 100%;
    width: auto;
  }
}

/* My Families: each family with its Head, your role and what you can do */
.families-table .family-name-cell strong {
  color: #1f2340;
}

.families-table .family-name-cell .avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.families-table .family-row-current {
  background: #f8f9ff;
}

.families-table .family-you,
.families-table .family-members,
.families-table .family-joined {
  color: #3d4260;
  white-space: nowrap;
}

.families-table .family-actions form {
  display: inline;
}

/* Family Head in the site's gradient, Admin purple, Viewer grey */
.role-pill {
  display: inline-flex;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.role-pill-head {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
}

.role-pill-admin {
  background: #eef0fd;
  color: #4c51bf;
}

.role-pill-viewer {
  background: #f0f1f6;
  color: #5b6080;
}

.status-family-current {
  background: #eef0fd;
  color: #4c51bf;
}

.status-family-active {
  background: #e8f7ee;
  color: #15803d;
}

.status-family-revoked {
  background: #fdecef;
  color: #be123c;
}

/* Phones: each family a card */
@media (max-width: 768px) {
  .families-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  /* The name, then the role and status side by side */
  .families-table .family-name-cell {
    order: 1;
    flex: 1 1 100%;
    min-width: 0;
  }

  .families-table .family-role,
  .families-table .family-status {
    order: 2;
  }

  /* Fills the rest of the line, so the details start the next one */
  .families-table .family-status {
    flex: 1 0 55%;
  }

  .families-table .family-you,
  .families-table .family-members,
  .families-table .family-joined {
    order: 4;
    flex: 1 1 28%;
  }

  .families-table .family-actions {
    order: 5;
    flex: 1 1 100%;
  }

  .families-table .family-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Create Another Family: the login it will use, and what a Family Head can do */
.family-form-login {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.5rem 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e2e6fb;
  border-radius: 12px;
  background: #f6f7fe;
  color: #3d4260;
  font-size: 0.9rem;
}

.family-form-login p {
  margin: 0;
}

.family-form-login-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #eef0fd;
  color: #5a67d8;
}

.family-head-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.family-head-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #3d4260;
  font-size: 0.9rem;
}

.family-head-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.family-head-list .icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: #15803d;
}

.family-head-note {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid #f0f1f7;
  color: #6b7090;
  font-size: 0.85rem;
}

/* Rails wraps a field with an error (and its label) in a div; let it take no
   part in the layout, so a label's "*" stays beside it */
.field_with_errors {
  display: contents;
}

/* Login and sign up: what ManagEasily is beside the form, on a soft lavender wash */
body.auth-split-page {
  overflow-x: hidden;
  background: linear-gradient(160deg, #f8f8fe 0%, #f2f2fc 55%, #eeeffb 100%);
}

/* Soft lavender shapes behind everything: a wave at the top right, and a
   wide curve behind the form */
body.auth-split-page::before,
body.auth-split-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

body.auth-split-page::before {
  top: -38vh;
  right: -12vw;
  width: 46vw;
  height: 70vh;
  background: rgba(226, 224, 250, 0.7);
}

body.auth-split-page::after {
  top: 52vh;
  right: -20vw;
  width: 90vw;
  height: 90vh;
  background: rgba(233, 232, 251, 0.6);
}

body.auth-split-page .site-footer {
  position: relative;
  background: transparent;
}

.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: start;
  gap: 3rem;
  max-width: 1240px;
  margin: 1rem auto 0;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  padding-top: 1rem;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  align-self: flex-start;
  text-decoration: none;
}

.auth-brand-logo {
  filter: drop-shadow(0 6px 14px rgba(139, 92, 246, 0.35));
}

.auth-brand > span {
  display: flex;
  flex-direction: column;
}

.auth-brand-name {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
}

.auth-brand-tagline {
  color: #6b7090;
  font-size: 0.9rem;
}

.auth-headline {
  margin: 2.75rem 0 1rem;
  color: #1f2340;
  font-size: clamp(2rem, 3.4vw, 2.9rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.auth-headline span {
  display: block;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-lead {
  max-width: 470px;
  margin: 0 0 2rem;
  color: #555b78;
  font-size: 1.05rem;
}

.auth-features {
  display: grid;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.auth-features strong {
  display: block;
  color: #1f2340;
  font-size: 1rem;
}

.auth-features li span:not(.auth-feature-icon) {
  color: #6b7090;
  font-size: 0.9rem;
}

.auth-feature-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.auth-feature-green { background: #e3f6ec; color: #15803d; }
.auth-feature-blue { background: #e8ebfc; color: #5a67d8; }
.auth-feature-amber { background: #fef1e2; color: #ea7a12; }
.auth-feature-pink { background: #fde8f1; color: #db2777; }

/* The drawing runs from the page's left edge to the form, and up behind the
   features (they sit above it); it fades out towards the form */
.auth-intro {
  --auth-bleed: calc(max(0px, (100vw - 1240px - 3rem) / 2) + 1.5rem);
}

.auth-features {
  position: relative;
  z-index: 1;
}

.auth-scene {
  display: block;
  width: calc(100% + var(--auth-bleed) + 1.5rem);
  height: auto;
  margin: -80px 0 -1.5rem calc(-1 * var(--auth-bleed));
  /* Faded towards the form and at the bottom: where both masks show */
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 82%, transparent 100%), linear-gradient(180deg, #000 0, #000 84%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, #000 0, #000 82%, transparent 100%), linear-gradient(180deg, #000 0, #000 84%, transparent 100%);
  mask-composite: intersect;
}

.auth-card {
  padding: 2.5rem 3rem;
  border: 1px solid #eceef6;
  border-radius: 20px;
  background: white;
  box-shadow: 0 20px 50px rgba(60, 60, 140, 0.10);
}

.auth-card h2 {
  margin: 0;
  color: #1f2340;
  font-size: 1.75rem;
  text-align: center;
}

.auth-card-subtitle {
  max-width: 420px;
  margin: 0.6rem auto 1.75rem;
  color: #6b7090;
  text-align: center;
}

.auth-form .form-group label {
  color: #1f2340;
  font-weight: 600;
}

.auth-form .field-with-icon input,
.auth-form .field-with-icon .select-button {
  padding-left: 3.2rem;
}

.field-icon-text {
  color: #5a67d8;
  font-size: 0.95rem;
  font-weight: 700;
}

/* The eye button inside the password field */
.password-field input {
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  color: #6b7090;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  background: #eef0fd;
  color: #5a67d8;
}

.password-toggle[hidden] {
  display: none;
}

.auth-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.95rem 1rem;
  font-size: 1.05rem;
}

/* The arrow at the right end, the text centred */
.auth-submit .icon {
  position: absolute;
  right: 1.25rem;
}

.auth-card .auth-switch {
  margin-bottom: 0;
}

/* Login: the link on a line of its own */
.auth-switch-stacked {
  line-height: 1.8;
}

/* Login: Remember me on the left, Forgot password? on the right */
.auth-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: -0.35rem 0 0;
  font-size: 0.92rem;
}

.auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: #555b78;
  font-weight: 500;
  cursor: pointer;
}

.auth-remember input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #5a67d8;
  cursor: pointer;
}

.auth-options a {
  color: #5a67d8;
  font-weight: 600;
  text-decoration: none;
}

.auth-options a:hover {
  text-decoration: underline;
}

/* Forgot password: who can set a new one */
.auth-help {
  display: grid;
  gap: 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-help li {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.auth-help .auth-feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.auth-help strong {
  display: block;
  margin-bottom: 0.15rem;
  color: #1f2340;
}

.auth-help li span:not(.auth-feature-icon) {
  color: #6b7090;
  font-size: 0.92rem;
}

.auth-help a {
  color: #5a67d8;
  font-weight: 600;
  overflow-wrap: anywhere;
}

a.auth-submit {
  text-decoration: none;
}

@media (max-width: 1000px) {
  .auth-split {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 560px;
  }

  /* The name and headline, then the form; the features and drawing are left out */
  .auth-features,
  .auth-scene {
    display: none;
  }

  .auth-headline {
    margin-top: 1.5rem;
  }

  .auth-lead {
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  .auth-split {
    margin-top: 0;
  }

  .auth-card {
    padding: 1.75rem 1.25rem;
  }

  .auth-card h2 {
    font-size: 1.45rem;
  }

  .auth-brand-name {
    font-size: 1.6rem;
  }

  .auth-headline {
    font-size: 1.9rem;
  }
}

/* Continue with Google: shown, but switched off until it's ready */
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #dfe2ee;
  border-radius: 10px;
  background: white;
  color: #1f2340;
  font: inherit;
  font-weight: 600;
}

.google-button > span {
  white-space: nowrap;
}

.google-button:disabled {
  cursor: not-allowed;
}

.google-form {
  margin: 0;
}

.google-button:not(:disabled) {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.google-button:not(:disabled):hover {
  border-color: #c7cdf5;
  background: #fafbff;
  box-shadow: 0 4px 14px rgba(90, 103, 216, 0.12);
}

.google-button:not(:disabled):focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.35);
  outline-offset: 2px;
}

.google-button:disabled .google-logo,
.google-button:disabled > span:not(.google-soon) {
  opacity: 0.55;
}

.google-soon {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #eef0fd;
  color: #5a67d8;
  font-size: 0.72rem;
  font-weight: 600;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: #626982;
  font-size: 0.9rem;
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  border-top: 1px solid #e6e8f2;
}

@media (max-width: 1000px) {
  /* The shapes are sized for wide screens; plain lavender here */
  body.auth-split-page::before,
  body.auth-split-page::after {
    display: none;
  }
}

@media (max-width: 480px) {
  .google-button {
    gap: 0.5rem;
    padding: 0.75rem 0.6rem;
    font-size: 0.92rem;
  }

  .google-soon {
    font-size: 0.66rem;
  }
}

/* Privacy Policy: the name, then the policy in a readable card */
.legal {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.legal > .auth-brand {
  margin-bottom: 1.75rem;
}

.legal-card {
  padding: 2.5rem 3rem;
  border: 1px solid #e8eaf6;
  border-radius: 20px;
  background: white;
  box-shadow: 0 10px 40px rgba(31, 35, 64, 0.08);
  color: #3d4260;
  line-height: 1.7;
}

.legal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.legal-header h1 {
  margin: 0;
  color: #1f2340;
  font-size: 2rem;
  line-height: 1.2;
}

.legal-header p {
  margin: 0.2rem 0 0;
  color: #6b7090;
  font-size: 0.92rem;
}

.legal-summary {
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e2e6fb;
  border-radius: 14px;
  background: #f6f7fe;
}

.legal-summary h2,
.legal-contents h2 {
  margin: 0 0 0.5rem;
  color: #1f2340;
  font-size: 1rem;
}

.legal-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.legal-contents {
  margin-bottom: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #eef0f8;
}

.legal-contents ol {
  columns: 2;
  column-gap: 2rem;
  margin: 0;
  padding-left: 1.4rem;
}

.legal-contents li {
  break-inside: avoid;
}

.legal a {
  color: #5a67d8;
  font-weight: 500;
}

.legal section {
  /* Clear of the page's top when a contents link scrolls here */
  scroll-margin-top: 1.5rem;
  padding-top: 1.5rem;
}

.legal section h2 {
  margin: 0 0 0.6rem;
  color: #1f2340;
  font-size: 1.25rem;
}

.legal section h3 {
  margin: 1rem 0 0.4rem;
  color: #1f2340;
  font-size: 1rem;
}

.legal section p,
.legal section ul {
  margin: 0 0 0.75rem;
}

.legal section ul {
  padding-left: 1.25rem;
}

.legal section li + li {
  margin-top: 0.35rem;
}

.legal strong {
  color: #1f2340;
}

.legal code {
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
  background: #f3f4fa;
  font-size: 0.88em;
}

@media (max-width: 768px) {
  .legal-card {
    padding: 1.5rem 1.25rem;
    border-radius: 16px;
  }

  .legal-header h1 {
    font-size: 1.6rem;
  }

  .legal-contents ol {
    columns: 1;
  }
}

/* Check Your Inbox, Join a family, an invitation that doesn't work: an icon
   above the card's heading */
.auth-card-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  border-radius: 18px;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.3);
}

.auth-note {
  margin: 1rem 0 0;
  color: #6b7090;
  font-size: 0.88rem;
  text-align: center;
}

/* Check Your Inbox: fixing a mistyped email, folded away */
.auth-fold {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #eef0f8;
}

.auth-fold > summary {
  color: #5a67d8;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.auth-fold .auth-submit {
  margin-top: 0.5rem;
}

/* A button that looks like a link, e.g. Log out in a sentence */
.link-button,
.auth-card .link-button {
  display: inline;
  width: auto;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: #4f5fc5;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

/* Join a family: what the invitation gives */
.invitation-facts {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 0.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid #e2e6fb;
  border-radius: 12px;
  background: #f6f7fe;
  list-style: none;
}

.invitation-facts li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.invitation-facts small {
  color: #6b7090;
  font-size: 0.88rem;
}

.invitation-facts strong {
  color: #1f2340;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

/* Family Members */
.members-forms {
  margin-bottom: 1.5rem;
}

.member-role-cards {
  margin-bottom: 1.25rem;
}

.member-role-cards .type-card {
  padding: 0.8rem 0.9rem;
}

.member-role-cards .type-card-icon {
  width: 40px;
  height: 40px;
}

.status-badge-pending {
  background: #fff4dc;
  color: #9a6400;
}

.members-table .member-person small {
  color: #6b7090;
  cursor: auto;
  overflow-wrap: anywhere;
}

.members-table .member-added small {
  color: #626982;
  cursor: auto;
}

.member-you {
  color: #6b7090;
  font-weight: 500;
}

.member-muted {
  color: #626982;
}

.members-table .member-muted a {
  color: #5a67d8;
}

.profile-card-icon-red { background: #fdecef; color: #be123c; }

.profile-card.danger-zone {
  margin-bottom: 1.5rem;
  border: 1px solid #f5c6cb;
  border-left: 4px solid #dc3545;
}

.profile-card.danger-zone h3 {
  margin-bottom: 0;
}

/* Edit a member: whose email and password they are */
.member-edit-card {
  max-width: 720px;
}

.member-note {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e2e6fb;
  border-radius: 12px;
  background: #f6f7fe;
}

.member-note p {
  margin: 0;
  color: #555b78;
  font-size: 0.9rem;
  line-height: 1.5;
}

.member-note .preview-notice-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #eef0fd;
  color: #5a67d8;
}

/* Profile: a new email waiting to be confirmed */
.profile-pending {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid #f6e0a8;
  border-radius: 12px;
  background: #fffaf0;
}

.profile-pending-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #fff1cc;
  color: #9a6400;
}

.profile-pending strong {
  color: #1f2340;
  overflow-wrap: anywhere;
}

.profile-pending p {
  margin: 0.15rem 0 0.6rem;
  color: #555b78;
  font-size: 0.9rem;
}

.profile-pending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.profile-pending-actions form {
  margin: 0;
}

.profile-pending-actions .btn {
  width: auto;
}

/* Phones: each member a card; the name and the role first, then the
   toggles side by side, then the actions */
@media (max-width: 768px) {
  .members-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .members-table .member-person {
    order: 1;
    flex: 1 1 calc(100% - 120px);
    min-width: 0;
  }

  .members-table .member-role {
    order: 2;
    margin-left: auto;
  }

  .members-table .member-status {
    order: 3;
    flex: 1 1 100%;
  }

  .members-table .member-toggle,
  .members-table .member-added {
    order: 4;
    flex: 1 1 30%;
  }

  .members-table .member-actions-cell {
    order: 5;
    flex: 1 1 100%;
  }

  .member-role-cards .type-cards-row {
    grid-template-columns: 1fr;
  }
}

/* Owner console (/sekret) */
.total-cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.page-title h2 .role-badge {
  margin-left: 0.4rem;
  vertical-align: 0.2em;
}

/* Settings and All Users as two pills */
.console-tabs {
  display: inline-flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  border: 1px solid #eceef6;
  border-radius: 12px;
  background: white;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.console-tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 9px;
  color: #555b78;
  font-weight: 600;
}

.console-tabs .tab:hover {
  background: #f5f6fd;
  color: #5a67d8;
}

.console-tabs .tab-active,
.console-tabs .tab-active:hover {
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
  color: white;
}

.list-section .settings-card {
  padding: 0 0 0.5rem;
}

.settings-card .setting-row {
  padding: 1.1rem 0.25rem;
  border-bottom-color: #f0f1f7;
}

.setting-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f1f2f6;
  color: #626982;
}

.setting-icon-on {
  background: #eef0fd;
  color: #5a67d8;
}

.settings-card .setting-text {
  flex: 1;
  min-width: 0;
}

.settings-card .setting-text h4 {
  margin: 0 0 0.15rem;
  color: #1f2340;
}

.settings-card .setting-text p {
  margin: 0;
  color: #6b7090;
}

.console-search {
  display: flex;
  flex: 1 1 420px;
  gap: 0.6rem;
  max-width: 620px;
  margin-left: auto;
}

.console-search .toolbar-search {
  flex: 1;
}

.console-search .toolbar-search input {
  padding-right: 1rem;
}

.console-search .btn {
  width: auto;
  white-space: nowrap;
}

.console-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.console-tags:empty {
  display: none;
}

.console-tags .role-badge {
  margin: 0;
}

.console-table .console-login strong {
  overflow-wrap: anywhere;
}

.console-table .membership-list {
  margin: 0;
  padding: 0;
  gap: 0.45rem;
}

.console-table .membership-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.console-table .membership-list .membership-name strong {
  display: inline;
}

.console-table .membership-list form {
  margin: 0;
}

.console-table .impersonate-button {
  margin: 0;
  width: auto;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
}

.console-joined {
  color: #555b78;
  white-space: nowrap;
}

.console-empty {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  padding: 2.5rem 1rem;
  color: #6b7090;
}

@media (max-width: 1100px) {
  .total-cards-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .total-cards-4 {
    grid-template-columns: 1fr;
  }

  .console-tabs {
    display: flex;
  }

  .console-tabs .tab {
    flex: 1;
    justify-content: center;
  }

  .console-search {
    flex-wrap: wrap;
    max-width: none;
  }

  .console-search .toolbar-search {
    flex-basis: 100%;
  }

  .console-table .console-login,
  .console-table .console-families {
    flex: 1 1 100%;
  }

  .console-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: #626982;
    font-size: 0.8rem;
  }

  .settings-card .setting-row {
    align-items: flex-start;
    gap: 0.9rem;
  }
}

/* Dropdown options with an icon or a person's avatar (application.js,
   optionIcon), in the list and in the field once chosen */
.select-value-icon {
  display: contents;
}

.select-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

/* Default colours; a category's or a type's own (e.g. .category-income) win */
:where(.select-icon) {
  background: #f3f4fa;
  color: #5a67d8;
}

.select-icon .icon {
  width: 15px;
  height: 15px;
}

.select-avatar {
  color: white;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.select-avatar::before {
  content: attr(data-initials);
}

.select-option-with-icon {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.select-option[aria-selected="true"] .select-icon:not(.select-avatar) {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

.select-option[aria-selected="true"] .select-avatar {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.select-with-icon .select-button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.select-with-icon .select-value {
  flex: 1;
  min-width: 0;
}

/* Keeps the field as tall as the others */
.select-button .select-icon {
  margin: -0.35rem 0;
}

/* In a field with its own icon, the chosen option's icon takes its place */
.field-with-icon:has(> .select-with-icon) > .field-icon {
  display: none;
}

.record-form .field-with-icon .select-with-icon .select-button {
  padding-left: 0.6rem;
}

.field-with-icon .select-button .select-icon {
  width: 32px;
  height: 32px;
  margin: -0.5rem 0;
}

.field-with-icon .select-button .select-icon .icon {
  width: 16px;
  height: 16px;
}

.field-with-icon .select-button .select-avatar {
  font-size: 0.75rem;
}

/* The bell in the header and its notifications (layouts/application,
   notifications/_notification): records others added for an earlier month */
.notifications-menu {
  position: relative;
}

.notifications-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: white;
  list-style: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.notifications-button::-webkit-details-marker {
  display: none;
}

.notifications-button:hover,
.notifications-menu[open] .notifications-button {
  background: rgba(255, 255, 255, 0.18);
}

.notifications-button:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.notifications-count {
  position: absolute;
  top: 2px;
  right: 0;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid #6d5bd0;
  border-radius: 999px;
  background: #e11d48;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.notifications-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: -8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - 90px);
  overflow: hidden;
  border: 1px solid #e6e7f1;
  border-radius: 18px;
  background: white;
  color: #1f2340;
  box-shadow: 0 24px 60px rgba(31, 35, 64, 0.22), 0 4px 12px rgba(31, 35, 64, 0.08);
  animation: user-menu-in 0.16s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .notifications-panel { animation: none; }
}

.notifications-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid #eef0f6;
}

.notifications-head strong {
  font-size: 1.1rem;
}

.notifications-read-all-form {
  display: inline;
}

.notifications-read-all {
  padding: 0.25rem 0;
  border: none;
  background: none;
  color: #5a67d8;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.notifications-read-all:hover {
  color: #434190;
  text-decoration: underline;
}

.notifications-panel .notifications-list {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notifications-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.notifications-list > li + li {
  border-top: 1px solid #f0f1f6;
}

/* ".header .notification" outranks the white header link rules */
.notification,
.header .notification {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  width: 100%;
  padding: 0.95rem 1.25rem;
  border-radius: 0;
  background: none;
  color: #1f2340;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.15s;
}

.notification-unread,
.header .notification-unread {
  background: #f4f3fd;
}

.notification:hover,
.header .notification:hover,
.notification:focus-visible {
  background: #eceafb;
  outline: none;
}

.notification:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.45);
}

.notification-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
}

.notification-icon-records {
  background: #eef0fd;
  color: #5a67d8;
}

.notification-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.notification-text strong {
  font-size: 0.95rem;
  line-height: 1.35;
}

.notification-text span {
  color: #4b5070;
  font-size: 0.9rem;
  line-height: 1.4;
}

.notification-text small {
  margin-top: 0.15rem;
  color: #626982;
  font-size: 0.8rem;
}

.notification-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 1.1rem;
  border-radius: 50%;
  background: #e11d48;
}

.notifications-none {
  margin: 0;
  padding: 1.75rem 1.25rem;
  color: #6b7090;
  text-align: center;
}

.notifications-foot {
  padding: 0.9rem 1.25rem 1.1rem;
  border-top: 1px solid #eef0f6;
}

.notifications-all,
.header .notifications-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #dfe3fb;
  border-radius: 12px;
  background: #f4f5fe;
  color: #4c51bf;
  font-weight: 600;
  text-decoration: none;
}

.header .notifications-all:hover {
  background: #eaecfd;
}

/* The Notifications page */
.notifications-page {
  padding: 0;
  overflow: hidden;
}

.notifications-page .pagination {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid #f0f1f6;
}

.notifications-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.25rem;
  color: #6b7090;
  text-align: center;
}

.notifications-empty p {
  margin: 0;
}

/* Phones: the panel opens under the header, as wide as the avatar's menu */
@media (max-width: 768px) {
  .header-actions {
    position: relative;
    gap: 0.5rem;
  }

  .notifications-menu {
    position: static;
  }

  .notifications-panel {
    right: 0;
    width: calc(100vw - 24px);
  }

  .notification,
  .header .notification {
    padding: 0.85rem 1rem;
  }
}

/* Shared UI rhythm: use the same controls in financial, account and public forms. */
:root {
  --ui-muted: #626982;
  --ui-radius: 10px;
  --ui-line: #e3e6f0;
}

.form-group input,
.form-group select,
.form-group textarea,
.select-button,
.btn {
  border-radius: var(--ui-radius);
}

.form-group label { font-weight: 500; }
.form-group .required { color: #be123c; }
.form-group .required[hidden] { display: none; }

.btn-outline,
.btn-secondary {
  border: 1px solid var(--ui-line);
  background: white;
  color: #1f2340;
}

.btn-outline:hover,
.btn-secondary:hover {
  background: #f5f6fd;
  border-color: #4f5fc5;
  color: #4f5fc5;
}

.btn:focus-visible,
.fixed-details > summary:focus-visible {
  outline: 3px solid #4f5fc5;
  outline-offset: 3px;
}

.records-table td small,
.field-hint,
.profile-facts small { color: var(--ui-muted); }
.records-table .record-date strong,
.records-table .record-person strong { font-weight: 500; }
.business-ownership-mobile { display: none; }
.business-name small:empty { display: none; }

/* Long instructions remain available without preceding every list. */
.info-guide > p,
.info-guide > ul { max-width: 78ch; }
.info-guide > summary { min-height: 28px; }
.fixed-details {
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  background: #fafbfe;
}
.fixed-details > summary { cursor: pointer; font-weight: 600; }
.fixed-details > summary span { color: var(--ui-muted); font-weight: 400; }
.fixed-details[open] > summary { margin-bottom: 1rem; }
.fixed-details > .field-hint { margin-bottom: 1.25rem; }
.fixed-details .record-fields > :last-child { margin-bottom: 0; }

.detail-actions { align-items: center; flex-wrap: wrap; }
.detail-actions .detail-more { flex-shrink: 0; }
.detail-more > summary { list-style: none; }
.detail-more > summary::-webkit-details-marker { display: none; }

.report-grid { align-items: start; }

/* Keep header/content edges aligned even beyond the content's maximum width. */
@media (min-width: 1441px) {
  .header { padding-inline: 0; }
  .header-content { padding-inline: 1.5rem; }
}

@media (min-width: 601px) and (max-width: 1100px) {
  .total-cards,
  .total-cards.total-cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  /* A deliberate family row avoids truncating the active family to one letter. */
  .header-js .header-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.5rem;
  }
  .header-js .brand { display: contents; }
  .header-js .brand h1 { grid-column: 1; grid-row: 1; min-width: 0; }
  .header-js .nav-toggle { grid-column: 2; grid-row: 1; min-height: 44px; }
  .header-js .header-actions { grid-column: 3; grid-row: 1; gap: 0.4rem; }
  .header-js .brand > .family-name,
  .header-js .family-switcher { grid-column: 1 / -1; grid-row: 2; justify-self: start; max-width: 100%; }
  .header-js nav { grid-column: 1 / -1; grid-row: 3; }
  .header-js .brand-link { font-size: 1.1rem; gap: 0.4rem; }
  .header-js .brand-logo { width: 32px; height: 32px; }
  .header-js .nav-toggle { padding: 0.4rem 0.6rem; }
  .header-js .user-menu-button { gap: 0.2rem; }
  .header-js .user-menu-button > .icon { display: none; }
  .header-js .notifications-button { min-width: 44px; min-height: 44px; }
  .header-js .user-menu-button { min-height: 44px; }

  .records-table .icon-btn,
  .records-table .expand-btn,
  .extension-pages .page-step,
  .pagination .page-step,
  .pagination .page-number { min-width: 44px; min-height: 44px; }
  .records-table .row-actions { gap: 0.5rem; }
  .records-table td[data-label]::before { font-size: 0.8125rem; color: var(--ui-muted); }
  .records-table td small { font-size: 0.8125rem; }
  .business-ownership-mobile { display: inline; }

  .detail-actions { flex-direction: row; gap: 0.5rem; }
  .detail-actions > .btn-primary { width: auto; flex: 1 1 auto; }
  .detail-actions .detail-more .btn { width: auto; }
  .detail-actions .detail-back-button { flex-basis: 100%; min-height: 44px; }
  .total-card { padding: 1rem; gap: 0.75rem; }
  .total-card-icon { width: 40px; height: 40px; border-radius: 10px; }
  .total-card strong { font-size: 1.5rem; overflow-wrap: anywhere; }
  .total-card small { margin-top: 0.25rem; font-size: 0.8125rem; }

  .profile-summary-banner { height: 40px; }
  .profile-summary-body { flex-direction: row; gap: 0.75rem; margin-top: -24px; padding: 0 1rem; }
  .profile-summary .avatar-xl { width: 56px; height: 56px; font-size: 1.2rem; border-width: 3px; }
  .profile-summary-text { padding-top: 30px; }
  .profile-name-row h2 { font-size: 1.2rem; }
  .profile-summary-text p { font-size: 0.875rem; }
  .profile-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 1rem; margin-top: 1rem; gap: 0.75rem; }
  .profile-facts li { gap: 0.5rem; align-items: flex-start; }
  .profile-fact-icon { width: 28px; height: 28px; flex-shrink: 0; }
  .profile-facts small { font-size: 0.8125rem; letter-spacing: 0; text-transform: none; }
  .profile-facts strong { font-size: 0.875rem; }
  .balance-summary { padding: 1rem; gap: 0.75rem; }
  .balance-summary .balance-closing .balance-amount { font-size: 1.4rem; }
  .report-range { padding: 1rem; }
  .report-range-form { gap: 0.75rem; }
  .report-totals { gap: 0.75rem; }
  .breadcrumb { flex-wrap: wrap; }
}

@media (max-width: 360px) {
  .header-js .brand-link { font-size: 0.95rem; }
  .header-js .brand-logo { width: 28px; height: 28px; }
  .header-js .brand-logo img { width: 22px; height: 22px; }
  .header-js .nav-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .header-js .nav-toggle { min-width: 44px; justify-content: center; }
}

/* The same compact introduction on login, signup, recovery and invitation pages. */
@media (max-width: 1000px) {
  .auth-split { gap: 1.25rem; }
  .auth-intro { padding-top: 0; }
  .auth-headline { margin: 1rem 0 0.5rem; font-size: 1.75rem; line-height: 1.2; }
  .auth-lead { font-size: 0.95rem; }
}
@media (max-width: 600px) {
  .auth-headline { font-size: 1.5rem; }
  .auth-brand-name { font-size: 1.4rem; }
  .auth-brand-tagline { font-size: 0.8125rem; }
  .auth-card { padding: 1.5rem 1rem; }
  .auth-card-subtitle { margin-bottom: 1.25rem; font-size: 0.95rem; }
  .auth-form .form-group { margin-bottom: 1rem; }
  .auth-submit { margin-top: 1rem; }
  .site-footer { font-size: 0.8125rem; gap: 0.4rem 1rem; }
}

.report-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.25rem 0 1rem;
}
.report-jumps a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: white;
  color: #4f5fc5;
  font-size: 0.875rem;
  text-decoration: none;
}
.report-jumps a:hover { background: #eef0fd; }
.report-jumps a:focus-visible { outline: 3px solid #4f5fc5; outline-offset: 2px; }
#report_balances,
#ratio_title,
.report-share,
#monthly_breakdown { scroll-margin-top: 1rem; }

@media (max-width: 768px) {
  .toolbar-field .select-value { white-space: normal; overflow-wrap: anywhere; }
  .toolbar-field .select-button { min-height: 46px; height: auto; padding-block: 0.6rem; }
  .total-card > div { min-width: 0; flex: 1; }
  .total-card small { display: block; line-height: 1.5; }
  .report-jumps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-jumps a { justify-content: center; }
}
@media (min-width: 375px) and (max-width: 768px) {
  .report-range-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-range-form .range-choices,
  .report-range-form > .btn { grid-column: 1 / -1; }
  .report-range-form .form-group { min-width: 0; }
  .report-range-form input[type="date"] { min-width: 0; font-size: 0.875rem; }
}

.profile-facts-panel > summary {
  margin: 1rem 0 0;
  padding: 0.75rem 1.75rem;
  border-top: 1px solid #eef0f8;
  color: #555b78;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}
.profile-facts-panel .profile-facts { margin-top: 0; }
@media (max-width: 768px) {
  .profile-facts-panel > summary { padding-inline: 1rem; min-height: 44px; }
  .toolbar-field .select-button { height: 100%; }
}

/* Legacy Letter (LegacyLettersController). The red alert under the header
   on every page of the Family Head, from 8 days before it's sent */
.legacy-alert {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.8rem max(1rem, calc((100% - 1400px) / 2 + 2rem));
  background: #be123c;
  color: white;
  box-shadow: 0 2px 6px rgba(190, 18, 60, 0.25);
}

.legacy-alert-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
}

.legacy-alert-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 220px;
  line-height: 1.4;
}

.legacy-alert-text span {
  color: #ffe4ea;
  font-size: 0.9rem;
}

.legacy-alert-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: white;
  color: #be123c;
  font-weight: 600;
  text-decoration: none;
}

.legacy-alert-button:hover {
  background: #ffe4ea;
  color: #9f1239;
}

/* Before a letter is written: why, beside how it works */
.legacy-start,
.legacy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.legacy-layout {
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}

.legacy-intro p:not(.profile-card-header p) {
  margin: 0 0 0.9rem;
  color: #3d4263;
  line-height: 1.6;
}

.legacy-guide {
  padding: 1.5rem;
  border: 1px solid #eceef6;
  border-radius: 14px;
  background: white;
  box-shadow: 0 1px 3px rgba(30, 30, 80, 0.06);
}

.legacy-guide h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f0f1f7;
  color: #1f2340;
  font-size: 1.1rem;
}

.legacy-guide h3 .icon {
  color: #5a67d8;
}

.legacy-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legacy-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.legacy-step-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e8ebfc;
  color: #5a67d8;
}

.legacy-steps strong {
  display: block;
  color: #1f2340;
  font-size: 0.95rem;
}

.legacy-steps span:not(.legacy-step-icon) {
  color: #6b7090;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* The letter's state, with postponing and the other actions */
.legacy-status-scheduled:has(.profile-card-icon-red) {
  border-left: 4px solid #be123c;
}

.legacy-status-sent {
  border-left: 4px solid #16a34a;
}

.legacy-status .profile-card-header p strong {
  color: #1f2340;
}

.legacy-date-row {
  display: flex;
  gap: 0.75rem;
}

.legacy-date-row .field-with-icon {
  flex: 1;
  min-width: 0;
}

.legacy-date-row .btn {
  flex-shrink: 0;
}

.legacy-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid #eef0f8;
}

.legacy-actions form {
  margin: 0;
}

.legacy-actions .btn {
  justify-content: center;
  width: 100%;
}

.legacy-note {
  margin: 0;
  color: #555b78;
  line-height: 1.6;
}

/* The letter as it will be read */
.legacy-meta {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0 0 1.25rem;
}

.legacy-meta > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.75rem;
}

.legacy-meta dt {
  color: #8a8fab;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.legacy-meta dd {
  margin: 0;
  color: #1f2340;
  overflow-wrap: anywhere;
}

.legacy-recipients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legacy-recipients-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.legacy-recipients-list strong,
.legacy-recipients-list small {
  display: block;
}

.legacy-recipients-list small {
  color: #6b7090;
}

.legacy-body {
  padding: 1rem 1.15rem;
  border-left: 4px solid #667eea;
  border-radius: 8px;
  background: #f6f7fe;
  color: #1f2340;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.legacy-body h1 {
  margin: 0.5rem 0;
  font-size: 1.25rem;
}

.legacy-body ul,
.legacy-body ol {
  padding-left: 1.5rem;
}

.legacy-body blockquote {
  margin: 0.5rem 0;
  padding-left: 0.9rem;
  border-left: 3px solid #c7cdf5;
  color: #555b78;
}

/* The form: two recipients, then the message in the editor (Trix) */
.legacy-recipients {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

.legacy-recipients legend {
  margin-bottom: 0.75rem;
  color: #1f2340;
  font-size: 1.05rem;
  font-weight: 600;
}

.legacy-recipients > .field-hint {
  margin-top: -0.75rem;
}

.legacy-form .optional {
  color: #8a8fab;
  font-weight: 400;
}

.letter-editor-field trix-toolbar {
  margin-bottom: 0.4rem;
}

.letter-editor-field trix-toolbar .trix-button-group {
  border-color: #dfe2f1;
  border-radius: 8px;
}

.letter-editor-field trix-toolbar .trix-button {
  border-color: #eceef6;
}

/* Text only: no attaching files */
.letter-editor-field .trix-button-group--file-tools {
  display: none;
}

.letter-editor {
  min-height: 16rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: white;
  color: #1f2340;
  line-height: 1.6;
}

.letter-editor:focus {
  border-color: #5a67d8;
  outline: none;
  box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.18);
}

@media (max-width: 900px) {
  .legacy-start,
  .legacy-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .legacy-date-row {
    flex-direction: column;
  }

  .legacy-meta > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
  }

  .letter-editor-field trix-toolbar .trix-button-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}

/* Cancelling or deleting the Legacy Letter, with the password */
.legacy-confirm {
  max-width: 560px;
}

/* Handing over the Family Head role (HeadTransfer): the alert for the member
   asked, the Family Head's waiting request, and the pages */
.head-transfer-alert {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.8rem max(1rem, calc((100% - 1400px) / 2 + 2rem));
  background: #4c51bf;
  color: white;
  box-shadow: 0 2px 6px rgba(76, 81, 191, 0.25);
}

.head-transfer-alert-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
}

.head-transfer-alert .legacy-alert-text span {
  color: #e0e4ff;
}

.head-transfer-alert-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: white;
  color: #4c51bf;
  font-weight: 600;
  text-decoration: none;
}

.head-transfer-alert-button:hover {
  background: #eef0fd;
}

.head-transfer-waiting {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #dfe3fb;
  border-radius: 14px;
  background: #f3f4fe;
  color: #1f2340;
}

.head-transfer-card .head-transfer-waiting {
  margin-bottom: 0;
}

.head-transfer-waiting-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e3e7fc;
  color: #5a67d8;
}

.head-transfer-waiting p {
  flex: 1;
  min-width: 220px;
  margin: 0;
  color: #555b78;
  line-height: 1.5;
}

.head-transfer-waiting strong {
  display: block;
  color: #1f2340;
}

.head-transfer-waiting form {
  margin: 0;
}

.head-transfer-card {
  max-width: 720px;
}

.member-edit-layout {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 1100px) {
  .member-edit-layout-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-edit-layout-two > .profile-card {
    max-width: none;
  }
}

/* A family's initials, square as in the family switcher */
.head-transfer-card .profile-card-header > .avatar {
  border-radius: 12px;
}

.head-transfer-list {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.head-transfer-list li {
  display: flex;
  gap: 0.6rem;
  color: #3d4260;
  line-height: 1.5;
}

.head-transfer-list .icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: #5a67d8;
}

/* The dashboard's header buttons: Download CSV and Add New Record, side by
   side on phones too */
.page-header-actions {
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .page-header-actions > * {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
  }

  .page-header-actions .csv-locked .btn {
    flex: 1;
    justify-content: center;
  }

  .page-header-actions {
    gap: 0.5rem;
  }

  .page-header-actions .btn {
    gap: 0.4rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }
}

/* Download CSV for members other than the Family Head: the tooltip shows on
   the wrapper, since a disabled button gets no mouse events */
.csv-locked {
  display: inline-flex;
  border-radius: 10px;
  cursor: not-allowed;
}

.csv-locked .btn {
  pointer-events: none;
  opacity: 0.55;
}

.csv-locked:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.45);
  outline-offset: 2px;
}

/* Download CSV's choices, in a dialog over the dashboard or on their own page */
.csv-dialog {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.csv-page {
  display: block;
  max-width: 500px;
  margin: 1.5rem 0;
  background: white;
}

.csv-export-form {
  padding: 1.25rem 1.25rem 0;
}

.csv-export-form .confirm-dialog-actions {
  padding: 1.25rem 0;
}

.csv-export-summary {
  margin: 0 0 1rem;
  line-height: 1.55;
  color: #555;
}

.csv-export-summary strong {
  color: #1f2340;
}

.csv-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  padding: 0;
  border: none;
}

.csv-columns legend {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #1f2340;
}

.csv-column {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e8eaf6;
  border-radius: 10px;
  color: #1f2340;
  cursor: pointer;
}

.csv-column:has(input:checked) {
  border-color: #c3cbf5;
  background: #f5f7ff;
}

.csv-column input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: #5a67d8;
}

.csv-column-fixed {
  cursor: default;
  color: #6b7090;
}

@media (max-width: 480px) {
  .csv-column {
    padding: 0.55rem 0.6rem;
    font-size: 0.9rem;
  }
}

/* The chat with ManagEasily Support: a round button fixed at the bottom
   right of every page, opening a panel above it (support_chats/_button) */
.support-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 900;
}

.support-chat-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 10px 28px rgba(90, 103, 216, 0.38);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.support-chat-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(90, 103, 216, 0.45);
}

.support-chat-button:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.45);
  outline-offset: 3px;
}

.support-chat-icon-open,
.support-chat-icon-close {
  display: inline-flex;
}

.support-chat-icon-close,
.support-chat-open .support-chat-icon-open {
  display: none;
}

.support-chat-open .support-chat-icon-close {
  display: inline-flex;
}

.support-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.3rem;
  border: 2px solid white;
  border-radius: 999px;
  background: #e53e3e;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
}

.support-chat-badge[hidden],
.support-chat-panel[hidden] {
  display: none;
}

.support-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100dvh - 7rem));
  animation: confirm-dialog-in 0.18s ease-out;
}

.support-chat-panel .support-chat-card {
  height: 100%;
  box-shadow: 0 20px 50px rgba(31, 35, 64, 0.25);
}

/* The conversation, in the panel or on its own page */
.support-chat-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e8eaf6;
  border-radius: 16px;
  background: white;
}

.support-page .support-chat-card {
  max-width: 640px;
  height: min(640px, calc(100dvh - 14rem));
  min-height: 420px;
  box-shadow: 0 4px 18px rgba(31, 35, 64, 0.06);
}

.support-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  color: white;
  background: linear-gradient(135deg, #4f5fc5 0%, #68418f 100%);
}

.support-chat-header h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.support-chat-header p {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.85;
}

.support-chat-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
}

.support-chat-close {
  flex-shrink: 0;
  display: inline-flex;
  margin-left: auto;
  padding: 0.35rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
}

.support-chat-close[hidden] {
  display: none;
}

.support-chat-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.support-thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.support-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  padding: 1rem;
  background: #f7f8fc;
}

.support-messages-empty {
  margin: auto 0;
  padding: 1rem;
  color: #6b7090;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}

.support-messages-empty[hidden] {
  display: none;
}

.support-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 82%;
}

.support-message-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.support-message-name {
  margin: 0 0.5rem 0.2rem;
  color: #6b7090;
  font-size: 0.75rem;
  font-weight: 600;
}

.support-message-support .support-message-name {
  color: #5a67d8;
}

.support-message-bubble {
  padding: 0.55rem 0.8rem;
  border: 1px solid #e8eaf6;
  border-radius: 14px 14px 14px 4px;
  background: white;
  color: #1f2340;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.support-message-mine .support-message-bubble {
  border-color: transparent;
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.support-message time {
  margin: 0.2rem 0.5rem 0;
  color: #9a9fb8;
  font-size: 0.7rem;
}

.support-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #eef0f8;
  background: white;
}

.support-form textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 0.6rem 0.8rem;
  border: 1px solid #dfe3f3;
  border-radius: 12px;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  resize: none;
}

.support-form textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.support-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
}

.support-send:hover {
  filter: brightness(1.05);
}

.support-form-error {
  flex-basis: 100%;
  margin: 0;
  color: #c53030;
  font-size: 0.8rem;
}

.support-form-error[hidden] {
  display: none;
}

.support-chat-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0 0.75rem 0.6rem;
  background: white;
  color: #9a9fb8;
  font-size: 0.72rem;
}

/* Support's answer at the top of the bell's list */
.notification-icon-support {
  background: #eef0fd;
  color: #764ba2;
}

/* Phones: a full-width sheet above the button, which moves out of the way
   of the page's own buttons at the bottom */
@media (max-width: 768px) {
  .support-chat {
    right: 1rem;
    bottom: 1rem;
  }

  .support-chat-button {
    width: 3.1rem;
    height: 3.1rem;
  }

  .support-chat-panel {
    position: fixed;
    right: 0.75rem;
    left: 0.75rem;
    bottom: 5rem;
    width: auto;
    height: min(560px, calc(100dvh - 6.5rem));
  }

  /* Room for the button below the footer, so it never covers it */
  body:has(.support-chat) .site-footer {
    padding-bottom: 5rem;
  }
}

/* The Owner Console's Chats tab: the families on the left, the open chat
   on the right (super_admin/_chats) */
.chat-inbox {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: min(680px, calc(100dvh - 12rem));
  min-height: 460px;
  overflow: hidden;
  border: 1px solid #e8eaf6;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 18px rgba(31, 35, 64, 0.06);
}

.chat-inbox-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #eef0f8;
}

.chat-inbox-list-head {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid #eef0f8;
}

.chat-inbox-list-head h3 {
  margin: 0 0 0.6rem;
  color: #1f2340;
  font-size: 1.05rem;
}

.chat-search {
  width: 100%;
}

.chat-list {
  flex: 1;
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
  list-style: none;
}

.chat-list li[hidden] {
  display: none;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  color: #1f2340;
  text-decoration: none;
}

.chat-list-item:hover {
  background: #f5f7ff;
}

.chat-list-item-open {
  background: #eef0fd;
}

.chat-list-item > .avatar,
.chat-inbox-thread-head > .avatar {
  flex-shrink: 0;
  border-radius: 12px;
}

.chat-list-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.chat-list-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-list-top strong {
  overflow: hidden;
  font-size: 0.93rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-top time {
  flex-shrink: 0;
  color: #9a9fb8;
  font-size: 0.72rem;
}

.chat-list-preview {
  overflow: hidden;
  color: #6b7090;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-item-unread .chat-list-preview {
  color: #1f2340;
  font-weight: 600;
}

.chat-list-dot {
  flex-shrink: 0;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #5a67d8;
}

.chat-list-empty {
  margin: 0;
  padding: 1.5rem 1rem;
  color: #6b7090;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
}

.chat-inbox-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-inbox-back {
  display: none;
  color: white;
}

.chat-inbox-placeholder {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  background: #f7f8fc;
  color: #6b7090;
  text-align: center;
}

.chat-inbox-placeholder p {
  margin: 0;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #e53e3e;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Phones: the list, or the open chat on its own with a way back */
@media (max-width: 768px) {
  .chat-inbox {
    grid-template-columns: minmax(0, 1fr);
    height: calc(100dvh - 9rem);
  }

  .chat-inbox-list {
    border-right: none;
  }

  .chat-inbox-open .chat-inbox-list,
  .chat-inbox:not(.chat-inbox-open) .chat-inbox-thread {
    display: none;
  }

  .chat-inbox-back {
    display: inline-flex;
  }

  .chat-inbox-open {
    height: calc(100dvh - 2rem);
  }
}

/* Phones: the console's three tabs share the width, and the Chats tab
   leaves out the totals so the chats come first */
@media (max-width: 768px) {
  .console-tabs {
    display: flex;
  }

  .console-tabs .tab {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 0.5rem;
    white-space: nowrap;
  }

  .console-totals-chats {
    display: none;
  }
}

/* The family's plan on every page: read-only (grey-blue), a trial ending or
   a payment due (amber) */
.plan-alert {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.8rem max(1rem, calc((100% - 1400px) / 2 + 2rem));
  color: white;
}

.plan-alert-read-only {
  background: #3f4a7a;
  box-shadow: 0 2px 6px rgba(63, 74, 122, 0.25);
}

.plan-alert-trial,
.plan-alert-overdue {
  background: #b45309;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.25);
}

.plan-alert-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
}

.plan-alert-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: white;
  color: #1f2340;
  font-weight: 600;
  text-decoration: none;
}

.plan-alert-button:hover {
  background: #eef0fd;
}

/* A feature of Family Plus and Pro, seen but locked */
.plan-locked {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px dashed #c3cbf5;
  border-radius: 12px;
  background: #f7f8ff;
  color: #3d4270;
  font-size: 0.92rem;
}

.plan-locked > span {
  flex: 1;
  min-width: 200px;
}

.plan-locked a {
  font-weight: 600;
}

.plan-locked-note {
  flex-basis: 100%;
  margin: 0;
}

/* Locked buttons keep their size; the note goes on its own line */
.form-actions:has(.plan-locked-note) {
  flex-wrap: wrap;
}

.form-actions:has(.plan-locked-note) > .btn,
.form-actions:has(.plan-locked-note) > .csv-locked {
  flex-shrink: 0;
  white-space: nowrap;
}

.plan-blocker {
  margin-bottom: 1rem;
}

/* Plan & Billing */
.billing-current {
  margin-bottom: 1.5rem;
}

.billing-families {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.billing-family,
.console-plan-family {
  padding: 1rem;
  border: 1px solid #e8eaf6;
  border-radius: 14px;
  background: #fbfbff;
}

.billing-family-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  color: #1f2340;
}

.billing-family-head > .avatar {
  border-radius: 10px;
}

.billing-family-note {
  margin: 0;
  color: #6b7090;
  font-size: 0.9rem;
}

.billing-usage {
  display: grid;
  gap: 0.7rem;
}

.usage-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  color: #555b78;
  font-size: 0.85rem;
}

.usage-top strong {
  flex-shrink: 0;
  color: #1f2340;
  white-space: nowrap;
}

.usage-track {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eaf6;
}

.usage-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #667eea, #764ba2);
}

.usage-full .usage-track span {
  background: #dc2626;
}

.usage-full .usage-top strong {
  color: #b91c1c;
}

.billing-plans h3 {
  margin: 0 0 1rem;
  color: #1f2340;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  border: 1px solid #e8eaf6;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 18px rgba(31, 35, 64, 0.06);
}

.plan-card-featured {
  border-color: #c3cbf5;
  box-shadow: 0 10px 30px rgba(90, 103, 216, 0.15);
}

.plan-card-current {
  border-color: #5a67d8;
}

.plan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-card-head h4 {
  margin: 0;
  color: #1f2340;
  font-size: 1.15rem;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  margin: 0;
  color: #6b7090;
}

.plan-price strong {
  color: #1f2340;
  font-size: 1.9rem;
}

.plan-price-yearly {
  margin: -0.4rem 0 0;
  color: #6b7090;
  font-size: 0.9rem;
}

.plan-features {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 0.5rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: #3d4270;
  font-size: 0.92rem;
}

.plan-features li .icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: #16a34a;
}

.plan-features .plan-feature-off {
  color: #9a9fb8;
}

.plan-features .plan-feature-off .icon {
  color: #c0c4d6;
}

.plan-blockers {
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.88rem;
}

.plan-blockers ul {
  display: grid;
  gap: 0.35rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.plan-blockers li {
  display: flex;
  gap: 0.4rem;
}

.plan-blockers li .icon {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.plan-choose {
  justify-content: center;
}

/* Paying for a plan (Safepay): a month or a year */
.plan-pay {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.plan-pay form,
.plan-pay .btn {
  width: 100%;
}

.plan-pay-note {
  grid-column: 1 / -1;
  color: #6b7090;
  font-size: 0.82rem;
}

.billing-payments {
  margin-top: 1.75rem;
}

.console-payments {
  margin-top: 1.25rem;
}

.console-payments .records-table {
  margin-top: 0.75rem;
}

.billing-payments h3 {
  margin: 0 0 0.75rem;
  color: #1f2340;
}

.billing-payments-table small {
  color: #6b7090;
}

/* Phones: payment history becomes labelled cards, including long credit
   descriptions and partial-refund statuses. */
@media (max-width: 768px) {
  .billing-payments-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 0.85rem 1rem;
    padding: 1rem 0;
  }

  .billing-payments-table td {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .billing-payments-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: #626982;
    font-size: 0.8125rem;
    font-weight: 500;
  }

  .billing-payments-table td[data-label="Plan"],
  .billing-payments-table td[data-label="Original period"] {
    grid-column: 1 / -1;
  }

  .billing-payments-table .status-badge {
    max-width: 100%;
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .plan-pay {
    grid-template-columns: minmax(0, 1fr);
  }
}

.billing-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  color: #555b78;
  font-size: 0.9rem;
  line-height: 1.5;
}

.billing-note .icon {
  flex-shrink: 0;
  margin-top: 0.2rem;
  color: #5a67d8;
}

/* Owner Console: one login's plan */
.console-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.console-plan-grid .profile-card {
  display: grid;
  gap: 0.9rem;
}

/* Adding days to a family's trial: one click, or another number */
.console-trial {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ui-line);
}

.console-trial-label {
  color: #1f2340;
  font-size: 0.85rem;
  font-weight: 600;
}

.console-trial-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.console-trial-chip {
  padding: 0.4rem 0.75rem;
  border: 1px solid #c3cbf5;
  border-radius: 999px;
  background: #eef0fd;
  color: #4c51bf;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.console-trial-chip:hover {
  border-color: #5a67d8;
  background: #5a67d8;
  color: white;
}

.console-trial-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.console-trial-form {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.console-trial-field {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.console-trial-field:focus-within {
  border-color: #4f5fc5;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.console-trial-field input {
  width: 4.5rem;
  padding: 0.45rem 0.25rem 0.45rem 0.75rem;
  border: 0;
  background: transparent;
  color: #1f2340;
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.console-trial-field input::-webkit-inner-spin-button,
.console-trial-field input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.console-trial-field input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.console-trial-form .btn {
  flex: 0 0 auto;
  width: auto;
  padding-inline: 1.1rem;
}

.console-trial-field span {
  padding-right: 0.75rem;
  color: #6b7090;
  font-size: 0.85rem;
}

.console-trial-hint {
  color: #6b7090;
  font-size: 0.78rem;
}

.console-trial form:has(.console-trial-end) {
  justify-self: start;
  margin-top: 0.15rem;
}

.console-plan-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  .plan-cards,
  .console-plan-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
