/* =====================================================================
   InfinityMoney360 v3 theme: modern shell, side menu, top bar, motion.
   Loaded after styles.css.
   ===================================================================== */
:root {
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 4px 12px rgba(16,24,40,.06), 0 12px 32px rgba(16,24,40,.06);
  --radius: 16px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --side: 264px;
  --side-mini: 84px;
}
body {
  background: #F2F4F9;
  background-image: radial-gradient(1200px 500px at 100% -10%, rgba(226,194,115,.12), transparent 60%),
                    radial-gradient(900px 500px at -10% 0%, rgba(28,79,156,.08), transparent 60%);
  background-attachment: fixed;
}

/* ---------- Layout: fixed side menu + content ---------- */
.layout { flex-wrap: nowrap; align-items: stretch; }
.sidebar {
  position: sticky; top: 0; height: 100vh; flex: 0 0 var(--side); width: var(--side); max-width: none;
  padding: 18px 14px; gap: 2px; overflow-y: auto; overflow-x: hidden; z-index: 60; scrollbar-width: thin;
  background: linear-gradient(180deg, #0F2D5C 0%, #0B2148 60%, #091B3B 100%);
  transition: width .3s var(--ease), flex-basis .3s var(--ease);
}
.sidebar .brand { padding: 4px 6px 18px; margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand-mark { width: 42px; height: 42px; border-radius: 12px; box-shadow: 0 0 0 3px rgba(226,194,115,.25); }
.brand-text { min-width: 0; transition: opacity .2s; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(201,211,230,.55); padding: 16px 12px 6px; white-space: nowrap; }
.nav-link { position: relative; min-height: 46px; border-radius: 12px; padding: 0 12px; color: #C9D3E6; white-space: nowrap; transition: background .2s, color .2s; }
.nav-link svg { flex: none; transition: transform .25s var(--ease); }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link:hover svg { transform: scale(1.12); }
.nav-link.active { background: linear-gradient(90deg, rgba(226,194,115,.22), rgba(226,194,115,.06)); color: #fff; box-shadow: none; }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold-light); animation: slideIn .4s var(--ease); }
.nav-link.active svg { color: var(--gold-light); }
.nav-label { flex: 1; transition: opacity .2s; }
.nav-badge { animation: pop .5s var(--ease) .3s both; }
.nav-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 6px; }
.sync-pill { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.05); color: #C9D3E6; font-size: 12.5px; white-space: nowrap; }
.collapse-btn { background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; width: 100%; text-align: left; }
.collapse-btn svg { transition: transform .3s var(--ease); }
.sidebar-user { display: none; }

/* Collapsed icon rail */
.layout.collapsed .sidebar { flex-basis: var(--side-mini); width: var(--side-mini); }
.layout.collapsed .brand-text, .layout.collapsed .nav-label, .layout.collapsed .nav-section { opacity: 0; width: 0; overflow: hidden; padding: 0; }
.layout.collapsed .nav-section { height: 12px; }
.layout.collapsed .nav-link { justify-content: center; padding: 0; }
.layout.collapsed .nav-badge { position: absolute; top: 4px; right: 6px; min-width: 18px; height: 18px; font-size: 10.5px; }
.layout.collapsed .collapse-btn svg { transform: rotate(180deg); }
.layout.collapsed .sync-pill { justify-content: center; padding: 10px 0; }
.layout.collapsed .sidebar .brand { justify-content: center; }

/* ---------- Top bar ---------- */
.content { padding-top: 0; }
.appbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px;
  margin: 0 calc(-1 * clamp(16px, 3vw, 32px)); padding: 12px clamp(16px, 3vw, 32px);
  background: rgba(242,244,249,.8); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(227,232,240,.8);
}
.icon-btn { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; transition: transform .2s var(--ease), box-shadow .2s; }
.icon-btn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.menu-btn { display: none; }
.bell-dot { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--loss); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; animation: pop .5s var(--ease) .4s both; }
#bell svg { animation: ring 1.2s ease 1.2s 1; transform-origin: 50% 10%; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.profile-btn { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; cursor: pointer; transition: box-shadow .2s; }
.profile-btn:hover { box-shadow: var(--shadow-md); }
.profile-btn .avatar { width: 36px; height: 36px; background: linear-gradient(135deg, var(--navy), #2A5AA8); }
.profile-name { display: flex; flex-direction: column; text-align: left; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.profile-name small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.pop-wrap { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 10px); width: min(380px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); padding: 8px; z-index: 70; animation: dropIn .22s var(--ease); }
.popover[hidden] { display: none; }
.popover-sm { width: 200px; }
.pop-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; }
.pop-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.pop-item:hover { background: var(--line-soft); color: var(--ink); }

/* ---------- Client switcher ---------- */
.switcher { position: relative; flex: 1 1 420px; max-width: 560px; min-width: 0; }
.switcher input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: #fff; padding: 0 70px 0 44px; font: inherit; font-size: 14.5px; color: var(--ink); box-shadow: var(--shadow-sm); transition: box-shadow .2s, border-color .2s; }
.switcher input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(28,79,156,.12), var(--shadow-md); }
.switcher-icon { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; }
.switcher kbd { position: absolute; right: 12px; top: 12px; font-family: var(--mono); font-size: 11px; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); }
.switch-list { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); padding: 6px; max-height: 420px; overflow-y: auto; z-index: 70; animation: dropIn .2s var(--ease); }
.switch-list[hidden] { display: none; }
.switch-head { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.switch-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; }
.switch-item.on, .switch-item:hover { background: var(--blue-soft); }
.switch-item .avatar.sm { width: 34px; height: 34px; font-size: 12px; background: linear-gradient(135deg, var(--gold), #8C6A22); }
.sw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sw-main b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-main small { font-size: 12px; color: var(--muted); }
.sw-val { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.switch-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- Surfaces ---------- */
.card { border: 1px solid rgba(227,232,240,.9); box-shadow: var(--shadow-sm); transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
.card:hover { box-shadow: var(--shadow-md); }
.kpi { position: relative; overflow: hidden; }
.kpi:hover { transform: translateY(-3px); }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(226,194,115,.18), transparent 70%); pointer-events: none; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi-icon.i-blue { background: #E7EEF8; color: #1C4F9C; }
.kpi-icon.i-gold { background: #FBF3E1; color: #8C6A22; }
.kpi-icon.i-green { background: #E6F4EA; color: #1F7A35; }
.kpi-icon.i-red { background: #FDECEA; color: #B42318; }
.kpi .v { font-size: 30px; letter-spacing: -.01em; }
.page-header { padding-top: 8px; }
.page-header h1 { font-size: 28px; letter-spacing: -.01em; }
.sync-bar, .summary, .filters { box-shadow: var(--shadow-sm); border-color: rgba(227,232,240,.9); }
.btn { border-radius: 10px; transition: transform .15s var(--ease), box-shadow .2s, background .2s; }
.btn:hover:not([disabled]) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active:not([disabled]) { transform: translateY(0) scale(.98); }
.btn-primary { background: linear-gradient(135deg, #1C4F9C, #143B78); border-color: transparent; }
.chip { transition: background .2s, color .2s, transform .15s; }
.chip:active { transform: scale(.96); }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #F7F9FD; }
.hero { background: linear-gradient(135deg, #0F2D5C 0%, #1A4A8C 50%, #0F2D5C 100%); background-size: 200% 200%; animation: sheen 12s ease infinite; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(226,194,115,.28), transparent 70%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.dot.pulse { background: #4ADE80; animation: pulse 2s infinite; }
.attention a { transition: transform .2s var(--ease), box-shadow .2s; }
.attention a:hover { transform: translateX(4px); box-shadow: var(--shadow-sm); }
.topbar { background: rgba(255,255,255,.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 40; }

/* ---------- Phone / tablet: side menu becomes a drawer ---------- */
.nav-overlay { display: none; }
@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-105%); transition: transform .3s var(--ease); box-shadow: 12px 0 32px rgba(14,34,68,.25); }
  .layout.collapsed .sidebar { flex-basis: var(--side); width: var(--side); }
  .layout.collapsed .brand-text, .layout.collapsed .nav-label, .layout.collapsed .nav-section { opacity: 1; width: auto; overflow: visible; }
  .layout.collapsed .nav-section { height: auto; padding: 16px 12px 6px; }
  .layout.collapsed .nav-link { justify-content: flex-start; padding: 0 12px; }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(14,34,68,.45); z-index: 55; animation: fade .25s; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .profile-name, .switcher kbd { display: none; }
  .profile-btn { padding: 0 4px; }
}
@media (max-width: 560px) {
  .switcher input { padding-right: 14px; font-size: 14px; }
  .appbar { gap: 8px; }
  .kpi .v { font-size: 26px; }
  .page-header h1 { font-size: 24px; }
}

/* ---------- Motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes slideIn { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes spinIn { from { transform: rotate(-120deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-4deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.55); } 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
@keyframes sheen { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes modalIn { from { transform: translateY(12px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-30px, 24px); } }

/* Page entrance, staggered */
.content > *:not(.appbar), .container > *, .login-card, .login-hero > * { animation: fadeUp .55s var(--ease) both; }
.content > *:nth-child(3) { animation-delay: .05s; }
.content > *:nth-child(4) { animation-delay: .1s; }
.content > *:nth-child(5) { animation-delay: .15s; }
.content > *:nth-child(6) { animation-delay: .2s; }
.content > *:nth-child(n+7) { animation-delay: .25s; }
.container > *:nth-child(2) { animation-delay: .05s; }
.container > *:nth-child(3) { animation-delay: .1s; }
.container > *:nth-child(4) { animation-delay: .15s; }
.container > *:nth-child(n+5) { animation-delay: .2s; }
.login-hero > *:nth-child(2) { animation-delay: .1s; }
.login-hero > *:nth-child(3) { animation-delay: .2s; }
.login-card { animation-delay: .15s; }
.kpis > *, .grid > *, .sources > *, .summary > * { animation: fadeUp .5s var(--ease) both; }
.kpis > *:nth-child(2), .grid > *:nth-child(2), .summary > *:nth-child(2) { animation-delay: .07s; }
.kpis > *:nth-child(3), .grid > *:nth-child(3), .summary > *:nth-child(3) { animation-delay: .14s; }
.kpis > *:nth-child(4), .summary > *:nth-child(4) { animation-delay: .21s; }
.kpis > *:nth-child(5), .summary > *:nth-child(n+5) { animation-delay: .28s; }

/* Charts draw themselves in */
.flows .in, .flows .out, .bars div, .proj-bars .b { transform-origin: bottom; animation: growY .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms + .2s); }
.hbar .track div, .progress div, .stack-bar > div { transform-origin: left; animation: growX 1s var(--ease) .25s both; }
.donut { animation: spinIn .9s var(--ease) .15s both; }

/* Freshly rendered lists */
.anim-in tbody tr, .anim-in .list-row, .anim-in .holding-card { animation: fadeUp .4s var(--ease) both; }
.anim-in tbody tr:nth-child(2) { animation-delay: .02s; }
.anim-in tbody tr:nth-child(3) { animation-delay: .04s; }
.anim-in tbody tr:nth-child(4) { animation-delay: .06s; }
.anim-in tbody tr:nth-child(5) { animation-delay: .08s; }
.anim-in tbody tr:nth-child(6) { animation-delay: .1s; }
.anim-in tbody tr:nth-child(n+7) { animation-delay: .12s; }

/* Panels and dialogs */
.drawer { animation: drawerIn .35s var(--ease); }
.drawer-backdrop:not([hidden]), .modal-backdrop:not([hidden]) { animation: fade .25s; }
.modal { animation: modalIn .3s var(--ease); }

/* Login */
.login-hero { position: relative; overflow: hidden; }
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; animation: float 14s ease-in-out infinite; }
.login-hero::before { width: 380px; height: 380px; right: -120px; top: -100px; background: radial-gradient(circle, rgba(226,194,115,.28), transparent 70%); }
.login-hero::after { width: 300px; height: 300px; left: -100px; bottom: -80px; background: radial-gradient(circle, rgba(95,168,106,.25), transparent 70%); animation-delay: -6s; }
.login-hero > * { position: relative; z-index: 1; }
.login-card { box-shadow: var(--shadow-md); border-radius: 20px; }
.login-logo { animation: pop .7s var(--ease) .3s both; }
.segmented button { transition: background .25s var(--ease), color .2s, box-shadow .25s; }

@media print { .appbar, .nav-overlay { display: none !important; } * { animation: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ---------- Typography: InfinityMoney360 Display (headings), InfinityMoney360 (text), InfinityMoney360 Mono (codes); see fonts.css ---------- */
body { font-feature-settings: "ss01" 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; letter-spacing: .005em; }
h1, h2, h3, .page-header h1, .login-hero h1, .login-card h2, .drawer-head h2, .modal h2, .card h2, .report-section h3 { font-family: var(--display); font-optical-sizing: auto; letter-spacing: -.015em; }
.page-header h1 { font-weight: 700; font-size: 30px; }
.card h2 { font-weight: 600; }
.login-hero h1 { font-weight: 700; letter-spacing: -.025em; }
.kpi .v, .hero .big, .hero-stats .v, .summary .v, .donut-hole div:first-child, .proj td b { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .v { font-weight: 700; }
.hero .big { font-weight: 700; letter-spacing: -.03em; }
.table, .num, .sw-val { font-variant-numeric: tabular-nums; }
.table th { font-family: var(--font); letter-spacing: .05em; }
.nav-link, .btn, .chip, .tabs button, .segmented button { letter-spacing: 0; }
.mono, .secret .pw, code, kbd { font-family: var(--mono); letter-spacing: 0; }
