/* ============================================================
   Agency app additions to the reference template's styles.
   Only what the template does not already have; built from its tokens.
   ============================================================ */

/* form layout: fields stacked in a card, actions on the right */
.form-fields {
  display: grid;
  gap: 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* messages: a refused change (role=alert) and a confirmation (role=status).
   Near-solid backgrounds and darkened text so they stay readable over any glass (WCAG AA, FND-NFR-008). */
.form-error,
.form-notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 500;
  box-shadow: var(--card-shadow);
}

.form-error {
  color: color-mix(in srgb, var(--red) 70%, #000);
  background: color-mix(in srgb, var(--red) 10%, #fff);
}

.form-notice {
  color: color-mix(in srgb, var(--green) 70%, #000);
  background: color-mix(in srgb, var(--green) 10%, #fff);
}

.form-actions .form-error {
  flex: 1 1 100%;
  margin: 0;
}

/* links styled as buttons keep the button look */
a.btn {
  text-decoration: none;
}

/* Text size (FND-FR-017a): the template is sized in pixels, so the whole app is scaled. */
html[data-text-size="larger"] {
  zoom: 1.1;
}

html[data-text-size="largest"] {
  zoom: 1.2;
}

/* BusyButton: a spinner in the button's own text colour while its work runs. */
.btn.is-busy {
  cursor: progress;
}
/* Disabled buttons fade so it is clear they cannot be pressed; a busy one stays clear so its spinner shows. */
.btn:disabled:not(.is-busy) {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-spin {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
  to {
    rotate: 360deg;
  }
}
/* The spinner is the only sign that work is running, so with reduced motion it turns slowly instead of stopping. */
[data-motion='reduced'] .btn .btn-spin {
  animation-duration: 1.6s !important;
  animation-iteration-count: infinite !important;
}
@media (prefers-reduced-motion: reduce) {
  .btn .btn-spin {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---------------- phones and tablets ---------------- */
/* Option labels never wrap; when a row of options is wider than the screen it scrolls sideways instead. */
.seg button {
  flex: none;
  white-space: nowrap;
}
@media (max-width: 900px) {
  /* The header's actions may shrink to the screen so a long row of options can scroll inside it. */
  .page-actions {
    min-width: 0;
    max-width: 100%;
  }
  .seg {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .seg::-webkit-scrollbar {
    display: none;
  }
}
@media (max-width: 720px) {
  /* KPI card labels wrap rather than being cut off with an ellipsis. */
  .kpi-foot strong,
  .kpi-foot small {
    white-space: normal;
  }
  /* Twelve month labels do not fit side by side: smaller, and every other one hidden (the current month always shows). */
  .rb-m {
    font-size: 11px;
  }
  .rb-col:nth-of-type(odd):not(.now) .rb-m {
    visibility: hidden;
  }
}


/* A tick box keeps its size when the label beside it wraps onto two lines. */
.fe-check input[type="checkbox"] {
  flex: none;
}

/* A row with an on/off switch keeps the switch beside its text on phones (other rows may still wrap). */
.set-row:has(> .switch) {
  flex-wrap: nowrap;
}

/* Long addresses and settings names in code style break rather than run off a narrow card. */
.card code {
  overflow-wrap: anywhere;
}

/* The dashboard's "Show as a table" scrolls sideways inside its card when the figures do not fit. */
.fin-table {
  max-width: 100%;
  overflow-x: auto;
}
@media (max-width: 720px) {
  .fin-table .st-table {
    font-size: 12.5px;
  }
  .fin-table .st-table .num {
    width: auto;
  }
}

/* The chart's hover box opens leftwards over the last two months so it never runs past the screen edge. */
.rb-col:nth-last-of-type(-n + 2) .rb-tip {
  left: auto;
  right: 0;
  transform: translate(0, -88%) scale(0.85);
}
.rb-col.on:nth-last-of-type(-n + 2) .rb-tip {
  transform: translate(0, -100%);
}

/* ---------------- phone bar: brand and account at the top of the page on phones only ---------------- */
.phone-bar {
  display: none;
}
@media (max-width: 720px) {
  .phone-bar {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -8px 0 18px;
  }
  .phone-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
  }
  .phone-brand .rail-mark {
    width: 30px;
    height: 30px;
    object-fit: contain;
  }
  .phone-brand b {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
  }
  .phone-me {
    position: relative;
  }
  .phone-me-btn {
    display: block;
    border-radius: 999px;
  }
  .phone-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    padding: 8px;
    border-radius: 18px;
    background: var(--solid);
    color: var(--on-solid);
    box-shadow: 0 18px 36px -14px rgba(0, 0, 0, 0.55);
    animation: rise 0.25s var(--ease) both;
  }
  .phone-menu-who {
    margin: 0;
    padding: 8px 10px 10px;
    font-weight: 600;
    border-bottom: 1px solid color-mix(in srgb, var(--on-solid) 18%, transparent);
  }
  .phone-menu a,
  .phone-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 12px;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
  }
  .phone-menu a:hover,
  .phone-menu button:hover {
    background: color-mix(in srgb, var(--on-solid) 10%, transparent);
  }
}
.phone-menu-glyph {
  display: inline-grid;
  width: 16px;
  height: 16px;
}
.phone-menu-glyph svg {
  width: 16px;
  height: 16px;
}
