/* =========================================================
   SomIoT · sistema de disseny
   Base: color de marca Sominternet #00AFAA, tipografia Inter
   Mode clar i fosc automàtic, animacions amb "reduced motion"
   ========================================================= */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/assets/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/assets/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Fitxes de disseny ---------- */
:root {
  --brand-50:  #e8f8f7;
  --brand-100: #c6eeec;
  --brand-200: #8fdcd8;
  --brand-300: #4fc8c3;
  --brand-400: #1bb8b3;
  --brand:     #00afaa;
  --brand-600: #00918d;
  --brand-700: #00726f;
  --brand-800: #065a58;
  --brand-900: #0a4544;
  --accent:    #6c5ce7;

  --bg:        #f4f7f8;
  --bg-2:      #eef3f4;
  --surface:   #ffffff;
  --surface-2: #f8fafb;
  --ink:       #0e1c21;
  --ink-2:     #33454c;
  --muted:     #6a7b81;
  --faint:     #9aa9ae;
  --line:      #e2e9eb;
  --line-2:    #d3dde0;

  --ok:        #13a35a;
  --ok-bg:     #e7f7ee;
  --warn:      #d98a00;
  --warn-bg:   #fff4dc;
  --danger:    #e2474c;
  --danger-bg: #fdecec;
  --info:      #2f80ed;
  --info-bg:   #e9f2fe;

  --r-xs: 6px;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --sh-1: 0 1px 2px rgba(14, 28, 33, .06), 0 1px 1px rgba(14, 28, 33, .04);
  --sh-2: 0 4px 12px -2px rgba(14, 28, 33, .08), 0 2px 4px -2px rgba(14, 28, 33, .05);
  --sh-3: 0 18px 40px -12px rgba(14, 28, 33, .18), 0 6px 12px -6px rgba(14, 28, 33, .08);
  --sh-brand: 0 10px 24px -8px rgba(0, 175, 170, .55);
  --ring: 0 0 0 4px rgba(0, 175, 170, .18);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast: 140ms;
  --t: 240ms;
  --t-slow: 520ms;

  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

  --sidebar-w: 264px;
  --topbar-h: 68px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0b1417;
    --bg-2:      #0f1b1f;
    --surface:   #111f24;
    --surface-2: #15262c;
    --ink:       #e8f1f2;
    --ink-2:     #c2d0d3;
    --muted:     #8a9ca1;
    --faint:     #5f7379;
    --line:      #1f3138;
    --line-2:    #2a3f46;
    --brand-50:  #0d2c2c;
    --brand-100: #0f3a39;
    --ok-bg:     #0f2a1c;
    --warn-bg:   #2c220c;
    --danger-bg: #2e1416;
    --info-bg:   #10213a;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 6px 16px -4px rgba(0, 0, 0, .5);
    --sh-3: 0 24px 48px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
::selection { background: var(--brand-100); color: var(--brand-900); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }
[hidden] { display: none !important; }
.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;
}

/* Barra de desplaçament discreta */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Animacions ---------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}
@keyframes pulse-ring {
  0%   { transform: scale(.6); opacity: .9; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(6%, -4%) scale(1.08); }
  66%  { transform: translate(-4%, 5%) scale(.95); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes dash { to { stroke-dashoffset: 0; } }
@keyframes flow { to { stroke-dashoffset: -40; } }

.anim-fade-up { animation: fade-up var(--t-slow) var(--ease) both; }
.anim-scale-in { animation: scale-in var(--t-slow) var(--ease) both; }
.stagger > * { animation: fade-up var(--t-slow) var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 90ms; }
.stagger > *:nth-child(3) { animation-delay: 140ms; }
.stagger > *:nth-child(4) { animation-delay: 190ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 290ms; }
.stagger > *:nth-child(7) { animation-delay: 340ms; }
.stagger > *:nth-child(8) { animation-delay: 390ms; }
.stagger > *:nth-child(n+9) { animation-delay: 430ms; }

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

/* ---------- Botons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font: 600 14px/1 var(--font);
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease),
              background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.btn:hover { border-color: var(--faint); box-shadow: var(--sh-1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary {
  --btn-bg: linear-gradient(180deg, var(--brand-400), var(--brand-600));
  --btn-fg: #fff;
  --btn-bd: transparent;
  background: var(--btn-bg);
  box-shadow: var(--sh-brand), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { box-shadow: 0 14px 28px -10px rgba(0, 175, 170, .7), inset 0 1px 0 rgba(255, 255, 255, .25); filter: saturate(1.1); border-color: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); box-shadow: none; border-color: transparent; }
.btn-danger { --btn-fg: var(--danger); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: var(--r); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

.btn .spinner { display: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .spinner {
  display: block; position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn:not(.btn-primary).is-loading .spinner { border-color: var(--line-2); border-top-color: var(--brand); }

/* ---------- Formularis ---------- */
.field { display: grid; gap: 7px; }
.field + .field { margin-top: 16px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.control { position: relative; }
.control > svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--faint); pointer-events: none;
  transition: color var(--t) var(--ease);
}
.input {
  width: 100%; height: 48px; padding: 0 14px;
  font: 500 15px var(--font); color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
.control > svg ~ .input, .control > .input.has-icon { padding-left: 44px; }
.input::placeholder { color: var(--faint); font-weight: 400; }
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.control:focus-within > svg { color: var(--brand); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(226, 71, 76, .14); }
.control .reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--faint); border-radius: var(--r-sm); cursor: pointer;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.control .reveal:hover { color: var(--ink-2); background: var(--bg-2); }
.control .reveal svg { width: 18px; height: 18px; position: static; transform: none; }

/* ---------- Avisos ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  animation: fade-up var(--t) var(--ease) both;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: grid; gap: 10px; width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--ink); color: #fff;
  box-shadow: var(--sh-3);
  font-size: 14px; font-weight: 500;
  animation: slide-in-right var(--t-slow) var(--ease-spring) both;
}
.toast.is-leaving { animation: fade-in var(--t) var(--ease) reverse both; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-300); flex: none; }
.toast.danger .dot { background: #ff7b7f; }

/* ---------- Targetes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.card.is-interactive { cursor: pointer; }
.card.is-interactive:hover { transform: translateY(-3px); box-shadow: var(--sh-3); border-color: var(--line-2); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: var(--bg-2); color: var(--ink-2);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.brand { background: var(--brand-50); color: var(--brand-700); }
.badge .live {
  position: relative; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.badge .live::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: currentColor;
  animation: pulse-ring 1.8s var(--ease) infinite;
}

/* Esquelets de càrrega */
.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--bg-2) 0, var(--line) 50%, var(--bg-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  color: transparent !important;
}

