/* ============================================================
   Pisão 360 — Design System
   Tokens da marca + componentes base
   ============================================================ */

:root {
    /* Marca */
    --p360-primary: #877D38;          /* dourado/azeitona */
    --p360-primary-600: #756c30;
    --p360-primary-700: #5f5827;
    --p360-primary-100: #ece9da;      /* fundo suave do primário */
    --p360-on-primary: #FFFFFF;

    /* Superfícies */
    --p360-surface: #FFFFFF;
    --p360-background: #F3F4F6;
    --p360-background-2: #e7e9ee;     /* faixa "afundada" — um tom acima do fundo da página */
    --p360-border: #e5e7eb;

    /* Funcionais */
    --p360-success: #16a34a;
    --p360-success-bg: #dcfce7;
    --p360-danger: #dc2626;
    --p360-danger-bg: #fee2e2;
    --p360-warning: #d97706;
    --p360-warning-bg: #fef3c7;
    --p360-info: #2563eb;
    --p360-info-bg: #dbeafe;

    /* Texto */
    --p360-text: #1f2937;
    --p360-text-muted: #6b7280;

    /* Forma / elevação */
    --p360-radius: 0.5rem;
    --p360-radius-sm: 0.25rem;
    --p360-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
    --p360-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

    /* Layout */
    --p360-header-h: 56px;
    --p360-nav-h: 46px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--p360-text);
    background: var(--p360-background);
}

