/* =========================================================================
   MoneyGlass design system
   -------------------------------------------------------------------------
   Layered on Bootstrap 5.3: Bootstrap supplies the grid and the responsive
   scaffolding, this file supplies the product's voice.

   Principles, in the order they win arguments:

   1. **Colour means something.** In, out, set aside, committed, covered.
      Never decoration. And never the only carrier of meaning - every
      coloured state also has a word.
   2. **Figures are the interface.** Tabular numerals everywhere, a clear
      size hierarchy, and no money value ever wraps mid-number.
   3. **Glass is a signature, not a texture.** The MoneyGlass visual and the
      hero surfaces use it. Ordinary cards stay flat and readable. If
      everything is frosted, nothing is special and nothing is legible.
   4. **Light, with room to breathe.** Generous spacing beats decoration.
   5. **Motion is optional.** Everything animated is a nicety and respects
      prefers-reduced-motion.

   See docs/UI_GUIDELINES.md.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Tokens
   ------------------------------------------------------------------------- */
:root {
  /* --- Ink: deep navy, never black. Black on white is harsh at length. --- */
  --mg-ink:          #012146;   /* the logo's navy ("Now") */
  --mg-ink-2:        #0F2E57;
  --mg-ink-3:        #3A5577;

  /* --- Text --- */
  --mg-text:         #12233D;
  --mg-text-soft:    #48607D;
  --mg-text-mute:    #667B95;

  /* --- Paper: cool near-white, with an ice tint for raised surfaces --- */
  --mg-page:         #F5F8FC;
  --mg-surface:      #FFFFFF;
  --mg-surface-2:    #EEF3F9;
  --mg-ice:          #EEF5FC;
  --mg-ice-2:        #DDEBF8;

  /* --- Lines --- */
  --mg-line:         rgba(1, 33, 70, 0.08);
  --mg-line-2:       rgba(1, 33, 70, 0.14);
  --mg-line-3:       rgba(1, 33, 70, 0.22);

  /* --- The core MoneyGlass colour --- */
  --mg-aqua:         #0261A8;   /* the logo's blue ("Organised") - primary actions */
  --mg-aqua-bright:  #3D9BE0;
  --mg-aqua-deep:    #014A82;
  --mg-aqua-tint:    #E3EFFA;
  --mg-aqua-tint-2:  #C6DDF3;

  /* --- Meaning --- */
  --mg-in:           #2F7A12;   /* money that arrived */
  --mg-in-tint:      #EAF5E0;
  --mg-out:          #B34A34;   /* money that left */
  --mg-out-tint:     #FBEBE7;
  --mg-committed:    #0F4677;   /* already spoken for */
  --mg-committed-tint: #E5EDF6;
  --mg-set-aside:    #853496;   /* the logo's purple */   /* in a pot */
  --mg-set-aside-tint: #F4E9F7;
  --mg-warn:         #A35500;
  --mg-warn-tint:    #FFF1E0;
  --mg-danger:       #B3372B;
  --mg-danger-tint:  #FBE7E4;

  /* --- Shape --- */
  --mg-r-sm:  10px;
  --mg-r:     14px;
  --mg-r-lg:  20px;
  --mg-r-xl:  28px;

  /* --- Depth. Three levels, used sparingly. --- */
  --mg-shadow-1: 0 1px 2px rgba(1, 33, 70, .04),
                 0 1px 3px rgba(1, 33, 70, .06);
  --mg-shadow-2: 0 2px 4px rgba(1, 33, 70, .04),
                 0 12px 28px -14px rgba(1, 33, 70, .22);
  --mg-shadow-3: 0 4px 8px rgba(1, 33, 70, .05),
                 0 32px 64px -28px rgba(1, 33, 70, .32);
  --mg-glow-aqua: 0 18px 44px -22px rgba(2, 97, 168, .45);

  /* --- Type ---
     Plus Jakarta Sans for headings: geometric, warm, distinctive without
     being a trend. Inter for body and every figure: unbeatable numerals and
     a proper tabular set. The previous Source Serif made the product read
     editorial and slightly old-fashioned - see docs/UI_GUIDELINES.md. */
  --mg-font-display: "Plus Jakarta Sans", "Inter", system-ui, -apple-system,
                     "Segoe UI", Roboto, sans-serif;
  --mg-font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
                     sans-serif;

  --bs-body-font-family: var(--mg-font-body);
  --bs-body-color: var(--mg-text);
  --bs-border-radius: var(--mg-r);
  --bs-link-color: var(--mg-aqua);
  --bs-link-hover-color: var(--mg-aqua-deep);

  /* --- Layout --- */
  /* D170: the approved logo's palette (sampled from the artwork). The bright
     green and orange are for fills, icons and accents - never small text on
     white (contrast). Text uses the deeper shades. */
  --mg-brand-navy:   #012146;
  --mg-brand-blue:   #0261A8;
  --mg-brand-green:  #57A607;
  --mg-brand-orange: #F98705;
  --mg-brand-purple: #853496;
  --mg-brand-teal:   #04A4B2;
  --mg-kind-personal:  #2F7A12;   --mg-kind-personal-tint:  #EDF6E4;
  --mg-kind-household: #6D2A7D;   --mg-kind-household-tint: #F4EAF7;
  --mg-kind-business:  #0F4677;   --mg-kind-business-tint:  #E5EDF6;
  --mg-sidebar: 248px;
  --mg-bottombar: 62px;
}

/* -------------------------------------------------------------------------
   2. Base and typography
   ------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--mg-page);
  color: var(--mg-text);
  font-family: var(--mg-font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, .mg-display {
  font-family: var(--mg-font-display);
  color: var(--mg-ink);
  letter-spacing: -0.021em;
  font-weight: 700;
  line-height: 1.18;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.06rem; }

.mg-display {
  font-weight: 800;
  letter-spacing: -0.032em;
  line-height: 1.05;
}

a { color: var(--mg-aqua); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--mg-aqua-deep); }

.mg-eyebrow {
  font-family: var(--mg-font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mg-text-mute);
  margin: 0 0 8px;
}

.mg-soft  { color: var(--mg-text-soft); }

.mg-hint {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--mg-text-mute);
}

/* --- Money. Tabular, tight, and never allowed to wrap mid-number. --- */
.mg-money {
  font-family: var(--mg-font-body);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.018em;
  white-space: nowrap;
}

/* A deliberate four-step scale. Anything outside it is a mistake. */
.mg-fig-hero { font-size: clamp(2.4rem, 1.6rem + 3.2vw, 3.4rem); font-weight: 700; line-height: 1; }
.mg-fig-1    { font-size: clamp(1.6rem, 1.3rem + 1.1vw, 2rem);   font-weight: 700; line-height: 1.1; }
.mg-fig-2    { font-size: 1.3rem;  font-weight: 650; line-height: 1.2; }
.mg-fig-3    { font-size: 1.02rem; font-weight: 600; line-height: 1.3; }

.mg-in-text  { color: var(--mg-in); }
.mg-out-text { color: var(--mg-out); }

/* -------------------------------------------------------------------------
   3. App shell
   -------------------------------------------------------------------------
   Desktop: a quiet left rail. Six destinations is a small, stable set, and a
   persistent rail keeps them all one click away while letting the content
   column breathe. It also gives optional modules somewhere to appear later
   without redesigning the header.

   Mobile: a bottom bar. Thumb-reachable is the only thing that matters
   one-handed, and six 62px targets fit a 375px screen comfortably.
   ------------------------------------------------------------------------- */
.mg-app { min-height: 100vh; }

/* The page never scrolls sideways. Wide content - tables, charts, the period
   row - is given its own overflow-x container; this stops anything that is
   missed from dragging every card's right-hand edge off a phone screen. */
.mg-main { min-width: 0; overflow-x: clip; }

.mg-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--mg-sidebar);
  background: var(--mg-surface);
  border-right: 1px solid var(--mg-line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 1030;
  overflow-y: auto;
}

.mg-main { padding: 26px 20px 40px; max-width: 1320px; }

@media (min-width: 992px) {
  .mg-main { margin-left: var(--mg-sidebar); padding: 32px 40px 64px; }
}

@media (max-width: 991.98px) {
  .mg-sidebar { display: none; }
  .mg-main { padding-bottom: calc(var(--mg-bottombar) + 28px); }
}

/* --- Brand lockup --- */
.mg-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: var(--mg-font-display);
  font-weight: 800;
  font-size: 1.16rem;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.mg-brand:hover { text-decoration: none; }
.mg-brand-mark { width: 26px; height: 26px; flex: 0 0 auto; }

/* Money in ink, Glass in aqua - the wordmark carries the palette. */
.mg-brand-money { color: var(--mg-ink); }
.mg-brand-glass { color: var(--mg-aqua); }

/* --- Rail navigation --- */
.mg-nav { display: flex; flex-direction: column; gap: 2px; }

.mg-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--mg-r-sm);
  color: var(--mg-text-soft);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}

.mg-nav-link:hover { background: var(--mg-surface-2); color: var(--mg-ink); text-decoration: none; }

.mg-nav-link.active {
  background: var(--mg-aqua-tint);
  color: var(--mg-aqua-deep);
  font-weight: 650;
}

/* Every icon has an intrinsic size. An <svg> with no width or height attribute
   falls back to the SVG default of 300x150 and scales to fill its parent, which
   drew the landing page's feature icons about six times too large across their
   own headings. Setting it on the class means a call site that forgets cannot
   break a page. */
.mg-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
}

.mg-nav-link .mg-ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.mg-nav-link.active .mg-ico { opacity: 1; }

.mg-nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mg-text-mute);
  padding: 0 11px;
  margin: 6px 0 4px;
}

.mg-sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

/* --- Mobile bottom bar --- */
.mg-bottombar {
  position: fixed;
  inset: auto 0 0 0;
  min-height: var(--mg-bottombar);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--mg-line);
  display: flex;
  z-index: 1040;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 992px) { .mg-bottombar { display: none; } }

.mg-tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 2px;
  color: var(--mg-text-mute);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-height: 56px;
}

.mg-tab .mg-ico { width: 20px; height: 20px; }
.mg-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.mg-tab.active { color: var(--mg-aqua-deep); }
.mg-tab:hover { text-decoration: none; color: var(--mg-ink); }

/* --- Mobile top bar --- */
.mg-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--mg-surface);
  border-bottom: 1px solid var(--mg-line);
  position: sticky;
  top: 0;
  z-index: 1020;
}

@media (min-width: 992px) { .mg-topbar { display: none; } }

/* -------------------------------------------------------------------------
   4. Surfaces
   ------------------------------------------------------------------------- */
.mg-card {
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  box-shadow: var(--mg-shadow-1);
}

.mg-card-pad    { padding: 20px 22px; }
.mg-card-pad-lg { padding: 26px 28px; }

.mg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--mg-line);
}

/* A card heading that is drawing attention to itself. Tinted rule only - the
   card body stays white, because a whole red panel reads as a crisis when the
   honest message is "check this". */
.mg-card-head-alert { border-bottom-color: var(--mg-danger-tint); }

/* A card heading and its summary stack rather than fight for width on a
   phone. "Needs / checking" broken across two lines beside a long summary is
   the sort of thing that makes a careful layout look careless. */
@media (max-width: 575.98px) {
  .mg-card-head { flex-direction: column; align-items: flex-start; gap: 4px; }
}

.mg-card-head h2, .mg-card-head h3 {
  font-family: var(--mg-font-body);
  font-size: .94rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--mg-ink);
}

/* Frosted glass. Used ONLY on the hero and the MoneyGlass panel - if every
   card is frosted the interface stops being readable and the signature stops
   being a signature. */
.mg-glass-surface {
  position: relative;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, .82), rgba(236, 250, 248, .58)),
    var(--mg-ice);
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: var(--mg-r-lg);
  box-shadow: var(--mg-shadow-2);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  overflow: hidden;
}

/* A single soft aqua bloom behind the hero. One gradient, not five. */
.mg-glass-surface::before {
  content: "";
  position: absolute;
  inset: -40% 40% 55% -20%;
  background: radial-gradient(closest-side, rgba(61, 155, 224, .30), transparent);
  pointer-events: none;
}

/* -------------------------------------------------------------------------
   5. Figure hierarchy
   -------------------------------------------------------------------------
   Not every number is a Bootstrap stat card. Four levels, set in section 2:
     .mg-fig-hero   the one number the screen is about
     .mg-fig-1      a primary supporting figure
     .mg-fig-2      a secondary figure, usually paired with another
     .mg-fig-3      context, inside a sentence or a working-out row
   ------------------------------------------------------------------------- */
/* Explanatory prose sits at a readable measure. Long lines of soft grey text
   under a big number are one of the fastest ways to make a screen unreadable. */
.mg-lede { max-width: 46ch; }

.mg-figure-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--mg-text-soft);
  margin-bottom: 3px;
}

.mg-figure-note {
  font-size: 12px;
  color: var(--mg-text-mute);
  margin-top: 3px;
  line-height: 1.45;
}

.mg-figure-grid {
  display: grid;
  gap: 1px;
  background: var(--mg-line);
  border-radius: var(--mg-r);
  overflow: hidden;
  border: 1px solid var(--mg-line);
}

.mg-figure-grid > * { background: var(--mg-surface); padding: 16px 18px; }

@media (min-width: 576px) { .mg-figure-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .mg-figure-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }

/* Three figures in a two-column grid leave a hole, and the hole is not empty:
   the grid's own background shows through it as a grey rectangle that reads as
   a broken card. So the third one spans the row until there is room for three
   across. */
.mg-figure-grid.cols-3 > :last-child:nth-child(3) { grid-column: 1 / -1; }

@media (min-width: 992px) {
  .mg-figure-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .mg-figure-grid.cols-3 > :last-child:nth-child(3) { grid-column: auto; }
}

/* A quiet accent bar, used only where a figure carries a meaning colour. */
.mg-accent {
  border-left: 3px solid var(--mg-accent-colour, var(--mg-line-2));
  padding-left: 13px;
}

.mg-accent-in        { --mg-accent-colour: var(--mg-in); }
.mg-accent-out       { --mg-accent-colour: var(--mg-out); }
.mg-accent-aqua      { --mg-accent-colour: var(--mg-aqua); }
.mg-accent-committed { --mg-accent-colour: var(--mg-committed); }
.mg-accent-set-aside { --mg-accent-colour: var(--mg-set-aside); }
.mg-accent-warn      { --mg-accent-colour: var(--mg-warn); }
.mg-accent-danger    { --mg-accent-colour: var(--mg-danger); }

/* The working-out row: "available now + still to come in - still to go out".
   Showing the arithmetic is what makes a projected figure trustworthy rather
   than magical, so it gets real layout rather than a footnote. It wraps to
   stacked rows on a phone instead of shrinking the numbers. */
.mg-working {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 16px;
  background: var(--mg-surface-2);
  border-radius: var(--mg-r);
}

.mg-working-part { display: flex; flex-direction: column; gap: 1px; }

.mg-working-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--mg-text-soft);
  white-space: nowrap;
}

.mg-working-op {
  font-size: 17px;
  font-weight: 500;
  color: var(--mg-text-mute);
  padding-top: 12px;
}

@media (max-width: 400px) {
  .mg-working { gap: 8px 12px; }
  .mg-working-op { padding-top: 10px; }
}

/* -------------------------------------------------------------------------
   6. Status: the human-readable health layer
   -------------------------------------------------------------------------
   Derived entirely from figures MoneyGlass already computes - no invented
   score. Every state carries a word AND a shape, never colour alone.
   ------------------------------------------------------------------------- */
.mg-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
}

.mg-status .mg-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}

.mg-status-good      { background: var(--mg-aqua-tint);      color: var(--mg-aqua-deep); }
.mg-status-steady    { background: var(--mg-committed-tint); color: #2A578F; }
.mg-status-watch     { background: var(--mg-warn-tint);      color: #7C5606; }
.mg-status-attention { background: var(--mg-danger-tint);    color: #8C2A1C; }

.mg-status-lg { font-size: 14.5px; padding: 8px 16px 8px 13px; }

/* -------------------------------------------------------------------------
   7. Period control
   ------------------------------------------------------------------------- */
.mg-periods {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--mg-surface-2);
  border: 1px solid var(--mg-line);
  border-radius: 999px;
}

.mg-periods a, .mg-periods button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mg-text-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
  min-height: 34px;
}

.mg-periods a:hover, .mg-periods button:hover:not(:disabled) {
  color: var(--mg-ink); text-decoration: none;
}

.mg-periods a.active, .mg-periods button.active {
  background: var(--mg-surface);
  color: var(--mg-ink);
  box-shadow: var(--mg-shadow-1);
}

/* Controls that exist but are not wired up yet are shown disabled rather than
   hidden, so the shape of the feature is honest. */
.mg-periods [aria-disabled="true"], .mg-periods button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

/* --- Moving through time -------------------------------------------------
   Arrows either side of the period's own name, which is both the label and the
   thing being changed. Putting the name between them is what makes "← August"
   read as one control rather than as three. */
.mg-period { display: flex; flex-direction: column; gap: 9px; align-items: flex-start; }

.mg-period-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mg-period-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface);
  color: var(--mg-text-soft);
  text-decoration: none;
  transition: all .12s ease;
}

.mg-period-step:hover {
  border-color: var(--mg-ink);
  color: var(--mg-ink);
  text-decoration: none;
}

.mg-period-now {
  font-family: var(--mg-font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--mg-ink);
  padding: 0 10px;
  min-width: 9.5rem;
  text-align: center;
  white-space: nowrap;
}

/* Offered only when it would actually go somewhere - see the template. */
.mg-period-today {
  margin-left: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--mg-aqua-tint);
  color: var(--mg-aqua-deep);
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.mg-period-today:hover { background: var(--mg-aqua-tint-2); color: var(--mg-aqua-deep); }

.mg-custom { align-self: stretch; min-width: min(340px, 100%); }

.mg-custom-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.mg-custom-form .btn { grid-column: 1 / -1; }

@media (min-width: 576px) {
  .mg-custom-form { grid-template-columns: 1fr 1fr auto; }
  .mg-custom-form .btn { grid-column: auto; }
}

@media (pointer: coarse) {
  .mg-period-step { width: 44px; height: 44px; }
  .mg-period-today { min-height: 44px; display: inline-flex; align-items: center; }
}

/* Search and period, side by side above a list. Search first on a phone:
   somebody who has opened this screen to find one payment should not scroll
   past a period control to do it. */
.mg-list-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

@media (min-width: 992px) {
  .mg-list-controls {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
  }
  .mg-list-controls .mg-search { max-width: 340px; flex: 1 1 260px; }
  .mg-list-controls .mg-period { align-items: flex-end; }
}

/* The period control on a row of its own. Right-aligned above the wide screens
   where it sits beside a hero, left-aligned on a phone where it is the first
   thing under the title. */
.mg-period-row { display: flex; }

@media (min-width: 768px) {
  .mg-period-row { justify-content: flex-end; }
  .mg-period-row .mg-period { align-items: flex-end; }
}

/* --- Search --------------------------------------------------------------
   One field, on the list it searches. Not a global command palette: people
   look for a payment while they are looking at payments. */
