/* Fifi Finance UI — Nexora visual tokens + emilkowalski motion craft */

:root {
  /* —— Nexora semantic tokens (HSL channels) —— */
  --background: 0 0% 100%;
  --foreground: 210 14% 17%;
  --primary: 210 14% 17%;
  --primary-foreground: 0 0% 100%;
  --secondary: 0 0% 96%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 96%;
  --muted-foreground: 184 5% 55%;
  --accent: 239 84% 67%;
  --accent-foreground: 0 0% 100%;
  --border: 0 0% 90%;
  --ring: 239 84% 67%;
  --radius: 0.5rem;
  --font-display: "Instrument Serif", "Noto Serif SC", "Songti SC", serif;
  --font-body: "Inter", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --shadow-dashboard: 0 25px 80px -12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.06);

  /* —— Compatible aliases for existing selectors —— */
  --fifi-ivory: hsl(var(--background));
  --fifi-sand: hsl(var(--secondary));
  --fifi-ink: hsl(var(--foreground));
  --fifi-muted: hsl(var(--muted-foreground));
  --fifi-surface: hsl(var(--background));
  --fifi-border: hsl(var(--border));
  --fifi-border-strong: hsl(var(--foreground) / 0.16);
  --fifi-accent: hsl(var(--primary));
  --fifi-accent-soft: hsl(var(--foreground) / 0.06);
  --fifi-accent-color: hsl(var(--accent));
  --fifi-credit: #be185d;
  --fifi-ok: #0f766e;
  --fifi-warn: #b45309;
  --fifi-danger: #b42318;

  --fifi-font-heading: var(--font-display);
  --fifi-font-body: var(--font-body);

  --fifi-radius: var(--radius);
  --fifi-radius-sm: calc(var(--radius) - 2px);
  --fifi-shadow: var(--shadow-dashboard);
  --fifi-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --fifi-sidebar-w: 260px;

  /* —— emil motion —— */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-press: 140ms;
  --duration-fast: 160ms;
  --duration-drawer: 320ms;

  /* aliases used elsewhere */
  --ff-ink: var(--fifi-ink);
  --ff-muted: var(--fifi-muted);
  --ff-accent: var(--fifi-accent);
  --ff-line: var(--fifi-border);
  --ff-panel: hsl(var(--secondary));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

.ff-body {
  margin: 0;
  min-height: 100vh;
  color: hsl(var(--foreground));
  background: hsl(var(--secondary));
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: hsl(var(--foreground));
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: hsl(var(--accent));
  text-decoration: underline;
}

/* Shell must not depend on Bootstrap utilities surviving CDN failure */
.ff-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.ff-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* —— Sidebar —— */
.ff-sidebar {
  width: var(--fifi-sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  background: hsl(var(--background));
  border-right: 1px solid hsl(var(--border));
  box-shadow: none;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 30;
}

.ff-sidebar__brand {
  padding: 1.15rem 1rem 0.9rem;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ff-brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  text-decoration: none !important;
  color: inherit;
}

.ff-brand-lockup:hover {
  text-decoration: none !important;
  color: inherit;
}

.ff-brand-lockup:hover .ff-brand-glyph {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.ff-brand-glyph {
  width: 2.35rem;
  height: 2.35rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.ff-brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.ff-brand-mark {
  font-family: var(--fifi-font-heading);
  font-weight: 650;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--fifi-ink);
}

.ff-brand-sub {
  font-size: 0.72rem;
  font-weight: 550;
  color: var(--fifi-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quiet Fold / Expand utility row */
.ff-nav-tools {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-top: 0.15rem;
  border-top: 1px solid hsl(var(--border));
}

.ff-nav-tools__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fifi-muted);
  font-family: var(--fifi-font-body);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.55rem;
  margin: 0;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: transform var(--duration-press) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-nav-tools__sep {
  width: 1px;
  height: 0.7rem;
  background: hsl(var(--foreground) / 0.16);
  flex-shrink: 0;
}

.ff-nav-tools__btn:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .ff-nav-tools__btn:hover {
    color: var(--fifi-ink);
    background: hsl(var(--foreground) / 0.06);
  }
}

.ff-nav-tools__btn:focus-visible {
  outline: 2px solid hsl(var(--foreground) / 0.35);
  outline-offset: 1px;
}

.ff-sidebar__tools {
  display: none;
}

.ff-sidebar__scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.45rem 0.55rem 1.25rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.ff-sidebar .nav-link {
  color: var(--fifi-muted);
  border-radius: var(--fifi-radius);
  padding: 0.42rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .ff-sidebar .nav-link:hover {
    background: var(--fifi-accent-soft);
    color: var(--fifi-ink);
  }
}

.ff-sidebar .nav-link:active {
  transform: scale(0.98);
  transition: transform var(--duration-press) var(--ease-out);
}

.ff-sidebar .nav-link.is-active {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-weight: 600;
}

.ff-nav-home {
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: var(--fifi-ink);
}

.ff-nav-group {
  margin: 0.08rem 0 0.28rem;
}

.ff-nav-group__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem 0.28rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fifi-muted);
  border-radius: var(--fifi-radius-sm);
}

