/* Panell d'administració · Carns B — sense dependències externes */

:root {
  color-scheme: light;
  --page: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #1c1917;
  --ink-2: #57534e;
  --muted: #8a8580;
  --line: rgba(28, 25, 23, 0.09);
  --line-2: rgba(28, 25, 23, 0.16);
  /* Colors de la marca Carns B (logo): granat #98033e i verd #268051 */
  --brand-green: #268051;
  --accent: #98033e;
  --accent-hover: #7c0232;
  --accent-ink: #ffffff;
  --accent-soft: #f9e5ec;
  --sidebar: #1f1a17;
  --sidebar-2: #2a2320;
  --sidebar-ink: #ece7e2;
  --sidebar-muted: #a39b94;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-soft: #e9f6e9;
  --warning-soft: #fff5de;
  --serious-soft: #fdefe9;
  --critical-soft: #fbeaea;
  --success-text: #006300;
  --series-1: #2a78d6;
  --chart-surface: #fcfcfb;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --bubble-in: #f1efeb;
  --bubble-out: #f9e5ec;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 6px 20px rgba(28, 25, 23, 0.05);
  --shadow-lg: 0 12px 40px rgba(28, 25, 23, 0.14);
  --radius: 14px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0f0d0c;
    --surface: #1a1a19;
    --surface-2: #212120;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.16);
    --accent: #ec6a98;
    --accent-hover: #f285ab;
    --accent-ink: #1c0710;
    --accent-soft: #3b1626;
    --sidebar: #141110;
    --sidebar-2: #221c1a;
    --good-soft: #142616;
    --warning-soft: #2c2410;
    --serious-soft: #2f1d15;
    --critical-soft: #301617;
    --success-text: #0ca30c;
    --series-1: #3987e5;
    --chart-surface: #1a1a19;
    --grid: #2c2c2a;
    --axis: #383835;
    --bubble-in: #262524;
    --bubble-out: #3b1626;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Icones ---------- */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand-green) 14%, transparent), transparent 55%),
    var(--page);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
}
.login-card .brand { margin-bottom: 26px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
.login-card p { margin: 0 0 22px; color: var(--ink-2); }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #b02a40, #7a1426);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; letter-spacing: 0.02em; font-size: 15px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
  flex: none;
}
.brand-logo { display: block; height: 40px; width: auto; background: #fff; border-radius: 10px; padding: 3px 6px; box-sizing: content-box; flex: none; }
.login-card .brand-logo { height: 60px; padding: 4px 8px; box-shadow: 0 0 0 1px var(--line); }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 8px; }
.sidebar .brand-sub { color: var(--sidebar-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-ink); text-decoration: none; font-weight: 500;
  border: 0; background: transparent; cursor: pointer; text-align: left; width: 100%;
  position: relative;
}
.nav-item .icon { color: var(--sidebar-muted); }
.nav-item:hover { background: var(--sidebar-2); }
.nav-item[aria-current='page'] { background: var(--sidebar-2); }
.nav-item[aria-current='page']::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: #ec6a98;
}
.nav-item[aria-current='page'] .icon { color: #f5a3c2; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px;
  background: var(--critical); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 14px 8px 0; }
