/* =====================================================================
   StuxNet web · el mateix disseny que l'app (blau clar, lletra Inter, capçaleres blaves)
   (colors: res/values/colors.xml · formes: res/drawable/bg_*.xml)
   ===================================================================== */
:root {
    --bg: #F3F6FC;
    --card: #FFFFFF;
    --panel: #F5F8FE;
    --input: #F5F8FE;
    --input-stroke: #DCE5F5;
    --banner: #EAF1FF;
    --divider: #EEF2FA;
    --text: #0F1B3D;
    --text2: #4A5878;
    --muted: #8A97B4;
    --accent: #1F6BFF;
    --on-accent: #FFFFFF;
    --link: #1F6BFF;
    --error: #E8435E;
    --ok: #20B97A;
    --nav-selected: #FFFFFF;
    --tile-selected: #EAF1FF;
    --bar: #9CC0FF;
    --bar-selected: #FF5A6E;
    --grid: #E6ECF7;
    --gradient: linear-gradient(135deg, #3D86FF 0%, #1F6BFF 50%, #1452E0 100%);
    --gradient-v: linear-gradient(180deg, #3D86FF 0%, #1F6BFF 50%, #1452E0 100%);
    --badge: linear-gradient(135deg, #1F6BFF, #5AC8FA);
    --shadow: 0 3px 0 rgba(31, 107, 255, .08), 0 10px 28px rgba(31, 107, 255, .07);
    --radius-card: 24px;
    --radius-panel: 18px;
    --radius-input: 14px;
    --sidebar: 288px;
}

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter_regular.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 500 600; font-display: swap; src: url("../fonts/inter_semibold.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter_bold.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 800 900; font-display: swap; src: url("../fonts/inter_extrabold.otf") format("opentype"); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.icon { width: 24px; height: 24px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Marc: menú lateral + contingut ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex: none; background: var(--card); display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.sidebar-head { background: var(--gradient); padding: 28px 20px 20px; color: #fff; }
.sidebar-head .logo { width: 56px; height: 56px; border-radius: 16px; background: #fff; padding: 4px; display: block; }
.sidebar-head .who { margin-top: 14px; font-weight: 700; font-size: 17px; }
.sidebar-head .role { opacity: .9; font-size: 13px; }
.nav { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.nav a, .nav button {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 28px;
    color: var(--text2); text-decoration: none; font-weight: 500; background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.nav a:hover, .nav button:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--nav-selected); color: #fff; }
.nav .sep { height: 1px; background: var(--divider); margin: 8px 12px; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; color: var(--muted); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px; padding: 14px 24px; position: sticky; top: 0; z-index: 20;
    background: transparent; backdrop-filter: blur(8px); border-bottom: 1px solid var(--divider);
}
.topbar h1 { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--panel); }
.menu-btn { display: none; }
.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px; }
.content.narrow { max-width: 760px; }
.backdrop { display: none; }

@media (max-width: 960px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(15,27,61,.25); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15,27,61,.35); z-index: 25; }
    .menu-btn { display: inline-flex; }
    .content { padding: 16px; }
    .topbar { padding: 10px 12px; }
}

/* ---------- Targetes i requadres (bg_card / bg_panel) ---------- */
.card { background: var(--card); border-radius: var(--radius-card); padding: 24px; }
.card + .card, .card + .stack, .stack + .card { margin-top: 20px; }
.card-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.card-title .icon { color: var(--accent); }
.card-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.panel { background: var(--panel); border-radius: var(--radius-panel); padding: 18px; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2 > .card + .card { margin-top: 0; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--divider); margin: 12px 0; border: 0; }
.empty { background: var(--panel); border-radius: var(--radius-panel); padding: 18px; color: var(--muted); }

/* ---------- Avisos de la pàgina ---------- */
.flash { border-radius: 16px; padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.flash.ok { background: rgba(32, 185, 122, .12); color: var(--ok); }
.flash.error { background: rgba(232, 67, 94, .10); color: var(--error); }
.flash.info { background: var(--banner); color: var(--text2); }

/* ---------- Formularis (Widget.StuxNet.TextInput) ---------- */
.field { display: block; margin-top: 14px; }
.field:first-child { margin-top: 0; }
.label { display: block; color: var(--text2); font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input, select.input, textarea.input {
    width: 100%; background: var(--input); border: 1px solid var(--input-stroke); border-radius: var(--radius-input);
    color: var(--text); font: inherit; padding: 12px 14px; min-height: 48px;
}
textarea.input { min-height: 120px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input::placeholder { color: var(--muted); }
.field.has-error .input { border-color: var(--error); }
.field-error { color: var(--error); font-size: 13px; margin-top: 4px; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.fields2 .field:nth-child(2) { margin-top: 0; }
@media (max-width: 560px) { .fields2 { grid-template-columns: 1fr; } .fields2 .field:nth-child(2) { margin-top: 14px; } }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ---------- Botons (Widget.StuxNet.Button.*) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 22px;
    border-radius: 24px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
    background: var(--accent); color: var(--on-accent); transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.outline { background: transparent; color: var(--accent); border-color: var(--input-stroke); }
.btn.outline:hover { background: rgba(31, 107, 255, .06); }
.btn.danger { background: transparent; color: var(--error); border-color: rgba(232, 67, 94, .45); }
.btn.text { background: none; color: var(--accent); border: 0; padding: 8px 12px; min-height: 40px; }
.btn.block { width: 100%; }
.btn .icon { width: 20px; height: 20px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* ---------- Pantalles d'entrada ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 460px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo { width: 88px; height: 88px; border-radius: 24px; background: #fff; padding: 6px; }
.auth-brand h1 { margin-top: 12px; font-size: 26px; }
.auth-title { font-size: 26px; font-weight: 700; }
.auth-sub { color: var(--text2); margin: 6px 0 20px; }
.profile-option {
    display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 16px; text-decoration: none; color: var(--text);
    background: var(--input); border: 1px solid var(--input-stroke); margin-top: 12px;
}
.profile-option:hover { border-color: var(--accent); background: var(--tile-selected); }
.profile-option .badge { width: 52px; height: 52px; border-radius: 18px; background: var(--badge); display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.profile-option strong { display: block; font-size: 17px; }
.profile-option span { color: var(--muted); font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--banner); color: var(--text2); border-radius: 20px; padding: 6px 14px; font-size: 14px; }
.chip a { font-weight: 600; text-decoration: none; }

/* ---------- Recuadres de la fitxa (item_tile) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
    background: var(--panel); border-radius: var(--radius-panel); padding: 18px; text-decoration: none; color: var(--text);
    display: flex; flex-direction: column; gap: 8px; min-height: 132px; border: 2px solid transparent; transition: border-color .15s, background .15s;
    font: inherit; text-align: left; cursor: pointer; width: 100%;
}
a.tile:hover, button.tile:hover { border-color: rgba(31, 107, 255, .35); }
.tile .icon { color: var(--accent); width: 28px; height: 28px; }
.tile strong { font-size: 16px; }
.tile small { color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tile.selected { background: var(--tile-selected); border-color: var(--accent); }
.tile.add { border: 2px dashed var(--input-stroke); background: transparent; align-items: center; justify-content: center; color: var(--accent); }

/* ---------- Capçalera de pacient i fotos ---------- */
.avatar {
    width: 64px; height: 64px; border-radius: 50%; background: var(--banner); color: var(--accent); display: flex; align-items: center;
    justify-content: center; font-weight: 700; overflow: hidden; flex: none; font-size: 20px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 30px; }
.avatar.sm { width: 48px; height: 48px; font-size: 16px; }
.patient-head { display: flex; gap: 18px; align-items: center; }
.patient-head h2 { font-size: 22px; }
.patient-row { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); }
.patient-row:hover h3 { color: var(--accent); }
.patient-row h3 { font-size: 16px; }

/* ---------- Gràfics ---------- */
.period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--input-stroke); border-radius: 22px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--text2); font: inherit; font-weight: 600; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.seg button + button { border-left: 1px solid var(--input-stroke); }
.seg button.on { background: var(--tile-selected); color: var(--accent); }
.period-nav { flex: 1; display: flex; align-items: center; min-width: 260px; }
.period .range { flex: 1; text-align: center; color: var(--text2); font-weight: 500; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.chart-msg { color: var(--accent); margin-top: 12px; min-height: 22px; font-size: 14px; }
.chart { width: 100%; height: 240px; margin-top: 8px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .bar { cursor: pointer; }
.chart .bar:hover { filter: brightness(1.15); }
.chart-empty { color: var(--muted); text-align: center; padding: 70px 0; }
.chart-summary { color: var(--text2); margin-top: 8px; font-size: 14px; }
.chart-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* Filtre per tipus (item_type_filter) */
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.types.five { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
.type {
    background: var(--input); border: 1px solid var(--input-stroke); border-radius: 16px; min-height: 64px; padding: 6px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text); font: inherit; font-size: 12px;
}
.type.on { background: var(--tile-selected); border: 2px solid var(--accent); }
.type input { position: absolute; opacity: 0; pointer-events: none; }
.type:has(input:checked) { background: var(--tile-selected); border: 2px solid var(--accent); }
@media (max-width: 520px) { .types.five { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); } }

/* ---------- Llistes en requadres (avisos, consums, despeses, medicació) ---------- */
.box { background: var(--panel); border-radius: var(--radius-panel); padding: 18px; }
.box + .box { margin-top: 12px; }
.box-head { display: flex; align-items: center; gap: 10px; }
.box-head .icon { color: var(--accent); width: 20px; height: 20px; }
.box-head b { color: var(--text); }
.box-head .when { color: var(--muted); }
.box-body { white-space: pre-wrap; color: var(--text); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--divider); }
.box-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.box-line { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--divider); }
.box-line .big { color: var(--accent); font-size: 20px; font-weight: 700; margin-left: auto; }
a.box, button.box, div.box[role=button] { display: block; text-decoration: none; color: inherit; width: 100%; text-align: left; font: inherit; border: 0; cursor: pointer; }
a.box:hover, button.box:hover, div.box[role=button]:hover { box-shadow: inset 0 0 0 1px rgba(31, 107, 255, .35); }

/* Taula (historial d'EtG, files de detall) */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--divider); }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Fila de detall (finestra d'una barra) */
.detail-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--radius-panel); padding: 12px 16px; min-height: 56px; }
.detail-row + .detail-row { margin-top: 8px; }
.detail-row .icon { width: 22px; height: 22px; }
.detail-row b { display: block; }
.detail-row small { color: var(--muted); }
.detail-row .val { margin-left: auto; color: var(--accent); font-weight: 700; font-size: 17px; white-space: nowrap; }
.detail-total { text-align: right; font-weight: 700; margin-top: 10px; }