.ff-nav-group__summary::-webkit-details-marker {
  display: none;
}

.ff-nav-group__summary::after {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.7;
  transition: transform var(--duration-fast) var(--ease-out);
}

.ff-nav-group[open] > .ff-nav-group__summary::after {
  transform: rotate(45deg);
}

@media (hover: hover) and (pointer: fine) {
  .ff-nav-group__summary:hover {
    color: var(--fifi-ink);
    background: hsl(var(--foreground) / 0.04);
  }
}

.ff-nav-group__links {
  display: flex;
  flex-direction: column;
  gap: 0.04rem;
  padding: 0.05rem 0 0.2rem;
}

.ff-nav-locale {
  margin-top: 0.75rem;
  padding: 0.7rem 0.55rem 0.25rem;
  border-top: 1px solid var(--fifi-border);
}

.ff-nav-locale .form-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fifi-muted);
  font-weight: 700;
}

body.ff-nav-collapsed .ff-sidebar {
  display: none;
}

.ff-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 28;
  background: hsl(var(--foreground) / 0.28);
  opacity: 0;
  transition: opacity var(--duration-drawer) var(--ease-out);
}

.ff-sidebar-backdrop.is-open {
  opacity: 1;
}

/* —— Icon / menu / ghost buttons —— */
.ff-icon-btn {
  appearance: none;
  border: 0;
  background: hsl(var(--foreground) / 0.06);
  color: var(--fifi-ink);
  border-radius: 8px;
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-icon-btn:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .ff-icon-btn:hover {
    background: hsl(var(--foreground) / 0.1);
  }
}

.ff-icon-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
  stroke: currentColor;
}

.ff-menu-toggle {
  appearance: none;
  border: 0;
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: var(--radius);
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-menu-toggle:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .ff-menu-toggle:hover {
    background: hsl(var(--foreground) / 0.08);
  }
}

.ff-menu-toggle__bars {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
  width: 14px;
}

.ff-menu-toggle__bars span {
  display: block;
  height: 1.5px;
  width: 100%;
  border-radius: 2px;
  background: currentColor;
}

.ff-btn-ghost {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fifi-muted);
  font-family: var(--fifi-font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.ff-btn-ghost:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .ff-btn-ghost:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--secondary));
    border-color: hsl(var(--border));
  }
}

.ff-icon-btn:focus-visible,
.ff-menu-toggle:focus-visible,
.ff-btn-ghost:focus-visible,
.ff-nav-tools__btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.ff-icon-btn:focus:not(:focus-visible),
.ff-menu-toggle:focus:not(:focus-visible),
.ff-btn-ghost:focus:not(:focus-visible),
.ff-nav-tools__btn:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* —— Topbar —— */
.ff-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid hsl(var(--border));
}

@media (min-width: 768px) {
  .ff-topbar {
    padding: 0.7rem 1.35rem;
  }
}

.ff-topbar__left,
.ff-topbar__right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.ff-topbar__right {
  flex-shrink: 0;
}

.ff-topbar__titles {
  min-width: 0;
}

.ff-topbar__title {
  font-family: var(--fifi-font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--fifi-ink);
}