h1, h2, h3, h4, h5 { margin: 0 0 .5rem; font-weight: 600; }
h1:focus { outline: none; }
a { color: var(--p360-primary-700); text-decoration: none; }
a:hover { text-decoration: underline; }
code { color: #c02d76; }

/* ---------- Validação de formulários ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--p360-success); }
.invalid { outline: 1px solid var(--p360-danger); }
.validation-message { color: var(--p360-danger); }

/* ---------- App shell ---------- */
.p360-app { min-height: 100vh; display: flex; flex-direction: column; }

.p360-header {
    height: var(--p360-header-h);
    background: var(--p360-primary);
    color: var(--p360-on-primary);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    box-shadow: var(--p360-shadow);
    position: sticky; top: 0; z-index: 40;
}
.p360-header__brand { font-size: 1.15rem; font-weight: 700; letter-spacing: .3px; color: var(--p360-on-primary); }
.p360-header__brand:hover { text-decoration: none; }
.p360-header__spacer { flex: 1; }
.p360-header__user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.p360-header__avatar {
    width: 32px; height: 32px; border-radius: 9999px;
    background: rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 600;
}

/* ---------- Top-nav de módulos ---------- */
.p360-nav {
    height: var(--p360-nav-h);
    background: var(--p360-surface);
    border-bottom: 1px solid var(--p360-border);
    display: flex; align-items: stretch; gap: .25rem;
    padding: 0 .5rem;
    overflow-x: auto; white-space: nowrap;
    position: sticky; top: var(--p360-header-h); z-index: 30;
}
.p360-nav__link {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: 0 .85rem; font-size: .9rem; color: var(--p360-text-muted);
    border-bottom: 3px solid transparent; text-decoration: none;
}
.p360-nav__link:hover { color: var(--p360-primary); text-decoration: none; background: var(--p360-background); }
.p360-nav__link.active {
    color: var(--p360-primary-700); font-weight: 600;
    border-bottom-color: var(--p360-primary);
}
.p360-nav__link i { width: 1.1em; text-align: center; }

/* ---------- Conteúdo ---------- */
.p360-content { flex: 1; min-width: 0; padding: 1.25rem; }

/* ---------- Cartão ---------- */
.p360-card {
    background: var(--p360-surface);
    border: 1px solid var(--p360-border);
    border-radius: var(--p360-radius);
    box-shadow: var(--p360-shadow);
    padding: 1rem;
}
.p360-card__title { font-weight: 600; margin-bottom: .5rem; }

/* Grelha de módulos (dashboard) */
.p360-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.p360-module-card {
    background: var(--p360-surface);
    border: 1px solid var(--p360-border);
    border-left: 4px solid var(--p360-primary);
    border-radius: var(--p360-radius);
    box-shadow: var(--p360-shadow);
    padding: 1rem; display: flex; gap: .85rem; align-items: center;
    color: var(--p360-text); transition: box-shadow .15s, transform .15s;
}
.p360-module-card:hover { box-shadow: var(--p360-shadow-lg); transform: translateY(-2px); text-decoration: none; }
.p360-module-card__icon {
    width: 42px; height: 42px; border-radius: var(--p360-radius-sm);
    background: var(--p360-primary-100); color: var(--p360-primary-700);
    display: grid; place-items: center; font-size: 1.2rem; flex: none;
}
.p360-module-card__label { font-weight: 600; }
.p360-module-card__hint { font-size: .8rem; color: var(--p360-text-muted); }

/* ---------- Botões ---------- */
.p360-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem; border-radius: var(--p360-radius-sm);
    border: 1px solid transparent; font-size: .9rem; font-weight: 500; cursor: pointer;
}
.p360-btn:disabled { opacity: .45; cursor: not-allowed; }
.p360-btn--primary { background: var(--p360-primary); color: var(--p360-on-primary); }
.p360-btn--primary:hover { background: var(--p360-primary-600); }
.p360-btn--ghost { background: transparent; border-color: var(--p360-border); color: var(--p360-text); }
.p360-btn--ghost:hover { background: var(--p360-background); }
.p360-btn--success { background: var(--p360-success); color: #fff; }
.p360-btn--danger { background: var(--p360-danger); color: #fff; }

/* ---------- Badges ---------- */
.p360-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .55rem; border-radius: 9999px; font-size: .75rem; font-weight: 600;
}
.p360-badge--success { background: var(--p360-success-bg); color: var(--p360-success); }
.p360-badge--danger { background: var(--p360-danger-bg); color: var(--p360-danger); }
.p360-badge--warning { background: var(--p360-warning-bg); color: var(--p360-warning); }
.p360-badge--info { background: var(--p360-info-bg); color: var(--p360-info); }
.p360-badge--neutral { background: var(--p360-background); color: var(--p360-text-muted); }

/* ---------- Backoffice ---------- */
.p360-admin-link {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .6rem; border-radius: var(--p360-radius-sm);
    color: var(--p360-text); font-size: .9rem;
}
.p360-admin-link:hover { background: var(--p360-background); text-decoration: none; }
.p360-admin-link.active { background: var(--p360-primary-100); color: var(--p360-primary-700); font-weight: 600; }
.p360-admin-link--disabled { color: var(--p360-text-muted); cursor: default; }
.p360-admin-link i { width: 1.1em; text-align: center; }

.p360-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.p360-table th, .p360-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--p360-border); vertical-align: middle; }
.p360-table th { color: var(--p360-text-muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.p360-table tbody tr:hover { background: var(--p360-background); }

/* Ações de linha: ação principal + menu "⋮" (mais ações) */
.p360-rowactions { position: relative; display: inline-flex; align-items: center; gap: .35rem; }
.p360-rowactions--open { z-index: 62; }
.p360-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--p360-radius-sm);
    background: transparent; color: var(--p360-text-muted); cursor: pointer;
}
.p360-iconbtn:hover { background: var(--p360-background); color: var(--p360-text); }
.p360-menu-backdrop { position: fixed; inset: 0; z-index: 60; }
.p360-menu {
    position: absolute; top: calc(100% + 4px); right: 0; min-width: 170px;
    background: var(--p360-surface); border: 1px solid var(--p360-border);
    border-radius: var(--p360-radius); box-shadow: var(--p360-shadow-lg);
    padding: .25rem; z-index: 63; display: flex; flex-direction: column;
}
.p360-menu button {
    display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
    padding: .45rem .6rem; border: none; background: transparent; border-radius: var(--p360-radius-sm);
    font-size: .88rem; color: var(--p360-text); cursor: pointer;
}
.p360-menu button:hover { background: var(--p360-background); }
.p360-menu button i { width: 1.1em; text-align: center; }
.p360-menu .p360-menu__danger { color: var(--p360-danger); }

.p360-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--p360-border); margin-bottom: 1rem; }
.p360-tab { padding: .5rem .85rem; cursor: pointer; border-bottom: 3px solid transparent; color: var(--p360-text-muted); }
.p360-tab:hover { color: var(--p360-primary); }
.p360-tab.active { color: var(--p360-primary-700); border-bottom-color: var(--p360-primary); font-weight: 600; }