/* ---------- Finestres (dialog) ---------- */
dialog {
    background: var(--card); color: var(--text); border: 0; border-radius: var(--radius-card); padding: 0; width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(15, 27, 61, .45); }
.dlg { padding: 24px; overflow-y: auto; max-height: calc(100vh - 40px); }
.dlg h2 { font-size: 20px; margin-bottom: 12px; }
.dlg .actions { justify-content: flex-end; }

/* ---------- Mapa (Leaflet) ---------- */
.map { height: 340px; border-radius: var(--radius-panel); overflow: hidden; background: var(--panel); margin-top: 14px; }
.suggestions { margin-top: 8px; }
.suggestions button { display: block; width: 100%; text-align: left; background: var(--panel); border: 0; color: var(--text); padding: 12px 14px; border-radius: 14px; font: inherit; cursor: pointer; }
.suggestions button + button { margin-top: 6px; }
.suggestions button:hover { background: var(--tile-selected); }

/* Llista per triar (assignar usuaris / professionals) */
.pick { display: flex; align-items: center; gap: 14px; background: var(--panel); border-radius: var(--radius-panel); padding: 12px 16px; cursor: pointer; border: 2px solid transparent; }
.pick + .pick { margin-top: 8px; }
.pick:has(input:checked) { background: var(--tile-selected); border-color: var(--accent); }
.pick input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.pick .grow small { display: block; color: var(--muted); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; background: var(--banner); color: var(--text2); font-size: 12px; }
.pill.ok { color: var(--ok); }
.ok-text { color: var(--ok); font-weight: 700; }
.error-text { color: var(--error); font-weight: 700; }