/* =========================================================
   LOGIN
   ========================================================= */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr);
}
.login-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px;
  color: #fff;
  background: radial-gradient(120% 120% at 0% 0%, #0fc4be 0%, #00918d 42%, #064a49 100%);
  isolation: isolate;
}
.login-hero .blob {
  position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); opacity: .55;
  animation: drift 18s var(--ease) infinite;
}
.login-hero .blob.b1 { width: 460px; height: 460px; left: -120px; top: -100px; background: #34e0d8; }
.login-hero .blob.b2 { width: 380px; height: 380px; right: -80px; bottom: 10%; background: #6c5ce7; opacity: .35; animation-duration: 22s; animation-delay: -6s; }
.login-hero .blob.b3 { width: 300px; height: 300px; left: 30%; bottom: -120px; background: #00d1a0; opacity: .4; animation-duration: 26s; animation-delay: -12s; }
.login-hero .grid-bg {
  position: absolute; inset: 0; z-index: -1; opacity: .18;
  background-image:
    linear-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .5) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 40% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 40% 40%, #000 20%, transparent 75%);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .35);
}
.brand-mark img { width: 28px; height: 28px; }
.brand-name { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.brand-name b { font-weight: 750; color: var(--brand); }
.login-hero .brand-name b { color: #b7fffb; }

.hero-copy { max-width: 520px; animation: fade-up 800ms var(--ease) 120ms both; }
.hero-copy .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  font-size: 13px; font-weight: 600; backdrop-filter: blur(6px);
}
.hero-copy .badge-dot {
  position: relative; width: 8px; height: 8px; border-radius: 50%; background: #b7fffb;
}
.hero-copy .badge-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: #b7fffb;
  animation: pulse-ring 1.8s var(--ease) infinite;
}
.hero-copy h1 { margin-top: 20px; font-size: clamp(30px, 3.2vw, 44px); font-weight: 750; letter-spacing: -.035em; line-height: 1.08; }
.hero-copy p { margin-top: 16px; font-size: 17px; color: rgba(255, 255, 255, .82); max-width: 460px; }

.hero-net {
  position: absolute; right: -40px; top: 50%; transform: translateY(-50%);
  width: min(560px, 62%); z-index: -1; opacity: .95;
  animation: float 9s ease-in-out infinite;
}
.hero-net .link { stroke: rgba(255, 255, 255, .35); stroke-width: 1.5; fill: none; stroke-dasharray: 4 6; animation: flow 2.4s linear infinite; }
.hero-net .link.strong { stroke: rgba(183, 255, 251, .75); stroke-dasharray: 6 8; animation-duration: 1.6s; }
.hero-net .node { fill: #fff; }
.hero-net .node.hub { fill: #b7fffb; }
.hero-net .halo { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: pulse-ring 2.6s var(--ease) infinite; }
.hero-net .halo.d1 { animation-delay: -.8s; }
.hero-net .halo.d2 { animation-delay: -1.6s; }

.hero-stats { display: flex; gap: 14px; flex-wrap: wrap; animation: fade-up 800ms var(--ease) 320ms both; }
.hero-stat {
  padding: 14px 18px; min-width: 150px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(10px);
}
.hero-stat .k { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, .7); }
.hero-stat .v { margin-top: 4px; font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.hero-stat .v svg { width: 18px; height: 18px; }

.login-side {
  display: grid; place-items: center;
  padding: 40px 24px;
  background: var(--surface);
  position: relative;
}
.login-card { width: min(400px, 100%); }
.login-card .brand { display: none; margin-bottom: 36px; }
.login-card .head { animation: fade-up 700ms var(--ease) 80ms both; }
.login-card .head h2 { font-size: 30px; font-weight: 750; letter-spacing: -.03em; }
.login-card .head p { margin-top: 8px; color: var(--muted); }
.login-card form { margin-top: 32px; animation: fade-up 700ms var(--ease) 180ms both; }
.login-card form.is-shaking { animation: shake 480ms var(--ease) both; }
.login-card .alert { margin-top: 18px; }
.login-card .actions { margin-top: 26px; }
.login-foot { margin-top: 36px; font-size: 13px; color: var(--muted); text-align: center; animation: fade-in 900ms var(--ease) 400ms both; }

.login-success {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), var(--brand) 0, var(--brand-700) 100%);
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
  transition: clip-path 700ms cubic-bezier(.7, 0, .3, 1);
}
.login-success.is-on { clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); }

@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-side { background: var(--bg); }
  .login-card { padding: 32px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-2); }
  .login-card .brand { display: inline-flex; }
}