/* ---------- Vista do utente (shell: sidebar + tabs de módulo) ---------- */
.p360-patient { display: flex; gap: 1.25rem; align-items: flex-start; }
.p360-patient__aside { width: 260px; flex: none; }
.p360-patient__main { flex: 1; min-width: 0; }
/* Espaço entre a barra de módulos (ou banner de alertas) e o conteúdo — ritmo vertical de 1rem,
   igual ao espaçamento entre cards; vale com ou sem faixa de sub-separadores */
.p360-modpanel { padding-top: 1rem; }

.p360-kv { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; padding: .12rem 0; }
.p360-kv .p360-kv__label { margin-bottom: 0; }

/* Separadores de módulo (Admissão / Médico / Enfermagem …) — barra branca elevada */
.p360-modtabs {
    display: flex; gap: .15rem; align-items: stretch;
    background: var(--p360-surface);
    border: 1px solid var(--p360-border);
    border-radius: var(--p360-radius);
    box-shadow: var(--p360-shadow);
    padding: 0 .35rem;
    overflow-x: auto; white-space: nowrap;
}
.p360-modtab {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .6rem .85rem; font-size: .9rem; color: var(--p360-text-muted);
    border-bottom: 3px solid transparent; text-decoration: none;
}
.p360-modtab:hover { color: var(--p360-primary); text-decoration: none; }
.p360-modtab--active { color: var(--p360-primary-700); font-weight: 600; border-bottom-color: var(--p360-primary); }
.p360-modtab i { width: 1.1em; text-align: center; }

/* Sub-separadores dentro de um módulo (Registo / Medicação / …) — faixa cinza destacada */
.p360-subtabs {
    display: flex; flex-wrap: wrap; gap: .15rem; align-items: stretch;
    background: var(--p360-background-2);
    border: 1px solid var(--p360-border);
    border-radius: var(--p360-radius);
    padding: .2rem .45rem 0;
    margin-bottom: .75rem;   /* respiração entre a faixa de sub-tabs e o conteúdo (como as .dash-tabs) */
}
.p360-subtab {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .8rem; cursor: pointer; font-size: .88rem;
    background: none; border: none; border-bottom: 3px solid transparent; color: var(--p360-text-muted);
}
.p360-subtab:hover { color: var(--p360-primary); }
.p360-subtab--active { color: var(--p360-primary-700); border-bottom-color: var(--p360-primary); font-weight: 600; }

@media (max-width: 820px) {
    .p360-patient { flex-direction: column; }
    .p360-patient__aside { width: 100%; }
}

/* Grelha de formulário responsiva (colapsa para 1 coluna em ecrãs estreitos) */
.p360-formgrid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.p360-formgrid .p360-field { margin-bottom: 0; }
.p360-formgrid .col-span-2 { grid-column: 1 / -1; }

/* Tabela responsiva: scroll horizontal em vez de rebentar o layout no telemóvel */
.p360-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Utilitários de layout partilhados (extraídos dos *.razor.css scoped da rollout MVVM) */
.p360-row-between { display: flex; justify-content: space-between; align-items: center; }
.p360-muted { color: var(--p360-text-muted); }

/* Layout padrão dos separadores de registo: editor à esquerda, Histórico Diário à direita */
.p360-registo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: stretch; }
@media (max-width: 1100px) { .p360-registo-grid { grid-template-columns: 1fr; align-items: start; } }

/* O card de registo (1.ª coluna) iguala a altura do Histórico Diário (2.ª coluna): o card vira
   coluna flex e o editor de texto cresce para preencher, em vez de deixar espaço vazio por baixo
   do botão. Aplica-se a todas as áreas que usam esta grelha (S. Social, Enfermagem, Médico, Psicologia). */
