@import "tailwindcss";

:root {
  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --font-feature: "cv11", "ss01", "ss03", "ss04", "tnum";

  font-family: var(--font-sans);
  font-feature-settings: var(--font-feature);
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* ---------- Brand (royal blue accent) ---------- */
  /* Accent: #3071C0. A confident royal blue that reads corporate without
     being corporate-stale. Derived hue: blue → 210°. The supporting ladder
     below calibrates hover, dark, soft, tint, and line for layering. */
  --primary: #3071C0;
  --primary-hover: #2A66AE;
  --primary-dark: #205192;
  --primary-darker: #143762;
  --primary-soft: #E6EFF8;
  --primary-softer: #F1F6FB;
  --primary-ink: #3071C0;
  --primary-tint: #6E97D0;
  --primary-line: #BCD1E8;

  /* ---------- Surfaces ---------- */
  --bg: #f7f6f2;
  --bg-tinted: #efede7;
  --surface: #ffffff;
  --surface-soft: #faf9f5;
  --surface-muted: #f3f2ec;
  --surface-inverse: #0f1f33;

  /* ---------- Text ---------- */
  --text: #0f172a;
  --text-strong: #020617;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-faint: #94a3b8;

  /* ---------- Lines ----------
     Hairlines: very low contrast for premium feel (cf. Stripe, Mercury, Linear).
     No box-shadows are used in this system — cards, modals, and surfaces
     rely entirely on borders for visual hierarchy. */
  --border: rgba(15, 23, 42, 0.07);
  --border-strong: rgba(15, 23, 42, 0.12);
  --border-emphasis: rgba(15, 23, 42, 0.18);

  /* ---------- States ---------- */
  --success: #15803d;
  --success-soft: #e8f6ec;
  --success-line: rgba(21, 128, 61, 0.18);
  --warning: #b45309;
  --warning-soft: #fbf4e3;
  --warning-line: rgba(180, 83, 9, 0.18);
  --danger: #b91c1c;
  --danger-soft: #fbeeed;
  --danger-line: rgba(185, 28, 28, 0.18);
  --info: #1d4ed8;
  --info-soft: #ebf1fb;
  --info-line: rgba(29, 78, 216, 0.18);
  --neutral: #475569;
  --neutral-soft: #eef0f3;
  --neutral-line: rgba(71, 85, 105, 0.18);

  /* ---------- Elevation ----------
     No box-shadows are used. Cards and surfaces rely on hairline borders
     (`--border`, `--border-strong`, `--border-emphasis`) for separation. */

  /* ---------- Radius ---------- */
  --radius-xs: 5px;
  --radius-sm: 5px;
  --radius-md: 5px;
  --radius-lg: 5px;
  --radius-xl: 5px;
  --radius-2xl: 5px;
  --radius-3xl: 5px;
  --radius-pill: 999px;

  /* ---------- Spacing ---------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* ---------- Layout ---------- */
  --sidebar-width: 240px;
  --header-height: 64px;
  --content-max: 1240px;

  /* ---------- Motion ---------- */
  --motion-fast: 140ms;
  --motion: 220ms;
  --motion-slow: 320ms;
  --easing-out: cubic-bezier(0.16, 1, 0.3, 1);
  --easing-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 5px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-feature-settings: var(--font-feature);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }

a { color: var(--primary-ink); text-decoration: none; transition: color var(--motion-fast) var(--easing-out); }
a:hover { color: var(--primary-dark); }

::selection { background: rgba(31, 79, 140, 0.18); color: var(--text-strong); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.28); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.app-shell { min-height: 100vh; }
.app-shell--mobile .app-main { margin-left: 0; }

/* ---------- Sidebar shell ---------- */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  animation: fade-in var(--motion) var(--easing-out);
}

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  display: flex; width: var(--sidebar-width); flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

/* ---------- App Main / Header ---------- */
.app-main { min-height: 100vh; margin-left: 0; transition: margin-left var(--motion) var(--easing-out); }
@media (min-width: 761px) {
  .app-main { margin-left: var(--sidebar-width); }
}

.header {
  position: sticky; top: 0; z-index: 30;
  display: flex; height: var(--header-height); align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(170%) blur(14px);
  -webkit-backdrop-filter: saturate(170%) blur(14px);
}
.header__context, .header__actions { display: flex; align-items: center; gap: 12px; }
.header__menu { display: none !important; }