/* Pàgines d'error */
.error-page { text-align: center; padding: 60px 16px; }
.error-page .code { font-size: 64px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Recuadres que es poden marcar (amics al grup social) */
label.tile { position: relative; }
label.tile input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
label.tile:has(input:checked) { background: var(--tile-selected); border-color: var(--accent); }
label.tile .state { font-size: 12px; color: var(--muted); }
label.tile:has(input:checked) .state { color: var(--accent); font-weight: 600; }
label.tile .state .on, label.tile:has(input:checked) .state .off { display: none; }
label.tile:has(input:checked) .state .on { display: inline; }
.tile .edit-link { position: absolute; top: 10px; right: 10px; }
.person-tile { align-items: center; text-align: center; }
.person-tile .avatar { margin-bottom: 4px; }
.tile small .icon { width: 14px; height: 14px; vertical-align: -2px; }

/* Verificació en dos passos */
.qr { width: 220px; height: 220px; margin: 16px auto 0; background: #fff; border-radius: 12px; padding: 8px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { font: 700 16px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--accent); background: var(--panel); padding: 8px 12px; border-radius: 10px; letter-spacing: .5px; }

/* Pestanyes amb enllaços (filtre per rol) */
.seg .seg-link { color: var(--text2); text-decoration: none; font-weight: 600; padding: 8px 16px; display: inline-flex; align-items: center; gap: 4px; min-height: 40px; }
.seg .seg-link + .seg-link { border-left: 1px solid var(--input-stroke); }
.seg .seg-link.on { background: var(--tile-selected); color: var(--accent); }
.seg { flex-wrap: wrap; }
.type .icon { width: 22px; height: 22px; color: var(--accent); }
@media (max-width: 600px) {
    .seg:has(.seg-link) { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .seg .seg-link { justify-content: center; }
    .seg .seg-link + .seg-link { border-left: 0; }
}

/* Tria d'idioma (pantalles d'entrada) */
.lang-links { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.lang-links a { color: var(--text2); text-decoration: none; font-size: 14px; padding: 8px 12px; border-radius: 999px; min-height: 36px; }
.lang-links a:hover { color: var(--text); }
.lang-links a[aria-current] { color: var(--accent); font-weight: 700; background: var(--tile-selected); }

/* Casella "Recorda aquest dispositiu" */
.check-line { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 4px; cursor: pointer; font-weight: 600; }
.check-line input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check-line small { display: block; font-weight: 400; color: var(--text2); font-size: 13px; margin-top: 2px; }

/* Notificacions al navegador: pregunta i avisos dins la pàgina */
.notif-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--tile-selected); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; }
.notif-banner > .icon { width: 24px; height: 24px; color: var(--accent); flex: none; }
.notif-banner small { display: block; color: var(--text2); font-size: 13px; margin-top: 2px; }
.notif-banner .grow { min-width: 200px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--card); border: 1px solid var(--accent); border-radius: 14px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(15,27,61,.18); cursor: pointer; }
.toast b { display: block; color: var(--text); }
.toast span { color: var(--text2); font-size: 14px; }
.live-flash { animation: liveflash 1.2s ease-out; }
@keyframes liveflash { from { background: rgba(31,107,255,.12); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .live-flash { animation: none; } }

/* Pestanyes amb icona i subratllat (desplaçables) */
.tabs { position: relative; display: flex; align-items: stretch; border-bottom: 1px solid var(--input-stroke); margin: 0 0 20px; }
.tabs-list { display: flex; gap: 4px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; flex: 1; }
.tabs-list::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 10px; padding: 14px 18px; color: var(--text2); text-decoration: none; font-weight: 600;
       font-size: 16px; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; border-radius: 10px 10px 0 0; }
.tab .icon { width: 22px; height: 22px; }
.tab:hover { color: var(--text); background: rgba(31,107,255,.05); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs-arrow { flex: none; width: 36px; border: 0; background: var(--bg); color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.tabs-arrow:hover { color: var(--text); }
.tabs-arrow[hidden] { display: none; }
.tabs-arrow .icon { width: 22px; height: 22px; }
@media (max-width: 600px) { .tab { padding: 12px 14px; font-size: 15px; gap: 8px; } }

/* Llistes de configuració */
.cfg-item { display: flex; gap: 14px; align-items: flex-start; }
.cfg-item .grow { min-width: 0; }
.cfg-item h3 { margin: 0; font-size: 16px; }
.cfg-item p { margin: 4px 0 0; color: var(--text2); white-space: pre-line; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--tile-selected); color: var(--text); font-size: 13px; }
button.chip { border: 1px solid var(--input-stroke); cursor: pointer; font: inherit; font-size: 13px; }
button.chip:hover { border-color: var(--accent); }
.var { color: var(--accent); font-weight: 700; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.type-dot { width: 44px; height: 44px; border-radius: 12px; background: var(--panel); display: flex; align-items: center; justify-content: center; flex: none; }
.type-dot .icon { width: 26px; height: 26px; }
.pick-list { max-height: 260px; overflow: auto; border: 1px solid var(--input-stroke); border-radius: 12px; padding: 6px; margin-top: 8px; }
.pick-list label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pick-list label:hover { background: var(--panel); }
.pick-list input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Recuadres d'avisos predefinits i d'ubicacions predefinides */
.preset-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 8px; }
button.tile { font: inherit; color: inherit; cursor: pointer; text-align: left; border: 1px solid transparent; width: 100%; }
button.tile:hover { border-color: var(--input-stroke); }
.tile.on { border-color: var(--accent) !important; background: var(--tile-selected); }
.tile.on > .icon { color: var(--accent); }
.tile small { white-space: normal; }

.link-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--input-stroke); text-underline-offset: 4px; }
.link-btn:hover { text-decoration-color: var(--accent); }