.mg-search { position: relative; display: flex; align-items: center; }

.mg-search .mg-ico {
  position: absolute;
  left: 12px;
  color: var(--mg-text-mute);
  pointer-events: none;
}

.mg-search input {
  padding-left: 38px;
  min-width: 0;
  width: 100%;
}

.mg-search-clear {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  color: var(--mg-text-mute);
  text-decoration: none;
}

.mg-search-clear:hover { color: var(--mg-ink); background: var(--mg-surface-2); }

/* The pill row cannot wrap - breaking "6 monthly" across two lines would be
   worse than scrolling - so it scrolls inside itself instead of pushing the
   page wide. The scrollbar is hidden because the row is obviously swipeable
   and a 15px bar under a 34px control looks broken. */
.mg-period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.mg-period-bar::-webkit-scrollbar { display: none; }
.mg-periods { flex-wrap: nowrap; }

@media (pointer: coarse) { .mg-periods a, .mg-periods button { min-height: 42px; } }

@media (max-width: 575.98px) {
  .mg-periods { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .mg-periods::-webkit-scrollbar { display: none; }
}

/* -------------------------------------------------------------------------
   8. The MoneyGlass visual
   -------------------------------------------------------------------------
   An inline SVG (templates/partials/moneyglass.html). Every geometry value
   comes from the server; nothing here computes a financial figure.

   It shows COMMITMENT COVERAGE and nothing else. The rim at 100% means this
   period's commitments are covered - not that the account is full.
   ------------------------------------------------------------------------- */
.mg-glass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.mg-glass-svg {
  width: 100%;
  /* The signature element of the product, drawn at a size that says so. It
     still scales down with its column, so a phone gets a glass that fits. */
  max-width: 268px;
  height: auto;
  display: block;
  overflow: visible;
}

/* The liquid rises on load. The final transform is set inline from server
   data; only the transition lives here. */
.mg-liquid { transition: transform 1100ms cubic-bezier(.22, 1, .36, 1); }

/* Decorative motion (D142). Off by default: it only runs once
   static/js/moneyglass.js adds .mg-glass-live (JavaScript on, motion not
   reduced), which is also what puts the pause control on the page - so
   there is never motion without a way to stop it. Paused while the glass
   is off screen or the tab is hidden. The still picture says everything. */
.mg-bubble { opacity: .32; }
.mg-glass-live .mg-wave-front { animation: mg-wave 7s linear infinite; }
.mg-glass-live .mg-wave-back { animation: mg-wave 11s linear infinite reverse; }
.mg-glass-live .mg-bubble { opacity: 0; animation: mg-bubble 9s ease-in infinite; }
.mg-glass-live .mg-bubble-2 { animation-duration: 11s; animation-delay: -3s; }
.mg-glass-live .mg-bubble-3 { animation-duration: 13s; animation-delay: -7s; }
.mg-glass-live .mg-bubble-4 { animation-duration: 10s; animation-delay: -5s; }
.mg-glass-paused .mg-wave, .mg-glass-paused .mg-bubble,
.mg-glass-offscreen .mg-wave, .mg-glass-offscreen .mg-bubble,
.mg-motion-hidden .mg-wave, .mg-motion-hidden .mg-bubble { animation-play-state: paused; }

/* One wavelength (40 units) per loop, so the surface never jumps. */
@keyframes mg-wave { from { transform: translateX(0); } to { transform: translateX(-40px); } }
/* Bubbles rise within the "money you have" band and fade before its top;
   --mg-rise is copied by the script from the template's data-rise (that
   band's height, server-drawn); without it the bubbles never animate. */
@keyframes mg-bubble {
  0%   { transform: translateY(0); opacity: 0; }
  15%  { opacity: .45; }
  80%  { opacity: .3; }
  100% { transform: translateY(var(--mg-rise, -40px)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-liquid { transition: none; }
  .mg-wave, .mg-bubble { animation: none !important; }
  .mg-bubble { opacity: .32 !important; }
}

/* Pause / play for the decorative motion. Inserted by JavaScript only. */
.mg-glass-motion {
  align-self: flex-end; margin-bottom: -8px;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--mg-line-2);
  background: var(--mg-surface); color: var(--mg-text-soft);
  font-size: 12.5px; font-weight: 600; line-height: 1; cursor: pointer;
}
.mg-glass-motion:hover { color: var(--mg-ink); border-color: var(--mg-line-3); }
.mg-glass-motion:focus-visible { outline: 3px solid var(--mg-aqua); outline-offset: 2px; }
.mg-glass-motion svg { width: 10px; height: 10px; }

/* Wide enough that a phrase like "Covered, once expected money arrives"
   breaks in two rather than three. */
.mg-glass-caption { text-align: center; max-width: 330px; }

.mg-glass-headline {
  font-family: var(--mg-font-display);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  color: var(--mg-ink);
}

.mg-glass-short { color: var(--mg-danger); }

/* Wide enough that "Covered by money still expected" stays on one line and its
   figure stays on the same baseline. A wrapped label with the amount floating
   beside its second line is the sort of small misalignment that makes a
   financial figure look approximate. */
.mg-glass-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 340px;
}

.mg-legend-row { display: flex; align-items: baseline; gap: 9px; font-size: 13px; }
.mg-legend-row .mg-legend-swatch { align-self: center; }
.mg-legend-swatch { width: 11px; height: 11px; border-radius: 3.5px; flex: 0 0 auto; }

.mg-swatch-held {
  background: linear-gradient(180deg, var(--mg-aqua-bright), var(--mg-aqua));
}

.mg-swatch-expected {
  background-color: var(--mg-aqua-tint-2);
  background-image: repeating-linear-gradient(
    135deg, rgba(2, 97, 168, .55) 0 3px, rgba(2, 97, 168, .12) 3px 6px);
}

.mg-swatch-due { background: var(--mg-out); }

.mg-legend-label { color: var(--mg-text-soft); flex: 1 1 auto; min-width: 0; }
.mg-legend-value { margin-left: auto; font-weight: 650; white-space: nowrap; }

/* -------------------------------------------------------------------------
   9. Transaction timeline
   ------------------------------------------------------------------------- */
.mg-timeline { list-style: none; margin: 0; padding: 0; }

.mg-tl-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--mg-line);
}

.mg-tl-item:last-child { border-bottom: 0; }
.mg-tl-item:hover { background: var(--mg-surface-2); }

/* Something that has happened recedes; the eye goes to what is still open.
   The left rule carries it, so it survives greyscale. */
.mg-tl-done { background: linear-gradient(90deg, var(--mg-in) 0 3px, transparent 3px); }
.mg-tl-done .mg-tl-name { color: var(--mg-text-soft); font-weight: 550; }
.mg-tl-overdue { background: linear-gradient(90deg, var(--mg-danger) 0 3px, var(--mg-danger-tint) 3px); }

.mg-tl-date {
  font-size: 11px;
  font-weight: 650;
  color: var(--mg-text-mute);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.mg-tl-date .mg-tl-day {
  display: block;
  font-size: 17px;
  color: var(--mg-ink);
  letter-spacing: -0.02em;
  text-transform: none;
}

.mg-tl-main { min-width: 0; }

.mg-tl-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--mg-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mg-tl-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--mg-text-mute);
}

.mg-tl-right { display: flex; align-items: center; gap: 14px; justify-self: end; min-width: 0; flex-wrap: wrap; }
.mg-tl-amount { font-weight: 700; font-size: 15px; }

@media (max-width: 575.98px) {
  .mg-tl-item { grid-template-columns: 44px 1fr; padding: 12px 16px; row-gap: 8px; }
  .mg-tl-right { grid-column: 1 / -1; justify-self: stretch; justify-content: space-between; }
}

/* --- Row actions: present, quiet, obvious on approach --- */
.mg-row-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* The two below are modifiers, and are used on their own in half a dozen
   places. A <button> whose only styling is `border-color` keeps the browser's
   own `border: 2px outset`, which draws a 1990s bevel - so they carry the base
   themselves rather than depending on being paired. */
.mg-mini-action,
.mg-mini-primary,
.mg-mini-quiet {
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface);
  color: var(--mg-text-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.45;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all .12s ease;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
}

.mg-mini-action:hover,
.mg-mini-quiet:hover {
  border-color: var(--mg-ink); color: var(--mg-ink);
  text-decoration: none; transform: translateY(-1px);
}

.mg-mini-primary { background: var(--mg-aqua); border-color: var(--mg-aqua); color: #fff; }
.mg-mini-primary:hover { background: var(--mg-aqua-deep); border-color: var(--mg-aqua-deep); color: #fff; }
.mg-mini-quiet { border-color: transparent; color: var(--mg-text-mute); }
.mg-mini-quiet:hover { border-color: var(--mg-line-2); }

/* Touch targets stay 44px on coarse pointers even though they look compact. */
@media (pointer: coarse) {
  .mg-mini-action { min-height: 44px; padding: 10px 15px; font-size: 12.5px; }
}

/* --- The plain list -------------------------------------------------------
   The timeline above is for dated money. This is its sibling for everything
   else that is a list of named things with a figure beside them: accounts,
   pots, people, plan features. Same rhythm, no date column.

   Two components rather than one with a modifier, because a date column that
   is sometimes empty produces ragged rows, and because "list of transactions"
   and "list of accounts" want genuinely different hover and status treatment. */
.mg-list { list-style: none; margin: 0; padding: 0; }

.mg-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--mg-line);
}

.mg-list-item:last-child { border-bottom: 0; }
.mg-list-main { min-width: 0; flex: 1 1 auto; }

.mg-list-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--mg-ink);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.mg-list-sub {
  font-size: 12.5px;
  color: var(--mg-text-mute);
  margin-top: 2px;
}

.mg-list-amount {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  text-align: right;
}

.mg-list-date {
  font-size: 12px;
  font-weight: 650;
  color: var(--mg-text-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 62px;
}

/* A small colour chip. Always sits next to a name, never alone - colour is a
   second channel here, never the only one. */
.mg-dot {
  /* inline-block, not inline: width and height do not apply to an inline box,
     and inside a non-flex parent the dot collapsed to a hairline. */
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--mg-dot-colour, var(--mg-line-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mg-dot-colour, var(--mg-line-2)) 18%, transparent);
}

@media (max-width: 575.98px) {
  .mg-list-item { padding: 13px 16px; flex-wrap: wrap; }
}

/* -------------------------------------------------------------------------
   10. Badges
   ------------------------------------------------------------------------- */
.mg-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--mg-surface-2);
  color: var(--mg-text-soft);
  white-space: nowrap;
}