.breadcrumb { display: flex; align-items: center; gap: 4px; color: var(--text-faint); font-size: 13px; }
.breadcrumb__link {
  padding: 4px 8px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-faint); font-size: 13px; font-weight: 500;
  transition: color var(--motion-fast) var(--easing-out), background var(--motion-fast) var(--easing-out);
}
.breadcrumb__link:hover { color: var(--text); background: var(--surface-muted); }
.breadcrumb__current { color: var(--text); font-weight: 600; letter-spacing: -.01em; }
.breadcrumb__separator { color: var(--border-strong); display: inline-flex; }

.global-search {
  display: flex; width: min(420px, 32vw); height: 42px; align-items: center; gap: 9px;
  padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-soft); color: var(--text-faint);
  transition: border var(--motion-fast) var(--easing-out), background var(--motion-fast) var(--easing-out);
}
.global-search:focus-within {
  background: var(--surface); border-color: var(--primary);
}
.global-search input, .table-search input {
  min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px;
}
.global-search input::placeholder { color: var(--text-faint); }
.global-search kbd {
  padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); color: var(--text-subtle);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em;
}

.role-switcher {
  position: relative; display: flex; height: 36px; align-items: center; gap: 5px;
  padding: 0 30px 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-subtle); font-size: 12px;
  transition: border var(--motion-fast) var(--easing-out);
}
.role-switcher:focus-within { border-color: var(--primary); }
.role-switcher select {
  max-width: 132px; appearance: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 12px; font-weight: 500;
}
.role-switcher > svg { position: absolute; right: 9px; pointer-events: none; }

.icon-button {
  display: grid; width: 36px; height: 36px; place-items: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted);
  transition: background var(--motion-fast) var(--easing-out), border var(--motion-fast) var(--easing-out), color var(--motion-fast) var(--easing-out);
}
.icon-button:hover { background: var(--surface-soft); color: var(--text); border-color: var(--border-emphasis); }
.icon-button:active { background: var(--surface-muted); }

.notification-button { position: relative; }
.notification-button span {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px;
  border: 1.5px solid var(--surface); border-radius: 50%; background: var(--danger);
}

.profile-button {
  display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted);
  transition: background var(--motion-fast) var(--easing-out), border var(--motion-fast) var(--easing-out);
}
.profile-button:hover { background: var(--surface-soft); border-color: var(--border-emphasis); }
.profile-button__avatar {
  display: grid; width: 30px; height: 30px; place-items: center;
  border-radius: var(--radius-xs); background: var(--primary-soft); color: var(--primary-ink);
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.profile-button__copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.profile-button__copy strong { color: var(--text); font-size: 12.5px; font-weight: 600; letter-spacing: -.005em; }
.profile-button__copy small { color: var(--text-faint); font-size: 10.5px; }

/* ---------- Content ---------- */
.content { width: 100%; }

.page-heading {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 28px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: 10px; color: var(--text-muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.eyebrow__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success);
  outline: 3px solid var(--success-soft);
  outline-offset: -1px;
}
h1 {
  margin: 0; color: var(--text-strong);
  font-size: 28px; line-height: 1.15; letter-spacing: -.028em; font-weight: 600;
}
h2 { margin: 0; color: var(--text); font-size: 16px; font-weight: 600; letter-spacing: -.012em; }
.page-heading p { margin: 6px 0 0; color: var(--text-subtle); font-size: 14px; max-width: 720px; line-height: 1.5; }
.page-heading__actions { display: flex; gap: 10px; }

/* ---------- Buttons ----------
   Canonical button system. Every button in the system uses `.button` plus a
   tone modifier. Size is controlled by `.button--sm` / `--lg`. Color is the
   only differentiator; shape, dimensions, and icon treatment stay uniform. */
.button {
  display: inline-flex; height: 40px; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; border: 1px solid var(--border-emphasis); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-strong);
  font-size: 13px; font-weight: 500; letter-spacing: -.005em;
  white-space: nowrap;
  transition:
    background var(--motion-fast) var(--easing-out),
    border var(--motion-fast) var(--easing-out),
    color var(--motion-fast) var(--easing-out);
}
.button:active { transform: translateY(1px); }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Tone: secondary is the canonical "Light" default — same shape, same
   dimensions, same icon treatment; only the colour changes downstream. */
.button--secondary { /* default (no-op — explicit for clarity) */ }

/* Tone: primary — filled brand */
.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.06) 100%);
  color: #fff;
}
.button--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Tone: ghost — no border, transparent until hover */
.button--ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.button--ghost:hover { background: var(--surface-muted); color: var(--text); border-color: transparent; }

/* Tone: subtle — soft surface, no border */
.button--subtle { border-color: transparent; background: var(--surface-muted); color: var(--text); }
.button--subtle:hover { background: var(--bg-tinted); color: var(--text-strong); border-color: transparent; }