.ff-topbar__meta,
.ff-topbar__user {
  color: var(--fifi-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.ff-topbar__user {
  max-width: 10rem;
}

.ff-locale-switch {
  display: inline-flex;
  align-items: center;
}

.ff-locale-select {
  appearance: none;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23858d8c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.45rem center;
  color: var(--fifi-ink);
  font-family: var(--fifi-font-body);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.35rem 1.5rem 0.35rem 0.55rem;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.2;
  transition: border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-locale-select:hover,
.ff-locale-select:focus {
  border-color: hsl(var(--ring));
  outline: none;
}

.ff-role-chip {
  display: inline-flex;
  align-items: center;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--fifi-border);
  background: hsl(var(--background));
  color: var(--fifi-muted);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ff-main-content {
  padding: 1.15rem 1rem 5.75rem;
  flex: 1;
}

@media (min-width: 768px) {
  .ff-main-content {
    padding: 1.5rem 1.75rem 2rem;
  }
}

.ff-main-content h1,
.ff-main-content .h3,
.ff-main-content .h4,
.ff-dash-hero__brand {
  font-family: var(--fifi-font-heading);
  color: var(--fifi-ink);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* —— Surfaces —— */
.border.bg-white,
.list-group.border.bg-white,
form.border.bg-white,
.ff-card {
  background: hsl(var(--background)) !important;
  border: 1px solid var(--fifi-border) !important;
  border-radius: var(--fifi-radius-sm);
  box-shadow: none;
  overflow: hidden;
}

/* Must allow horizontal scroll on small screens — never overflow:hidden here */
.table-responsive {
  background: hsl(var(--background)) !important;
  border: 1px solid var(--fifi-border) !important;
  border-radius: var(--fifi-radius-sm);
  box-shadow: none;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-responsive > .table {
  margin-bottom: 0;
  min-width: 36rem;
}

.table-responsive .ff-date,
.table-responsive .ff-date-range {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fifi-muted);
  font-weight: 700;
  background: hsl(var(--secondary)) !important;
  border-bottom: 1px solid var(--fifi-border) !important;
  white-space: nowrap;
}

.table td {
  border-color: hsl(var(--border)) !important;
  color: var(--fifi-ink);
  vertical-align: middle;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.table-hover > tbody > tr {
  transition: background-color var(--duration-fast) var(--ease-out);
}

.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: var(--fifi-accent-soft);
  background-color: var(--fifi-accent-soft) !important;
}

.font-monospace,
.ff-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.ff-num {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  font-weight: 550;
}

.ff-num--strong {
  font-weight: 650;
  color: var(--fifi-ink);
}

.form-control,
.form-select {
  border-color: hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: var(--fifi-ink);
  box-shadow: none;
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.form-control:focus,
.form-select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.2);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fifi-ink);
}

/* —— Buttons (charcoal primary + pill CTAs + emil press) —— */
.btn {
  border-radius: 999px !important;
  font-family: var(--fifi-font-body);
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.45rem 1rem;
  box-shadow: none;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 0.28rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.35rem;
  border-radius: 999px !important;
}

.btn-primary {
  --bs-btn-color: hsl(var(--primary-foreground));
  --bs-btn-bg: hsl(var(--primary));
  --bs-btn-border-color: hsl(var(--primary));
  --bs-btn-hover-color: hsl(var(--primary-foreground));
  --bs-btn-hover-bg: hsl(var(--foreground) / 0.88);
  --bs-btn-hover-border-color: hsl(var(--foreground) / 0.88);
  --bs-btn-active-color: hsl(var(--primary-foreground));
  --bs-btn-active-bg: hsl(var(--foreground));
  --bs-btn-active-border-color: hsl(var(--foreground));
  background: hsl(var(--primary)) !important;
  border-color: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
}

.btn-primary:hover {
  background: hsl(var(--foreground) / 0.88) !important;
  border-color: hsl(var(--foreground) / 0.88) !important;
  color: hsl(var(--primary-foreground)) !important;
}

.btn-outline-primary {
  --bs-btn-color: hsl(var(--foreground));
  --bs-btn-border-color: hsl(var(--border));
  --bs-btn-hover-bg: hsl(var(--secondary));
  --bs-btn-hover-border-color: hsl(var(--border));
  --bs-btn-hover-color: hsl(var(--foreground));
  background: hsl(var(--background)) !important;
  color: hsl(var(--foreground)) !important;
  border-color: hsl(var(--border)) !important;
}

.btn-outline-primary:hover {
  background: hsl(var(--secondary)) !important;
  color: hsl(var(--foreground)) !important;
}

.btn-outline-secondary {
  --bs-btn-color: hsl(var(--foreground));
  --bs-btn-border-color: hsl(var(--border));
  --bs-btn-hover-bg: hsl(var(--secondary));
  --bs-btn-hover-color: hsl(var(--foreground));
  background: hsl(var(--background)) !important;
  color: hsl(var(--foreground)) !important;
  border-color: hsl(var(--border)) !important;
}

.btn-outline-danger {
  color: var(--fifi-danger) !important;
  border-color: rgba(180, 35, 24, 0.35) !important;
  background: hsl(var(--background)) !important;
}

.btn-outline-danger:hover {
  background: rgba(180, 35, 24, 0.08) !important;
}

.btn-warning {
  background: #f5d78e !important;
  border-color: #e8c56a !important;
  color: #3f2a08 !important;
}

.btn-link {
  color: var(--fifi-ink) !important;
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
}

.btn-link:hover {
  color: var(--fifi-ink) !important;
  text-decoration: underline;
}

.btn-link:active {
  transform: none;
}

/* —— Page chrome —— */
.ff-page-head,
.ff-main-content > .d-flex.justify-content-between.align-items-center.mb-3,
.ff-main-content > .d-flex.justify-content-between.mb-3,
.ff-main-content > .d-flex.justify-content-between.align-items-center.mb-3.flex-wrap,
.ff-main-content > .d-flex.justify-content-between.align-items-start.mb-3.flex-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-start !important;
  justify-content: space-between;
  margin-bottom: 1.15rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--fifi-border);
}