/* Selector de pacient amb cerca ("Fer canvis") */
.combo { position: relative; margin-top: 6px; }
.combo-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--input-stroke);
             background: var(--bg); color: var(--text); font: inherit; cursor: pointer; text-align: left; min-height: 60px; }
.combo-btn:hover, .combo-btn[aria-expanded="true"] { border-color: var(--accent); }
.combo-btn small { display: block; color: var(--text2); font-size: 13px; }
.combo-chevron { transform: rotate(90deg); transition: transform .15s; color: var(--text2); }
.combo-btn[aria-expanded="true"] .combo-chevron { transform: rotate(-90deg); }
.combo-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--panel); border-radius: 16px;
             box-shadow: 0 16px 40px rgba(15,27,61,.18); padding: 10px; border: 1px solid var(--input-stroke); }
.combo-search { display: flex; align-items: center; gap: 8px; border: 2px solid var(--accent); border-radius: 12px; padding: 8px 12px; background: var(--bg); }
.combo-search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; flex: 1; min-width: 0; }
.combo-search .icon { color: var(--text2); width: 20px; height: 20px; }
.combo-pop ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.combo-pop li a { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; color: var(--text); text-decoration: none; }
.combo-pop li a:hover, .combo-pop li a:focus { background: var(--tile-selected); outline: none; }
.combo-pop li a.on { background: var(--tile-selected); color: var(--accent); font-weight: 700; }