/* Tone: success — filled green */
.button--success {
  border-color: var(--success);
  background: var(--success);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.06) 100%);
  color: #fff;
}
.button--success:hover {
  background: #126835;
  border-color: #126835;
}

/* Tone: warning — light fill, warning-foreground label */
.button--warning {
  border-color: var(--warning-line);
  background: var(--warning-soft);
  color: var(--warning);
}
.button--warning:hover {
  background: var(--warning-soft);
  border-color: var(--warning);
  filter: saturate(1.1) brightness(0.97);
}

/* Tone: danger — filled red, distinguishable from Light/Secondary at rest. */
.button--danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}
.button--danger:hover {
  border-color: var(--danger);
  background: #7f1d1d;
  color: #fff;
}

/* Modifier: icon-only — square aspect, hide label visually */
.button--icon { padding: 0; width: 40px; }
.button--icon .button__label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Standard sizes — only the height, radius, and typography scale. */
.button--sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: var(--radius-xs); }
.button--sm.button--icon { width: 32px; }
.button--lg { height: 48px; padding: 0 20px; font-size: 13.5px; border-radius: var(--radius-md); }
.button--lg.button--icon { width: 48px; }
.button--block { width: 100%; }

.button .button__spinner { animation: spin 0.7s linear infinite; }
.button .button__icon { flex: 0 0 auto; display: inline-flex; }

/* ---------- Button aliases ----------
   The system historically used several per-context class names
   (.head-action, .market-action, .action, .quick-action, .form-page__action,
   .auth-shell__cta). Each is now rewritten as a thin alias for the canonical
   `.button` system, so existing templates inherit the canonical sizing and
   colour variants without code rewrites. */
.head-action,
.market-action,
.action,
.quick-action,
.form-page__action,
.auth-shell__cta {
  display: inline-flex;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--border-emphasis);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.005em;
  white-space: nowrap;
  transition:
    background var(--motion-fast) var(--easing-out),
    border var(--motion-fast) var(--easing-out),
    color var(--motion-fast) var(--easing-out);
}
.head-action:active,
.market-action:active,
.action:active,
.quick-action:active,
.form-page__action:active,
.auth-shell__cta:active { transform: translateY(1px); }

/* Tone aliases — same mapping as .button--{tone}. */
.head-action--primary,
.market-action--primary,
.action--primary,
.form-page__action--primary,
.auth-shell__cta--primary {
  border-color: var(--primary);
  background: var(--primary);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.06) 100%);
  color: #fff;
}
.head-action--primary:hover,
.market-action--primary:hover,
.action--primary:hover,
.form-page__action--primary:hover,
.auth-shell__cta--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.head-action--secondary,
.market-action--secondary,
.action--secondary { /* default Light — same as .button */ }

.head-action--danger,
.market-action--danger,
.action--danger {
  border-color: var(--border-emphasis);
  background: var(--surface);
  color: var(--text-strong);
}
.head-action--danger:hover,
.market-action--danger:hover,
.action--danger:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.head-action--ghost,
.market-action--ghost,
.action--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}
.head-action--ghost:hover,
.market-action--ghost:hover,
.action--ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: transparent;
}

.action--warning {
  border-color: var(--warning-line);
  background: var(--warning-soft);
  color: var(--warning);
}
.action--warning:hover {
  background: var(--warning-soft);
  border-color: var(--warning);
  filter: saturate(1.1) brightness(0.97);
}
.action--success {
  border-color: var(--primary);
  background: var(--primary);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.06) 100%);
  color: #fff;
}
.action--success:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Auth CTA — primary CTA in auth flows */
.auth-shell__cta--primary:disabled { opacity: .55; cursor: not-allowed; }

/* Form-page footer actions keep the form's comfortable padding rhythm. */
.form-page__action { min-width: 160px; }

/* Quaternary "subtle" tone */
.quick-action--subtle,
.head-action--subtle,
.market-action--subtle,
.action--subtle {
  border-color: transparent;
  background: var(--surface-muted);
  color: var(--text);
}
.quick-action--subtle:hover,
.head-action--subtle:hover,
.market-action--subtle:hover,
.action--subtle:hover {
  background: var(--bg-tinted);
  color: var(--text-strong);
  border-color: transparent;
}

/* ---------- Cards / Surfaces ---------- */
.card, .panel-card, .kpi-card, .data-card, .overview-card, .attention-card, .data-table,
.detail-card, .deposit-summary > article, .audit-summary > article,
.financial-card, .filters, .audit-layout .detail-panel, .tabs,
.section-header + * {
  border-color: var(--border);
}