.ff-page-head__title,
.ff-page-head h1,
.ff-main-content > .d-flex.justify-content-between h1.h3 {
  font-family: var(--fifi-font-heading);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin: 0 0 0.25rem;
}

.ff-page-head__meta,
.ff-page-head p,
.ff-main-content > .d-flex.justify-content-between .text-secondary {
  color: var(--fifi-muted) !important;
  font-size: 0.88rem;
  margin: 0;
  max-width: 40rem;
  line-height: 1.5;
}

.ff-page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ff-filter-bar,
.ff-main-content > form.row.g-2.align-items-end.mb-3 {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: none;
  padding: 0.85rem 1rem;
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 1rem;
}

.ff-meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--fifi-border);
  border-radius: var(--fifi-radius-sm);
  background: hsl(var(--background));
  overflow: hidden;
}

.ff-meta-strip__item {
  padding: 0.85rem 1rem;
  border-right: 1px solid var(--fifi-border);
  min-width: 0;
}

.ff-meta-strip__item:last-child {
  border-right: 0;
}

.ff-meta-strip__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fifi-muted);
  margin-bottom: 0.3rem;
}

.ff-meta-strip__value {
  font-size: 0.95rem;
  font-weight: 550;
  color: var(--fifi-ink);
  line-height: 1.3;
}

.ff-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid hsl(var(--border));
  border-left: 2px solid var(--fifi-warn);
  border-radius: var(--radius);
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-size: 0.88rem;
  line-height: 1.45;
}

.ff-banner--info {
  border-left-color: var(--fifi-ink);
}

.ff-banner--danger {
  border-left-color: var(--fifi-danger);
  background: rgba(180, 35, 24, 0.05);
}

/* Status chips — replace Bootstrap badges */
.ff-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--fifi-border-strong);
  background: var(--fifi-accent-soft);
  color: var(--fifi-ink);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}

.ff-status::before {
  content: "";
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}

.ff-status--posted,
.ff-status--approved {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.22);
  color: var(--fifi-ok);
}

.ff-status--draft,
.ff-status--calculated {
  background: hsl(var(--foreground) / 0.06);
  border-color: hsl(var(--foreground) / 0.16);
  color: var(--fifi-muted);
}

.ff-status--void,
.ff-status--reversed {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.22);
  color: var(--fifi-warn);
}

.badge.text-bg-success,
.badge.text-bg-secondary,
.badge.text-bg-warning,
.badge.text-bg-danger,
.badge.text-bg-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--fifi-border-strong);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.4;
  background: var(--fifi-accent-soft) !important;
  color: var(--fifi-ink) !important;
}

.badge.text-bg-success {
  background: rgba(15, 118, 110, 0.08) !important;
  border-color: rgba(15, 118, 110, 0.22);
  color: var(--fifi-ok) !important;
}

.badge.text-bg-secondary {
  background: hsl(var(--foreground) / 0.06) !important;
  border-color: hsl(var(--foreground) / 0.16);
  color: var(--fifi-muted) !important;
}

.badge.text-bg-warning {
  background: rgba(180, 83, 9, 0.08) !important;
  border-color: rgba(180, 83, 9, 0.22);
  color: var(--fifi-warn) !important;
}

.badge.text-bg-danger {
  background: rgba(180, 35, 24, 0.08) !important;
  border-color: rgba(180, 35, 24, 0.22);
  color: var(--fifi-danger) !important;
}