/* Manteniment (apartat tancat per l'administrador) */
.maint { text-align: center; padding: 28px 12px; }
.maint-ic { display: inline-flex; width: 64px; height: 64px; border-radius: 50%; align-items: center; justify-content: center; background: var(--tile-selected); color: var(--accent); }
.maint-ic .icon { width: 32px; height: 32px; }
.maint h2 { margin: 14px 0 6px; font-size: 19px; }
.maint p { margin: 6px auto 0; max-width: 520px; }
.tile.in-maint { opacity: .75; }
.tile.in-maint small { color: var(--warn, #FFC857); }
.maint-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: #1a1630; background: #FFC857; border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.maint-badge .icon { width: 14px; height: 14px; }

/* L'administrador dins del compte d'un altre */
.impersona { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #FFC857; color: #1a1630; padding: 10px 20px; }
.impersona > .icon { width: 22px; height: 22px; flex: none; }
.impersona small { display: block; font-size: 13px; opacity: .85; }
.impersona form { margin: 0; }
.impersona .btn { background: #1a1630; color: #fff; }
.impersona .btn .icon { color: #fff; }
.entra-com { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.maint-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-top: 8px; }
.maint-grid .pick + .pick { margin-top: 0; }
.maint-grid .pick > .icon { width: 22px; height: 22px; color: var(--accent); }
.maint-apartats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Desplegable d'ubicacions i avisos predefinits */
.combo-pop li button { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 14px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.combo-pop li button:hover, .combo-pop li button:focus { background: var(--tile-selected); outline: none; }
.combo-pop li button.on { background: var(--tile-selected); }
.combo-pop li button.on b { color: var(--accent); }
.combo-pop li button small { display: block; color: var(--text2); font-size: 13px; margin-top: 2px; }
.combo-ic { display: inline-flex; width: 40px; height: 40px; flex: none; align-items: center; justify-content: center; border-radius: 50%; background: var(--tile-selected); color: var(--accent); }
.combo-ic .icon { width: 20px; height: 20px; }
.combo-check { color: var(--accent); visibility: hidden; flex: none; }
.combo-pop li button.on .combo-check { visibility: visible; }
.combo-btn b.muted { font-weight: 500; color: var(--text2); }

/* Canvis pendents (botó «Aplica») */
.pend-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 20px; background: var(--accent); color: #fff; }
.pend-bar > .icon { width: 22px; height: 22px; flex: none; }
.pend-bar small { display: block; font-size: 13px; opacity: .85; }
.pend-bar .btn { background: #fff; color: var(--accent); }
.pend-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pend-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--tile-selected); }
.pend-list li.has-error { outline: 2px solid var(--error, #ff6b6b); }
.pend-list li small { display: block; margin-top: 4px; }
.pend-list form { margin: 0; }


/* =====================================================================
   Disseny nou (com l'app): menú i capçaleres blaus, targetes blanques amb ombra suau,
   pestanyes en una franja blava i accessos ràpids de colors
   ===================================================================== */
h1, h2, h3 { letter-spacing: -.01em; }
.card { box-shadow: var(--shadow); }
.box, .detail-row, .pick, .empty { border: 1px solid var(--divider); }
.tile { background: var(--card); border: 2px solid var(--divider); box-shadow: 0 2px 0 rgba(31,107,255,.05); }
.tile .icon { color: var(--accent); }
.avatar { background: var(--banner); color: var(--accent); }
.btn { border-radius: 16px; box-shadow: 0 4px 14px rgba(31,107,255,.22); }
.btn.outline, .btn.danger, .btn.text { box-shadow: none; }
.btn.outline { background: var(--card); }
.input:focus { box-shadow: 0 0 0 3px rgba(31,107,255,.15); }
.seg { border-color: var(--input-stroke); background: var(--card); }
.seg button.on, .seg .seg-link.on { background: var(--accent); color: #fff; }

/* Menú lateral blau (bg_drawer) */
.sidebar { background: var(--gradient-v); color: #fff; }
.sidebar-head { background: transparent; padding: 28px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.16); }
.sidebar-head .logo { width: 56px; height: 56px; border-radius: 16px; background: none; padding: 0; }
.nav a, .nav button { color: rgba(255,255,255,.92); border-radius: 16px; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav a.active { background: #fff; color: var(--accent); font-weight: 700; box-shadow: 0 6px 16px rgba(10,40,120,.25); }
.nav .sep { background: rgba(255,255,255,.18); }
.sidebar-foot { color: rgba(255,255,255,.7); }

/* Barra superior blava (bg_toolbar) */
.topbar { background: var(--gradient); color: #fff; border-bottom: 0; box-shadow: 0 6px 20px rgba(31,107,255,.18); }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:hover { background: rgba(31,107,255,.08); }

/* Salutació del tauler (bg_header): franja blava amb les puntes de baix arrodonides */
.hero { position: relative; overflow: hidden; background: var(--gradient); color: #fff; border-radius: var(--radius-card);
        margin: 0 0 22px; padding: 26px 28px 30px; box-shadow: 0 10px 28px rgba(31,107,255,.22); }
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -110px; top: -120px; border-radius: 50%;
               border: 38px solid rgba(255,255,255,.07); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h2 { font-size: 26px; font-weight: 800; }
.hero p { margin: 4px 0 0; color: rgba(255,255,255,.85); }
.hero .btn { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; border: 1px solid rgba(255,255,255,.35); }
.hero .btn:hover { background: rgba(255,255,255,.28); }
@media (max-width: 960px) { .hero { padding: 22px 20px 26px; } }
/* Una sola columna (p. ex. el pacient, que no té «Últimes accions»): ocupa tota l'amplada */
.grid2 > :only-child { grid-column: 1 / -1; }
.content { max-width: 1280px; }

/* Accessos ràpids (item_quick_tile): rajoles de colors */
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.quick a { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 108px; padding: 14px;
           border-radius: 20px; color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; line-height: 1.25;
           box-shadow: 0 6px 16px rgba(15,27,61,.12); transition: transform .15s, box-shadow .15s; }
.quick a:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(15,27,61,.16); }
.quick .qi { width: 36px; height: 36px; border-radius: 12px; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; }
.quick .qi .icon { width: 20px; height: 20px; color: #fff; }
.q-sky { background: linear-gradient(135deg, #5AC8FA, #2EA8F0); }
.q-green { background: linear-gradient(135deg, #4CD9A0, #20B97A); }
.q-coral { background: linear-gradient(135deg, #FF8A80, #FF5A6E); }
.q-amber { background: linear-gradient(135deg, #FFC861, #FFA41B); }
.q-violet { background: linear-gradient(135deg, #A98BFF, #7C5CFF); }
.q-pink { background: linear-gradient(135deg, #FF8CC6, #F0559D); }

/* Pestanyes en una franja blava amb la triada en blanc (bg_tabs / bg_tab_pill) */
.tabs { background: var(--gradient); border: 0; border-radius: 18px; padding: 6px; margin: 0 0 20px; box-shadow: 0 6px 18px rgba(31,107,255,.18); }
.tab { color: rgba(255,255,255,.9); border: 0; border-radius: 13px; margin: 0; padding: 10px 16px; font-size: 15px; }
.tab:hover { color: #fff; background: rgba(255,255,255,.14); }
.tab.on { background: #fff; color: var(--accent); }
.tabs-arrow { background: transparent; color: #fff; }
.tabs-arrow:hover { color: #fff; background: rgba(255,255,255,.14); border-radius: 10px; }

/* Pantalles d'entrada (bg_auth): franja blava a dalt i la targeta blanca a sobre */
body.auth-body { background: var(--bg); }
body.auth-body::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 340px; background: var(--gradient);
                         border-radius: 0 0 32px 32px; z-index: -1; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 14px; color: #fff; text-align: left; }
.auth-brand .logo { width: 64px; height: 64px; border-radius: 18px; background: none; padding: 0; }
.auth-brand h1 { margin: 0; font-size: 26px; font-weight: 800; }
.auth-brand small { display: block; font-size: 12px; font-weight: 700; letter-spacing: .14em; opacity: .85; text-transform: uppercase; }
.auth .card { box-shadow: 0 18px 50px rgba(15,27,61,.14); }
.auth-title { text-align: center; }
.auth-sub { text-align: center; }
.profile-option { background: var(--card); border: 1.5px solid var(--input-stroke); }
.profile-option:hover { border-color: var(--accent); background: var(--tile-selected); }
.lang-links a { background: rgba(255,255,255,.0); }

/* Casella amb text (p. ex. usuaris que veuen la ubicació pública) */
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