.placeholder-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 64px 20px; border: 1px dashed var(--border-emphasis); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text-subtle);
  text-align: center;
}
.placeholder-card strong { color: var(--text); font-size: 14px; font-weight: 600; }
.placeholder-card span { color: var(--text-faint); font-size: 12.5px; max-width: 480px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card {
  position: relative;
  padding: 20px 20px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
  transition: transform var(--motion-fast) var(--easing-out), border-color var(--motion-fast) var(--easing-out);
  overflow: hidden;
}
/* Subtle top accent stripe (via pseudo; non-color users still see a quiet card). */
.kpi-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary-tint) 0%, var(--primary-line) 60%, transparent 100%);
  opacity: .55; transition: opacity var(--motion) var(--easing-out);
}
.kpi-card:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.kpi-card:hover::before { opacity: 1; }
.kpi-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-card__label {
  color: var(--text-muted); font-size: 11.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
}
.kpi-card__icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: var(--radius-sm); background: var(--surface-muted); color: var(--text-muted); }
.kpi-card__icon--primary { background: var(--primary-soft); color: var(--primary-ink); }
.kpi-card__icon--success { background: var(--success-soft); color: var(--success); }
.kpi-card__icon--warning { background: var(--warning-soft); color: var(--warning); }
.kpi-card__icon--danger { background: var(--danger-soft); color: var(--danger); }
.kpi-card__value {
  display: block; margin-top: 14px; color: var(--text-strong);
  font-size: 26px; font-weight: 600; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.kpi-card__footer { display: flex; gap: 6px; margin-top: 8px; color: var(--text-faint); font-size: 11px; }
.kpi-card__trend { color: var(--success); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.kpi-card__trend--down { color: var(--danger); }

/* ---------- Status badge ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  width: max-content;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent;
  line-height: 1;
}
.status-badge--success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.status-badge--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.status-badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.status-badge--info    { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.status-badge--neutral { background: var(--neutral-soft); color: var(--neutral); border-color: var(--neutral-line); }

/* ---------- States (loading / empty / error) ---------- */
.skeleton {
  display: block; position: relative; overflow: hidden;
  background: linear-gradient(90deg, var(--surface-muted) 0%, var(--bg-tinted) 50%, var(--surface-muted) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-xs);
}
.skeleton--text { height: 12px; border-radius: 5px; }
.skeleton--avatar { width: 32px; height: 32px; border-radius: var(--radius-sm); }
.skeleton--block { height: 96px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 56px 20px; border: 1px dashed var(--border-emphasis); border-radius: var(--radius-lg);
  background: var(--surface); text-align: center;
}
.empty-state__icon {
  display: grid; width: 44px; height: 44px; place-items: center;
  border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary-ink);
}
.empty-state strong { color: var(--text); font-size: 14px; font-weight: 600; }
.empty-state span { color: var(--text-subtle); font-size: 12.5px; max-width: 460px; }
.empty-state__actions { margin-top: 6px; display: flex; gap: 8px; }

.error-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 32px 20px; border: 1px solid var(--danger-line); border-radius: var(--radius-lg);
  background: var(--danger-soft); color: #7f1d1d; text-align: center;
}
.error-state__icon {
  display: grid; width: 38px; height: 38px; place-items: center;
  border-radius: 50%; background: var(--danger-soft); color: var(--danger);
}
.error-state strong { font-size: 14px; font-weight: 600; }
.error-state span { color: #991b1b; font-size: 12.5px; max-width: 480px; }
.error-state__actions { display: flex; gap: 8px; margin-top: 6px; }

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-up { animation: fade-up var(--motion) var(--easing-out); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Tables (legacy global selectors) ---------- */
.insight-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(300px, .8fr); gap: 18px; margin-bottom: 18px; }
.overview-card, .attention-card, .data-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.overview-card, .attention-card { padding: 20px; }
.card-heading, .data-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.card-heading h2, .data-card__header h2 { margin: 0; color: var(--text-strong); font-size: 15px; font-weight: 600; }
.card-heading select { height: 32px; padding: 0 28px 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface); color: var(--text-muted); font-size: 11px; }
.chart-summary { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 24px; }
.chart-summary > div { display: flex; flex-direction: column; gap: 3px; }
.chart-summary span { color: var(--text-faint); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.chart-summary strong { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.chart {
  display: flex; height: 150px; align-items: flex-end; gap: 7px;
  margin-top: 14px; padding: 12px 8px 0;
  border-bottom: 1px solid var(--border);
  background: repeating-linear-gradient(to bottom, rgba(15,23,42,.03) 0, rgba(15,23,42,.03) 1px, transparent 1px, transparent 37px);
}
.chart__bar { flex: 1; max-width: 42px;   border-radius: 5px 5px 0 0; background: var(--primary-tint); opacity: .82; transition: opacity var(--motion-fast) var(--easing-out); }
.chart__bar:hover { opacity: 1; }
.chart-labels { display: flex; justify-content: space-between; padding: 8px 4px 0; color: var(--text-faint); font-size: 10px; }
.attention-count { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 11px; font-weight: 600; }
.attention-list { margin: 16px -8px 0; }
.attention-list button {
  display: grid; width: 100%; grid-template-columns: 34px 1fr 18px; align-items: center; gap: 10px;
  padding: 12px 8px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text-faint); text-align: left;
  transition: background var(--motion-fast) var(--easing-out);
}
.attention-list button:hover { background: var(--surface-soft); }
.attention-list button:last-child { border-bottom: 0; }
.attention-list button > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.attention-list strong { color: var(--text); font-size: 12px; font-weight: 600; }
.attention-list small { color: var(--text-faint); font-size: 10px; }
.attention-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; }
.attention-icon--warning { background: var(--warning-soft); color: var(--warning); }
.attention-icon--danger { background: var(--danger-soft); color: var(--danger); }
.attention-icon--neutral { background: var(--neutral-soft); color: var(--neutral); }
.attention-card__link {
  display: flex; align-items: center; gap: 6px; margin: 15px 0 0; border: 0;
  background: transparent; color: var(--primary-ink); font-size: 12px; font-weight: 500;
  transition: gap var(--motion-fast) var(--easing-out), color var(--motion-fast) var(--easing-out);
}
.attention-card__link:hover { gap: 9px; }