.alert {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  border-left: 2px solid hsl(var(--accent));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  box-shadow: none;
}

.alert-warning {
  border-left-color: var(--fifi-warn);
}

.alert-danger {
  border-left-color: var(--fifi-danger);
  background: rgba(180, 35, 24, 0.05);
}

.alert-success {
  border-left-color: var(--fifi-ok);
  background: rgba(15, 118, 110, 0.06);
}

/* —— Pagination / dropdowns / empty —— */
.pagination {
  gap: 0.25rem;
  margin: 1rem 0 0;
}

.page-link {
  border-radius: 999px !important;
  border: 1px solid hsl(var(--border)) !important;
  color: hsl(var(--foreground)) !important;
  background: hsl(var(--background)) !important;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 550;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-press) var(--ease-out);
}

.page-link:hover {
  background: hsl(var(--secondary)) !important;
  border-color: hsl(var(--border)) !important;
  color: hsl(var(--foreground)) !important;
}

.page-link:active {
  transform: scale(0.97);
}

.page-item.active .page-link {
  background: hsl(var(--primary)) !important;
  border-color: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
}

.page-item.disabled .page-link {
  opacity: 0.45;
}

.dropdown-menu {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow-dashboard);
  padding: 0.35rem;
  background: hsl(var(--background));
}

.dropdown-item {
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: hsl(var(--foreground));
  padding: 0.45rem 0.7rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.list-group-item {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
  background: hsl(var(--background));
}

.ff-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
}

/* —— Dashboard —— */
.ff-dash-hero {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.ff-dash-hero__brand {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  line-height: 1.1;
  color: hsl(var(--foreground));
}

.ff-dash-hero__lead {
  color: hsl(var(--muted-foreground));
  max-width: 28rem;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.ff-dash-health {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--fifi-border);
  border-left: 3px solid var(--fifi-ok);
  border-radius: 8px;
  background: hsl(var(--background));
  color: var(--fifi-ink);
  text-decoration: none !important;
}

.ff-dash-health--warning {
  border-left-color: var(--fifi-warn);
}

.ff-dash-health--fail {
  border-left-color: var(--fifi-danger);
}

.ff-dash-health__eyebrow {
  display: block;
  color: var(--fifi-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ff-dash-health__status {
  display: block;
  margin-top: 0.1rem;
  font-size: 1rem;
}

.ff-dash-health__summary {
  color: var(--fifi-muted);
  font-size: 0.78rem;
  text-align: right;
}

.ff-dash-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.ff-stat-card {
  display: block;
  background: hsl(var(--background));
  border: 1px solid var(--fifi-border);
  border-radius: 12px;
  padding: 1.15rem 1.2rem 1rem;
  text-decoration: none !important;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-press) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--fifi-ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.28s var(--ease-out);
}

.ff-stat-card:active {
  transform: scale(0.99);
}

@media (hover: hover) and (pointer: fine) {
  .ff-stat-card:hover {
    border-color: var(--fifi-border-strong);
    background: hsl(var(--background));
  }
  .ff-stat-card:hover::before {
    transform: scaleX(1);
  }
}

.ff-stat-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ff-stat-card__label {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--fifi-muted);
  letter-spacing: 0.01em;
}

.ff-stat-card__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--fifi-accent-soft);
}