.mg-tag-expected   { background: var(--mg-warn-tint);      color: #7C5606; }
.mg-tag-confirmed  { background: var(--mg-committed-tint); color: #2A578F; }
.mg-tag-actual     { background: var(--mg-in-tint);        color: #145E3D; }
.mg-tag-overdue    { background: var(--mg-danger-tint);    color: #8C2A1C; }
.mg-tag-partial    { background: var(--mg-warn-tint);      color: #7C5606; }
.mg-tag-unexpected { background: var(--mg-set-aside-tint); color: #4B3BA8; }
.mg-tag-estimate   { background: var(--mg-set-aside-tint); color: #4B3BA8; }
.mg-tag-good       { background: var(--mg-in-tint);        color: #145E3D; }
.mg-tag-birthday   { background: rgba(133, 52, 150, .13);  color: #6D2A7D; }   /* D174f */
.mg-tag-bad        { background: var(--mg-out-tint);       color: #8C2A1C; }

/* "You matched this before." Its own tone because it is a different kind of
   claim from the others: not a judgement about the money, but a reminder of
   something the user themselves confirmed. */
.mg-tag-remembered { background: var(--mg-committed-tint); color: #2A578F; }

/* Expected against actual, side by side inside one figure cell. Wraps to
   stacked on a narrow screen rather than shrinking the money. */
.mg-drift-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin-top: 4px;
}

.mg-drift-pair > span { display: flex; flex-direction: column; }

/* What the bank actually wrote. Monospaced, because the whole point of the
   remembered-payees screen is that this string is unreadable machine wording
   and the column beside it is not. */
.mg-alias-pattern {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: -0.01em;
  color: var(--mg-text-soft);
  word-break: break-word;
}

/* -------------------------------------------------------------------------
   11. Progress, pots and accounts
   ------------------------------------------------------------------------- */
.mg-track { height: 7px; border-radius: 999px; background: var(--mg-surface-2); overflow: hidden; }

.mg-track > div {
  height: 100%;
  border-radius: 999px;
  background: var(--mg-set-aside);
  transition: width 700ms cubic-bezier(.22, 1, .36, 1);
}

/* Reserved for the future bank-reconciliation trust indicator. Rendered now
   only as "last updated"; the component is here so the eventual
   "MoneyGlass matches your bank" slots in without a redesign. */
.mg-trust {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--mg-surface-2); color: var(--mg-text-soft);
}

.mg-trust-ok { background: var(--mg-in-tint); color: #145E3D; }
.mg-trust-stale { background: var(--mg-warn-tint); color: #7C5606; }

/* --- Account cards -------------------------------------------------------
   A card, not a row: the question here is "is this still right?", and that
   needs room for a date and a source. The foot strip is where the bank
   connection indicator will live - see docs/BANK_RECONCILIATION.md - so that
   feature will change what it says rather than how the page is laid out. */
.mg-account {
  display: flex;
  flex-direction: column;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  box-shadow: var(--mg-shadow-1);
  overflow: hidden;
  transition: box-shadow .15s ease, transform .15s ease;
}

.mg-account:hover { box-shadow: var(--mg-shadow-2); transform: translateY(-1px); }
.mg-account-body { padding: 20px 22px; flex: 1 1 auto; }

/* The working behind a derived balance. Small, quiet, and always present when
   there has been movement - a figure a user cannot reconstruct is one they have
   to take on trust. */
.mg-account-working {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--mg-text-soft);
  background: var(--mg-surface-2);
  border-radius: var(--mg-r-sm);
  padding: 9px 12px;
}

.mg-account-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 22px;
  background: var(--mg-surface-2);
  border-top: 1px solid var(--mg-line);
  min-height: 54px;
}

/* --- Debt ----------------------------------------------------------------
   Cash and debt sit side by side with the net between them, so the three
   figures read as one sentence rather than as three unrelated numbers. */
.mg-net-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 20px;
}

.mg-net-row .mg-working-op { padding-top: 18px; }

.mg-debt-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 14px;
}

.mg-debt-plan {
  border-top: 1px solid var(--mg-line);
  padding-top: 14px;
}

/* A debt with no plan is money leaving that no forecast knows about. It is
   marked, not hidden - and in words as well as colour. */
.mg-debt-plan-none {
  border-top-color: var(--mg-warn);
  color: var(--mg-text-soft);
}

.mg-debt-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--mg-r-sm);
  background: var(--mg-warn-tint);
  color: #7C5606;
  font-size: 13.5px;
  line-height: 1.5;
}

.mg-debt-warning .mg-ico { flex: 0 0 auto; }

/* --- Pots ----------------------------------------------------------------
   Three kinds, three looks. An obligation (tax, VAT) is money you are holding
   for somebody else and is drawn in the committed blue; protection (buffers,
   emergency funds) in the calm aqua; a goal in the set-aside violet. Each also
   states its kind in words at the top of the card, so the distinction survives
   greyscale, colour blindness and a screen reader. */
.mg-pot {
  display: flex;
  flex-direction: column;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-top: 3px solid var(--mg-pot-colour, var(--mg-line-2));
  border-radius: var(--mg-r);
  box-shadow: var(--mg-shadow-1);
  padding: 18px 22px 20px;
  transition: box-shadow .15s ease, transform .15s ease;
}

.mg-pot:hover { box-shadow: var(--mg-shadow-2); transform: translateY(-1px); }

.mg-pot-obligation { --mg-pot-colour: var(--mg-committed); --mg-pot-tint: var(--mg-committed-tint); }
.mg-pot-protection { --mg-pot-colour: var(--mg-aqua);      --mg-pot-tint: var(--mg-aqua-tint); }
.mg-pot-goal       { --mg-pot-colour: var(--mg-set-aside); --mg-pot-tint: var(--mg-set-aside-tint); }

.mg-pot-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  background: var(--mg-pot-tint, var(--mg-surface-2));
  color: var(--mg-pot-colour, var(--mg-text-soft));
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
  margin-bottom: 12px;
}

.mg-pot .mg-track-pot > div { background: var(--mg-pot-colour, var(--mg-aqua)); }
.mg-pot-foot { margin-top: auto; padding-top: 16px; }

/* Bootstrap has no min-width utility, and a flex child needs one to ellipsis. */
.min-w-0 { min-width: 0; }

/* -------------------------------------------------------------------------
   12. Projection chart
   -------------------------------------------------------------------------
   Inline SVG, no charting library. Every coordinate is built server-side in
   finance/services/chart.py; this only styles it. Nothing here computes.
   ------------------------------------------------------------------------- */
.mg-chart { width: 100%; height: auto; display: block; overflow: visible; }
.mg-chart-line { fill: none; stroke: var(--mg-aqua); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.mg-chart-area { fill: url(#mgChartFade); stroke: none; }

.mg-chart-wrap { padding: 4px 2px 0; }

/* Axis labels sit under the chart, each anchored at its own x position rather
   than evenly spaced, so a label always lines up with the point it names. */
.mg-chart-axis {
  position: relative;
  height: 20px;
  margin-top: 2px;
}

.mg-chart-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--mg-text-mute);
  white-space: nowrap;
}

/* First and last labels pull inside the edge so they are never clipped. */
.mg-chart-axis span:first-child { transform: none; }
.mg-chart-axis span:last-child  { transform: translateX(-100%); }
.mg-chart-zero { stroke: var(--mg-danger); stroke-width: 1; stroke-dasharray: 4 4; opacity: .55; }
.mg-chart-grid { stroke: var(--mg-line); stroke-width: 1; }
.mg-chart-dot  { fill: var(--mg-surface); stroke: var(--mg-aqua); stroke-width: 2.5; }
.mg-chart-low  { fill: var(--mg-danger); stroke: var(--mg-surface); stroke-width: 2; }
.mg-chart-label { font-size: 10px; font-weight: 600; fill: var(--mg-text-mute); font-family: var(--mg-font-body); }

/* A quiet table. Bootstrap's default puts a rule under every row, which turns
   a twelve-month forecast into a ladder; here only the header is ruled and the
   rows are separated by space. */
.mg-table { --bs-table-bg: transparent; margin: 0; }
.mg-table > thead > tr > th {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--mg-text-mute);
  border-bottom: 1px solid var(--mg-line);
  padding: 10px 22px;
  background: transparent;
}
.mg-table > tbody > tr > td {
  border-bottom: 1px solid var(--mg-line);
  padding: 11px 22px;
  font-size: 14px;
  color: var(--mg-text);
}
.mg-table > tbody > tr:last-child > td { border-bottom: none; }
.mg-table > tbody > tr:hover > td { background: var(--mg-surface-2); }

/* -------------------------------------------------------------------------
   13. Buttons
   ------------------------------------------------------------------------- */
.btn-mg, .btn-mg-accent, .btn-mg-quiet {
  font-family: var(--mg-font-body);
  font-weight: 650;
  font-size: 14px;
  border-radius: var(--mg-r-sm);
  padding: 9px 18px;
  line-height: 1.4;
  transition: all .14s ease;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn-mg { background: var(--mg-ink); border: 1px solid var(--mg-ink); color: #fff; }
.btn-mg:hover { background: var(--mg-ink-2); border-color: var(--mg-ink-2); color: #fff; transform: translateY(-1px); box-shadow: var(--mg-shadow-2); }

.btn-mg-accent {
  background: linear-gradient(180deg, #0B6FBE, var(--mg-aqua));
  border: 1px solid var(--mg-aqua-deep);
  color: #FFFFFF;
  box-shadow: var(--mg-glow-aqua);
}

.btn-mg-accent:hover, .btn-mg-accent:focus { color: #FFFFFF; transform: translateY(-1px); filter: brightness(1.06); }

.btn-mg-quiet { background: var(--mg-surface); border: 1px solid var(--mg-line-2); color: var(--mg-text); }
.btn-mg-quiet:hover { border-color: var(--mg-ink); color: var(--mg-ink); transform: translateY(-1px); }

.btn-lg.btn-mg, .btn-lg.btn-mg-accent, .btn-lg.btn-mg-quiet {
  font-size: 15.5px; padding: 13px 26px; min-height: 50px; border-radius: var(--mg-r);
}

.btn-sm.btn-mg, .btn-sm.btn-mg-accent, .btn-sm.btn-mg-quiet {
  font-size: 13px; padding: 7px 14px; min-height: 36px;
}

@media (pointer: coarse) {
  .btn-sm.btn-mg, .btn-sm.btn-mg-accent, .btn-sm.btn-mg-quiet { min-height: 44px; }
}

/* -------------------------------------------------------------------------
   14. Forms
   ------------------------------------------------------------------------- */
.form-label { font-size: 13.5px; font-weight: 650; color: var(--mg-ink); margin-bottom: 5px; }

.form-control, .form-select {
  border: 1px solid var(--mg-line-2);
  border-radius: var(--mg-r-sm);
  padding: 10px 13px;
  font-size: 15px;
  color: var(--mg-text);
  background-color: var(--mg-surface);
  min-height: 44px;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--mg-aqua);
  box-shadow: 0 0 0 3.5px var(--mg-aqua-tint);
  outline: none;
}

.form-control::placeholder { color: var(--mg-text-mute); }
.form-control-lg { font-size: 16.5px; padding: 13px 16px; min-height: 52px; }

.form-check-input { width: 1.05em; height: 1.05em; margin-top: .22em; border-color: var(--mg-line-3); }
.form-check-input:checked { background-color: var(--mg-aqua); border-color: var(--mg-aqua); }
.form-check-input:focus { border-color: var(--mg-aqua); box-shadow: 0 0 0 3.5px var(--mg-aqua-tint); }

/* Column headings above an onboarding grid - a label row, not a data row. */
.mg-onboard-head { border-bottom: 0 !important; }

.mg-field-error { font-size: 12.5px; color: var(--mg-danger); margin-top: 4px; font-weight: 550; }

/* Marking what is optional, rather than starring what is required. Most fields
   in this product are optional, so the quieter mark is the more common one. */
.mg-optional {
  font-weight: 500;
  font-size: 12px;
  color: var(--mg-text-mute);
  margin-left: 6px;
}

/* --- Progressive disclosure: the heart of the form simplification --- */
.mg-more {
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r-sm);
  background: var(--mg-surface-2);
  margin-top: 6px;
}

.mg-more > summary {
  cursor: pointer;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--mg-text-soft);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--mg-r-sm);
  min-height: 44px;
}

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

.mg-more > summary::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s ease;
  margin-left: 2px;
}

.mg-more[open] > summary::before { transform: rotate(45deg); }
.mg-more > summary:hover { color: var(--mg-ink); }
.mg-more-body { padding: 4px 15px 15px; border-top: 1px solid var(--mg-line); }

/* --- The direction switch -------------------------------------------------
   Two big targets rather than a dropdown. "Actually, this is money coming in"
   is a thought people have halfway through typing, and it should cost one tap.
   Each half carries its own meaning colour AND its own icon and words. */
.mg-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mg-switch > a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 58px;
  padding: 12px 16px;
  border: 1.5px solid var(--mg-line-2);
  border-radius: var(--mg-r);
  background: var(--mg-surface);
  color: var(--mg-text-soft);
  font-weight: 650;
  font-size: 14.5px;
  text-align: center;
  text-decoration: none;
  transition: all .14s ease;
}

.mg-switch > a:hover { border-color: var(--mg-ink); color: var(--mg-ink); }

.mg-switch-in.active {
  background: var(--mg-in-tint);
  border-color: var(--mg-in);
  color: #145E3D;
  box-shadow: var(--mg-shadow-1);
}

.mg-switch-out.active {
  background: var(--mg-out-tint);
  border-color: var(--mg-out);
  color: #8C2A1C;
  box-shadow: var(--mg-shadow-1);
}

@media (max-width: 400px) {
  .mg-switch > a { font-size: 13px; padding: 12px 10px; gap: 6px; }
}

/* A link-styled button for a destructive action. Word first, colour second -
   it says what will be removed, so it is never colour alone. */
.mg-remove {
  background: none;
  border: 0;
  padding: 6px 0;
  min-height: 44px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--mg-danger);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.mg-remove:hover { color: #8C2A1C; }

/* --- Choice chips: friendly contextual defaults for quick add --- */
.mg-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.mg-chip {
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mg-text-soft);
  cursor: pointer;
  transition: all .12s ease;
  min-height: 38px;
}

.mg-chip:hover { border-color: var(--mg-aqua); color: var(--mg-aqua-deep); background: var(--mg-aqua-tint); }

@media (pointer: coarse) { .mg-chip { min-height: 44px; } }

/* --- Big directional choice, for "money in or money out?" --- */

/* -------------------------------------------------------------------------
   15. Help, empty states, messages
   ------------------------------------------------------------------------- */
.mg-help {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--mg-text-soft);
  background: var(--mg-aqua-tint);
  border-radius: var(--mg-r-sm);
  padding: 13px 16px;
  border-left: 3px solid var(--mg-aqua);
}

.mg-help strong { color: var(--mg-ink); }

.mg-empty { text-align: center; padding: 44px 24px; color: var(--mg-text-soft); }
.mg-empty h3 { font-size: 1.05rem; margin-bottom: 7px; }
.mg-empty p { max-width: 38ch; margin-inline: auto; }

.alert { border: 0; border-radius: var(--mg-r-sm); font-size: 14px; padding: 12px 16px; }
.alert-success { background: var(--mg-in-tint); color: #145E3D; }
.alert-info    { background: var(--mg-committed-tint); color: #2A578F; }
.alert-warning { background: var(--mg-warn-tint); color: #7C5606; }
.alert-danger  { background: var(--mg-danger-tint); color: #8C2A1C; }

/* -------------------------------------------------------------------------
   16. Marketing surfaces
   ------------------------------------------------------------------------- */
.mg-marketing-nav {
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--mg-line);
  position: sticky; top: 0; z-index: 1030;
}

.mg-hero {
  position: relative;
  overflow: hidden;
  padding: 68px 0 76px;
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(61, 155, 224, .20), transparent 58%),
    radial-gradient(880px 460px at 96% 4%, rgba(61, 116, 196, .16), transparent 54%),
    var(--mg-page);
}

.mg-hero h1 {
  font-size: clamp(2.2rem, 1.4rem + 3.4vw, 3.7rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.03;
  margin-bottom: 18px;
}

.mg-hero-lead {
  font-size: clamp(1.02rem, .96rem + .45vw, 1.19rem);
  color: var(--mg-text-soft);
  max-width: 33rem;
  line-height: 1.6;
}

.mg-feature {
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  padding: 22px;
  height: 100%;
  transition: all .16s ease;
}

.mg-feature:hover { box-shadow: var(--mg-shadow-2); transform: translateY(-2px); }
.mg-feature h3 { font-size: 1.02rem; margin-bottom: 7px; }

.mg-feature-icon .mg-ico { width: 20px; height: 20px; }

.mg-feature-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 14px;
  background: var(--mg-aqua-tint); color: var(--mg-aqua-deep);
}

.mg-price-card {
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r-lg);
  padding: 30px 28px;
  height: 100%;
  display: flex; flex-direction: column;
}

.mg-price-card.featured { border-color: var(--mg-aqua); box-shadow: var(--mg-shadow-3); position: relative; }

.mg-price-badge {
  position: absolute; top: -11px; left: 28px;
  background: var(--mg-aqua); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 11px; border-radius: 999px;
}

.mg-marketing-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  color: var(--mg-text-soft);
  text-decoration: none;
  border-radius: var(--mg-r-sm);
}

.mg-marketing-link:hover { color: var(--mg-ink); background: var(--mg-surface-2); }

.mg-footer {
  background: var(--mg-surface);
  border-top: 1px solid var(--mg-line);
  padding: 34px 0 44px;
  margin-top: 24px;
}

/* Prose stops at a readable measure however wide the screen gets. */
.mg-measure { max-width: 54ch; }

.mg-cta {
  text-align: center;
  padding: 48px 24px 54px;
  border-radius: var(--mg-r-lg);
  background:
    radial-gradient(700px 320px at 50% -30%, rgba(61, 155, 224, .22), transparent 60%),
    var(--mg-surface);
  border: 1px solid var(--mg-line);
}

/* The timeline gets its own frame when it appears outside a card, as an
   illustration on the front page. */
.mg-timeline-framed {
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  overflow: hidden;
  background: var(--mg-surface);
}

/* -------------------------------------------------------------------------
   17. Auth and onboarding
   ------------------------------------------------------------------------- */
.mg-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }

@media (min-width: 992px) { .mg-auth { grid-template-columns: 1fr 1fr; } }

.mg-auth-aside { display: none; padding: 56px 52px; flex-direction: column; justify-content: space-between; }

@media (min-width: 992px) { .mg-auth-aside { display: flex; } }

/* The dark half. Ink rather than a photograph: it is calm, it costs nothing to
   load, and it makes the aqua of the mark the only colour on the panel. */
.mg-auth-dark {
  background:
    radial-gradient(720px 420px at 20% 0%, rgba(61, 155, 224, .22), transparent 62%),
    radial-gradient(560px 380px at 90% 100%, rgba(61, 116, 196, .20), transparent 58%),
    var(--mg-ink);
  color: rgba(255, 255, 255, .78);
}

.mg-auth-quote {
  font-family: var(--mg-font-display);
  font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: #fff;
  margin-bottom: 16px;
}

/* The "here is what happens next" list on the registration panel. Numbers
   rather than ticks: nothing has been achieved yet, and a row of green ticks
   before somebody has typed anything is the kind of false reassurance this
   product is meant to avoid. */
.mg-auth-steps {
  margin: 20px 0 0;
  padding: 0 0 0 22px;
  color: rgba(255, 255, 255, .74);
  font-size: 14.5px;
  line-height: 1.5;
}

.mg-auth-steps li { margin-bottom: 9px; }
.mg-auth-steps li::marker { color: var(--mg-aqua-bright); font-weight: 700; }

.mg-auth-sub { font-size: 1rem; line-height: 1.6; max-width: 34ch; margin: 0; }
.mg-auth-foot { font-size: 12.5px; color: rgba(255, 255, 255, .55); }

.mg-auth-h1 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem);
  margin-bottom: 6px;
}

.mg-auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.mg-auth-form-inner { width: 100%; max-width: 400px; }

/* Set-up has its own shell: brand, progress, one question. No app navigation,
   because a workspace that is half set up has nowhere useful to navigate to. */
.mg-onboard { min-height: 100vh; display: flex; flex-direction: column; background: var(--mg-page); }

.mg-onboard-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--mg-surface);
  border-bottom: 1px solid var(--mg-line);
}

.mg-onboard-main { flex: 1 1 auto; padding: 32px 20px 64px; }
.mg-onboard-inner { width: 100%; max-width: 720px; margin: 0 auto; }

.mg-steps { display: flex; gap: 6px; margin-bottom: 26px; }

.mg-steps span {
  height: 5px; flex: 1 1 0; border-radius: 999px;
  background: var(--mg-line-2);
  transition: background .3s ease;
}

.mg-steps span.done { background: var(--mg-aqua); }

.mg-onboard-row {
  display: grid; gap: 10px; grid-template-columns: 1fr;
  padding: 14px 0; border-bottom: 1px solid var(--mg-line);
}

/* D150: the steps by name under the bar. Small, wraps on a phone. */
.mg-step-names {
  display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0;
  margin: 0 0 22px; font-size: 12.5px; color: var(--mg-ink-3, #6B7785);
}
.mg-step-names li.done { color: var(--mg-aqua-deep); }
.mg-step-names li.current { color: var(--mg-ink); font-weight: 700; }

/* D150: which way the money goes, in words and colour (IN green, OUT red). */
.mg-direction {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--mg-r-sm, 10px); border-left: 5px solid;
}
.mg-direction-in  { background: var(--mg-in-tint);  border-color: var(--mg-in); }
.mg-direction-out { background: var(--mg-out-tint); border-color: var(--mg-out); }
/* D151: step 2, the money you have now - neither in nor out, so the brand aqua. */
.mg-direction-have { background: var(--mg-aqua-tint); border-color: var(--mg-aqua-deep); }
.mg-direction-have > div > strong, .mg-direction-have .mg-direction-mark { color: var(--mg-aqua-deep); }
.mg-direction-have .mg-direction-mark { font-size: 18px; padding-top: 3px; }
.mg-onboard-list.is-have .mg-card-head { border-top: 4px solid var(--mg-aqua-deep); }
.mg-direction > div > strong { display: block; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; }
.mg-direction-in  > div > strong, .mg-direction-in  .mg-direction-mark { color: #145E3D; }
.mg-direction-out > div > strong, .mg-direction-out .mg-direction-mark { color: #8C2A1C; }
.mg-direction-mark { font-size: 26px; line-height: 1; font-weight: 700; }

/* D150: an entry already added - what, how much, Edit / Delete. */
.mg-onboard-entry { flex-wrap: wrap; }
.mg-onboard-entry-what { flex: 1 1 180px; min-width: 0; }
.mg-onboard-entry-amount { font-weight: 700; white-space: nowrap; }
.mg-onboard-entry-actions { display: flex; gap: 6px; }
.mg-onboard-list.is-in  .mg-card-head { border-top: 4px solid var(--mg-in); }
.mg-onboard-list.is-out .mg-card-head { border-top: 4px solid var(--mg-out); }
.mg-onboard-total { border-top: 1px solid var(--mg-line); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }

@media (min-width: 768px) {
  .mg-onboard-row.accounts { grid-template-columns: 2fr 1.3fr 1fr; align-items: end; }
  .mg-onboard-row.money    { grid-template-columns: 2fr 1fr 1.2fr 1.1fr; align-items: end; }
}

/* -------------------------------------------------------------------------
   18. Utilities that earn their place
   ------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
   19. Accessibility
   ------------------------------------------------------------------------- */
:focus-visible { outline: 2.5px solid var(--mg-aqua); outline-offset: 2px; border-radius: 4px; }

/* For a heading that a screen reader needs and the page does not - the
   actions column of a table, say. Not `display:none`, which hides it from
   assistive technology too. */
.mg-hidden-label {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.mg-skip {
  position: absolute; left: -9999px; top: 0; z-index: 1100;
  background: var(--mg-ink); color: #fff;
  padding: 12px 20px; border-radius: 0 0 var(--mg-r-sm) 0;
  font-weight: 650;
}

.mg-skip:focus { left: 0; color: #fff; }

/* Everything animated here is decorative. Under reduced motion the final
   state appears immediately - nothing is lost. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .mg-sidebar, .mg-bottombar, .mg-topbar, .mg-periods, .btn, .mg-row-actions { display: none !important; }
  .mg-main { margin-left: 0; }
  .mg-card { box-shadow: none; border: 1px solid #ccc; }
}

/* -------------------------------------------------------------------------
   20. Small shell pieces
   ------------------------------------------------------------------------- */
.mg-avatar {
  width: 24px; height: 24px; border-radius: 7px;
  display: inline-grid; place-items: center;
  background: var(--mg-ink); color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  flex: 0 0 auto;
}

/* The lockup on a dark panel: "Money" cannot stay navy against navy. */
.mg-brand-light .mg-brand-money { color: #FFFFFF; }
.mg-brand-light .mg-brand-glass { color: var(--mg-aqua-bright); }

.mg-ws-switch {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--mg-line); border-radius: var(--mg-r-sm);
  background: var(--mg-surface-2); color: var(--mg-text);
  font-size: 13.5px; font-weight: 600; text-align: left;
  min-height: 44px;
  transition: border-color .12s ease;
}

.mg-ws-switch:hover { border-color: var(--mg-line-3); color: var(--mg-ink); }
.mg-ws-switch .mg-ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-ws-switch .mg-ico { margin-left: auto; opacity: .5; width: 15px; height: 15px; }

.mg-ws-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.mg-ws-dot-personal { background: var(--mg-aqua); }
.mg-ws-dot-business { background: var(--mg-committed); }

.dropdown-menu {
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  box-shadow: var(--mg-shadow-2);
  padding: 6px;
  font-size: 14px;
}

.dropdown-item { border-radius: var(--mg-r-sm); padding: 8px 11px; min-height: 40px; display: flex; align-items: center; gap: 8px; }
.dropdown-item:active { background: var(--mg-aqua); }
.dropdown-header { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mg-text-mute); }

/* =========================================================================
   Kevin phase: onboarding attribution, archiving, trust, people, pots
   -------------------------------------------------------------------------
   Everything below reuses the tokens above. No new colour is introduced, and
   nothing here carries meaning that is not also written in words nearby.
   ========================================================================= */

/* --- Onboarding: which account these items belong to (P1.12) ------------- */
.mg-attach {
  background: var(--mg-ice);
  border: 1px solid var(--mg-aqua-tint-2);
  border-radius: var(--mg-r);
  padding: 16px 18px;
}
.mg-attach .form-select { max-width: 420px; }

/* --- Stopping a repeating item -------------------------------------------
   A plain list with room to breathe. This is a page somebody reads before
   doing something they cannot undo, so the lines are wide and unhurried. */
.mg-stop-list { list-style: none; margin: 0; padding: 0; }
.mg-stop-list > li {
  padding: 10px 0 10px 26px;
  position: relative;
  color: var(--mg-text-soft);
  line-height: 1.55;
  border-bottom: 1px solid var(--mg-line);
}
.mg-stop-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.mg-stop-list > li::before {
  content: ""; position: absolute; left: 4px; top: 18px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--mg-aqua);
}
.mg-stop-list strong { color: var(--mg-ink); }

/* --- "Balance may need checking" (P1.11) ---------------------------------
   Calm, not alarming. An old balance is not wrong, it has just stopped being
   a fact about today - and the tone has to match that. */
.mg-stale-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--mg-warn-tint);
  border-top: 1px solid var(--mg-line);
  font-size: 13px; line-height: 1.45;
  color: #7C5606;
}
.mg-stale-strip strong { color: #5F4104; }
.mg-stale-strip form { margin: 0; }

/* --- People and invitations ---------------------------------------------- */
.mg-avatar-quiet {
  background: var(--mg-surface-2);
  color: var(--mg-text-mute);
  display: inline-flex; align-items: center; justify-content: center;
}
.mg-role-select { max-width: 170px; }

/* --- A table that may be wider than its column ----------------------------
   Wide content scrolls inside its own box rather than pushing the page
   sideways. Named, because inline styles are banned by a test and rightly. */
.mg-scroll-x { overflow-x: auto; position: relative; } /* D170: contain absolutely positioned children (e.g. visually-hidden labels) so they cannot widen the page */

/* --- Bank reconciliation --------------------------------------------------
   The satisfying screen. Restrained on purpose: a high-confidence suggestion
   may look positive, but nothing here may look *settled* before the user has
   confirmed it. A green tick that turns out to be wrong costs more trust than
   ten honest questions. */
.mg-bank-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding: 12px 14px; margin-bottom: 14px;
  background: var(--mg-surface-2);
  border-radius: var(--mg-r-sm);
}