.p360-registo-grid > .p360-card:first-child { display: flex; flex-direction: column; }
.p360-registo-grid > .p360-card:first-child .p360-rte { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.p360-registo-grid > .p360-card:first-child .p360-rte__area { flex: 1 1 auto; max-height: none; }

/* Editor de texto rico (WYSIWYG) */
.p360-rte { border: 1px solid var(--p360-border); border-radius: var(--p360-radius-sm); overflow: hidden; background: var(--p360-surface); }
.p360-rte__toolbar { display: flex; flex-wrap: wrap; gap: .15rem; padding: .3rem; border-bottom: 1px solid var(--p360-border); background: var(--p360-background); }
.p360-rte__toolbar button, .p360-rte__color {
    display: inline-flex; align-items: center; gap: .25rem; min-width: 28px; height: 28px; justify-content: center;
    border: 1px solid transparent; border-radius: var(--p360-radius-sm); background: transparent; cursor: pointer;
    font-size: .85rem; color: var(--p360-text);
}
.p360-rte__toolbar button:hover, .p360-rte__color:hover { background: var(--p360-surface); border-color: var(--p360-border); }
.p360-rte__color { position: relative; overflow: hidden; padding: 0 .4rem; }
.p360-rte__color input[type=color] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.p360-rte__area { padding: .55rem .65rem; font-size: .9rem; line-height: 1.5; outline: none; overflow-y: auto; max-height: 360px; }
.p360-rte__area:focus { box-shadow: inset 0 0 0 2px var(--p360-primary-100); }

/* Render do texto rico (no histórico) */
.p360-rich { white-space: normal; }
.p360-rich p { margin: 0 0 .35rem; }
.p360-rich ul, .p360-rich ol { margin: .25rem 0 .25rem 1.25rem; }
.p360-rich mark { padding: 0 .1em; }

/* Indicadores numéricos (resumo de ocupação) */
.p360-stat { background: var(--p360-background); border-radius: var(--p360-radius-sm); padding: .6rem .75rem; text-align: center; }
.p360-stat__num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.p360-stat__label { font-size: .75rem; color: var(--p360-text-muted); text-transform: uppercase; letter-spacing: .03em; }

/* Barra de progresso de ocupação */
.p360-bar { height: 8px; border-radius: 4px; background: var(--p360-background); overflow: hidden; }
.p360-bar__fill { height: 100%; background: var(--p360-primary); transition: width .2s; }

/* Paginação de listas (componente PagerBar) */
.p360-pager { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .6rem; }
.p360-pager__info { font-size: .8rem; color: var(--p360-text-muted); min-width: 9ch; text-align: center; }

/* Modal largo (ex.: rastreio do lote — vista densa de dados) */
.p360-modal.p360-modal--wide { max-width: 920px; }

/* Rastreio do lote: resumo (KPIs) + chips de filtro por tipo de movimento */
.trace-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 640px) { .trace-kpis { grid-template-columns: repeat(2, 1fr); } }
.trace-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin: .7rem 0 .5rem; }
.trace-chip {
    border: 1px solid var(--p360-border); background: var(--p360-surface); color: var(--p360-text-muted);
    border-radius: 999px; padding: .25rem .75rem; font-size: .82rem; cursor: pointer; transition: all .15s;
}
.trace-chip:hover { border-color: var(--p360-primary); color: var(--p360-primary); }
.trace-chip.is-active { background: var(--p360-primary); border-color: var(--p360-primary); color: #fff; }

/* ---------- Modal ---------- */
.p360-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: grid; place-items: center; z-index: 60; padding: 1rem;
}
.p360-modal {
    background: var(--p360-surface); border-radius: var(--p360-radius);
    box-shadow: var(--p360-shadow-lg); width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
}
.p360-modal__header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .85rem 1rem; border-bottom: 1px solid var(--p360-border); font-weight: 600;
}
.p360-modal__body { padding: 1rem; }
.p360-modal__footer {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding: .85rem 1rem; border-top: 1px solid var(--p360-border);
}
.p360-modal__close { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--p360-text-muted); }

/* ---------- Formulário ---------- */
.p360-field { margin-bottom: .85rem; }
.p360-field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .25rem; color: var(--p360-text); }
.p360-input {
    width: 100%; padding: .5rem .6rem; border: 1px solid var(--p360-border);
    border-radius: var(--p360-radius-sm); font-size: .9rem; background: var(--p360-surface);
}
.p360-input:focus { outline: 2px solid var(--p360-primary-100); border-color: var(--p360-primary); }
.p360-checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.p360-check {
    display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem;
    border: 1px solid var(--p360-border); border-radius: 9999px; font-size: .82rem; cursor: pointer;
}
.p360-check input { accent-color: var(--p360-primary); }
.p360-kv__label { font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--p360-text-muted); margin-bottom: .15rem; }

