/* ==========================================================================
   Coopit · Incidències — sistema de disseny
   Conviu amb Bootstrap 4 (modals, pestanyes, graella) i DataTables 2.
   Estructura:
     1. Variables   2. Base   3. Barra superior   4. Pàgina i capçaleres
     5. Targetes i estadístiques   6. Botons   7. Formularis   8. Insígnies
     9. Taules i DataTables   10. Modals   11. Pestanyes i desplegables
     12. Paginació   13. Toasts   14. Perfil   15. Historial d'incidències
     16. Autenticació   17. Utilitats i responsive
   ========================================================================== */

/* 1. Variables ------------------------------------------------------------ */
:root {
    --brand-50: #f0f6fb;
    --brand-100: #dcebf6;
    --brand-200: #bcd8ec;
    --brand-300: #93bddc;
    --brand-400: #6aa2cc;
    --brand-500: #488cbf;   /* color del logotip */
    --brand-600: #33729f;
    --brand-700: #295d82;
    --brand-800: #234c6a;
    --brand-900: #183449;

    --ink: #10283c;
    --ink-2: #3b5166;
    --muted: #64798c;
    --line: #e3eaf1;
    --line-strong: #cbd8e4;
    --bg: #f3f6fa;
    --surface: #ffffff;

    --ok-bg: #e2f6ec;     --ok-fg: #0d7748;     --ok-dot: #22a86b;
    --warn-bg: #fff3d9;   --warn-fg: #8f5508;   --warn-dot: #f0a30a;
    --prog-bg: #e1eefa;   --prog-fg: #1f5c92;   --prog-dot: #3b8bd0;
    --bad-bg: #fde8e8;    --bad-fg: #a02525;    --bad-dot: #e04848;
    --orange-bg: #ffeadb; --orange-fg: #9c4509;
    --idle-bg: #eceff3;   --idle-fg: #4a5a6a;   --idle-dot: #94a3b1;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 40, 60, .05), 0 1px 3px rgba(16, 40, 60, .04);
    --shadow-md: 0 6px 16px -4px rgba(16, 40, 60, .10), 0 2px 6px rgba(16, 40, 60, .05);
    --shadow-lg: 0 24px 60px -16px rgba(16, 40, 60, .35);
    --ring: 0 0 0 3px rgba(72, 140, 191, .28);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --topbar-h: 68px;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: .9375rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'locl' 0;
}

button, input, select, textarea { font-feature-settings: 'locl' 0; }

h1, h2, h3, h4, h5, h6 { color: var(--ink); font-family: var(--font); font-weight: 650; letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-800); text-decoration: none; }
img { max-width: 100%; }
::selection { background: var(--brand-200); color: var(--ink); }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.icon {
    width: 1.15em; height: 1.15em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    vertical-align: -.2em;
}

/* 3. Barra superior ------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar::after {           /* fil de color de marca */
    content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-300) 60%, transparent);
    opacity: .9;
}
.topbar-inner {
    max-width: 1320px; height: var(--topbar-h); margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand img { height: 44px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; padding-left: 12px; border-left: 1px solid var(--line-strong); }
.brand-text strong { font-size: .95rem; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: .72rem; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }

.topnav { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.topnav a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 10px;
    color: var(--ink-2); font-weight: 550; font-size: .9rem;
    transition: background .15s, color .15s;
}
.topnav a .icon { color: var(--muted); transition: color .15s; }
.topnav a:hover { background: var(--brand-50); color: var(--brand-800); }
.topnav a:hover .icon { color: var(--brand-600); }
.topnav a.is-active { background: var(--brand-100); color: var(--brand-800); }
.topnav a.is-active .icon { color: var(--brand-600); }

.menu { position: relative; }
.menu-toggle {
    display: flex; align-items: center; gap: 10px;
    background: transparent; border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 12px 5px 5px; cursor: pointer; color: var(--ink);
    font-family: inherit; font-size: .9rem; font-weight: 600;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.menu-toggle:hover, .menu.is-open .menu-toggle { border-color: var(--brand-300); background: var(--brand-50); }
.menu-toggle .who { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.menu-toggle .who small { font-size: .7rem; font-weight: 500; color: var(--muted); }
.menu-toggle .chev { color: var(--muted); transition: transform .2s; }
.menu.is-open .chev { transform: rotate(180deg); }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: 6px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .15s, transform .15s, visibility .15s;
}
.menu.is-open .menu-panel { opacity: 1; visibility: visible; transform: none; }
.menu-panel .menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-panel .menu-head strong { display: block; font-size: .9rem; }
.menu-panel .menu-head span { display: block; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border: 0; background: transparent; border-radius: 9px;
    font-family: inherit; font-size: .9rem; font-weight: 550; color: var(--ink-2);
    cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--brand-50); color: var(--brand-800); }
.menu-item.danger { color: var(--bad-fg); }
.menu-item.danger:hover { background: var(--bad-bg); color: var(--bad-fg); }
.menu-item .icon { color: var(--muted); }
.menu-item.danger .icon { color: var(--bad-fg); }

.nav-toggle {
    display: none; margin-left: auto; width: 42px; height: 42px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
    align-items: center; justify-content: center;
}

/* 4. Pàgina i capçaleres -------------------------------------------------- */
.page { max-width: 1320px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 24px;
}
.page-title { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: .95rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-600); margin-bottom: 6px; }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
.stack > * + * { margin-top: 24px; }