.data-card__header { padding: 19px 20px 15px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.table-search {
  display: flex; width: min(360px, 50%); height: 36px; align-items: center; gap: 8px;
  padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); color: var(--text-faint);
  transition: border var(--motion-fast) var(--easing-out);
}
.table-search:focus-within { border-color: var(--primary); }
.filter-count { display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-size: 9px; font-weight: 600; }
.table-scroll { overflow-x: auto; }

.reference { color: var(--primary-ink); font-size: 11px; font-weight: 500; font-family: var(--font-mono); }
.amount { color: var(--text-strong); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- Tables: global normal-weight policy ----------
   Every value rendered inside a table cell (numeric or textual) must use the
   normal text weight, regardless of inline markup (<b>, <strong>) or
   per-component styling. */
table { font-weight: 400; }
table th, table td, table tbody, table thead, table tr { font-weight: 400; }
table th strong, table th b,
table td strong, table td b,
table tbody strong, table tbody b,
table thead strong, table thead b,
table tr strong, table tr b { font-weight: 400; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(3px);
  animation: fade-in var(--motion) var(--easing-out);
}
.modal {
  width: min(480px, 100%);
  border: 1px solid var(--border-emphasis);
  border-radius: var(--radius-xl);
  background: var(--surface);
  overflow: hidden;
}
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 14px; border-bottom: 1px solid var(--border); }
.modal__heading { display: flex; gap: 12px; }
.modal__icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: var(--radius-md); background: var(--warning-soft); color: var(--warning); }
.modal h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.012em; }
.modal p { margin: 5px 0 0; color: var(--text-subtle); font-size: 12.5px; line-height: 1.5; }
.modal__body { padding: 12px 24px; }
.confirmation-summary {
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
  padding: 15px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: 12px;
}
.confirmation-summary span { color: var(--text-subtle); }
.confirmation-summary strong { color: var(--text-strong); font-weight: 600; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 12px 24px;
  background: var(--surface);
}
.modal-enter-active, .modal-leave-active { transition: opacity var(--motion) var(--easing-out); }
.modal-enter-active .modal, .modal-leave-active .modal { transition: transform var(--motion) var(--easing-out); }
.modal-enter-from, .modal-leave-to { opacity: 0; }
.modal-enter-from .modal, .modal-leave-to .modal { transform: translateY(8px) scale(.98); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .global-search { width: min(400px, 60vw); }
  .role-switcher span { display: none; }
  .profile-button__copy { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .insight-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); width: 280px; transition: transform var(--motion) var(--easing-out); }
  .sidebar--open { transform: translateX(0); }
  .app-main { margin-left: 0 !important; }
  .header { height: var(--header-height); padding: 0 16px; }
  .header__menu { display: grid !important; }
  .global-search { display: none; }
  .content { padding: 0; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading__actions { width: 100%; }
  .page-heading__actions .button { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .role-switcher { display: none; }
}

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