/* ---------- Placeholder "em construção" ---------- */
.p360-placeholder {
    display: grid; place-items: center; text-align: center;
    min-height: 50vh; color: var(--p360-text-muted);
}
.p360-placeholder i { font-size: 3rem; color: var(--p360-primary); margin-bottom: 1rem; }

/* ---------- Splash de carregamento ---------- */
.p360-splash { display: grid; place-items: center; min-height: 100vh; gap: 1rem; }
.p360-splash__brand { font-size: 2rem; font-weight: 700; color: var(--p360-primary); }

/* ---------- Estado de erro Blazor ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: var(--p360-warning-bg); color: var(--p360-text);
    bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box;
    display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: #fff; }
.blazor-error-boundary::after { content: "Ocorreu um erro."; }

.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 0 auto; }
.loading-progress circle {
    fill: none; stroke: var(--p360-border); stroke-width: .6rem; transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--p360-primary); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text { text-align: center; font-weight: 600; color: var(--p360-text-muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "A carregar"); }

@media (max-width: 640px) {
    .p360-header__user span { display: none; }
}

/* ---------- Toasts (feedback global) ---------- */
.p360-toasts {
    position: fixed; top: 1rem; right: 1rem; z-index: 200;
    display: flex; flex-direction: column; gap: .55rem;
    max-width: min(380px, calc(100vw - 2rem)); pointer-events: none;
}

.p360-toast {
    position: relative; overflow: hidden;
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .7rem .85rem .8rem;
    border-radius: var(--p360-radius);
    background: var(--p360-surface);
    border: 1px solid var(--p360-border);
    border-left: 4px solid var(--p360-text-muted);
    box-shadow:
        0 1px 2px rgba(17, 24, 39, .06),
        0 8px 18px -6px rgba(17, 24, 39, .16);
    font-size: .9rem; color: var(--p360-text); pointer-events: auto;
    transition: transform .14s ease-out, box-shadow .14s ease-out;
    animation: p360-toast-in .22s cubic-bezier(.2, .8, .2, 1) both;
}

.p360-toast:hover {
    transform: translateY(-1px);
    box-shadow:
        0 2px 4px rgba(17, 24, 39, .08),
        0 12px 24px -6px rgba(17, 24, 39, .2);
}

/* ícone num badge circular tonal por nível */
.p360-toast__icon {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 1.85rem; height: 1.85rem; margin-top: .05rem;
    border-radius: 999px;
    background: var(--p360-background); color: var(--p360-text-muted);
    font-size: 1rem; line-height: 1;
}

.p360-toast__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.p360-toast__title { font-weight: 600; font-size: .9rem; line-height: 1.25; color: var(--p360-text); }
.p360-toast__text { color: var(--p360-text-muted); font-size: .85rem; line-height: 1.35; word-wrap: break-word; overflow-wrap: anywhere; }

.p360-toast__close {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; margin: -.15rem -.2rem 0 0;
    background: none; border: none; border-radius: var(--p360-radius-sm);
    cursor: pointer; color: var(--p360-text-muted);
    font-size: 1.15rem; line-height: 1;
    transition: background .12s ease-out, color .12s ease-out;
}
.p360-toast__close:hover { background: var(--p360-background); color: var(--p360-text); }
.p360-toast__close:focus-visible { outline: 2px solid var(--p360-primary); outline-offset: 1px; }

/* barra de progresso de auto-dismiss (4s) — pausa no hover para dar controlo ao clínico */
.p360-toast__bar {
    position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
    transform-origin: left center;
    background: var(--p360-text-muted);
    animation: p360-toast-bar 4s linear forwards;
}
.p360-toast:hover .p360-toast__bar { animation-play-state: paused; }

/* ---- variantes por nível ---- */
.p360-toast--success { border-left-color: var(--p360-success); }
.p360-toast--success .p360-toast__icon { background: var(--p360-success-bg); color: var(--p360-success); }
.p360-toast--success .p360-toast__bar { background: var(--p360-success); }

