/* Rouandi Brochures — admin design system
   Inter for interface text, Poppins (brand) for titles and figures. Navy + burgundy from rouandi.ma. */

/* Smooth page-to-page navigation: the sidebar stays put, the content cross-fades. */
@view-transition { navigation: auto; }
.side { view-transition-name: side; }
.mtop { view-transition-name: mtop; }
::view-transition-old(root) { animation: vt-out .16s ease both; }
::view-transition-new(root) { animation: vt-in .26s cubic-bezier(.2,.8,.2,1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(4px); } }
::view-transition-group(side), ::view-transition-group(mtop), ::view-transition-group(tabbar) { animation: none; }

:root {
  --navy: #102a49; --navy-2: #173a63; --navy-3: #0c2139;
  --burgundy: #901924; --burgundy-2: #7a1520; --burgundy-soft: #fcf0f1; --burgundy-line: #f3d3d7;
  --bg: #f5f7fa; --card: #fff; --text: #1e293b; --muted: #64748b; --faint: #94a3b8;
  --line: #e5e9f0; --line-2: #f1f4f8;
  --good: #15803d; --good-bg: #e9f7ef; --bad: #b42318; --bad-bg: #fdeeee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --shadow-lg: 0 20px 50px rgba(12,33,57,.18), 0 2px 6px rgba(12,33,57,.06);
  --side: 252px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: Poppins, Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; font: 400 14px/1.55 var(--font); background: var(--bg); color: var(--text); font-feature-settings: "cv11", "ss01"; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 6px; }

/* ---------- Sidebar ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy-3); color: #a9b7c9;
        display: flex; flex-direction: column; padding: 20px 14px 16px; z-index: 50; border-right: 1px solid rgba(255,255,255,.04); }
.side .logo { padding: 6px 10px 28px; display: block; }
.side .logo img { height: 34px; width: auto; display: block; }
.side .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #6c809b; padding: 0 12px 8px; font-weight: 600; }
.side nav { display: grid; gap: 2px; }
.side nav a { position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 8px; text-decoration: none;
              font-weight: 500; font-size: 14px; transition: background .15s, color .15s; }
.side nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--burgundy); }
.side nav a.on svg { color: #f3c9ce; }
.side .foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.05); }
.avatar { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #a52230, var(--burgundy-2)); color: #fff; display: grid; place-items: center;
          font: 600 14px var(--display); text-transform: uppercase; flex-shrink: 0; }
.side .who { flex: 1; min-width: 0; line-height: 1.3; }
.side .who b { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.side .who span { font-size: 12px; color: #6c809b; }
.side .out { background: transparent; border: 0; color: #a9b7c9; padding: 7px; border-radius: 7px; cursor: pointer; display: grid; }
.side .out:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Layout ---------- */
.mtop { display: none; }
.main { margin-left: var(--side); min-height: 100vh; }
.page { max-width: 1280px; margin: 0 auto; padding: 32px 36px 72px; animation: page-in .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
@supports (view-transition-name: a) { .page { animation: none; } }
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.phead h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 600; color: var(--navy); letter-spacing: -.02em; }
.phead p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Mobile app layout: top bar + bottom tab bar ---------- */
.tabbar { display: none; }
@media (max-width: 960px) {
  .side, .scrim { display: none !important; }
  .mtop { display: flex !important; position: sticky; top: 0; z-index: 40; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; align-items: center; gap: 12px;
          background: rgba(255,255,255,.88); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line); }
  .mtop img { height: 26px; width: auto; }
  .mtop .mtitle { font: 600 15px var(--display); color: var(--navy); margin-left: auto; margin-right: auto; position: absolute; left: 50%; transform: translateX(-50%); opacity: 0; }
  .mtop .mout { margin-left: auto; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; view-transition-name: tabbar;
            padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
            border-top: 1px solid var(--line); }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 4px; border-radius: 10px; text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 600; transition: color .15s, background .15s; -webkit-tap-highlight-color: transparent; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--burgundy); }
  .tabbar a.on svg { stroke-width: 2.1; }
  .tabbar a:active { background: var(--line-2); }
  .main { margin-left: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .page { padding: 20px 16px 32px; }
  .phead { margin-bottom: 18px; padding-bottom: 16px; }
  .phead h1 { font-size: 24px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Pop-ups become bottom sheets */
  .modal { place-items: end center; padding: 0; }
  .modal .box { max-width: none !important; width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.9,.2,1);
                padding-bottom: env(safe-area-inset-bottom); }
  .modal.open .box { transform: none; }
  .modal .box::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: #d6dce5; margin: 8px auto 0; }
  .modal .mh { padding: 10px 16px 14px; }
  .modal .mb { padding: 16px; }
  .modal .mf { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal .mf .btn { flex: 1; }
  .menu { left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); border-radius: 16px; padding: 8px; transform: translateY(20px); transform-origin: bottom center; }
  .menu.open { transform: none; }
  .menu button, .menu a { padding: 13px 12px; font-size: 15px; }
}
@media (min-width: 961px) { .mtop { display: none !important; } }
/* ---------- Building blocks ---------- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 0 16px;
       font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, color .15s; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--burgundy); color: #fff; box-shadow: 0 1px 2px rgba(144,25,36,.25), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--burgundy-2); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-light { background: #fff; color: var(--text); border-color: var(--line); box-shadow: var(--shadow); }
.btn-light:hover { border-color: #cbd3df; background: #fafbfc; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #8f1b13; }
.iconbtn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.iconbtn:hover { background: var(--line-2); color: var(--navy); }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
select.input { padding-right: 32px; appearance: none; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(16,42,73,.1); }
.input::placeholder { color: var(--faint); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 17px; height: 17px; }
.search .input { padding-left: 38px; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--line-2); color: var(--muted); border: 1px solid var(--line); }

/* KPI tile (shared) */
.kpi .l { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi .v { font: 600 28px/1.15 var(--display); color: var(--navy); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.pill.up { background: var(--good-bg); color: var(--good); }
.pill.down { background: var(--bad-bg); color: var(--bad); }
.pill.flat { background: var(--line-2); color: var(--muted); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(12,33,57,.45); backdrop-filter: blur(4px);
         opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal.open { opacity: 1; pointer-events: auto; }
.modal .box { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
              transform: translateY(10px) scale(.985); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.modal.open .box { transform: none; }
.modal .mh { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 17px; font-weight: 600; color: var(--navy); }
.modal .mb { padding: 20px; display: grid; gap: 16px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 16px 16px; }

/* ---------- Menu ---------- */
.menu { position: fixed; z-index: 90; min-width: 210px; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; border: 1px solid var(--line);
        opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none; transition: opacity .12s, transform .12s; }
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; cursor: pointer; text-decoration: none; text-align: left; font-size: 14px; color: var(--text); }
.menu svg { color: var(--muted); width: 16px; height: 16px; }
.menu button:hover, .menu a:hover { background: var(--line-2); }
.menu .danger, .menu .danger svg { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; z-index: 100; transform: translate(-50%, 80px); background: var(--navy-3); color: #fff; padding: 11px 16px; border-radius: 10px;
         font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); opacity: 0; transition: .3s cubic-bezier(.2,.8,.2,1); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast svg { color: #6ee7a8; }

.skeleton { background: linear-gradient(100deg, #eef1f5 30%, #f7f8fa 50%, #eef1f5 70%); background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