/* 5. Targetes i estadístiques -------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin: 0; min-width: 0;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 18px 22px; background: transparent; border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-header .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title { font-size: 1.05rem; font-weight: 650; margin: 0; padding: 0; }
.card-sub { font-size: .82rem; color: var(--muted); margin-top: 1px; }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--line); background: #fafcfe; border-radius: 0 0 var(--radius) var(--radius); }
.icon-chip {
    width: 40px; height: 40px; flex: none; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-100); color: var(--brand-700); font-size: 1.15rem;
}
.count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 8px;
    border-radius: 999px; background: var(--brand-50); color: var(--brand-700);
    font-size: .75rem; font-weight: 700; border: 1px solid var(--brand-100);
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.stats.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
    display: flex; align-items: center; gap: 16px; padding: 18px 20px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 46px; height: 46px; flex: none; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-num { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 550; margin-top: 2px; }
.tone-brand { background: var(--brand-100); color: var(--brand-700); }
.tone-ok { background: var(--ok-bg); color: var(--ok-fg); }
.tone-warn { background: var(--warn-bg); color: var(--warn-fg); }
.tone-prog { background: var(--prog-bg); color: var(--prog-fg); }
.tone-bad { background: var(--bad-bg); color: var(--bad-fg); }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: .9rem; }
.empty .icon { width: 30px; height: 30px; color: var(--line-strong); display: block; margin: 0 auto 8px; }

/* 6. Botons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
    font-family: var(--font); font-size: .875rem; font-weight: 600; line-height: 1.3;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus, .btn.focus { outline: 0; box-shadow: var(--ring); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }

.btn.btn-primary, .btn.btn-success { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: 0 1px 2px rgba(16,40,60,.15); }
.btn.btn-primary:hover, .btn.btn-success:hover,
.btn.btn-primary:not(:disabled):not(.disabled):active, .btn.btn-success:not(:disabled):not(.disabled):active { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.btn.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.btn.btn-secondary:hover, .btn.btn-secondary:not(:disabled):not(.disabled):active { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-800); }

.btn.btn-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.btn.btn-info:hover, .btn.btn-info:not(:disabled):not(.disabled):active { background: var(--brand-100); border-color: var(--brand-200); color: var(--brand-800); }

.btn.btn-danger { background: #cf3a3a; border-color: #cf3a3a; color: #fff; box-shadow: 0 1px 2px rgba(120,20,20,.2); }
.btn.btn-danger:hover, .btn.btn-danger:not(:disabled):not(.disabled):active { background: #b52d2d; border-color: #b52d2d; color: #fff; }
.btn.btn-danger:focus { box-shadow: 0 0 0 3px rgba(207, 58, 58, .28); }

.btn.btn-danger-soft { background: var(--bad-bg); border-color: #f8cfcf; color: var(--bad-fg); }
.btn.btn-danger-soft:hover { background: #fbd5d5; border-color: #f2b8b8; color: #861c1c; }

.btn.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.btn-ghost:hover { background: var(--brand-50); color: var(--brand-800); }

.btn.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 8px; }
.btn.btn-lg { padding: 12px 20px; font-size: .95rem; }
.btn.btn-block { display: flex; width: 100%; }
.btn.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; }
.btn-group-inline { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* 7. Formularis ----------------------------------------------------------- */
label, .form-label { display: block; margin: 0 0 6px; font-size: .84rem; font-weight: 600; color: var(--ink-2); }
label .opt { font-weight: 500; color: var(--muted); }