/* =========================================================
   APLICACIÓ (panell)
   ========================================================= */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; min-height: 100dvh;
}

/* --- Barra lateral --- */
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 30;
}
.sidebar .brand { padding: 4px 10px 22px; }
.sidebar .brand-mark { background: var(--brand-50); box-shadow: none; }
.nav { display: grid; gap: 2px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group { margin-top: 18px; padding: 0 12px 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.nav-group:first-child { margin-top: 0; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 42px; padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 550; color: var(--ink-2);
  cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; color: var(--faint); transition: color var(--t) var(--ease), transform var(--t) var(--ease-spring); }
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-2); transform: scale(1.08); }
.nav-item.is-active { background: var(--brand-50); color: var(--brand-700); }
.nav-item.is-active svg { color: var(--brand); }
.nav-item.is-active::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--brand);
  animation: scale-in var(--t) var(--ease) both;
}
.nav-item .soon { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); background: var(--bg-2); padding: 3px 7px; border-radius: 6px; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: var(--r);
  transition: background var(--t) var(--ease);
}
.user-chip:hover { background: var(--bg-2); }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-300), var(--brand-700));
}
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who b { display: block; font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; font-size: 12px; color: var(--muted); }

/* --- Zona principal --- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 20px -16px rgba(0, 0, 0, .3); }
.topbar .crumbs { font-size: 13px; color: var(--muted); }
.topbar .crumbs b { color: var(--ink); font-weight: 650; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }

.content { padding: 28px 32px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page { animation: fade-up var(--t-slow) var(--ease) both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { margin-top: 6px; color: var(--muted); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.kpi { padding: 20px; position: relative; overflow: hidden; }
.kpi .ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600);
  transition: transform var(--t) var(--ease-spring);
}
.kpi:hover .ico { transform: rotate(-6deg) scale(1.08); }
.kpi .ico svg { width: 22px; height: 22px; }
.kpi .ico.violet { background: #efedfd; color: var(--accent); }
.kpi .ico.green { background: var(--ok-bg); color: var(--ok); }
.kpi .ico.blue { background: var(--info-bg); color: var(--info); }
.kpi .k { margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi .v { margin-top: 2px; font-size: 32px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.kpi::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-50), transparent 70%);
  opacity: 0; transition: opacity var(--t) var(--ease);
}
.kpi:hover::after { opacity: 1; }

/* Estat buit */
.empty {
  display: grid; place-items: center; text-align: center;
  padding: 64px 24px;
}
.empty .art {
  width: 96px; height: 96px; border-radius: 28px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-50), var(--surface-2));
  color: var(--brand); margin-bottom: 20px;
  animation: float 5s ease-in-out infinite;
}
.empty .art svg { width: 44px; height: 44px; }
.empty h3 { font-size: 18px; }
.empty p { margin-top: 8px; color: var(--muted); max-width: 420px; }

.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* Capa de fons per al menú mòbil */
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(5, 15, 18, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--t) var(--ease); }

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
    transform: translateX(-102%);
    transition: transform var(--t-slow) var(--ease);
    box-shadow: var(--sh-3);
  }
  .app.is-menu-open .sidebar { transform: none; }
  .app.is-menu-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
}

/* Pantalla de càrrega inicial */
.boot {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity var(--t-slow) var(--ease), visibility var(--t-slow);
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot .brand-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--surface); box-shadow: var(--sh-2); position: relative; }
.boot .brand-mark img { width: 36px; height: 36px; }
.boot .brand-mark::after {
  content: ''; position: absolute; inset: -6px; border-radius: 20px;
  border: 2px solid var(--brand); opacity: .6;
  animation: pulse-ring 1.6s var(--ease) infinite;
}