.ff-stat-card__icon--blue { background: #dbeafe; }
.ff-stat-card__icon--sand { background: hsl(var(--secondary)); }
.ff-stat-card__icon--teal { background: #ccfbf1; }
.ff-stat-card__icon--amber { background: #fef3c7; }
.ff-stat-card__icon--rose { background: #fce7f3; }
.ff-stat-card__icon--navy { background: hsl(var(--accent) / 0.15); }

.ff-stat-card__value {
  font-family: var(--fifi-font-heading);
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 650;
  color: var(--fifi-ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.ff-stat-card__value--neg {
  color: var(--fifi-danger);
}

.ff-stat-card__foot {
  font-size: 0.78rem;
  color: var(--fifi-muted);
  line-height: 1.45;
}

.ff-dash-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.ff-chart-panel {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  padding: 1.15rem 1.2rem 1rem;
}

.ff-chart-panel__title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--fifi-ink);
  margin: 0 0 1rem;
}

.ff-chart-panel__canvas-wrap {
  position: relative;
  height: 220px;
}

.ff-chart-panel__canvas-wrap--donut {
  height: 220px;
  max-width: 280px;
  margin: 0 auto;
}

.ff-dash-activity {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.ff-activity-panel {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  padding: 1.1rem 1.15rem;
}

.ff-activity-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ff-activity-panel__title {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--fifi-ink);
  margin: 0;
}

.ff-activity-panel__link {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--fifi-ink);
  text-decoration: none;
}

.ff-activity-panel__link:hover {
  text-decoration: underline;
}

.ff-activity-empty {
  margin: 0;
  color: var(--fifi-muted);
  font-size: 0.85rem;
}

.ff-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ff-activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--fifi-border);
  text-decoration: none !important;
  color: inherit;
}

.ff-activity-list li:last-child .ff-activity-item {
  border-bottom: 0;
  padding-bottom: 0.15rem;
}

.ff-activity-item__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ff-activity-item__title {
  font-size: 0.88rem;
  font-weight: 550;
  color: var(--fifi-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ff-activity-item__meta {
  font-size: 0.75rem;
  color: var(--fifi-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ff-activity-item__amt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--fifi-ink);
  flex-shrink: 0;
}

@media (min-width: 700px) {
  .ff-dash-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .ff-dash-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .ff-dash-charts {
    grid-template-columns: 1.4fr 0.8fr 0.8fr;
  }

  .ff-dash-activity {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ff-launch-section {
  margin-top: 1.5rem;
}

.ff-launch-section__title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fifi-muted);
  margin: 0 0 0.55rem;
}

/* —— Accounting health —— */
.ff-health-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ff-health-score,
.ff-health-count {
  border: 1px solid var(--fifi-border);
  border-radius: 8px;
  background: hsl(var(--background));
  padding: 1rem;
}

.ff-health-score {
  border-left: 3px solid var(--fifi-ok);
}

.ff-health-status--warning.ff-health-score {
  border-left-color: var(--fifi-warn);
}

.ff-health-status--fail.ff-health-score {
  border-left-color: var(--fifi-danger);
}

.ff-health-score__label,
.ff-health-count span {
  display: block;
  color: var(--fifi-muted);
  font-size: 0.72rem;
}

.ff-health-score__value {
  display: block;
  margin-top: 0.15rem;
  color: var(--fifi-ink);
  font-size: 1.35rem;
}

.ff-health-count strong {
  display: block;
  color: var(--fifi-ink);
  font-family: var(--fifi-font-heading);
  font-size: 1.6rem;
  line-height: 1;
}

.ff-health-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.ff-health-card {
  min-width: 0;
  border: 1px solid var(--fifi-border);
  border-radius: 8px;
  background: hsl(var(--background));
  padding: 1rem;
}

.ff-health-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.ff-health-card__head h2 {
  margin: 0;
  color: var(--fifi-ink);
  font-size: 0.95rem;
}

.ff-health-card p {
  margin: 0 0 0.7rem;
  color: var(--fifi-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.ff-health-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
  background: rgba(15, 118, 110, 0.08);
  color: var(--fifi-ok);
  font-size: 0.66rem;
  font-weight: 700;
  white-space: nowrap;
}

.ff-health-status--warning.ff-health-status {
  background: rgba(180, 83, 9, 0.09);
  color: var(--fifi-warn);
}

.ff-health-status--fail.ff-health-status {
  background: rgba(180, 35, 24, 0.08);
  color: var(--fifi-danger);
}

.ff-health-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.ff-health-values div {
  min-width: 0;
}

.ff-health-values dt {
  color: var(--fifi-muted);
  font-size: 0.66rem;
  font-weight: 550;
}

.ff-health-values dd {
  margin: 0.15rem 0 0;
  color: var(--fifi-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ff-health-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}

.ff-health-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.42rem 0;
  border-top: 1px solid var(--fifi-border);
  color: var(--fifi-muted);
  font-size: 0.74rem;
}

.ff-health-list a,
.ff-health-link {
  color: var(--fifi-ink);
  font-size: 0.76rem;
  font-weight: 550;
  text-decoration: none;
}

.ff-health-list a:hover,
.ff-health-link:hover {
  text-decoration: underline;
}

.ff-health-footnote {
  margin: 1rem 0 0;
  color: var(--fifi-muted);
  font-size: 0.72rem;
}

@media (min-width: 700px) {
  .ff-health-overview {
    grid-template-columns: 2fr repeat(3, 1fr);
  }

  .ff-health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ff-launch {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--fifi-border);
  border-radius: var(--fifi-radius-sm);
  background: hsl(var(--background));
  overflow: hidden;
}

.ff-launch__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.65rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--fifi-border);
  border-radius: 0;
  background: transparent;
  color: var(--fifi-ink) !important;
  text-decoration: none !important;
  font-weight: 550;
  font-size: 0.9rem;
  box-shadow: none;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-launch__item:last-child {
  border-bottom: 0;
}

.ff-launch__item::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--fifi-muted);
  border-top: 1.5px solid var(--fifi-muted);
  transform: rotate(45deg);
  opacity: 0.55;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.ff-launch__item:active {
  transform: scale(0.99);
}

@media (hover: hover) and (pointer: fine) {
  .ff-launch__item:hover {
    background: var(--fifi-accent-soft);
    color: var(--fifi-ink) !important;
    box-shadow: none;
  }
}

@media (min-width: 900px) {
  .ff-dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 1.75rem;
  }

  .ff-dash-grid .ff-launch-section {
    margin-top: 0;
  }
}

/* —— Login Hero (Nexora composition, Fifi brand) —— */
.ff-login-body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: hsl(var(--background));
  font-family: var(--font-body);
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
}