.form-control {
    display: block; width: 100%; height: auto; min-height: 44px;
    padding: 10px 14px; font-family: var(--font); font-size: .95rem; line-height: 1.4; color: var(--ink);
    background-color: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
    box-shadow: 0 1px 1px rgba(16, 40, 60, .03) inset;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
    -webkit-appearance: none; appearance: none;
}
.form-control::placeholder { color: #9aacbb; opacity: 1; }
.form-control:hover { border-color: var(--brand-300); }
.form-control:focus { outline: 0; border-color: var(--brand-500); box-shadow: var(--ring); background-color: #fff; color: var(--ink); }
.form-control:disabled, .form-control[readonly] { background-color: #f3f6f9; color: var(--muted); cursor: not-allowed; }
textarea.form-control { min-height: 110px; resize: vertical; }
select.form-control {
    padding-right: 40px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364798c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}
input[type="date"].form-control { min-height: 44px; }
.form-control.is-invalid { border-color: #e04848; }

.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
.form-spacing { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.form-row > .form-group { margin-bottom: 18px; min-width: 0; }
.form-hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.field-error { font-size: .82rem; color: var(--bad-fg); margin-top: 6px; }
.field-error ul { list-style: none; margin: 0; padding: 0; }

.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; font-size: .9rem; color: var(--ink-2); cursor: pointer; margin: 0; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-600); }

/* Càrrega de fitxers */
.dropzone {
    position: relative; display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border: 1.5px dashed var(--line-strong); border-radius: 12px;
    background: #fafcfe; color: var(--ink-2); cursor: pointer; margin: 0;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--brand-400); background: var(--brand-50); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--brand-100); color: var(--brand-700); display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.dropzone strong { display: block; font-size: .9rem; color: var(--ink); }
.dropzone small { color: var(--muted); font-size: .8rem; }
.dropzone .dz-name { color: var(--brand-700); font-weight: 600; }

.file-plain { display: block; width: 100%; padding: 8px; border: 1px dashed var(--line-strong); border-radius: 10px; background: #fafcfe; font-size: .85rem; color: var(--ink-2); }
.file-plain::file-selector-button { margin-right: 12px; padding: 7px 12px; border: 0; border-radius: 8px; background: var(--brand-100); color: var(--brand-800); font-weight: 600; cursor: pointer; }

/* Vista prèvia d'imatge clicable */
.img-edit { position: relative; display: block; width: 100%; border-radius: 14px; overflow: hidden; cursor: pointer; background: #f3f6f9; border: 1px solid var(--line); margin: 0; }
.img-edit img { display: block; width: 100%; height: 210px; object-fit: contain; background: repeating-conic-gradient(#f6f9fc 0% 25%, #fff 0% 50%) 50% / 18px 18px; }
.img-edit .img-edit-label {
    position: absolute; inset: auto 0 0 0; padding: 10px; text-align: center; color: #fff; font-size: .82rem; font-weight: 600;
    background: linear-gradient(transparent, rgba(16, 40, 60, .78)); opacity: 0; transition: opacity .15s;
}
.img-edit:hover .img-edit-label { opacity: 1; }

/* 8. Insígnies ------------------------------------------------------------ */
.pill {
    display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px;
    font-size: .76rem; font-weight: 650; line-height: 1.5; white-space: nowrap; letter-spacing: .005em;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-prog { background: var(--prog-bg); color: var(--prog-fg); }
.pill-bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill-orange { background: var(--orange-bg); color: var(--orange-fg); }
.pill-idle { background: var(--idle-bg); color: var(--idle-fg); }
.pill-brand { background: var(--brand-100); color: var(--brand-800); }
.pill .icon { width: .95em; height: .95em; }
.badge { font-family: var(--font); }

/* Avatars */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 36px; height: 36px; border-radius: 50%; font-size: .78rem; font-weight: 700; letter-spacing: .02em;
    overflow: hidden; user-select: none;
}
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.35rem; }
.avatar.is-logo { border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.avatar.is-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.avatar.avatar-lg.is-logo, .avatar.avatar-xl.is-logo { border-radius: 14px; }

.cell-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-person .name { font-weight: 600; color: var(--ink); line-height: 1.25; }
.cell-person .sub { font-size: .8rem; color: var(--muted); line-height: 1.25; }

/* 9. Taules i DataTables -------------------------------------------------- */
.table-wrap { overflow-x: auto; }
div.dt-container { padding: 0; font-family: var(--font); color: var(--ink); }
div.dt-container div.dt-layout-row { margin: 0; padding: 0; }
div.dt-container div.dt-layout-row:not(.dt-layout-table) { padding: 16px 22px; }
div.dt-container div.dt-layout-row:first-child { border-bottom: 1px solid var(--line); }
div.dt-container div.dt-layout-row:last-child:not(.dt-layout-table) { border-top: 1px solid var(--line); background: #fafcfe; border-radius: 0 0 var(--radius) var(--radius); }
div.dt-container div.dt-layout-row.dt-layout-table { padding: 0; border: 0; }
div.dt-container div.dt-layout-row div.dt-layout-cell { padding: 0; }
div.dt-container div.dt-layout-row.dt-layout-table > div.dt-layout-cell { width: 100%; overflow-x: auto; }
div.dt-container .dt-length, div.dt-container .dt-search { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 0; }
div.dt-container .dt-length label, div.dt-container .dt-search label { margin: 0; font-weight: 500; color: var(--muted); }
div.dt-container .dt-search label { display: none; }
div.dt-container .dt-input {
    height: 38px; padding: 6px 12px; border: 1px solid var(--line-strong) !important; border-radius: 10px;
    background-color: #fff; font-family: var(--font); font-size: .875rem; color: var(--ink); margin: 0 !important;
    transition: border-color .15s, box-shadow .15s;
}
div.dt-container .dt-search .dt-input {
    width: 260px; padding-left: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364798c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 13px center;
}
div.dt-container .dt-input:focus { outline: 0; border-color: var(--brand-500) !important; box-shadow: var(--ring); }
div.dt-container .dt-length select.dt-input { padding-right: 8px; }
div.dt-container .dt-info { color: var(--muted); font-size: .83rem; padding: 0; }
div.dt-container .dt-paging { padding: 0; display: flex; }
div.dt-container .dt-paging nav { display: flex; gap: 4px; align-items: center; }
div.dt-container .dt-paging .dt-paging-button {
    min-width: 34px; height: 34px; padding: 0 10px; margin: 0 !important;
    border: 1px solid transparent !important; border-radius: 9px !important; background: transparent !important;
    color: var(--ink-2) !important; font-family: var(--font); font-size: .84rem; font-weight: 600; cursor: pointer;
    box-shadow: none !important; transition: background .15s, color .15s;
}
div.dt-container .dt-paging .dt-paging-button:hover:not(.disabled):not(.current) { background: var(--brand-50) !important; color: var(--brand-800) !important; border-color: var(--brand-100) !important; }
div.dt-container .dt-paging .dt-paging-button.current { background: var(--brand-600) !important; color: #fff !important; border-color: var(--brand-600) !important; }
div.dt-container .dt-paging .dt-paging-button.disabled { opacity: .4; cursor: default; }

table.dataTable.data-table { width: 100% !important; border-collapse: separate; border-spacing: 0; margin: 0 !important; font-size: .9rem; border-bottom: 0 !important; }
table.dataTable.data-table > thead > tr > th {
    padding: 12px 18px !important; background: #f7fafc; color: var(--muted);
    font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; text-align: left !important;
    border-top: 0 !important; border-bottom: 1px solid var(--line) !important; white-space: nowrap;
}
table.dataTable.data-table > thead > tr > th.dt-orderable-asc,
table.dataTable.data-table > thead > tr > th.dt-orderable-desc,
table.dataTable.data-table > thead > tr > th.dt-ordering-asc,
table.dataTable.data-table > thead > tr > th.dt-ordering-desc { padding-right: 34px !important; }
table.dataTable.data-table > thead > tr > th span.dt-column-order { right: 10px; opacity: .6; }
table.dataTable.data-table > thead > tr > th.dt-orderable-asc:hover,
table.dataTable.data-table > thead > tr > th.dt-orderable-desc:hover { background: var(--brand-50); outline: 0; color: var(--brand-800); }
table.dataTable.data-table > tbody > tr > td,
table.dataTable.data-table > tbody > tr > th {
    padding: 14px 18px !important; vertical-align: middle; text-align: left !important;
    border-top: 0 !important; border-bottom: 1px solid var(--line) !important; font-weight: 400; color: var(--ink);
}
table.dataTable.data-table > tbody > tr:last-child > td,
table.dataTable.data-table > tbody > tr:last-child > th { border-bottom: 0 !important; }
table.dataTable.data-table > tbody > tr { background: #fff; transition: background .12s; }
table.dataTable.data-table > tbody > tr:hover { background: var(--brand-50) !important; }
table.dataTable.data-table > tbody > tr.row-link { cursor: pointer; }
table.dataTable.data-table td.num, table.dataTable.data-table th.num { width: 1%; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.dataTable.data-table td.actions, table.dataTable.data-table th.actions { text-align: right !important; width: 1%; white-space: nowrap; padding-right: 18px !important; }
table.dataTable.data-table .dt-empty { padding: 34px 16px !important; text-align: center !important; color: var(--muted); }
.cell-title { font-weight: 600; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cell-desc { font-size: .8rem; color: var(--muted); max-width: 340px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .82rem; color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }

/* 10. Modals -------------------------------------------------------------- */
.modal-backdrop.show { opacity: .5; background: #0b1f30; }
.modal-content {
    border: 0; border-radius: 20px; background: var(--surface);
    box-shadow: var(--shadow-lg); overflow: hidden; font-family: var(--font);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 22px 26px 18px; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--surface);
}
.modal-header .m-lead { display: flex; align-items: center; gap: 14px; min-width: 0; }
.modal-title, .modal-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.015em; margin: 0; line-height: 1.25; }
.modal-header .m-sub { font-size: .84rem; color: var(--muted); margin-top: 2px; }
.modal-header .close {
    float: none; margin: 0; padding: 0; width: 34px; height: 34px; flex: none;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;
    color: var(--muted); opacity: 1; text-shadow: none; font-weight: 400; font-size: 1.4rem; line-height: 1; background: transparent; border: 0;
    transition: background .15s, color .15s;
}
.modal-header .close:hover { background: var(--idle-bg); color: var(--ink); }
.modal-body { padding: 24px 26px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line);
    background: #fafcfe; border-radius: 0;
}
.modal-footer > * { margin: 0; }
.modal-dialog { margin-left: auto; margin-right: auto; }

.modal-confirm .modal-body { text-align: center; padding: 34px 30px 26px; }
.modal-confirm .confirm-icon {
    width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.modal-confirm h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.modal-confirm p { color: var(--muted); font-size: .92rem; }
.modal-confirm .modal-footer { justify-content: center; }

.modal-2col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; }
.modal-2col > div { min-width: 0; }

/* 11. Pestanyes i desplegables ------------------------------------------- */
.segmented {
    display: inline-flex; gap: 4px; padding: 5px; border-radius: 14px;
    background: #e8eef4; border: 0; margin: 0 0 24px;
}
.segmented .nav-item { margin: 0; }
.segmented .nav-link, .nav-tabs.segmented .nav-link {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border: 0; border-radius: 10px;
    color: var(--ink-2); font-weight: 600; font-size: .9rem; background: transparent; margin: 0;
    transition: background .15s, color .15s, box-shadow .15s;
}
.segmented .nav-link:hover { color: var(--brand-800); background: rgba(255,255,255,.55); border: 0; }
.segmented .nav-link.active { background: #fff; color: var(--brand-800); box-shadow: var(--shadow-sm); border: 0; }
.nav-tabs.segmented { border-bottom: 0; }
.tab-content > .tab-pane { outline: 0; }

.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; font-family: var(--font); }
.dropdown-item { border-radius: 8px; padding: 8px 12px; font-weight: 550; font-size: .9rem; color: var(--ink-2); }
.dropdown-item:hover { background: var(--brand-50); color: var(--brand-800); }

/* 12. Paginació ---------------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pager-info { font-size: .8rem; color: var(--muted); }
.pager-links { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pager-links a, .pager-links span {
    min-width: 32px; height: 32px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; font-size: .82rem; font-weight: 600; color: var(--ink-2); background: transparent; border: 1px solid transparent;
}
.pager-links a { background: #fff; border-color: var(--line); }
.pager-links a:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-800); }
.pager-links .is-current { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pager-links .is-disabled { color: var(--line-strong); }

/* 13. Toasts (toastr) ----------------------------------------------------- */
#toast-container > div {
    opacity: 1; width: 380px; max-width: calc(100vw - 32px); padding: 16px 18px 16px 58px; border-radius: 14px;
    background-position: 18px center; background-size: 24px; box-shadow: var(--shadow-lg);
    font-family: var(--font); font-size: .92rem; font-weight: 550; line-height: 1.4;
}
#toast-container > div:hover { box-shadow: var(--shadow-lg); opacity: 1; }
.toast-success { background-color: #0f8a55 !important; }
.toast-error { background-color: #c73333 !important; }
.toast-info { background-color: var(--brand-600) !important; }
.toast-warning { background-color: #c98108 !important; }
.toast-progress { opacity: .35; background-color: #000; }
.toast-close-button { color: #fff; opacity: .8; text-shadow: none; }

/* 14. Perfil -------------------------------------------------------------- */
.profile-hero {
    display: flex; align-items: center; gap: 20px; padding: 22px 26px; margin-bottom: 24px;
    background: linear-gradient(120deg, var(--brand-900), var(--brand-700) 60%, var(--brand-500));
    border-radius: var(--radius); color: #fff; box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.profile-hero::after { content: ''; position: absolute; right: -60px; top: -90px; width: 280px; height: 280px; border-radius: 50%; background: rgba(255,255,255,.07); }
.profile-hero h1 { color: #fff; font-size: 1.5rem; }
.profile-hero p { color: rgba(255,255,255,.78); margin-top: 2px; }
.profile-hero .avatar { background: #fff; border: 0; box-shadow: 0 6px 16px rgba(0,0,0,.2); }

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; }
.user-card { display: flex; flex-direction: column; height: 100%; }
.user-card .card-body { flex: 1; }
.user-card-head { display: flex; align-items: center; gap: 14px; padding: 20px 22px 0; min-height: 92px; }
.user-card-head .who { min-width: 0; }
.user-card-head .who strong { display: block; font-size: 1rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.user-card-head .who span { display: block; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.user-card .card-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-card .card-foot form { margin: 0; }
.user-card .field-inline { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.user-add {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 260px;
    background: transparent; border: 2px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
    cursor: pointer; font-family: var(--font); font-weight: 600; transition: border-color .15s, background .15s, color .15s;
}
.user-add:hover { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-800); }
.user-add .plus { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; }

.company-grid { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 24px; align-items: start; }
.logo-stage {
    position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 300px; padding: 28px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); font-family: var(--font);
}
button.logo-stage { cursor: pointer; }
.logo-stage img { max-width: 100%; max-height: 260px; object-fit: contain; }
.logo-stage .logo-edit {
    position: absolute; left: 14px; right: 14px; bottom: 14px; padding: 9px; border-radius: 10px; text-align: center;
    background: rgba(16, 40, 60, .82); color: #fff; font-size: .82rem; font-weight: 600; opacity: 0; transition: opacity .15s;
}
button.logo-stage:hover .logo-edit { opacity: 1; }
.info-list { margin: 0; }
.info-list .info-row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.info-list .info-row:last-child { border-bottom: 0; }
.info-list dt { font-size: .82rem; font-weight: 600; color: var(--muted); margin: 0; }
.info-list dd { margin: 0; font-weight: 550; }

/* 15. Historial d'incidències (vista client) ------------------------------ */
.sticky-col { position: sticky; top: calc(var(--topbar-h) + 20px); }
.history-group + .history-group { margin-top: 26px; }
.history-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.history-title .count { margin-left: auto; }
.ticket {
    position: relative; padding: 15px 16px 15px 20px; margin-bottom: 12px; background: #fff;
    border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.ticket::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--idle-dot); }
.ticket.is-warn::before { background: var(--warn-dot); }
.ticket.is-prog::before { background: var(--prog-dot); }
.ticket.is-ok::before { background: var(--ok-dot); }
.ticket:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ticket-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ticket-title { font-size: .95rem; font-weight: 650; line-height: 1.35; color: var(--ink); }
.ticket-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.ticket-meta .icon { width: 1em; height: 1em; }
.ticket-desc { margin-top: 8px; font-size: .84rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticket-solution { margin-top: 8px; padding: 8px 10px; border-radius: 9px; background: var(--ok-bg); color: var(--ok-fg); font-size: .82rem; }
.ticket-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }

/* 16. Autenticació -------------------------------------------------------- */
.auth-body { background: var(--surface); }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside {
    position: relative; overflow: hidden; color: #fff; padding: 56px 64px;
    display: flex; flex-direction: column; justify-content: space-between;
    background:
        radial-gradient(900px 500px at 105% -10%, rgba(147, 189, 220, .35), transparent 60%),
        radial-gradient(700px 500px at -10% 110%, rgba(72, 140, 191, .45), transparent 60%),
        linear-gradient(155deg, var(--brand-900) 0%, #1e4562 45%, var(--brand-600) 100%);
}
.auth-aside::before, .auth-aside::after { content: ''; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .12); pointer-events: none; }
.auth-aside::before { width: 520px; height: 520px; right: -300px; top: 22%; }
.auth-aside::after { width: 340px; height: 340px; right: -190px; top: calc(22% + 90px); border-color: rgba(255, 255, 255, .09); }
.auth-aside > * { position: relative; z-index: 1; }
.auth-logo img { width: 190px; height: auto; display: block; }
.auth-aside h2 { color: #fff; font-size: 2.35rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.12; max-width: 460px; }
.auth-aside .tagline { margin-top: 14px; font-size: 1.05rem; color: rgba(255, 255, 255, .78); max-width: 440px; line-height: 1.55; }
.auth-points { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .9); font-weight: 500; }
.auth-points .tick { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.auth-aside small { color: rgba(255, 255, 255, .55); font-size: .8rem; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 28px 32px; background: var(--surface); }
.auth-card { width: 100%; max-width: 410px; }
.auth-mobile-logo { display: none; margin-bottom: 26px; }
.auth-mobile-logo img { height: 56px; width: auto; }
.auth-title { font-size: 1.85rem; font-weight: 750; letter-spacing: -.025em; line-height: 1.15; }
.auth-sub { margin: 8px 0 30px; color: var(--muted); font-size: .98rem; }
.auth-card .form-group { margin-bottom: 20px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 26px; flex-wrap: wrap; }
.auth-row a { font-size: .87rem; font-weight: 600; }
.auth-note { font-size: .92rem; color: var(--ink-2); background: var(--brand-50); border: 1px solid var(--brand-100); padding: 14px 16px; border-radius: 12px; margin-bottom: 22px; }
.auth-status { font-size: .9rem; font-weight: 550; color: var(--ok-fg); background: var(--ok-bg); padding: 12px 14px; border-radius: 12px; margin-bottom: 20px; }
.auth-foot { margin-top: 34px; font-size: .8rem; color: var(--muted); text-align: center; }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; font-size: .87rem; color: var(--brand-600); cursor: pointer; }
.link-btn:hover { color: var(--brand-800); text-decoration: underline; }

/* 17. Utilitats i responsive --------------------------------------------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0 !important; }

@media (max-width: 1199.98px) {
    .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); }
    .sticky-col { position: static; }
    .company-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 991.98px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-mobile-logo { display: block; }
    .auth-main { justify-content: flex-start; padding-top: 56px; min-height: 100vh; }

    .nav-toggle { display: inline-flex; }
    .topbar-inner { gap: 12px; flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding-top: 10px; padding-bottom: 10px; }
    .topbar .brand-text { display: none; }
    .topnav {
        order: 5; width: 100%; margin: 0; padding: 4px 0 8px; flex-direction: column; align-items: stretch; display: none;
    }
    .topnav.is-open { display: flex; }
    .menu { margin-left: 0; }
    .menu-toggle .who { display: none; }
    .menu-toggle { padding-right: 8px; }
}
@media (max-width: 767.98px) {
    .page { padding: 22px 16px 48px; }
    .topbar-inner { padding-left: 16px; padding-right: 16px; }
    .page-title { font-size: 1.4rem; }
    .form-row, .modal-2col { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .modal-body { padding: 20px; }
    .modal-header, .modal-footer { padding-left: 20px; padding-right: 20px; }
    .dt-container .dt-search .dt-input { width: 100%; }
    .dt-container .dt-layout-row:first-child, .dt-container .dt-layout-row:last-child { padding: 14px 16px; }
    .dt-container .dt-layout-cell { width: 100%; }
    .dt-container .dt-layout-row { flex-wrap: wrap; gap: 10px; }
    .dt-container .dt-search { width: 100%; }
    .dt-container .dt-search .dt-input { flex: 1; }
    .info-list .info-row { grid-template-columns: 1fr; gap: 4px; }
    .auth-main { padding-left: 20px; padding-right: 20px; }
    .profile-hero { padding: 18px; }
}
@media (max-width: 575.98px) {
    .stats { gap: 12px; }
    .stat { padding: 14px; gap: 12px; }
    .stat-num { font-size: 1.4rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
    .card-header { padding: 16px; }
    .card-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