.p360-toast--error { border-left-color: var(--p360-danger); }
.p360-toast--error .p360-toast__icon { background: var(--p360-danger-bg); color: var(--p360-danger); }
.p360-toast--error .p360-toast__bar { background: var(--p360-danger); }

.p360-toast--warning { border-left-color: var(--p360-warning); }
.p360-toast--warning .p360-toast__icon { background: var(--p360-warning-bg); color: var(--p360-warning); }
.p360-toast--warning .p360-toast__bar { background: var(--p360-warning); }

.p360-toast--info { border-left-color: var(--p360-info); }
.p360-toast--info .p360-toast__icon { background: var(--p360-info-bg); color: var(--p360-info); }
.p360-toast--info .p360-toast__bar { background: var(--p360-info); }

@keyframes p360-toast-in {
    from { opacity: 0; transform: translateX(1rem); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes p360-toast-bar {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* acessibilidade: respeitar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .p360-toast { animation: none; transition: none; }
    .p360-toast:hover { transform: none; }
    .p360-toast__bar { animation: none; transform: scaleX(1); opacity: .45; }
}

/* ---------- Spinner em ações (botões a gravar/processar) ---------- */
.p360-spin { animation: p360-spin .7s linear infinite; }
@keyframes p360-spin { to { transform: rotate(360deg); } }

/* ---------- Grelha do blister (mapa de tomas) ---------- */
.p360-bgrid { overflow-x: auto; margin: .1rem 0 .2rem; }
.p360-bgrid__grid { display: grid; gap: 4px; align-items: stretch; }
.p360-bgrid__day { text-align: center; padding: 3px 0; border-radius: var(--p360-radius-sm); }
.p360-bgrid__day--today { background: var(--p360-info-bg); }
.p360-bgrid__day-d { font-size: .66rem; font-weight: 600; color: var(--p360-text-muted); }
.p360-bgrid__day-dt { font-size: .6rem; color: var(--p360-text-muted); }
.p360-bgrid__day--today .p360-bgrid__day-d, .p360-bgrid__day--today .p360-bgrid__day-dt { color: var(--p360-info); }
.p360-bgrid__moment { position: sticky; left: 0; z-index: 1; background: var(--p360-surface); display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: .74rem; font-weight: 500; }
.p360-bgrid__cell { min-width: 0; min-height: 34px; border-radius: var(--p360-radius-sm); padding: 4px; display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--p360-border); background: var(--p360-surface); }
.p360-bgrid__cell--empty { border-style: dashed; background: transparent; }
.p360-bgrid__chip { display: flex; align-items: center; justify-content: space-between; gap: 6px; max-width: 100%; border-radius: var(--p360-radius-sm); padding: 2px 8px; font-size: .68rem; font-weight: 500; color: var(--p360-text); }
.p360-bgrid__chip:hover { filter: brightness(.97); }
.p360-bgrid__chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p360-bgrid__chip-qty { flex: none; font-weight: 700; font-size: .64rem; opacity: .9; }
.p360-bgrid__chip-qty.is-one { font-weight: 400; opacity: .4; }
.p360-bgrid__legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .4rem; font-size: .72rem; color: var(--p360-text-muted); }
.p360-bgrid__legend-item { display: inline-flex; align-items: center; gap: 6px; }
.p360-bgrid__legend-sw { flex: none; width: 11px; height: 11px; border-radius: 3px; }
/* Dias/células já preparados (cobertos por um blister) — realce verde "Preparado" (claro vs. proposta). */
.p360-bgrid__day--covered { background: var(--p360-success-bg); }
.p360-bgrid__day--covered .p360-bgrid__day-d, .p360-bgrid__day--covered .p360-bgrid__day-dt { color: var(--p360-success); }
.p360-bgrid__day-prep { font-size: .52rem; font-weight: 700; color: var(--p360-success); line-height: 1.1; margin-top: 1px; white-space: nowrap; }
.p360-bgrid__day-prep i { font-size: .5rem; }
.p360-bgrid__cell--covered { background: var(--p360-success-bg); border-color: var(--p360-success); }
.p360-bgrid__cell--covered .p360-bgrid__chip { box-shadow: 0 0 0 1px rgba(22, 163, 74, .25); } /* destaca o chip sobre o fundo verde */