.ff-login-viewport {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ff-login-video,
.ff-login-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.ff-login-fallback {
  background:
    radial-gradient(900px 520px at 20% 10%, hsl(var(--accent) / 0.18), transparent 60%),
    radial-gradient(800px 480px at 85% 80%, hsl(var(--foreground) / 0.08), transparent 55%),
    hsl(var(--secondary));
  z-index: 0;
}

.ff-login-video-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    hsl(var(--background) / 0.72) 0%,
    hsl(var(--background) / 0.55) 42%,
    hsl(var(--background) / 0.82) 100%
  );
  pointer-events: none;
}

.ff-login-hero {
  position: relative;
  z-index: 10;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: clamp(1rem, 4vw, 5rem);
}

.ff-login-card {
  width: min(100%, 22rem);
  border-radius: 1rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.9);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-dashboard);
  padding: 1.35rem 1.35rem 1.4rem;
  animation: ff-login-up 500ms var(--ease-out) both;
}

.ff-login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.ff-login-brand__glyph {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.ff-login-brand__name {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.ff-login-brand__tagline {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

.ff-login-card__title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.ff-login-card .form-control {
  border-radius: var(--radius);
}

.ff-login-card .btn-primary {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 1.2rem;
}

.ff-login-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.ff-login-alert {
  margin: 0 0 0.85rem;
}

@keyframes ff-login-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ff-login-card {
    animation: none;
  }

  .ff-login-video {
    display: none;
  }
}

@media (max-width: 899px) {
  .ff-login-body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .ff-login-viewport {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
}

/* —— Toasts —— */
.ff-toast-stack {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(22rem, calc(100vw - 1.5rem));
  pointer-events: none;
}

.ff-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  border-radius: 6px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--foreground) / 0.1);
  box-shadow: var(--fifi-shadow);
  color: var(--fifi-ink);
  font-size: 0.88rem;
  font-weight: 550;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 280ms var(--ease-out), opacity 280ms var(--ease-out);
}

.ff-toast[data-state="closed"] {
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
}

.ff-toast__body {
  flex: 1;
  min-width: 0;
}

.ff-toast__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fifi-muted);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--duration-press) var(--ease-out);
}

.ff-toast__close:active {
  transform: scale(0.97);
}

.ff-toast--success { border-color: rgba(15, 118, 110, 0.28); }
.ff-toast--danger { border-color: rgba(180, 35, 24, 0.28); }
.ff-toast--warning { border-color: rgba(180, 83, 9, 0.28); }

/* —— Mobile nav / sheet —— */
.ff-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  gap: 0.1rem;
  align-items: end;
  padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
  background: hsl(var(--background) / 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--fifi-border);
}

.ff-bottom-nav__item {
  text-align: center;
  text-decoration: none;
  color: var(--fifi-muted);
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.4rem 0.1rem;
  border-radius: var(--fifi-radius-sm);
  transition: transform var(--duration-press) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-bottom-nav__item:active {
  transform: scale(0.97);
}

.ff-bottom-nav__item.is-active {
  color: var(--fifi-ink);
  background: hsl(var(--foreground) / 0.08);
}

.ff-bottom-nav__plus {
  width: 2.85rem;
  height: 2.85rem;
  margin-bottom: 0.1rem;
  border: 0;
  border-radius: 10px;
  background: var(--fifi-ink);
  color: #fff;
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 500;
  box-shadow: var(--fifi-shadow);
  transition: transform var(--duration-press) var(--ease-out);
}

.ff-bottom-nav__plus:active {
  transform: scale(0.97);
}

.ff-action-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: hsl(var(--foreground) / 0.32);
  opacity: 0;
  transition: opacity var(--duration-drawer) var(--ease-out);
}