.user-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
}
.sidebar .avatar { background: #3b2330; color: #f5c2d6; }
.user-row .name { font-weight: 600; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--sidebar-muted); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover { color: var(--sidebar-ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 28px 36px 8px;
}
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -0.015em; }
.topbar .subtitle { color: var(--ink-2); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.content { padding: 16px 36px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1280px; width: 100%; }
.content.loading { opacity: 0.55; transition: opacity 0.2s; }

/* ---------- Targetes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 16px; }
.card-head .hint { color: var(--muted); font-size: 13px; }
.card-body { padding: 14px 22px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -6px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 124px; }
.kpi .label { color: var(--ink-2); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kpi .label .icon { color: var(--muted); }
.kpi .value { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .delta { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .delta.up { color: var(--success-text); }
.kpi.clickable { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.kpi.clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

/* ---------- Estats ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.chip.good { background: var(--good-soft); border-color: transparent; }
.chip.good .icon { color: var(--good); }
.chip.warning { background: var(--warning-soft); border-color: transparent; }
.chip.warning .icon { color: #c98500; }
.chip.serious { background: var(--serious-soft); border-color: transparent; }
.chip.serious .icon { color: var(--serious); }
.chip.critical { background: var(--critical-soft); border-color: transparent; }
.chip.critical .icon { color: var(--critical); }
.chip.neutral .icon { color: var(--muted); }

.status-list { display: flex; flex-direction: column; }
.status-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.status-row:first-child { border-top: 0; padding-top: 4px; }
.status-row .what { font-weight: 600; min-width: 92px; }
.status-row .detail { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.status-row .right { margin-left: auto; text-align: right; }

/* ---------- Avisos ---------- */
.banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
}
.banner .icon { width: 22px; height: 22px; }
.banner.warning { background: var(--warning-soft); border-color: transparent; }
.banner.warning > .icon { color: #c98500; }
.banner.critical { background: var(--critical-soft); border-color: transparent; }
.banner.critical > .icon { color: var(--critical); }
.banner.info > .icon { color: var(--accent); }
.banner .text { flex: 1; min-width: 220px; }
.banner strong { display: block; }

/* ---------- Botons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not([disabled]) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-secondary:hover:not([disabled]) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: var(--critical); border-color: var(--line-2); }
.btn-danger:hover:not([disabled]) { background: var(--critical-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.icon-btn { padding: 7px; border-radius: 8px; }

/* ---------- Formularis ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
.field .help { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1.2fr auto; gap: 12px; align-items: end; }
.form-row .field { margin: 0; }
.form-error { color: var(--critical); font-size: 14px; margin: 4px 0 10px; min-height: 1em; }

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 14px; }
.segmented button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 36px; }
.filters .push { margin-left: auto; }
.mt { margin-top: 14px; }

/* ---------- Taules ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: 0.03em;
  text-transform: uppercase; padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-click { cursor: pointer; }
tr.row-click:hover td { background: var(--surface-2); }
tr.expanded td { background: var(--surface-2); }
tr.detail td { background: var(--surface-2); padding-top: 0; }
.detail-box { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px 16px; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.kv b { color: var(--ink); font-weight: 600; }

.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .actions { display: flex; gap: 6px; align-items: center; }
.list-row.inactive .title, .list-row.inactive .sub { opacity: 0.55; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--line-2); position: relative; transition: background 0.15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Gràfic ---------- */
.chart-figure { margin: 0; position: relative; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .xlab { fill: var(--muted); font-size: 11px; }
.chart-svg .xlab.today { fill: var(--ink); font-weight: 700; }
.chart-svg .bar { fill: var(--series-1); transition: opacity 0.1s; }
.chart-svg .vlabel { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg .hit:focus { outline: none; }
.chart-svg g.col.hover .bar, .chart-svg g.col:focus-within .bar { opacity: 0.8; }
.chart-svg g.col:focus .hit { stroke: var(--accent); stroke-width: 1.5; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 8px 12px; font-size: 13px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip .v { font-weight: 700; font-size: 16px; display: block; }
.chart-tip .k { color: var(--ink-2); }
.chart-empty { position: absolute; inset: 0 0 34px 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.chart-tools { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- Converses ---------- */
.convo { padding: 16px 20px; }
.convo-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.convo-head .grow { flex: 1; min-width: 180px; }
.chat { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 4px 2px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble.assistant { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.bubble .who { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.bubble .time { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }
.bubble-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bubble-btn { font-size: 12px; line-height: 1.3; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.chat-note { align-self: center; max-width: 92%; text-align: center; font-size: 12px; color: var(--muted); padding: 2px 10px; }

/* ---------- Incidències ---------- */
.incident { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.incident.resolved { opacity: 0.7; }
.incident-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.incident-head .grow { flex: 1; min-width: 200px; }
.incident .what-to-do { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: 14px; color: var(--ink-2); }
details.tech summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.tech pre { white-space: pre-wrap; font-size: 12px; color: var(--ink-2); background: var(--surface-2); padding: 10px; border-radius: 8px; margin: 8px 0 0; overflow-wrap: anywhere; }

/* ---------- Buit ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--line-2); margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }

/* ---------- Sistema ---------- */
.sys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.copy-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.copy-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.big-number { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.stat-line:first-child { border-top: 0; }

/* ---------- Toasts i diàlegs ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px;
  background: var(--ink); color: var(--page); padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--critical); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

dialog.modal {
  border: 0; border-radius: 18px; padding: 0; max-width: 440px; width: calc(100% - 32px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(15, 13, 12, 0.45); }
.modal-body { padding: 24px 24px 8px; }
.modal-body h3 { margin: 0 0 8px; font-size: 18px; }
.modal-body p { margin: 0; color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .sys-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .nav { min-width: 0; }
  .user-row .link-btn { white-space: nowrap; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px;
  }
  .sidebar .brand-text, .sidebar-foot .user-row .name, .sidebar-foot .user-row .brand-sub { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; flex: 1; scrollbar-width: none; }
  .nav-item { padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  .nav-item[aria-current='page']::before { display: none; }
  .nav-item .label { display: none; }
  .nav-item[aria-current='page'] .label { display: inline; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .topbar { padding: 18px 16px 4px; }
  .topbar h1 { font-size: 22px; }
  .content { padding: 12px 16px 40px; }
  .kpi .value { font-size: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}
@media (max-width: 520px) {
  .sidebar > .brand, .sidebar-foot .avatar { display: none; }
  .nav-item { padding: 8px 9px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; min-height: 0; }
  .kpi .value { font-size: 24px; }
  .card-head, .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