/* ---------- Folha de preparação (PIM): faixa de filtros + progresso + faixa por fármaco ---------- */
.p360-chips-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .6rem; }
.p360-chips-filter__prog { margin-left: auto; flex: 0 1 240px; min-width: 160px; align-self: center; }
.p360-chips-filter__prog-head { display: flex; justify-content: space-between; gap: .75rem; font-size: .72rem; color: var(--p360-text-muted); margin-bottom: .2rem; white-space: nowrap; }
.p360-chips-filter__prog-val { font-weight: 600; color: var(--p360-text); }
.p360-chip-filter { font-size: .8rem; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--p360-border); background: var(--p360-surface); color: var(--p360-text-muted); cursor: pointer; }
.p360-chip-filter:hover { color: var(--p360-text); }
.p360-chip-filter--active { background: var(--p360-info-bg); color: var(--p360-info); border-color: var(--p360-info-bg); font-weight: 600; }
.p360-card--done { opacity: .68; padding: .5rem .85rem; }
.p360-card--done:hover { opacity: 1; }
.p360-flines { display: flex; flex-direction: column; gap: .3rem; margin-top: .55rem; }
.p360-fline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .4rem .55rem; border-radius: var(--p360-radius-sm); background: var(--p360-background); border-left: 3px solid var(--p360-text-muted); }
.p360-fline--ok { border-left-color: var(--p360-success); }
.p360-fline--warn { border-left-color: var(--p360-warning); }
.p360-fline--danger { border-left-color: var(--p360-danger); }
.p360-fline--side { background: transparent; margin-left: .8rem; }
.p360-fline__sw { width: 13px; height: 13px; border-radius: 50%; flex: none; border: 1.5px solid var(--p360-border); }
.p360-fline__name { font-size: .92rem; }
.p360-fline__gap { flex: 1 1 auto; }
.p360-fline__total { font-size: .82rem; color: var(--p360-text); }
.p360-fline__lot { font-size: .78rem; color: var(--p360-text-muted); }
.p360-fline__act { display: inline-flex; gap: .25rem; }
.p360-fline__note { font-size: .78rem; color: var(--p360-danger); margin: -.1rem 0 .15rem 1.2rem; }
.p360-flines__group { font-size: .74rem; font-weight: 600; color: var(--p360-text-muted); text-transform: uppercase; letter-spacing: .03em; margin-top: .35rem; }

/* Atividades — vista Lista do calendário (FullCalendar): conteúdo rico do evento. */
.atvcal-li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.atvcal-li__title { font-weight: 600; }
.atvcal-li .atvcal-cat { font-size: .66rem; border: 1px solid; border-radius: 1rem; padding: .04rem .45rem; font-weight: 600; }
.atvcal-li__meta { color: var(--p360-text-muted); font-size: .8rem; display: inline-flex; align-items: center; gap: .35rem; }
.atvcal-li__status { margin-left: auto; font-size: .72rem; color: var(--p360-text-muted); }
.atvcal-li .atvcal-sep { color: #cbd5e1; }

/* Atividades — cards do calendário (Mês/Semana/Dia): barra da categoria à esquerda + fundo claro + estado. */
#atividades-cal .fc-event, #atividades-cal-residente .fc-event { border-width: 0 0 0 4px; border-radius: 4px; }
#atividades-cal .fc-event .fc-event-main, #atividades-cal-residente .fc-event .fc-event-main { padding: 0; }
/* Recorta o que não cabe (eventos curtos) e dá um pouco mais de altura por hora para o card respirar. */
#atividades-cal .fc-timegrid-event, #atividades-cal-residente .fc-timegrid-event { overflow: hidden; }
#atividades-cal .fc-timegrid-slot, #atividades-cal-residente .fc-timegrid-slot { height: 1.9rem; }
.atvev { padding: 1px 3px; line-height: 1.2; overflow: hidden; }
.atvev--xs { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.atvev--xs .atvev__time { flex: none; }
.atvev--xs .atvev__title { min-width: 0; }
.atvev__time { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.atvev__title { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atvev__meta { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atvev__foot { font-size: 11px; opacity: .9; }
.atvev-m { display: flex; align-items: center; gap: 4px; font-size: 12px; padding: 0 2px; overflow: hidden; white-space: nowrap; }
.atvev-m__time { font-weight: 600; }