.ff-action-backdrop.is-open {
  opacity: 1;
}

.ff-action-sheet {
  position: fixed;
  left: 0.5rem;
  right: 0.5rem;
  bottom: calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 51;
  background: hsl(var(--background));
  border: 1px solid var(--fifi-border);
  border-radius: 12px;
  padding: 0.45rem 0.45rem 0.55rem;
  box-shadow: 0 12px 32px hsl(var(--foreground) / 0.12);
  opacity: 0;
  transform: translateY(100%) scale(0.96);
  transform-origin: bottom center;
  transition: transform var(--duration-drawer) var(--ease-drawer),
    opacity var(--duration-drawer) var(--ease-drawer);
  will-change: transform, opacity;
}

.ff-action-sheet.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.ff-action-sheet__handle {
  width: 2.1rem;
  height: 0.22rem;
  margin: 0.25rem auto 0.45rem;
  border-radius: 999px;
  background: hsl(var(--foreground) / 0.18);
}

.ff-action-sheet__item,
.ff-action-sheet__cancel {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.85rem 0.85rem;
  border-radius: var(--fifi-radius);
  color: var(--fifi-ink);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  transition: transform var(--duration-press) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.ff-action-sheet__item:active,
.ff-action-sheet__cancel:active {
  transform: scale(0.98);
  background: var(--fifi-accent-soft);
}

.ff-action-sheet__item.is-disabled {
  color: #9aa3ad;
  font-weight: 500;
}

.ff-action-sheet__cancel {
  margin-top: 0.2rem;
  text-align: center;
  color: var(--fifi-muted);
}

.ff-mobile-page .sticky-actions {
  position: sticky;
  bottom: 5.25rem;
  background: linear-gradient(180deg, hsl(var(--secondary) / 0), hsl(var(--secondary)) 40%);
  padding-top: 0.75rem;
  display: grid;
  gap: 0.5rem;
}

.ff-mobile-page .sticky-actions .btn,
.ff-mobile-stack .btn {
  width: 100%;
}

.ff-mobile-stack {
  display: grid;
  gap: 0.55rem;
}

.ff-mobile-list a.list-group-item {
  padding: 0.9rem 1rem;
  font-weight: 600;
  color: var(--fifi-ink);
  border-color: hsl(var(--foreground) / 0.06);
  transition: background-color var(--duration-fast) var(--ease-out),
    transform var(--duration-press) var(--ease-out);
}

.ff-mobile-list a.list-group-item:active {
  transform: scale(0.99);
  background: var(--fifi-accent-soft);
}

/* —— Responsive —— */
@media (max-width: 767.98px) {
  .ff-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform var(--duration-drawer) var(--ease-drawer);
    box-shadow: none;
    will-change: transform;
  }

  body.ff-drawer-open .ff-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px hsl(var(--foreground) / 0.12);
  }

  body.ff-drawer-open .ff-sidebar-backdrop {
    display: block;
  }

  body.ff-nav-collapsed .ff-sidebar {
    display: flex;
  }

  .ff-topbar .ff-role-chip {
    display: none;
  }

  .ff-main-content > .d-flex.justify-content-between.align-items-center.mb-3 > a.btn,
  .ff-main-content > .d-flex.justify-content-between.mb-3 > a.btn,
  .ff-main-content > .d-flex.justify-content-between.align-items-center.mb-3 > .btn,
  .ff-main-content > .d-flex.justify-content-between.mb-3 > .btn {
    width: 100%;
  }

  .ff-main-content > form.row.g-2 .btn {
    width: 100%;
  }

  .ff-toast-stack {
    top: auto;
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
    right: 0.65rem;
    left: 0.65rem;
    width: auto;
  }

  .ff-toast[data-state="closed"] {
    transform: translateY(8px) scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .btn:active,
  .ff-icon-btn:active,
  .ff-launch__item:active,
  .ff-bottom-nav__plus:active,
  .ff-action-sheet,
  .ff-sidebar {
    transform: none !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .ff-topbar,
  .ff-bottom-nav {
    background: var(--fifi-ivory);
  }
}