.mg-bank-counts {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-size: 13px; color: var(--mg-text-soft);
}
.mg-bank-counts strong { color: var(--mg-ink); font-variant-numeric: tabular-nums; }

/* A suggestion needs room for its reasons, which is the part that earns
   trust - "same amount, two days apart" beats "87%". */
.mg-suggestion { align-items: flex-start; }
.mg-suggestion .mg-list-main { padding-right: 12px; }

/* --- Income target -------------------------------------------------------
   Its own bar, deliberately not the glass. The glass answers "is this period
   covered?" and a picture that also answered "am I hitting my target?" would
   answer neither - the same fault P0.2 existed to remove, in a new place. */
.mg-target-bar {
  position: relative; display: flex;
  height: 22px; border-radius: 999px; overflow: hidden;
  background: var(--mg-surface-2);
  border: 1px solid var(--mg-line);
}
.mg-target-fill {
  background: linear-gradient(90deg, var(--mg-aqua-deep), var(--mg-aqua));
  transition: width .8s cubic-bezier(.22,.61,.36,1);
}
/* Possible income is hatched, never solid. Work nobody has agreed to must not
   look like money in the bank. */
.mg-target-possible {
  background-image: repeating-linear-gradient(
    -45deg, var(--mg-aqua-tint-2) 0 6px, transparent 6px 12px);
  border-left: 1px dashed var(--mg-line-2);
  transition: width .8s cubic-bezier(.22,.61,.36,1);
}
.mg-target-scale {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 8px; font-size: 12px; color: var(--mg-text-mute);
}
.mg-target-scale strong { color: var(--mg-ink); font-variant-numeric: tabular-nums; }

.mg-track-target { height: 8px; }
.mg-track-target > div { background: var(--mg-aqua); }

/* --- The calendar --------------------------------------------------------
   Calm and roomy. A month grid that tries to show everything ends up showing
   nothing, so only a few things reach it - see services/calendar.py. */
.mg-cal { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 680px; }
.mg-cal th {
  padding: 10px 8px; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mg-text-mute);
  border-bottom: 1px solid var(--mg-line);
}
.mg-cal-day {
  vertical-align: top; height: 104px; width: 14.28%;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--mg-line);
  border-right: 1px solid var(--mg-line);
}
.mg-cal tr > td:last-child { border-right: 0; }
.mg-cal tr:last-child > td { border-bottom: 0; }
.mg-cal-out { background: var(--mg-surface-2); }
.mg-cal-out .mg-cal-number { color: var(--mg-text-mute); opacity: .6; }
.mg-cal-today { background: var(--mg-aqua-tint); }
.mg-cal-today .mg-cal-number {
  background: var(--mg-aqua); color: #fff;
  border-radius: 999px; padding: 1px 7px;
}
.mg-cal-number {
  display: inline-block; font-size: 12px; font-weight: 700;
  color: var(--mg-text-soft); margin-bottom: 6px;
}
.mg-cal-number a { color: inherit; text-decoration: none; }
.mg-cal-number a:hover { text-decoration: underline; }

.mg-cal-entry {
  display: block; font-size: 11px; line-height: 1.35;
  padding: 3px 6px; margin-bottom: 3px;
  border-radius: 6px; border-left: 3px solid var(--mg-line-3);
  background: var(--mg-surface-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-cal-title { font-weight: 600; color: var(--mg-ink); }
.mg-cal-amount { color: var(--mg-text-soft); font-variant-numeric: tabular-nums; }
/* Colour is a second signal only - every entry also carries its words in the
   list underneath, which is what a screen reader and a phone both read. */
.mg-cal-tax      { border-left-color: var(--mg-warn); background: var(--mg-warn-tint); }
.mg-cal-deadline { border-left-color: var(--mg-danger); background: var(--mg-danger-tint); }
.mg-cal-payment  { border-left-color: var(--mg-out); background: var(--mg-out-tint); }
.mg-cal-review   { border-left-color: var(--mg-in); background: var(--mg-in-tint); }
.mg-cal-renewal  { border-left-color: var(--mg-committed); background: var(--mg-committed-tint); }

/* --- The running-cost line -----------------------------------------------
   One sentence, said plainly. Kevin's "running cost / day" is the figure in
   his prototype people actually repeat out loud. */
.mg-daycost {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  padding: 14px 18px; border-radius: var(--mg-r);
  background: var(--mg-surface-2);
  border: 1px solid var(--mg-line);
}
.mg-daycost-line { font-size: 16px; font-weight: 600; color: var(--mg-ink); }
.mg-daycost-scales {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-size: 12px; color: var(--mg-text-mute);
}
.mg-daycost-scales strong { color: var(--mg-text-soft); font-variant-numeric: tabular-nums; }

/* --- The Architects module -----------------------------------------------
   Reuses every Core component. A module that shipped its own visual language
   would make the product feel like two products bolted together, which is the
   thing an optional module most has to avoid. */
.mg-avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.mg-card-head h2 .mg-avatar { margin-right: 6px; vertical-align: middle; }

/* -------------------------------------------------------------------------
   21. The owner area
   -------------------------------------------------------------------------
   The platform owner's own administration, at /owner/. Superusers only.

   It reuses the entire design system - the same tokens, cards, figures, lists
   and tables as the customer product - and changes exactly one thing: the
   rail is dark. That is the whole visual difference, and it is enough.

   The reason it is *only* that: somebody with the owner area and a customer's
   workspace open in two tabs must never act on the wrong one, and a glance has
   to settle it. A second colour scheme would have made the owner area feel
   like a different application, which is what Django admin already feels like
   and precisely what this replaces.

   Nothing here restyles a component. If a rule below sets more than a colour,
   it is because the owner shell has a part the customer shell does not.
   ------------------------------------------------------------------------- */
.mg-owner-sidebar {
  background: var(--mg-ink);
  border-right-color: rgba(255, 255, 255, 0.08);
}

.mg-owner-sidebar .mg-brand,
.mg-owner-sidebar .mg-brand-money { color: #fff; }
.mg-owner-sidebar .mg-brand-glass { color: var(--mg-aqua-bright); }

.mg-owner-sidebar .mg-nav-link { color: rgba(255, 255, 255, 0.72); }
.mg-owner-sidebar .mg-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.mg-owner-sidebar .mg-nav-link.active {
  background: rgba(61, 155, 224, 0.16);
  color: var(--mg-aqua-bright);
}
.mg-owner-sidebar .mg-nav-section { color: rgba(255, 255, 255, 0.42); }

/* The user menu is a Core component and sits on a dark ground here. */
.mg-owner-sidebar .mg-user-menu,
.mg-owner-sidebar .mg-user-button {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}
.mg-owner-sidebar .mg-user-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.mg-owner-sidebar .btn-mg-quiet {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.9);
}
.mg-owner-sidebar .btn-mg-quiet:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Says which area this is, on both the rail and the mobile bar. Words, not
   only a colour - the same rule as every other state in the product. */
.mg-owner-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(61, 155, 224, 0.16);
  color: var(--mg-aqua-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.mg-owner-topbar .mg-owner-badge {
  background: var(--mg-aqua-tint);
  color: var(--mg-aqua-deep);
}

/* At 320px the wordmark, the badge and the avatar were 19px too wide for the
   owner bar, so every owner page scrolled sideways (found by the D149
   walkthrough). Tighter padding there keeps all three, badge words included. */
@media (max-width: 359.98px) {
  .mg-owner-topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .mg-owner-topbar .mg-owner-badge { margin-left: 0 !important; }
}

/* The escape hatch to Django admin. Quiet, last, and it says what it is for -
   two lines rather than one, because "Advanced Django admin" on its own reads
   like a feature rather than a warning. */
.mg-owner-admin-link {
  display: block;
  padding: 9px 11px;
  border-radius: var(--mg-r-sm);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.35;
}

.mg-owner-admin-link:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
  text-decoration: none;
}

.mg-owner-admin-link span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

/* --- Filters above a list ------------------------------------------------
   A row on a desktop, a stack on a phone. Owner administration is a desktop
   job, but "usable on a tablet in a meeting" is a real requirement. */
.mg-owner-filters {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: end;
  padding: 16px 18px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
}

@media (min-width: 768px) {
  .mg-owner-filters { grid-template-columns: 2fr 1fr 1fr auto; }
}

@media (min-width: 1200px) {
  .mg-owner-filters { grid-template-columns: 2fr repeat(4, 1fr) auto; }
}

.mg-owner-filter .form-label {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--mg-text-mute);
  margin-bottom: 4px;
}

.mg-owner-filter-go {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* --- Pagination --- */
.mg-owner-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-top: 1px solid var(--mg-line);
}

.mg-owner-pager .disabled { opacity: .45; cursor: default; }

/* --- A short definition list: label left, value right --- */
.mg-owner-facts { list-style: none; margin: 0; padding: 0; }

.mg-owner-facts li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--mg-line);
  font-size: 13.5px;
}

.mg-owner-facts li:last-child { border-bottom: none; }
.mg-owner-facts li > span:first-child { color: var(--mg-text-soft); }
.mg-owner-facts li > span:last-child {
  font-weight: 600;
  color: var(--mg-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- One audit entry's before and after ---------------------------------
   Both sides shown, because "what was it before?" is the question an audit
   log is actually asked. */
.mg-owner-event { align-items: flex-start; }

.mg-owner-changes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 7px;
}

.mg-owner-change {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 12px;
}

.mg-owner-change-field {
  font-weight: 650;
  color: var(--mg-text-soft);
  min-width: 9rem;
}

.mg-owner-change-was {
  color: var(--mg-text-mute);
  text-decoration: line-through;
}

.mg-owner-change-now { font-weight: 650; color: var(--mg-ink); }

/* =========================================================================
   Household phase
   -------------------------------------------------------------------------
   Navigation by area, Insights (Money Freedom), the Hub, Vault, Tasks and
   Shopping. Built from the tokens above - nothing here introduces a colour,
   a radius or a shadow the rest of the product does not already use.
   ========================================================================= */

/* --- Search, in the rail --- */
.mg-nav-search {
  position: relative;
  display: flex;
  align-items: center;
}
.mg-nav-search .mg-ico {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--mg-text-mute);
  pointer-events: none;
}
.mg-nav-search input {
  width: 100%;
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface-2);
  border-radius: var(--mg-r-sm);
  padding: 8px 10px 8px 34px;
  font-size: 13.5px;
  color: var(--mg-text);
}
.mg-nav-search input:focus { outline: none; border-color: var(--mg-aqua); background: var(--mg-surface); box-shadow: 0 0 0 3px var(--mg-aqua-tint); }

/* --- An area that opens to show its own pages --- */
.mg-nav-caret {
  margin-left: auto;
  width: 14px !important;
  height: 14px !important;
  opacity: .5 !important;
  transition: transform .15s ease;
}
.mg-nav-caret.open { transform: rotate(90deg); }

.mg-nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 6px 20px;
  padding-left: 12px;
  border-left: 1px solid var(--mg-line-2);
}
.mg-nav-sublink {
  display: block;
  padding: 7px 10px;
  border-radius: var(--mg-r-sm);
  color: var(--mg-text-soft);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.mg-nav-sublink:hover { background: var(--mg-surface-2); color: var(--mg-ink); text-decoration: none; }
.mg-nav-sublink.active { color: var(--mg-aqua-deep); font-weight: 650; background: var(--mg-surface-2); }

/* --- The same pages as chips, on a phone --- */
.mg-subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: -6px -20px 18px;
  padding: 0 20px 4px;
  scrollbar-width: none;
}
.mg-subnav::-webkit-scrollbar { display: none; }
.mg-subnav-link {
  flex: 0 0 auto;
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--mg-text-soft);
  text-decoration: none;
  white-space: nowrap;
}
.mg-subnav-link:hover { text-decoration: none; color: var(--mg-ink); }
.mg-subnav-link.active { background: var(--mg-aqua-tint); border-color: var(--mg-aqua-tint-2); color: var(--mg-aqua-deep); }
@media (min-width: 992px) { .mg-subnav { display: none; } }

/* --- Page heading row, shared by every new screen --- */
.mg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.mg-head h1 { margin-bottom: 4px; }
.mg-head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mg-row-link { color: inherit; text-decoration: none; }
.mg-row-link:hover { color: var(--mg-aqua-deep); text-decoration: underline; text-underline-offset: 3px; }

/* --- One compact period control: a select, not a wall of buttons --- */
.mg-range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.mg-range select, .mg-range input { width: auto; min-height: 40px; font-size: 14px; }
.mg-range .mg-range-custom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 575.98px) {
  .mg-range { width: 100%; }
  .mg-range select { flex: 1 1 auto; }
}

/* --- The figure a screen is about, with its honest caption --- */
.mg-spotlight {
  padding: 24px 26px;
  border-radius: var(--mg-r-lg);
  background: linear-gradient(160deg, var(--mg-surface) 30%, var(--mg-ice));
  border: 1px solid var(--mg-line);
  box-shadow: var(--mg-shadow-1);
}
.mg-spotlight .mg-fig-hero { line-height: 1.05; }
.mg-spotlight-caption { color: var(--mg-text-soft); font-size: 15px; margin-top: 6px; }
.mg-spotlight-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px 22px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--mg-line);
}
@media (max-width: 575.98px) { .mg-spotlight { padding: 20px 18px; } }

/* --- Horizontal bars: a name, a bar, a figure. The figure is always there,
   so the bar is a second channel and never the only one. --- */
.mg-bars { list-style: none; margin: 0; padding: 0; }
.mg-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--mg-line);
}
.mg-bar-row:last-child { border-bottom: 0; }
.mg-bar-name { font-weight: 600; font-size: 14.5px; color: var(--mg-ink); min-width: 0; overflow-wrap: anywhere; }
.mg-bar-name a { color: inherit; text-decoration: none; }
.mg-bar-name a:hover { color: var(--mg-aqua-deep); text-decoration: underline; text-underline-offset: 3px; }
.mg-bar-figure { font-weight: 700; white-space: nowrap; text-align: right; }
.mg-bar-track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--mg-surface-2);
  overflow: hidden;
}
.mg-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--mg-dot-colour, var(--mg-aqua));
}
.mg-bar-sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--mg-text-mute); }
@media (max-width: 575.98px) { .mg-bar-row { padding: 12px 16px; } }

/* --- Month by month, as columns, with a table underneath for anyone who
   cannot see the columns --- */
.mg-months {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  padding: 10px 4px 0;
}
.mg-month {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.mg-month-bar {
  width: 100%;
  max-width: 34px;
  min-height: 2px;
  border-radius: 6px 6px 2px 2px;
  background: var(--mg-aqua-tint-2);
}
.mg-month-bar.peak { background: var(--mg-aqua); }
.mg-month-label { font-size: 10.5px; color: var(--mg-text-mute); font-weight: 600; }

/* --- What if? Options as cards. A difference, never "savings". --- */
.mg-whatif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.mg-whatif {
  border: 1px solid var(--mg-line-2);
  border-radius: var(--mg-r);
  padding: 16px 18px;
  background: var(--mg-surface);
}
.mg-whatif-title { font-weight: 700; color: var(--mg-ink); margin-bottom: 6px; }
.mg-whatif dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 3px 12px; font-size: 13.5px; }
.mg-whatif dt { font-weight: 500; color: var(--mg-text-soft); }
.mg-whatif dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.mg-whatif-compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--mg-line);
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  overflow: hidden;
}
.mg-whatif-compare > div { background: var(--mg-surface); padding: 14px 16px; }
@media (max-width: 575.98px) { .mg-whatif-compare { grid-template-columns: 1fr; } }
.mg-whatif-modes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mg-assumption {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--mg-text-soft);
  margin-top: 12px;
}
.mg-assumption .mg-ico { width: 16px; height: 16px; margin-top: 1px; color: var(--mg-aqua-deep); }

/* --- Facts about a thing: label above value, wrapping in a grid --- */
.mg-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 22px;
  margin: 0;
}
.mg-facts dt { font-size: 12px; font-weight: 650; color: var(--mg-text-soft); margin-bottom: 2px; }
.mg-facts dd { margin: 0; font-weight: 600; color: var(--mg-ink); overflow-wrap: anywhere; }

/* --- The Hub home: calm tiles --- */
.mg-hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) { .mg-hub-grid { grid-template-columns: 1fr 1fr; } }
.mg-hub-tile { display: flex; flex-direction: column; }
.mg-hub-count {
  font-family: var(--mg-font-display);
  font-weight: 800;
  font-size: 2rem;
  line-height: 1;
  color: var(--mg-ink);
  letter-spacing: -0.03em;
}
.mg-hub-today {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  align-items: baseline;
}

/* --- Tasks: a big, honest tick target --- */
.mg-task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--mg-line);
}
.mg-task:last-child { border-bottom: 0; }
.mg-task-main { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.mg-task-title { font-weight: 600; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-task-title a { color: inherit; text-decoration: none; }
.mg-task-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.mg-task.is-done .mg-task-title { color: var(--mg-text-mute); text-decoration: line-through; }
.mg-task-meta { font-size: 12.5px; color: var(--mg-text-mute); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.mg-check {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -6px 0 -6px -8px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--mg-aqua-deep);
}
.mg-check-box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--mg-line-3);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mg-surface);
}
.mg-check-box .mg-ico { width: 15px; height: 15px; opacity: 0; }
.mg-check:hover .mg-check-box { border-color: var(--mg-aqua); }
.mg-check.is-on .mg-check-box { background: var(--mg-aqua); border-color: var(--mg-aqua); color: #fff; }
.mg-check.is-on .mg-check-box .mg-ico { opacity: 1; }
@media (max-width: 575.98px) { .mg-task { padding: 12px 16px; } }

/* --- Comments and changes on a task --- */
.mg-thread { list-style: none; margin: 0; padding: 0; }
.mg-thread li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--mg-line); }
.mg-thread li:last-child { border-bottom: 0; }
.mg-thread-body { min-width: 0; flex: 1 1 auto; }
.mg-thread-who { font-weight: 650; color: var(--mg-ink); font-size: 14px; }
.mg-thread-when { font-size: 12px; color: var(--mg-text-mute); margin-left: 6px; }
.mg-thread-text { margin-top: 3px; white-space: pre-line; overflow-wrap: anywhere; }
.mg-thread li.is-event { padding: 7px 0; }
.mg-thread li.is-event .mg-thread-body { font-size: 13px; color: var(--mg-text-soft); }

/* --- Things linked to a thing --- */
.mg-linked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mg-linked li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r-sm);
  background: var(--mg-surface);
}
.mg-linked .mg-ico { color: var(--mg-aqua-deep); }
.mg-linked-main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.mg-linked-kind { font-size: 11.5px; color: var(--mg-text-mute); font-weight: 600; }

/* --- The Vault --- */
.mg-shelves { display: flex; flex-wrap: wrap; gap: 6px; }
.mg-shelf {
  border: 1px solid var(--mg-line-2);
  background: var(--mg-surface);
  border-radius: 999px;
  padding: 7px 13px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mg-text-soft);
  text-decoration: none;
}
.mg-shelf:hover { text-decoration: none; color: var(--mg-ink); border-color: var(--mg-ink); }
.mg-shelf.active { background: var(--mg-aqua-tint); border-color: var(--mg-aqua-tint-2); color: var(--mg-aqua-deep); }
.mg-shelf-count { font-size: 11.5px; color: var(--mg-text-mute); font-weight: 650; }
.mg-docs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.mg-doc {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  background: var(--mg-surface);
  box-shadow: var(--mg-shadow-1);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.mg-doc:hover { text-decoration: none; border-color: var(--mg-aqua); color: inherit; }
.mg-doc-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--mg-aqua-tint);
  color: var(--mg-aqua-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mg-doc-main { min-width: 0; }
.mg-doc-title { font-weight: 650; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-doc-sub { font-size: 12.5px; color: var(--mg-text-mute); margin-top: 2px; }
.mg-preview {
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-r);
  background: var(--mg-surface-2);
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.mg-preview img { display: block; max-width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.mg-preview iframe { display: block; width: 100%; height: 75vh; min-height: 420px; border: 0; background: #fff; }
@media (max-width: 575.98px) { .mg-preview iframe { height: 60vh; min-height: 320px; } }

/* --- Shopping. Built for one thumb in a supermarket aisle. --- */
.mg-shop { max-width: 640px; }
.mg-shop-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  position: sticky;
  top: 8px;
  z-index: 5;
  background: var(--mg-page);
  padding: 6px 0 10px;
}
@media (max-width: 991.98px) { .mg-shop-add { top: 62px; } }
.mg-shop-add input { min-height: 54px; font-size: 17px; }
.mg-shop-add .btn { min-height: 54px; padding-inline: 20px; font-size: 16px; }
.mg-shop-list { list-style: none; margin: 0; padding: 0; }
.mg-shop-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--mg-line);
}
.mg-shop-item:last-child { border-bottom: 0; }
.mg-shop-item form { display: flex; }
.mg-shop-item form:first-child { flex: 1 1 auto; min-width: 0; }
.mg-shop-toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 14px 18px;
  min-height: 64px;
  font-size: 17px;
  color: var(--mg-ink);
}
.mg-shop-toggle:hover { background: var(--mg-surface-2); }
.mg-shop-box {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 2px solid var(--mg-line-3);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mg-surface);
}
.mg-shop-box .mg-ico { width: 18px; height: 18px; opacity: 0; color: #fff; }
.mg-shop-item.is-in .mg-shop-box { background: var(--mg-in); border-color: var(--mg-in); }
.mg-shop-item.is-in .mg-shop-box .mg-ico { opacity: 1; }
.mg-shop-item.is-in .mg-shop-name { color: var(--mg-text-mute); text-decoration: line-through; }
.mg-shop-text { min-width: 0; }
.mg-shop-name { font-weight: 600; overflow-wrap: anywhere; }
.mg-shop-detail { display: block; font-size: 13px; color: var(--mg-text-mute); font-weight: 500; margin-top: 1px; }
.mg-shop-remove {
  flex: 0 0 auto;
  width: 52px;
  border: 0;
  background: transparent;
  color: var(--mg-text-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mg-shop-remove:hover { color: var(--mg-danger); background: var(--mg-danger-tint); }
.mg-shop-finish { position: sticky; bottom: calc(var(--mg-bottombar) + 10px); z-index: 4; }
@media (min-width: 992px) { .mg-shop-finish { bottom: 16px; } }
.mg-again { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-again form { display: inline-flex; }
.mg-chip-done { display: inline-flex; align-items: center; cursor: default; color: var(--mg-text-mute); background: var(--mg-surface-2); }
.mg-chip-done:hover { border-color: var(--mg-line-2); color: var(--mg-text-mute); background: var(--mg-surface-2); }

/* The Shopping card on the household dashboard and the Hub home. */
.mg-shopcard .mg-card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.mg-shopcard-counts { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; }
.mg-shopcard-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 600; }
.mg-shopcard-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 16px; }
.mg-shopcard-add .form-control, .mg-shopcard-add .btn { min-height: 48px; }
.mg-shopcard-add .btn { display: inline-flex; align-items: center; gap: 6px; padding-inline: 16px; }
.mg-shopcard .btn-mg-accent { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.mg-shop-add .btn { display: inline-flex; align-items: center; gap: 6px; }

/* A brief confirmation with an Undo, announced to screen readers. */
.mg-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--mg-bottombar) + 18px);
  transform: translateX(-50%);
  z-index: 1060;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: var(--mg-r);
  background: var(--mg-ink);
  color: #fff;
  box-shadow: var(--mg-shadow-3);
  font-size: 14.5px;
}
.mg-toast[hidden] { display: none; }
.mg-toast button {
  border: 0;
  background: transparent;
  color: var(--mg-aqua-bright);
  font-weight: 700;
  min-height: 40px;
  padding: 0 8px;
}
@media (min-width: 992px) { .mg-toast { bottom: 24px; } }

/* --- Search --- */
.mg-search-big { display: flex; gap: 8px; max-width: 640px; }
.mg-search-big input { min-height: 50px; font-size: 16px; }

/* --- Onboarding: three big choices --- */
.mg-type-choices { display: grid; gap: 10px; }
@media (min-width: 768px) { .mg-type-choices { grid-template-columns: repeat(3, 1fr); } }
.mg-type-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1.5px solid var(--mg-line-2);
  border-radius: var(--mg-r);
  background: var(--mg-surface);
  cursor: pointer;
  min-height: 92px;
}
.mg-type-choice input { position: absolute; opacity: 0; pointer-events: none; }
.mg-type-choice-title { font-weight: 700; color: var(--mg-ink); }
.mg-type-choice-sub { font-size: 13px; color: var(--mg-text-soft); }
.mg-type-choice:has(input:checked) { border-color: var(--mg-aqua); background: var(--mg-aqua-tint); box-shadow: 0 0 0 3px var(--mg-aqua-tint); }
.mg-type-choice:has(input:focus-visible) { outline: 3px solid var(--mg-aqua); outline-offset: 2px; }

/* Step one as three one-tap answers (D144). Always one column: a phone and a
   laptop read the same three rows, top to bottom, and each is a big target. */
.mg-type-choices:has(.mg-type-choice-button) { grid-template-columns: 1fr; gap: 12px; }
.mg-type-choice-button {
  flex-direction: row; align-items: center; gap: 16px; width: 100%; text-align: left;
  font: inherit; color: inherit; min-height: 88px; padding: 18px 20px;
}
.mg-type-choice-button:hover { border-color: var(--mg-aqua); box-shadow: var(--mg-shadow-2); }
.mg-type-choice-button:focus-visible { outline: 3px solid var(--mg-aqua); outline-offset: 2px; }
.mg-type-choice-button .mg-type-choice-title { font-family: var(--mg-font-display); font-size: 1.2rem; }
.mg-type-choice-button .mg-type-choice-sub { font-size: 15px; }
.mg-type-choice-icon { flex: 0 0 auto; }
.mg-type-choice-text { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.mg-type-choice-go { width: 20px; height: 20px; color: var(--mg-text-mute); flex: 0 0 auto; }
.mg-onboard-chosen { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.mg-onboard-chosen .mg-aud-icon { width: 40px; height: 40px; }
.mg-onboard-chosen a { font-weight: 600; }

/* --- First steps: a brand-new workspace's dashboard (D144) ---
   Instead of a wall of zeros: one heading, a sentence, and a few big actions,
   exactly one of them primary. */
.mg-start { margin-bottom: 24px; }
.mg-start-head h2 { font-size: 1.45rem; margin-bottom: 4px; }
.mg-start-actions { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .mg-start-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mg-start-actions.mg-start-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .mg-start-actions.mg-start-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mg-start-action {
  display: flex; align-items: flex-start; gap: 14px; height: 100%; min-height: 72px; padding: 18px 18px;
  border: 1.5px solid var(--mg-line-2); border-radius: var(--mg-r); background: var(--mg-surface);
  color: var(--mg-ink); text-decoration: none;
}
.mg-start-action:hover { border-color: var(--mg-aqua); box-shadow: var(--mg-shadow-2); color: var(--mg-ink); text-decoration: none; }
.mg-start-action:focus-visible { outline: 3px solid var(--mg-aqua); outline-offset: 2px; }
.mg-start-action .mg-start-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: inline-flex;
  align-items: center; justify-content: center; background: var(--mg-aqua-tint); color: var(--mg-aqua-deep);
}
.mg-start-action .mg-start-icon .mg-ico { width: 20px; height: 20px; }
.mg-start-title { display: block; font-weight: 750; font-size: 1.05rem; line-height: 1.3; }
.mg-start-line { display: block; font-size: 14.5px; color: var(--mg-text-soft); margin-top: 2px; }
/* The one strongest action: filled, so it is unmistakable without colour too
   (it is also first, and says "Start here"). */
.mg-start-action.is-primary { background: var(--mg-ink); border-color: var(--mg-ink); color: #fff; }
.mg-start-action.is-primary .mg-start-line { color: rgba(255, 255, 255, .82); }
.mg-start-action.is-primary .mg-start-icon { background: rgba(255, 255, 255, .14); color: #fff; }
.mg-start-action.is-primary:hover { color: #fff; box-shadow: var(--mg-shadow-3); }
.mg-start-here { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; opacity: .85; }
.mg-start-next { margin-top: 16px; }

/* --- First-time tips (D144) ---
   Plain notes at the top of a page, dismissed with "Got it" (a real form, so
   it works without JavaScript) and then gone for good on this device. */
.mg-tip {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid var(--mg-line-2); border-left: 4px solid var(--mg-aqua);
  border-radius: var(--mg-r-sm); background: var(--mg-aqua-tint);
}
.mg-tip > .mg-ico { flex: 0 0 auto; width: 20px; height: 20px; color: var(--mg-aqua-deep); margin-top: 2px; }
.mg-tip-text { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--mg-ink); }
.mg-tip form { margin: 0; flex: 0 0 auto; }
.mg-tip button { min-height: 36px; }

/* --- The workspace kind, beside its name --- */
.mg-ws-dot-household { background: var(--mg-set-aside); }
.mg-ws-kind { font-size: 11px; color: var(--mg-text-mute); font-weight: 600; margin-left: auto; padding-left: 8px; }

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

@media print {
  .mg-subnav, .mg-nav-search, .mg-shop-add, .mg-toast, .mg-shop-finish { display: none !important; }
}

/* An author display rule beats the hidden attribute; put it back. */
.mg-range-custom[hidden] { display: none !important; }

/* Tasks and document dates on the one calendar: calm, distinct, and a done
   task says so in words in the list beside the grid as well as being struck. */
.mg-cal-task    { border-left-color: var(--mg-aqua); background: var(--mg-aqua-tint); }
.mg-cal-expiry  { border-left-color: var(--mg-set-aside); background: var(--mg-set-aside-tint); }
.mg-cal-done    { opacity: .7; }
.mg-cal-done .mg-cal-title { text-decoration: line-through; }

/* --- Uploading a statement, step by step. The current step is named, not
   only coloured. --- */
.mg-import-steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  counter-reset: mg-step;
  font-size: 12.5px;
  color: var(--mg-text-mute);
}
.mg-import-steps li { counter-increment: mg-step; display: inline-flex; align-items: center; gap: 6px; }
.mg-import-steps li::before {
  content: counter(mg-step);
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
  border: 1.5px solid var(--mg-line-3);
}
.mg-import-steps li.done::before { background: var(--mg-aqua-tint); border-color: var(--mg-aqua); color: var(--mg-aqua-deep); }
.mg-import-steps li[aria-current="step"] { color: var(--mg-ink); font-weight: 700; }
.mg-import-steps li[aria-current="step"]::before { background: var(--mg-aqua); border-color: var(--mg-aqua); color: #fff; }

/* Room for the select chevron, so "Last 12 months" never runs into it. */
.mg-range select.form-select { padding-right: 2.4rem; min-width: 11rem; }

/* The shopping list keeps "Need  2" on one line, even on a phone. */
.mg-shop .mg-card-head { flex-direction: row; align-items: center; }

/* --- Refunds (D108) ------------------------------------------------------ */
.mg-refund-pick .mg-list-item { align-items: center; gap: .75rem; }
.mg-refund-pick .form-check-input { flex: 0 0 auto; width: 1.25rem; height: 1.25rem; margin: 0; }
.mg-refund-pick label.mg-list-main { cursor: pointer; }
.mg-refund-amount { width: 7.5rem; flex: 0 0 auto; text-align: right; }
@media (max-width: 575.98px) {
  .mg-refund-pick .mg-list-item { flex-wrap: wrap; }
  .mg-refund-amount { margin-left: 2rem; }
}

/* --- Saved scenarios and goals (D109, D110) ------------------------------ */
.mg-scenario-col { border: 1px solid var(--mg-aqua); }
.mg-change-row { flex-wrap: wrap; }
.mg-change-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.mg-apply > summary { list-style: none; cursor: pointer; }
.mg-apply > summary::-webkit-details-marker { display: none; }
.mg-scenario-total { border-top: 1px solid var(--mg-line); }
.mg-save-scenario { border-top: 1px dashed var(--mg-line-2); padding-top: .75rem; }
.mg-goal .mg-tag { white-space: nowrap; }
.mg-goal-on_target { background: var(--mg-aqua-tint); }
.mg-goal-no_data { opacity: .8; }
@media (max-width: 575.98px) {
  .mg-change-actions { width: 100%; padding-left: 0; }
  .mg-save-scenario .w-auto { width: 100% !important; }
}

/* --- Reports & exports -------------------------------------------------- */
.mg-export-row { flex-wrap: wrap; }
.mg-export-form { display: flex; gap: .5rem; align-items: center; }
.mg-export-form .form-select { width: auto; }
@media (max-width: 575.98px) { .mg-export-form, .mg-export-row > .btn { width: 100%; } .mg-export-form .form-select { flex: 1; } }

/* --- The printable summary ------------------------------------------------ */
.mg-report { max-width: 900px; }
.mg-report-head { border-bottom: 2px solid var(--mg-ink-2); padding-bottom: .75rem; margin-bottom: 1.25rem; }
.mg-report-section { margin-bottom: 1.75rem; break-inside: avoid; }
.mg-report-section h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.mg-report-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem 1.25rem; margin: 0 0 .5rem; }
.mg-report-figures dt { font-weight: 500; color: var(--mg-text-soft); font-size: .85rem; }
.mg-report-figures dd { font-size: 1.25rem; font-weight: 600; margin: 0; }
.mg-report-foot { border-top: 1px solid var(--mg-line-2); padding-top: .75rem; margin-top: 2rem; }
@media print {
  @page { margin: 16mm; }
  body { background: #fff !important; }
  .mg-report { max-width: none; }
  .mg-report-tools, .mg-subnav, .alert { display: none !important; }
  .mg-report-section { page-break-inside: avoid; }
  .mg-in-text { color: #000 !important; }
  a { color: inherit; text-decoration: none; }
}

/* --- Billing (D111-D118) ------------------------------------------------- */
.mg-narrow { max-width: 640px; }
.mg-billing-facts { margin: 1rem 0 0; }
.mg-billing-facts dd { margin: 0; }
.mg-billing-state-grace, .mg-billing-state-read_only { background: var(--mg-warn-tint); color: var(--mg-warn); }
.mg-billing-state-active, .mg-billing-state-trial { background: var(--mg-aqua-tint); color: var(--mg-aqua-deep); }
.mg-billing-banner { margin-bottom: 1rem; }
.mg-plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.mg-plan-card { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; border: 1px solid var(--mg-line-2); border-radius: var(--mg-r); background: var(--mg-surface); cursor: pointer; min-height: 56px; }
.mg-plan-card.is-chosen { border-color: var(--mg-aqua); box-shadow: 0 0 0 2px var(--mg-aqua-tint-2); }
.mg-plan-card .form-check-input { margin: 0 0 .25rem; }
.mg-plan-name { font-weight: 600; }
.mg-plan-price { font-size: 1.4rem; font-weight: 600; }
.mg-plan-price small { font-size: .8rem; font-weight: 400; color: var(--mg-text-soft); }
.mg-plan-detail { font-size: .85rem; color: var(--mg-text-soft); }
.mg-checkout-lines { margin: 0 0 1rem; }
.mg-checkout-lines > div { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--mg-line); }
.mg-checkout-lines dt { font-weight: 400; }
.mg-checkout-lines dd { margin: 0; white-space: nowrap; }
.mg-checkout-total { font-weight: 600; border-bottom: 0 !important; }

.mg-row-attention td { background: var(--mg-warn-tint); }

/* --- Two-step verification (D121) ---------------------------------------- */
/* The QR SVG has a viewBox and no fixed size (accounts/two_factor.qr_svg), so this
   scales the whole code - never crops it. Up to 280px; narrower on a small screen. */
.mg-qr svg { display: block; width: 100%; max-width: 280px; height: auto; aspect-ratio: 1 / 1; background: #fff; border-radius: var(--mg-r-sm); }
.mg-secret { font-size: 1rem; letter-spacing: .05em; word-break: break-all; }
/* Two-step set-up: which choice to make in the app, before the QR code (D146). */
.mg-app-help { background: var(--mg-committed-tint); border-left: 4px solid #2A578F; border-radius: var(--mg-r-sm); padding: .85rem 1rem; color: var(--mg-ink); }
.mg-app-help-warn { color: #8A2C1F; }
.mg-setup-key { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; }
.mg-setup-key dt { font-weight: 600; }
.mg-setup-key dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 400px) { .mg-setup-key { grid-template-columns: 1fr; } .mg-setup-key dd { margin-bottom: .4rem; } }
.mg-recovery-codes { columns: 2; list-style: none; padding: 0; font-size: 1.05rem; }
.mg-recovery-codes li { padding: .25rem 0; }

.mg-plan-select { padding-right: 2.5rem; max-width: 100%; }


/* ---------------------------------------------------------------------------
   Irreversible actions - closing and deleting (D123, D124). Red is never the
   only signal: the button's words say what it does, and the section heading
   says it cannot be undone.
   --------------------------------------------------------------------------- */
.btn-mg-danger { background: var(--mg-danger); border: 1px solid var(--mg-danger); color: #fff; }
.btn-mg-danger:hover, .btn-mg-danger:focus-visible { background: #8C2A1C; border-color: #8C2A1C; color: #fff; }
.mg-danger-zone { border-left: 4px solid var(--mg-danger); }

/* Owner support summary: a compact fact grid. */
.mg-support-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.mg-support-facts dt { font-size: 12px; color: var(--mg-text-soft, #5b6b7a); font-weight: 600; }
.mg-support-facts dd { margin: 0; }

/* Error pages (core/errors.py): the reference stands out without shouting. */
.mg-error-body { background: var(--mg-bg, #F6F8FA); min-height: 100vh; }
.mg-error-ref { background: var(--mg-surface, #fff); border: 1px dashed var(--mg-line-2, #c9d3dc); border-radius: 10px; padding: 10px 14px; }

/* Owner > System > Launch readiness. The word carries the meaning; colour only repeats it. */
.mg-launch-badge { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.mg-launch-blocker { background: var(--mg-danger-tint); color: #8C2A1C; }
.mg-launch-warning { background: #FFF4D6; color: #6B4E00; }
.mg-launch-pass { background: #E3F6EF; color: #145C43; }
.mg-launch-list { margin: 0 0 4px; padding-left: 1.1rem; }
.mg-launch-list li { margin-bottom: 4px; }

/* Owner billing-mode band (§15): test and demo mode must never be mistaken for live. */
.mg-owner-mode { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.mg-owner-mode-test { background: #FFF1C7; color: #6B4A00; border: 2px dashed #C99A06; }
.mg-owner-mode-off { background: var(--mg-committed-tint); color: #2A578F; }
.mg-launch-next { font-size: 13.5px; margin-top: 2px; }
.mg-launch-next-label { font-weight: 600; }

/* ==========================================================================
   Redesign: identity, navigation, directory, front page (UI_GUIDELINES §22)
   ========================================================================== */

/* --- Workspace switcher: name and kind, always in words --- */
.mg-ws-switch .mg-ws-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mg-ws-switch .mg-ws-type { font-size: 12px; font-weight: 600; color: var(--mg-text-mute); }
.mg-ws-switch .mg-ws-dot { width: 10px; height: 10px; }
.mg-ws-bar { width: 100%; }
.mg-ws-bar .mg-ws-switch { background: var(--mg-surface); min-height: 52px; font-size: 15px; }
.mg-ws-bar .mg-ws-switch .mg-ws-name { white-space: normal; overflow-wrap: anywhere; }
.mg-ws-bar .dropdown-menu { width: 100%; }

/* --- "Where am I?" bar at the top of every workspace page --- */
.mg-where { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 18px; }
.mg-where-ws { align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--mg-ink); }
.mg-where-ws .mg-ws-dot { width: 10px; height: 10px; }
/* A long workspace name wraps; it is never cut off or pushed off-screen. */
.mg-where-name { min-width: 0; overflow-wrap: anywhere; }
.mg-where-type {
  font-size: 12px; font-weight: 700; color: var(--mg-text-soft);
  background: var(--mg-surface-2); border: 1px solid var(--mg-line); border-radius: 999px; padding: 2px 10px;
}
.mg-trail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 14px; }
.mg-trail li { display: inline-flex; align-items: center; }
.mg-trail li + li::before { content: "\203A"; color: var(--mg-text-mute); margin-right: 4px; }
.mg-trail a { color: var(--mg-aqua-deep); font-weight: 600; text-decoration: none; padding: 6px 2px; }
.mg-trail a:hover { text-decoration: underline; }
@media (max-width: 991.98px) { .mg-where { flex-direction: column; align-items: stretch; } }

/* --- Phone bottom bar: five tabs, readable labels --- */
.mg-tab { font-size: 12px; min-height: 58px; }
.mg-tab .mg-ico { width: 22px; height: 22px; }

/* --- Sidebar: long area names wrap rather than vanish --- */
.mg-nav-link { white-space: normal; line-height: 1.25; }

/* --- Page heading: the page's name first, dates second --- */
.mg-page-sub { font-size: 15px; color: var(--mg-text-soft); margin: 2px 0 0; }

/* --- Dashboard shortcut strip --- */
.mg-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.mg-shortcut {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--mg-line-2); border-radius: 999px; background: var(--mg-surface);
  color: var(--mg-ink); font-weight: 600; font-size: 14px; text-decoration: none;
}
.mg-shortcut:hover { border-color: var(--mg-aqua); color: var(--mg-aqua-deep); text-decoration: none; }
.mg-shortcut .mg-ico { width: 18px; height: 18px; color: var(--mg-aqua-deep); }
.mg-home-row { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; }
@media (min-width: 768px) { .mg-home-row { grid-template-columns: 1fr 1fr; } }
.mg-home-row > .mg-card { margin-bottom: 0 !important; }

/* --- Tasks card (dashboard) and organiser tiles --- */
.mg-taskcard-list { list-style: none; margin: 12px 0 0; padding: 0; }
.mg-taskcard-list li { padding: 6px 0; border-top: 1px solid var(--mg-line); font-weight: 600; }
.mg-taskcard-list li:first-child { border-top: 0; }
.mg-taskcard-list .mg-hint { font-weight: 500; }
.mg-tile-foot { margin-top: auto; padding: 0 22px 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.mg-tile-foot .btn { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }

/* --- All sections directory --- */
.mg-dir { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .mg-dir { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1400px) { .mg-dir { grid-template-columns: 1fr 1fr 1fr; } }
.mg-dir-group .mg-card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.mg-dir-list { list-style: none; margin: 0; padding: 0 0 6px; }
.mg-dir-link {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 22px; min-height: 52px;
  color: var(--mg-ink); text-decoration: none; border-top: 1px solid var(--mg-line);
}
.mg-dir-list li:first-child .mg-dir-link { border-top: 0; }
.mg-dir-link:hover { background: var(--mg-surface-2); text-decoration: none; color: var(--mg-ink); }
.mg-dir-link .mg-ico { width: 20px; height: 20px; color: var(--mg-aqua-deep); margin-top: 2px; flex: 0 0 auto; }
.mg-dir-name { display: block; font-weight: 700; }
.mg-dir-desc { display: block; font-size: 14px; color: var(--mg-text-soft); }

/* --- Front page: three audiences, in the hero under the headline --- */
.mg-aud-pick { display: grid; gap: 10px; max-width: 34rem; }
.mg-aud-choice {
  display: grid; grid-template-columns: auto 1fr auto;
  grid-template-areas: "icon name go" "icon for go" "chips chips chips";
  column-gap: 14px; row-gap: 0; align-items: center;
  padding: 12px 14px; border: 1px solid var(--mg-line-2); border-radius: var(--mg-r);
  background: var(--mg-surface); color: var(--mg-ink); text-decoration: none; min-height: 44px;
}
.mg-aud-choice:hover, .mg-aud-choice:focus-visible { border-color: var(--mg-aqua); text-decoration: none; color: var(--mg-ink); box-shadow: var(--mg-shadow-2); }
.mg-aud-icon { grid-area: icon; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.mg-aud-icon .mg-ico { width: 22px; height: 22px; }
.mg-aud-go { grid-area: go; width: 18px; height: 18px; color: var(--mg-text-mute); }
.mg-aud-chips { grid-area: chips; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mg-aud-chips > span {
  font-size: 13px; font-weight: 600; line-height: 1.2; padding: 5px 10px; border-radius: 999px;
  background: var(--mg-surface-2); color: var(--mg-ink); border: 1px solid var(--mg-line);
}
@media (min-width: 576px) {
  /* Wide enough: chips sit beside the name instead of underneath. */
  .mg-aud-choice { grid-template-columns: auto 8.5em 1fr auto; grid-template-areas: "icon name chips go" "icon for chips go"; }
  .mg-aud-chips { margin-top: 0; }
}
.mg-example-pots li { grid-template-columns: 7em 1fr auto; }
.mg-example-module { border-color: #C9D9EF; }
.mg-aud-personal { background: var(--mg-aqua-tint); color: var(--mg-aqua-deep); }
.mg-aud-household { background: var(--mg-set-aside-tint); color: #4B3BA8; }
.mg-aud-business { background: #E5EEFA; color: #2A578F; }
.mg-aud-name { grid-area: name; font-family: var(--mg-font-display); font-weight: 800; font-size: 1.15rem; line-height: 1.1; }
.mg-aud-for { grid-area: for; font-weight: 600; color: var(--mg-text-soft); }
.mg-aud-line { grid-area: line; margin-top: 10px; color: var(--mg-text-soft); font-size: 15px; }
.mg-aud-section { padding: 56px 0; scroll-margin-top: 72px; }
.mg-aud-section-alt { background: var(--mg-surface); border-top: 1px solid var(--mg-line); border-bottom: 1px solid var(--mg-line); }
.mg-aud-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 16px; }
.mg-aud-points li { padding-left: 26px; position: relative; color: var(--mg-text-soft); }
.mg-aud-points li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 10px; height: 10px; border-radius: 50%; background: var(--mg-aqua); }
.mg-aud-points strong { color: var(--mg-ink); }
#how-it-works { scroll-margin-top: 72px; }

/* Labelled example previews - static illustrations, never customer data. */
.mg-example { border: 1px solid var(--mg-line-2); border-radius: var(--mg-r); background: var(--mg-page); padding: 18px 20px; }
.mg-example-cap { font-weight: 700; color: var(--mg-ink); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mg-example-sub { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mg-text-mute); margin: 10px 0 4px; }
.mg-example-list { list-style: none; margin: 0; padding: 0; }
.mg-example-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--mg-line); font-weight: 600; }
.mg-example-list li:first-child { border-top: 0; }
.mg-example-list .mg-ico { width: 18px; height: 18px; color: var(--mg-aqua-deep); flex: 0 0 auto; }
.mg-example-list li.is-done { color: var(--mg-text-mute); text-decoration: line-through; }
.mg-example-box { width: 22px; height: 22px; border: 2px solid var(--mg-line-3); border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; background: var(--mg-surface); }
.mg-example-list li.is-done .mg-example-box { background: var(--mg-in); border-color: var(--mg-in); }
.mg-example-list li.is-done .mg-example-box .mg-ico { color: #fff; width: 14px; height: 14px; }
.mg-example-bars { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.mg-example-bars li { display: grid; grid-template-columns: 9.5em 1fr auto; gap: 12px; align-items: center; font-weight: 600; }
.mg-example-bar { height: 12px; border-radius: 999px; background: var(--mg-surface-2); overflow: hidden; }
.mg-example-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--mg-aqua); }
.mg-w-80 { width: 80%; }
.mg-w-60 { width: 60%; }
.mg-w-30 { width: 30%; }
.mg-w-15 { width: 15%; }
@media (max-width: 420px) {
  .mg-example-bars li { grid-template-columns: 1fr auto; }
  .mg-example-bar { grid-column: 1 / -1; order: 3; }
}

/* "How it works" on the front page (D142). Its own names on purpose: the
   onboarding progress bar owns `.mg-steps`, and its `.mg-steps span` rule
   (5px tall grey bars) used to squash these cards' text into overflow.
   Cards take their content's natural height; rows line up via the grid. */
.mg-how { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 576px) { .mg-how { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .mg-how { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mg-how-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 22px; min-width: 0;
  background: var(--mg-surface); border: 1px solid var(--mg-line); border-radius: var(--mg-r);
}
.mg-how-n {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--mg-ink); color: #fff; font-weight: 800; margin-bottom: 4px;
}
.mg-how-title { font-size: 1.05rem; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.mg-how-text { font-size: 15px; line-height: 1.5; color: var(--mg-text-soft); margin: 0; overflow-wrap: anywhere; }
.mg-how-note { margin-top: 32px; margin-left: auto; margin-right: auto; max-width: 42rem; }

@media (max-width: 575.98px) { .mg-shortcut:nth-child(n+5) { display: none; } }

/* A dismissible message keeps its text clear of the close button, whatever
   its padding (the onboarding "email confirmed" note overlapped it). D144. */
.alert-dismissible { padding-right: 3.25rem; }
.alert-dismissible .btn-close { top: 50%; transform: translateY(-50%); padding: .75rem; }

/* ---------------------------------------------------------------------------
   Architects invoicing on a phone (P3.41): a card per period, not a squeezed
   six-column table. The two answers first (to invoice, to arrive), the split
   quietly under them, then each job as one tappable line to its project.
   --------------------------------------------------------------------------- */
.mg-inv-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
@media (min-width: 768px) and (max-width: 991.98px) {
  .mg-inv-cards { grid-template-columns: 1fr 1fr; }
  .mg-inv-card:nth-child(odd) { border-right: 1px solid var(--mg-line); }
}
.mg-inv-card { padding: 14px 16px; border-top: 1px solid var(--mg-line); min-width: 0; }
.mg-inv-period { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.mg-inv-totals { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.mg-inv-totals p { margin: 0; display: flex; flex-direction: column; }
.mg-inv-totals span { font-size: 13px; color: var(--mg-text-mute); }
.mg-inv-totals strong { font-size: 18px; }
.mg-inv-split { margin: 6px 0 0; }
.mg-inv-items { list-style: none; margin: 10px 0 0; padding: 0; }
.mg-inv-items li + li { border-top: 1px dashed var(--mg-line); }
.mg-inv-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; min-height: 44px;
  color: inherit; text-decoration: none;
}
.mg-inv-item:hover .mg-inv-item-who, .mg-inv-item:focus-visible .mg-inv-item-who { text-decoration: underline; }
.mg-inv-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.mg-inv-item-who { font-weight: 600; color: var(--mg-aqua-deep); overflow-wrap: anywhere; }
.mg-inv-item-what, .mg-inv-item-when { font-size: 13px; color: var(--mg-text-mute); overflow-wrap: anywhere; }
.mg-inv-item-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.mg-inv-item-go { flex: 0 0 auto; font-size: 22px; color: var(--mg-text-mute); line-height: 1; }

/* More / All sections: an area with a single page is one linked card (no
   "Household dashboard" heading over a "Household dashboard" link). */
.mg-dir-solo-group { align-self: start; }
.mg-dir-link.mg-dir-solo { border-top: 0; padding: 16px 18px; border-radius: inherit; }
.mg-dir-solo-name { font-size: 1.05rem; font-weight: 700; margin: 0 0 2px; color: var(--mg-ink); }

/* The marketing header at 320px: "Now Organised" + Sign in + Get started must
   fit without sideways scrolling (found by walkthrough_redesign, P2.37). */
@media (max-width: 359.98px) {
  .mg-marketing-nav .container-xl.gap-3 { gap: 8px !important; }
  .mg-marketing-nav .mg-brand { font-size: 1rem; gap: 6px; }
  .mg-marketing-nav .mg-brand-mark { width: 22px; height: 22px; }
  .mg-marketing-nav .btn-sm { padding-left: 10px; padding-right: 10px; }
}
/* Narrow phones: the fee and status go under the job, in one row, so the
   client and project get the full width instead of wrapping word by word. */
@media (max-width: 419.98px) {
  .mg-inv-item { flex-wrap: wrap; row-gap: 4px; }
  .mg-inv-item-main { flex: 1 1 calc(100% - 24px); }
  .mg-inv-item-go { order: 2; }
  .mg-inv-item-side { order: 3; flex: 1 1 100%; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; }
}

/* -------------------------------------------------------------------------
   D152: PDF statements - the editable review rows and the area tool
   ------------------------------------------------------------------------- */
.mg-pdf-row {
  display: grid; gap: 8px; grid-template-columns: 1fr;
  padding: 12px 22px; border-bottom: 1px solid var(--mg-line);
}
.mg-pdf-row:last-child { border-bottom: 0; }
.mg-pdf-row.is-excluded { background: var(--mg-page); opacity: .75; }
.mg-pdf-row.has-warning { border-left: 4px solid var(--mg-warn); }
.mg-pdf-head { border-bottom: 1px solid var(--mg-line) !important; padding-top: 10px; padding-bottom: 6px; }
.mg-pdf-include { display: flex; align-items: center; gap: 8px; }
.mg-pdf-balance { align-self: center; white-space: nowrap; }
.mg-pdf-flags { grid-column: 1 / -1; margin: 0; padding-left: 18px; font-size: 13px; color: var(--mg-ink-3); }
.mg-pdf-flags li.is-warning { color: #7A5300; font-weight: 600; }
@media (min-width: 992px) {
  .mg-pdf-row { grid-template-columns: 56px 150px minmax(0, 1fr) 120px 140px 120px; align-items: center; }
}

.mg-area-surface { position: relative; border: 1px solid var(--mg-line); border-radius: var(--mg-r-sm); overflow: hidden; user-select: none; }
.mg-area-surface img { display: block; width: 100%; height: auto; pointer-events: none; }
.mg-area-surface.is-drawing { cursor: crosshair; touch-action: none; outline: 3px solid var(--mg-aqua); }
.mg-area-box { position: absolute; border: 3px solid var(--mg-aqua-deep); background: rgba(61, 155, 224, 0.16); pointer-events: none; }
.mg-pdf-account { max-width: 28rem; }

/* D153: Manage Workspaces - one card per workspace; actions wrap under on a phone. */
.mg-ws-manage-row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }
.mg-ws-manage-row.is-same-name { border-left: 4px solid var(--mg-warn); }
.mg-ws-manage-main { flex: 1 1 280px; min-width: 0; }
.mg-ws-manage-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* D154: matching - "+ Add Category" beside the list, the remember box, bulk review, rules. */
.mg-cat-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.mg-cat-row > select { flex: 1 1 220px; min-width: 0; }
.mg-newcat summary { list-style: none; cursor: pointer; }
.mg-newcat summary::-webkit-details-marker { display: none; }
.mg-newcat[open] { flex: 1 1 100%; }
.mg-newcat-body { margin-top: 8px; padding: 12px; border: 1px solid var(--mg-line); border-radius: var(--mg-r-sm); background: var(--mg-page); }
.mg-remember { display: block; font-size: 13px; color: var(--mg-ink-3); margin: 4px 0 6px; }
.mg-remember input { margin-right: 4px; }
.mg-bulk-row { flex-wrap: wrap; }
.mg-bulk-row.is-off { opacity: .7; }
.mg-bulk-check { width: 24px; }
.mg-bulk-what { flex: 1 1 220px; min-width: 0; margin: 0; }
.mg-rule-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; }
.mg-rule-row.is-off { opacity: .7; }
.mg-rule-main { flex: 1 1 260px; min-width: 0; }
.mg-rule-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* D155: several statements, Review Bank Transactions, "What was this?". */
.mg-many-list:empty { display: none; }
.mg-many-list .mg-list-item { flex-wrap: wrap; gap: 6px; }
.mg-upload-row { flex-wrap: wrap; gap: 8px; }
.mg-review-progress { display: block; width: 100%; height: 10px; accent-color: var(--mg-accent, #0f8a7e); }
.mg-review-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.mg-review-head, .mg-review-row { display: grid; grid-template-columns: 92px minmax(0, 2.2fr) 96px 96px minmax(0, 1.6fr) 118px 78px; gap: 10px; align-items: center; }
.mg-review-head { padding: 10px 16px 0; font-size: 12px; }
.mg-review-row { padding-top: 10px; padding-bottom: 10px; }
.mg-review-in, .mg-review-out { text-align: right; }
@media (max-width: 860px) {
  .mg-review-head { display: none; }
  .mg-review-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "date amount" "desc desc" "suggest suggest" "status act"; }
  .mg-review-date { grid-area: date; font-weight: 600; }
  .mg-review-desc { grid-area: desc; }
  .mg-review-in, .mg-review-out { grid-area: amount; }
  .mg-review-in:empty, .mg-review-out:empty { display: none; }
  .mg-review-suggest { grid-area: suggest; }
  .mg-review-status { grid-area: status; }
  .mg-review-act { grid-area: act; justify-self: end; }
}
.mg-what-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mg-what-grid > details { border: 1px solid var(--mg-line); border-radius: var(--mg-r-sm); padding: 10px 12px; background: var(--mg-card, #fff); }
.mg-what-grid > details > summary { cursor: pointer; font-weight: 600; }
.mg-what-grid > details[open] { grid-column: 1 / -1; }
.mg-partner { display: block; padding: 6px 0; }
.mg-held-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* D156: merchant category rule wordings - narrow inputs that wrap on a phone. */
.mg-rule-input { max-width: 16rem; }
.mg-rule-match { max-width: 12rem; }

/* D159: what a matched bank line was recorded as. */
.mg-recorded { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 0; }
.mg-recorded dt { font-weight: 500; color: var(--mg-text-mute); }
.mg-recorded dd { margin: 0; font-weight: 600; }
@media (max-width: 400px) { .mg-recorded { grid-template-columns: minmax(0, 1fr); } .mg-recorded dd { margin-bottom: 6px; } }


/* D159: the shopping list by shop. Big targets; nothing wider than a phone. */
.mg-shop-section-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 8px; border-bottom: 1px solid var(--mg-line); flex-wrap: wrap; }
.mg-shop-section.is-folded .mg-shop-section-head { border-bottom: 0; }
.mg-shop-fold { flex: 1 1 auto; min-width: 0; min-height: 48px; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; text-align: left; color: inherit; }
.mg-shop-fold-ico { flex: none; width: 18px; height: 18px; transform: rotate(90deg); transition: transform .15s; }
.mg-shop-section.is-folded .mg-shop-fold-ico { transform: rotate(0deg); }
.mg-shop-section-name { font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; overflow-wrap: anywhere; }
.mg-shop-count { flex: none; font-size: 14px; font-weight: 600; color: var(--mg-text-mute); }
.mg-shop-moves { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.mg-shop-moves form { display: inline; }
.mg-shop-move, .mg-shop-drag { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--mg-line); border-radius: 10px; background: var(--mg-surface); color: inherit; font-weight: 600; padding: 0 10px; }
.mg-shop-move:hover, .mg-shop-drag:hover { background: var(--mg-surface-2); }
.mg-shop-drag { cursor: grab; touch-action: none; }
.mg-shop-section.is-dragging { opacity: .85; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.mg-shop-section.is-dragging .mg-shop-drag { cursor: grabbing; }
.mg-shop-move-word { display: none; }
@media (min-width: 576px) { .mg-shop-move-word { display: inline; } }
.mg-shop-qty { font-weight: 700; }
.mg-shop-edit { flex: none; align-self: center; min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; font-size: 14px; font-weight: 600; color: var(--mg-text-mute); text-decoration: none; }
.mg-shop-edit:hover { color: inherit; text-decoration: underline; }
.mg-shop-only { flex: none; }
.mg-shop-manage { list-style: none; padding: 0; margin: 0 0 16px; }
.mg-shop-manage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--mg-line); }
.mg-shop-manage-row:last-child { border-bottom: 0; }
.mg-shop-manage-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.mg-shop-manage-actions { display: inline-flex; gap: 6px; }
.mg-shop-manage-more { flex: 1 1 100%; }

/* ---- D160: the account dashboard ------------------------------------------ */
/* D161: account next steps, the add button above Recent, entry questions. */
.mg-next-steps { display: grid; gap: 10px; }
.mg-next-step {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px; min-height: 64px;
  border: 1px solid var(--mg-line); border-radius: 12px; background: var(--mg-surface);
  color: inherit; text-decoration: none;
}
.mg-next-step:hover, .mg-next-step:focus-visible { background: var(--mg-surface-2); }
.mg-next-step .mg-ico { flex: none; margin-top: 2px; color: var(--mg-aqua); }
.mg-add-above { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.mg-entry-question { border: 1px solid var(--mg-line); border-radius: 10px; padding: 12px 14px 4px; }
.mg-entry-question legend { float: none; width: auto; font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.mg-list-item.is-this { background: var(--mg-surface-2); }
.mg-radios { border: 0; padding: 0; margin: 0; min-width: 0; }
.mg-radios legend { float: none; font-size: inherit; }
.mg-radio { min-height: 44px; display: flex; align-items: flex-start; gap: 10px; padding-left: 0; margin-bottom: 4px; }
.mg-radio .form-check-input { float: none; margin: 3px 0 0; flex: none; width: 1.25rem; height: 1.25rem; }
.mg-radio .form-check-label { flex: 1 1 auto; min-width: 0; }
.mg-forecast-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mg-forecast-form .form-select, .mg-forecast-form .form-control { width: auto; min-height: 36px; }
.mg-forecast-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mg-future-list { list-style: none; padding: 0; display: grid; gap: 4px; }
.mg-future-list .mg-list-date { display: inline-block; min-width: 92px; }
.mg-recon { color: var(--mg-text-mute); }
.mg-chart-axis .mg-axis-start { left: 0; }
.mg-chart-axis .mg-axis-end { left: 100%; }
.mg-recon.is-on { color: var(--mg-aqua); font-weight: 600; }
@media (max-width: 575.98px) {
  .mg-forecast-summary { grid-template-columns: 1fr 1fr; }
  .mg-forecast-summary > :first-child { grid-column: 1 / -1; }
  .mg-head-actions { flex-wrap: wrap; }
}

/* ---- D164/D165: plans and savings pots ------------------------------------- */
.mg-pot-progress { height: 8px; }
.mg-pot-bar { background: var(--mg-aqua); }
.mg-plan-facts dd { margin-bottom: .35rem; }

/* ---- D167: the shared calendar --------------------------------------------- */
.mg-cal-month { border: 1px solid var(--mg-line); border-radius: 12px; overflow: hidden; background: var(--mg-surface); }
.mg-cal-head, .mg-cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mg-cal-head span { padding: 6px; font-size: .75rem; font-weight: 600; color: var(--mg-text-mute); text-align: center; border-bottom: 1px solid var(--mg-line); }
.mg-cal-day { min-height: 96px; padding: 4px; border-right: 1px solid var(--mg-line); border-bottom: 1px solid var(--mg-line); min-width: 0; }
.mg-cal-day.is-other { background: var(--mg-surface-2); }
/* D174f fix (a D167 bug): the older money calendar's table rule '.mg-cal-day
   { width: 14.28%; height: 104px }' also reached these grid cells, squeezing
   each to a seventh of its column. Undo it for the grid only. */
.mg-cal-week > .mg-cal-day { width: auto; height: auto; }
.mg-cal-day.is-today .mg-cal-date { background: var(--mg-aqua); color: #fff; }
.mg-cal-date { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; font-size: .8rem; text-decoration: none; color: inherit; }
.mg-cal-item, .mg-cal-more { display: block; font-size: .72rem; line-height: 1.3; padding: 2px 4px; margin-top: 2px; border-radius: 4px; text-decoration: none; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-cal-item.is-entry { background: rgba(2, 97, 168, .12); }
.mg-cal-item.is-task { background: rgba(116, 87, 201, .12); }
.mg-cal-item.is-milestone { background: rgba(214, 140, 0, .14); }
.mg-cal-item.is-birthday { background: rgba(133, 52, 150, .13); }   /* D174f: logo purple */
.mg-cal-item.is-done { text-decoration: line-through; opacity: .7; }
.mg-cal-row { padding: 4px 0; }
@media (max-width: 575.98px) {
  .mg-cal-day { min-height: 64px; padding: 2px; }
  .mg-cal-item { font-size: .65rem; padding: 1px 2px; }
}

/* D168: a short amount box (paying out money kept for someone). */
.mg-amount-input { width: 6rem; }

/* =========================================================================
   D170 DESIGN SYSTEM LAYER - the approved Now Organised logo
   -------------------------------------------------------------------------
   Colours come from the logo (tokens at the top of this file). Bright green
   and orange are fills and accents only; text uses the deeper shades. One
   colour per kind of space, from the logo pills: Personal green, Household
   purple, Business blue - always with a word or icon too, never colour alone.
   ========================================================================= */

/* --- The logo ------------------------------------------------------------ */
.mg-brand-logo { display: inline-flex; line-height: 0; }
.mg-brand-lockup { height: 44px; width: auto; max-width: 100%; }
.mg-sidebar .mg-brand-lockup { height: 52px; }
.mg-topbar .mg-brand-lockup { height: 34px; }
.mg-marketing-nav .mg-brand-lockup { height: 46px; }
.mg-footer .mg-brand-lockup { height: 56px; }
@media (max-width: 575.98px) {
  .mg-marketing-nav .mg-brand-lockup { height: 34px; }
}
/* On a dark ground the white artwork sits on a deliberate white plate. */
.mg-brand-plate { background: #FFFFFF; border-radius: 12px; padding: 6px 10px; box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .45); }
.mg-brand-mark { width: 30px; height: 30px; }

/* --- Kinds of space -------------------------------------------------------- */
.mg-kind-pill { display: inline-flex; width: fit-content; align-items: center; gap: 6px; font-weight: 700; font-size: .85rem;
  padding: 5px 12px; border-radius: 999px; border: 1.5px solid currentColor; margin-bottom: .6rem; }
.mg-kind-pill .mg-ico { width: 16px; height: 16px; }
.mg-kind-personal  { color: var(--mg-kind-personal);  background: var(--mg-kind-personal-tint); }
.mg-kind-household { color: var(--mg-kind-household); background: var(--mg-kind-household-tint); }
.mg-kind-business  { color: var(--mg-kind-business);  background: var(--mg-kind-business-tint); }
.mg-aud-personal  { background: var(--mg-kind-personal-tint);  color: var(--mg-kind-personal); }
.mg-aud-household { background: var(--mg-kind-household-tint); color: var(--mg-kind-household); }
.mg-aud-business  { background: var(--mg-kind-business-tint);  color: var(--mg-kind-business); }

/* --- Focus, motion --------------------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--mg-brand-blue); outline-offset: 2px; border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn-mg-accent:hover, .btn-mg-quiet:hover { transform: none; }
}

/* --- Homepage -------------------------------------------------------------- */
.mg-home-hero { padding: 48px 0 56px; background:
  radial-gradient(900px 420px at 0% 0%, rgba(87, 166, 7, .10), transparent 60%),
  radial-gradient(900px 480px at 100% 10%, rgba(2, 97, 168, .10), transparent 60%),
  linear-gradient(180deg, #FFFFFF, var(--mg-page)); }
.mg-home-title { font-family: var(--mg-font-display); font-weight: 800; letter-spacing: -0.035em;
  color: var(--mg-ink); font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; margin-bottom: .6rem; }
.mg-home-lead { font-size: clamp(1.1rem, 2.2vw, 1.35rem); font-weight: 650; color: var(--mg-brand-blue); margin-bottom: .6rem; }
.mg-home-sub { font-size: 1.05rem; color: var(--mg-text-soft); max-width: 36rem; }
.mg-home-logo-card { background: #FFFFFF; border-radius: var(--mg-r-xl); padding: clamp(16px, 3vw, 32px);
  box-shadow: var(--mg-shadow-3); border: 1px solid var(--mg-line); }
.mg-home-logo { width: 100%; height: auto; display: block; }
.mg-home-section { padding: 64px 0; }
.mg-home-band { background: #FFFFFF; border-top: 1px solid var(--mg-line); border-bottom: 1px solid var(--mg-line); }
.mg-home-h2 { font-family: var(--mg-font-display); font-weight: 800; letter-spacing: -0.02em; color: var(--mg-ink);
  font-size: clamp(1.6rem, 3.2vw, 2.25rem); margin-bottom: .5rem; }
.mg-home-h3 { font-family: var(--mg-font-display); font-weight: 750; color: var(--mg-ink); font-size: 1.45rem; }
.mg-home-intro { color: var(--mg-text-soft); max-width: 44rem; margin: 0 auto 2rem; font-size: 1.05rem; }
.mg-home-area { padding: 28px 0; }
.mg-home-area + .mg-home-area { border-top: 1px dashed var(--mg-line-2); }
.mg-home-list { padding-left: 1.1rem; margin-bottom: 1rem; }
.mg-home-list li { margin-bottom: .45rem; color: var(--mg-text); }
.mg-home-list li::marker { color: var(--mg-brand-green); }
.mg-home-area-household .mg-home-list li::marker { color: var(--mg-brand-purple); }
.mg-home-area-business .mg-home-list li::marker { color: var(--mg-brand-blue); }
.mg-home-privacy { display: flex; gap: 10px; align-items: flex-start; background: var(--mg-kind-household-tint);
  border-radius: var(--mg-r); padding: 12px 14px; color: var(--mg-ink); }
.mg-home-privacy .mg-ico { color: var(--mg-kind-household); width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; }
.mg-home-fact { background: var(--mg-page); border-radius: var(--mg-r-lg); padding: 20px; height: 100%; }
.mg-home-fact .mg-ico { width: 28px; height: 28px; color: var(--mg-brand-blue); }
.mg-home-fact h3 { font-size: 1.05rem; font-weight: 750; margin: 10px 0 6px; color: var(--mg-ink); }
.mg-home-fact p { margin: 0; color: var(--mg-text-soft); }
.mg-home-cta { background: linear-gradient(135deg, var(--mg-ice), #FFFFFF 60%, var(--mg-kind-personal-tint));
  border: 1px solid var(--mg-line); border-radius: var(--mg-r-xl); padding: clamp(28px, 5vw, 56px); }

/* Previews built from the product components, labelled Example. */
.mg-demo { background: #FFFFFF; border: 1px solid var(--mg-line); border-radius: var(--mg-r-lg);
  box-shadow: var(--mg-shadow-2); padding: 18px; }
.mg-demo-head { font-weight: 700; color: var(--mg-ink); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.mg-demo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mg-demo-stat { background: var(--mg-page); border-radius: var(--mg-r); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mg-demo-label { font-size: .8rem; color: var(--mg-text-soft); font-weight: 600; }
.mg-demo-big { font-family: var(--mg-font-display); font-weight: 800; font-size: 1.6rem; color: var(--mg-ink); }
.mg-demo .mg-out { color: var(--mg-out); }
.mg-demo .mg-in { color: var(--mg-in); }
.mg-demo-pots > div:not(.progress) { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; margin-top: 6px; }
.mg-w-60 { width: 60%; }
.mg-w-30 { width: 30%; }
.mg-demo-shop, .mg-demo-offers, .mg-demo-dates { list-style: none; padding: 0; margin: 0 0 10px; }
.mg-demo-shop li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--mg-line); }
.mg-demo-shop li.is-in { color: var(--mg-text-mute); text-decoration: line-through; }
.mg-demo-box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--mg-line-3); display: inline-flex;
  align-items: center; justify-content: center; flex: 0 0 auto; }
.mg-demo-shop li.is-in .mg-demo-box { background: var(--mg-brand-green); border-color: var(--mg-brand-green); color: #fff; }
.mg-demo-box .mg-ico { width: 14px; height: 14px; }
.mg-demo-offers li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: var(--mg-page); }
.mg-demo-offers li.is-chosen { background: var(--mg-kind-household-tint); color: var(--mg-kind-household); font-weight: 650; }
.mg-demo-dates li { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--mg-line); }
.mg-demo-date { color: var(--mg-text-soft); font-weight: 650; }
.mg-demo-task { display: flex; gap: 8px; align-items: center; background: var(--mg-kind-business-tint); color: var(--mg-kind-business);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; }

/* Pricing */
.mg-price-card { background: #FFFFFF; border: 1px solid var(--mg-line); border-radius: var(--mg-r-lg); padding: 22px; height: 100%;
  border-top: 5px solid var(--mg-kind-personal); box-shadow: var(--mg-shadow-1); }
.mg-price-household { border-top-color: var(--mg-kind-household); }
.mg-price-business { border-top-color: var(--mg-kind-business); }
.mg-price { font-family: var(--mg-font-display); font-weight: 800; font-size: 2.4rem; color: var(--mg-ink); margin: 0; line-height: 1.1; }
.mg-price-per { color: var(--mg-text-soft); font-weight: 600; margin-bottom: .6rem; }
.mg-price-example { margin: 22px auto 6px; max-width: 40rem; background: var(--mg-ice); border-radius: var(--mg-r); padding: 12px 16px; }

/* Footer */
.mg-footer-h { font-weight: 750; color: var(--mg-ink); margin-bottom: .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.mg-footer nav .mg-marketing-link { display: block; padding: 3px 0; }

/* Audience choices pick up the kind colours on hover. */
.mg-aud-choice-personal:hover, .mg-aud-choice-personal:focus-visible { border-color: var(--mg-kind-personal); }
.mg-aud-choice-household:hover, .mg-aud-choice-household:focus-visible { border-color: var(--mg-kind-household); }
.mg-aud-choice-business:hover, .mg-aud-choice-business:focus-visible { border-color: var(--mg-kind-business); }

/* --- D170 dashboards -------------------------------------------------------- */
.mg-dash-h { font-family: var(--mg-font-display); font-size: 1.15rem; font-weight: 750; color: var(--mg-ink);
  display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.mg-kind-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--mg-kind-personal); }
.mg-kind-dot-household { background: var(--mg-kind-household); }
.mg-kind-dot-business { background: var(--mg-kind-business); }
.mg-dash-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .mg-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .mg-dash-grid:not(.mg-dash-grid-2) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mg-dash-grid > :empty { display: none; }
.mg-dash-card .mg-card-head h2 { font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.mg-dash-card .mg-card-head .mg-ico { color: var(--mg-brand-blue); }
.mg-dash-card-household .mg-card-head .mg-ico { color: var(--mg-kind-household); }
.mg-dash-card-business .mg-card-head .mg-ico { color: var(--mg-kind-business); }
.mg-dash-counts { list-style: none; padding: 0; margin: 0 0 10px; }
.mg-dash-counts li { padding: 6px 0; border-bottom: 1px solid var(--mg-line); }
.mg-dash-counts li:last-child { border-bottom: 0; }
.mg-dash-counts strong { font-family: var(--mg-font-display); font-size: 1.1rem; color: var(--mg-ink); margin-right: 4px; }
.mg-dash-when { display: flex; flex-direction: column; align-items: center; min-width: 3.4rem; margin-right: 12px;
  font-size: .75rem; color: var(--mg-text-soft); line-height: 1.15; }
.mg-dash-when strong { font-size: .9rem; color: var(--mg-ink); }
.mg-dash-when.is-today span { color: var(--mg-brand-blue); font-weight: 750; }

/* Quick actions: large, friendly, wrap on a phone. */
.mg-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.mg-quick-action { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; background: #FFFFFF; border: 1px solid var(--mg-line-2); color: var(--mg-ink);
  font-weight: 650; font-size: .92rem; text-decoration: none; box-shadow: var(--mg-shadow-1); }
.mg-quick-action .mg-ico { width: 18px; height: 18px; color: var(--mg-brand-blue); }
.mg-quick-action:hover, .mg-quick-action:focus-visible { border-color: var(--mg-brand-blue); color: var(--mg-brand-blue); text-decoration: none; }
@media (max-width: 575.98px) {
  .mg-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-quick-action { justify-content: flex-start; }
}

/* --- D171 ------------------------------------------------------------------ */
/* What kind of date a "Coming up" line is - colour is a second signal, the word is the first. */
.mg-dash-kind { display: inline-block; font-size: .72rem; font-weight: 650; line-height: 1.5;
  padding: 0 7px; border-radius: 999px; background: #EEF2F7; color: #1F2A37; }
.mg-dash-kind-task { background: #E6F0FA; color: #0F4677; }
.mg-dash-kind-entry { background: #F3E8F6; color: #5B2268; }
.mg-dash-kind-milestone { background: #E9F4E1; color: #24600E; }
.mg-dash-kind-money { background: #FFF1E0; color: #7A3E00; }
/* Statement review on a phone: no empty "suggestion" line under every row. */
@media (max-width: 860px) {
  .mg-review-suggest.is-empty { display: none; }
  .mg-review-row { row-gap: 6px; }
}
/* Numbered stages (statement checking). Not .mg-steps - the onboarding bar owns that. Wraps to a column on a phone. */
.mg-stages { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); counter-reset: none; }
.mg-stage { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px;
  background: #FFFFFF; border: 1px solid var(--mg-line); font-size: .9rem; color: var(--mg-text-soft); }
.mg-stage strong { color: var(--mg-ink); }
.mg-stage-n { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 750; font-size: .8rem;
  background: #EEF2F7; color: var(--mg-ink); }
.mg-stage.is-current { border-color: var(--mg-brand-blue); box-shadow: 0 0 0 1px var(--mg-brand-blue) inset; }
.mg-stage.is-current .mg-stage-n { background: var(--mg-brand-blue); color: #FFFFFF; }
/* Every dropdown keeps room for its chevron (a few page styles had squeezed it, so
   "Any plan" ran into the arrow), and filter dropdowns never shrink below their words. */
select.form-select { padding-right: 2.25rem; background-position: right .7rem center; }
.mg-forecast-form select.form-select { min-width: 8.5rem; }
/* Calendar month on a phone: dots in the grid, the words in the list underneath. */
.mg-cal-phone-list { display: none; }
@media (max-width: 575.98px) {
  .mg-cal-phone-list { display: block; }
  .mg-cal-day { min-height: 58px; }
  .mg-cal-item { display: inline-block; width: 8px; height: 8px; padding: 0; margin: 2px 2px 0 0;
    border-radius: 50%; font-size: 0; line-height: 0; vertical-align: middle; }
  .mg-cal-item.is-entry { background: var(--mg-brand-blue); }
  .mg-cal-item.is-task { background: #7457C9; }
  .mg-cal-item.is-milestone { background: #D68C00; }
  .mg-cal-item.is-done { opacity: .45; }
  .mg-cal-more { font-size: .65rem; padding: 0; }
}

/* --- D172 ------------------------------------------------------------------ */
.mg-perm-table th, .mg-perm-table td { vertical-align: middle; }
.mg-perm-table td .form-check-input { width: 1.4rem; height: 1.4rem; }
.mg-perm-table thead th { font-size: .82rem; color: var(--mg-text-soft); font-weight: 650; white-space: nowrap; }
.mg-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mg-sponsor { border: 1px solid var(--mg-line); border-radius: 12px; padding: 12px 14px; background: #FBFCFE; }
.mg-invite-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.6rem;
  font-weight: 750; letter-spacing: .08em; color: var(--mg-ink); }
.mg-trial-strip { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-radius: 12px; background: #EEF5FC; border: 1px solid #D5E5F5; margin-bottom: 16px;
  font-size: .9rem; color: #0F3F6E; }
.mg-trial-strip.is-ended { background: #FFF1E0; border-color: #F5D6AE; color: #6B3600; }
.mg-trial-strip a { font-weight: 650; }
.mg-shared-tag { display: inline-block; font-size: .72rem; font-weight: 650; padding: 0 7px; border-radius: 999px;
  background: #F3E8F6; color: #5B2268; }

/* D173: what the household spends - total = household accounts + members. */
.mg-hs-figures { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
.mg-hs-figure { flex: 1 1 160px; min-width: 0; }
.mg-hs-total .mg-fig-2 { color: var(--mg-ink); }
.mg-hs-op { align-self: center; font-size: 1.4rem; color: var(--mg-soft, #6B7785); font-weight: 600; }
.mg-hs-payers { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; }
.mg-hs-payers li span { color: var(--mg-soft, #6B7785); }
@media (max-width: 575.98px) {
  .mg-hs-figures { flex-direction: column; gap: 10px; }
  .mg-hs-op { display: none; }
  .mg-hs-figure { flex: 0 0 auto; width: 100%; }
}

/* =========================================================================
   D174d. Homepage: the promotional video fills the first screen.
   The section is sized by the viewport (100svh), so nothing shifts while the
   video loads; the poster (frame 0 of the video) is both the <video> poster
   and the section's own background, so a failed video still looks finished.
   ========================================================================= */
.mg-video-hero {
  position: relative; isolation: isolate; overflow: hidden; width: 100%;
  min-height: 100vh; min-height: 100svh;
  display: flex; align-items: flex-end; color: #FFFFFF;
  background: #000000 url("../img/home/now-organised-video-poster-1280.cab68f8c033c.jpg") center / cover no-repeat;
}
.mg-video-hero-media {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2;
  object-fit: cover; object-position: center; background: #000000;
}
.mg-video-hero[data-state="error"] .mg-video-hero-media { display: none; }
/* D174f: below 768px the portrait edit plays. It is shown whole - no cropping,
   no stretching - from the top of the hero; any height left over at the bottom
   is the hero's navy, where the headline panel sits anyway. Without the
   portrait file (or if it fails and the main video is used) the landscape
   video is cropped to fill as before, with the portrait poster (a centre crop
   of the landscape frame 0 until the portrait frame replaces it). The phone
   never fetches the landscape poster: this rule replaces the background. */
@media (max-width: 767.98px) {
  .mg-video-hero {
    background: #01152E url("../img/home/now-organised-video-poster-portrait.08efd8c9dc3a.jpg") center / cover no-repeat;
  }
  .mg-video-hero[data-source="mobile"] { background-position: center top; background-size: contain; }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-media {
    object-fit: contain; object-position: center top; background: transparent;
  }
}
.mg-video-hero-shade {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 24%),
    linear-gradient(0deg, rgba(1, 21, 46, .85) 0%, rgba(1, 21, 46, .45) 32%, rgba(1, 21, 46, 0) 60%);
}
/* Bottom padding keeps the text clear of Sound/Replay at every width. */
.mg-video-hero-content { width: 100%; padding: 104px 0 calc(100px + env(safe-area-inset-bottom)); }
/* The text sits on a translucent panel: the video has bright frames (its own
   white logo card), and white text must stay readable over every one. */
.mg-video-hero-panel {
  display: inline-block; max-width: 40rem; padding: clamp(18px, 2.4vw, 30px);
  border-radius: 20px; background: rgba(1, 21, 46, .62); border: 1px solid rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .6);
}
.mg-video-hero-title {
  font-family: var(--mg-font-display); font-weight: 800; letter-spacing: -0.035em; line-height: 1.03;
  font-size: clamp(2rem, 1rem + 3.2vw, 3.6rem); color: #FFFFFF; margin: 0 0 .5rem;
}
.mg-video-hero-lead {
  font-size: clamp(1.05rem, .9rem + .9vw, 1.5rem); font-weight: 650; color: #FFFFFF;
  max-width: 34rem; margin-bottom: 1.25rem; text-shadow: 0 1px 12px rgba(0, 0, 0, .45);
}
.mg-video-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.mg-video-hero-note { color: #FFFFFF; margin: .75rem 0 0; }
.mg-video-hero-note a { color: #FFFFFF; text-decoration: underline; }
.btn-mg-on-dark {
  color: #FFFFFF; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .75);
  font-weight: 700;
}
/* The same size and shape as the accent button beside it. */
.btn-lg.btn-mg-on-dark { font-size: 15.5px; padding: 13px 26px; min-height: 50px; border-radius: var(--mg-r);
  display: inline-flex; align-items: center; }
.btn-mg-on-dark:hover, .btn-mg-on-dark:focus-visible { color: #FFFFFF; background: rgba(255, 255, 255, .24); border-color: #FFFFFF; }

/* The header lies over the video on the homepage only (white plate logo). */
.mg-marketing-nav.mg-nav-over-video {
  position: absolute; top: 0; left: 0; right: 0;
  background: transparent; border-bottom: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.mg-nav-over-video .mg-marketing-link { color: #FFFFFF; text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }
.mg-nav-over-video .mg-marketing-link, .mg-nav-over-video .btn { white-space: nowrap; }
.mg-nav-over-video .mg-brand-lockup { height: 52px; }
.mg-nav-over-video :focus-visible, .mg-video-hero :focus-visible { outline-color: #FFFFFF; }

/* Sound and Replay: bottom right, clear of the edges and the safe areas. */
.mg-video-controls {
  position: absolute; z-index: 2; display: flex; align-items: center; gap: 10px;
  right: max(20px, calc(env(safe-area-inset-right) + 16px));
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
}
.mg-video-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 48px; min-height: 48px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, .7); background: rgba(1, 21, 46, .55); color: #FFFFFF;
  font-weight: 650; cursor: pointer; touch-action: manipulation;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.mg-video-btn:hover { background: rgba(1, 21, 46, .78); border-color: #FFFFFF; }
.mg-video-btn .mg-ico { width: 22px; height: 22px; }
.mg-video-btn[data-sound="off"] .mg-video-ico-on,
.mg-video-btn[data-sound="on"] .mg-video-ico-off { display: none; }
.mg-video-hero[data-state="error"] .mg-video-controls,
.mg-video-hero[data-state="poster"] .mg-video-controls { display: none; }
.mg-video-loading {
  width: 18px; height: 18px; border-radius: 50%; opacity: 0;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #FFFFFF;
  animation: mg-video-spin .9s linear infinite;
}
.mg-video-hero[data-state="loading"] .mg-video-loading { opacity: 1; }
@keyframes mg-video-spin { to { transform: rotate(360deg); } }
/* Play joins Sound and Replay, so it can never cover the text. */
.mg-video-play {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--mg-aqua-deep); color: #FFFFFF; font-weight: 700;
  background: linear-gradient(180deg, #0B6FBE, var(--mg-aqua)); cursor: pointer; touch-action: manipulation;
}
.mg-video-play[hidden] { display: none; }
.mg-video-play .mg-ico { width: 26px; height: 26px; }

/* Below the hero: the D170 "who it is for" picker and introduction. */
.mg-home-intro-band { padding: 44px 0 8px; }

/* Text stays above the controls wherever the two could meet. */
@media (max-width: 575.98px) {
  .mg-nav-over-video .mg-brand-lockup { height: 34px; }
  .mg-video-btn { width: 52px; height: 52px; padding: 0; }
  .mg-video-btn-label { display: none; }
  .mg-video-hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .mg-video-hero-panel { display: block; }
}
@media (max-width: 359.98px) {
  .mg-nav-over-video .mg-brand-lockup { height: 28px; }
  .mg-nav-over-video .mg-brand-plate { padding: 4px 7px; }
}
@media (max-height: 520px) {
  .mg-video-hero-content { padding-top: 76px; padding-bottom: 88px; }
  .mg-video-hero-panel { padding: 14px 18px; }
  .mg-video-hero-title { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mg-video-loading { animation: none; }
}

/* =========================================================================
   D174g. Phones: the portrait video is shown whole in its own 9:16 frame (the
   "stage"), and the headline, Get Started and Sign In sit beneath it - beside
   it when the phone is turned sideways - so nothing covers the wordmark. The
   frame is as wide as the screen unless that would make it taller than the
   screen less a 76px band beneath it, where Sound and Replay sit - so the
   whole video and its controls fit the first screen and the controls cover
   none of it. Turned sideways, they sit beside the frame instead.
   Desktop, laptop and tablet keep the D174d layout: there the stage simply
   fills the hero. Sign in and Get started also stay in the header on phones.
   ========================================================================= */
/* Its own stacking context, so the video and shade inside it are painted
   above its poster background (phones) - and, on desktop, exactly as before. */
.mg-video-hero-stage { position: absolute; inset: 0; z-index: -1; }
@media (orientation: portrait) {
  .mg-video-hero[data-source="mobile"],
  .mg-video-hero[data-source="fallback"] {
    --mg-stage-w: 100vw;
    --mg-stage-w: min(100vw, (100vh - 76px) * 9 / 16);
    --mg-stage-w: min(100vw, (100svh - 76px) * 9 / 16);
    display: block; min-height: 0; background: #01152E;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-stage,
  .mg-video-hero[data-source="fallback"] .mg-video-hero-stage {
    position: relative; inset: auto; z-index: 0; width: var(--mg-stage-w); aspect-ratio: 9 / 16;
    margin: 0 auto; overflow: hidden;
    background: #01152E url("../img/home/now-organised-video-poster-portrait.08efd8c9dc3a.jpg") center / cover no-repeat;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-controls,
  .mg-video-hero[data-source="fallback"] .mg-video-controls {
    top: calc(var(--mg-stage-w) * 16 / 9 + 8px); bottom: auto;
    right: calc((100% - var(--mg-stage-w)) / 2 + 12px);
  }
}
@media (orientation: landscape) {
  .mg-video-hero[data-source="mobile"] {
    flex-direction: row-reverse; align-items: center; background: #01152E;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-stage {
    position: relative; inset: auto; z-index: 0; flex: 0 0 auto; overflow: hidden;
    height: 100vh; height: 100svh; width: calc(100vh * 9 / 16); width: calc(100svh * 9 / 16);
    background: #01152E url("../img/home/now-organised-video-poster-portrait.08efd8c9dc3a.jpg") center / cover no-repeat;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-content {
    flex: 1 1 auto; min-width: 0; padding: 84px 0 76px;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-controls {
    right: calc(100vh * 9 / 16 + 14px); right: calc(100svh * 9 / 16 + 14px); bottom: 14px;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-btn { width: 48px; height: 48px; padding: 0; }
  .mg-video-hero[data-source="mobile"] .mg-video-btn-label { display: none; }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-title { font-size: clamp(1.6rem, 1rem + 2.4vw, 2.4rem); }
}
/* Wherever the headline is beside or below the frame (not over the video):
   the shade only darkens the top, for the header, and the headline is on the
   hero's own navy, so it needs no glass panel. The main video used as a
   fallback in landscape keeps the D174d overlay, glass panel included. */
.mg-video-hero[data-source="mobile"] .mg-video-hero-shade {
  background: linear-gradient(180deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, 0) 18%);
}
.mg-video-hero[data-source="mobile"] .mg-video-hero-panel {
  display: block; max-width: 40rem; padding: 0; background: none; border: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
@media (orientation: portrait) {
  .mg-video-hero[data-source="fallback"] .mg-video-hero-shade {
    background: linear-gradient(180deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, 0) 18%);
  }
  .mg-video-hero[data-source="fallback"] .mg-video-hero-panel {
    display: block; max-width: 40rem; padding: 0; background: none; border: 0; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .mg-video-hero[data-source="mobile"] .mg-video-hero-content,
  .mg-video-hero[data-source="fallback"] .mg-video-hero-content {
    padding: 84px 0 calc(30px + env(safe-area-inset-bottom));
  }
}
/* The header's text links lie over the video's white background on phones
   (and over the portrait video on a phone turned sideways, which can be wider
   than 768px): a dark pill keeps "Sign in" readable on every frame. */
@media (max-width: 767.98px) {
  .mg-nav-over-video .mg-marketing-link {
    background: rgba(1, 21, 46, .62); border-radius: 999px; padding: 8px 14px; text-shadow: none;
  }
}
body:has(.mg-video-hero[data-source="mobile"]) .mg-nav-over-video .mg-marketing-link {
  background: rgba(1, 21, 46, .62); border-radius: 999px; padding: 8px 14px; text-shadow: none;
}

/* D174h: "/?video-debug=1" only - what the video did, readable on a real phone. */
.mg-video-diag {
  position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 2000;
  margin: 0 auto; max-width: 30rem; padding: 10px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .86); color: #FFFFFF; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; pointer-events: none;
}

/* D174f: account actions stay reachable at the top, including short screens. */
.mg-account-menu .dropdown-menu { max-height: min(360px, calc(100dvh - 140px)); overflow-y: auto; }
img.mg-avatar { object-fit: cover; }
.mg-profile-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; font-size: 28px; }
.mg-cal-item.is-birthday { border-left: 3px solid var(--mg-aqua); }

/* D174f: a bigger logo on the sign-in screens - about twice the previous size
   in the desktop branding panel, a little larger above the form on phones.
   Scoped to the auth layout only; the 2x lockup (crop of the approved source,
   pills removed as before) keeps it sharp. Nothing else on the page changes. */
.mg-auth-aside > .mg-brand .mg-brand-lockup { height: 88px; }
.mg-auth-aside > .mg-brand .mg-brand-plate { padding: 12px 18px; border-radius: 18px; }
.mg-auth-form-inner > .mg-brand .mg-brand-lockup { height: 56px; }
@media (max-width: 359.98px) {
  .mg-auth-form-inner > .mg-brand .mg-brand-lockup { height: 46px; }
}

/* D176: the Owner & Support Centre's sections on phones and tablets (the rail is hidden below 992px). */
.mg-centre-tabs { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; scrollbar-width: thin; }
.mg-centre-tabs a { flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--mg-line, #d9e1ec); font-size: 14px; font-weight: 600; text-decoration: none; color: inherit; }
.mg-centre-tabs a.active { background: #01152E; border-color: #01152E; color: #FFFFFF; }
/* D176: reading widths for the Centre's and support's forms (instead of inline styles). */
.mg-measure-xs { max-width: 16rem; }
.mg-measure-sm { max-width: 32rem; }
.mg-measure-md { max-width: 42rem; }
.mg-year-input { width: 6.5rem; }
