/* =====================================================================
   PULSARIS · Sistema de design
   Paleta retirada do logótipo: navy #0E1830 · dourado #B07F44
   Tipografia: Sora (títulos) · IBM Plex Sans (texto) · IBM Plex Mono (dados)
   Assinatura visual: medidores segmentados ("pulse meter") e números
   sempre em monoespaçado, para que as métricas alinhem opticamente.
   ===================================================================== */

:root {
    /* Cor */
    --ink:        #0E1830;
    --ink-soft:   #16213A;
    --ink-line:   #22304F;
    --slate:      #5A6884;
    --slate-soft: #8C97AC;
    --gold:       #B07F44;
    --gold-lift:  #D6A45C;
    --gold-wash:  #FAF3E8;
    --paper:      #F5F6F8;
    --surface:    #FFFFFF;
    --line:       #E3E7EE;
    --line-soft:  #EFF1F5;

    /* Estados */
    --go:    #2E7D5B;   --go-wash:    #EAF4EF;
    --flow:  #3C5A9A;   --flow-wash:  #EDF1F9;
    --halt:  #C0453C;   --halt-wash:  #FBEDEC;
    --warn:  #C8871F;   --warn-wash:  #FDF4E5;
    --idle:  #5A6884;   --idle-wash:  #F0F2F6;

    /* Tipografia */
    --font-display: 'Sora', 'Segoe UI', system-ui, sans-serif;
    --font-body:    'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    --font-data:    'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

    /* Métrica */
    --sidebar-w: 244px;
    --topbar-h: 62px;
    --radius:    10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(14, 24, 48, .06);
    --shadow:    0 2px 8px rgba(14, 24, 48, .07);
    --shadow-lg: 0 12px 36px rgba(14, 24, 48, .16);
    --speed: 130ms;
}

/* ---------- Reposição ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -.015em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
svg { width: 16px; height: 16px; flex-shrink: 0; }

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Números, datas e códigos usam sempre o monoespaçado. */
.num, .data, time, .kpi-value, .meter-label, .count {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
}

/* =====================================================================
   Estrutura
   ===================================================================== */

.shell { display: flex; min-height: 100vh; }

/* ---------- Barra lateral ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--ink);
    color: #C6CEDE;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--ink-line);
}
.sidebar-brand .mark {
    width: 30px; height: 30px; flex: none;
    border-radius: 8px;
    background: linear-gradient(140deg, #24365C 0%, #16213A 55%, var(--gold) 55%, var(--gold-lift) 100%);
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-weight: 700; font-size: 15px; color: #fff;
}
.sidebar-brand .name {
    font-family: var(--font-display);
    font-weight: 600; font-size: 15px; color: #fff;
    letter-spacing: .16em;
}
.sidebar-brand .tag {
    display: block;
    font-family: var(--font-data);
    font-size: 8.5px; letter-spacing: .1em;
    color: var(--slate-soft); text-transform: uppercase;
}

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }

.nav-label {
    font-family: var(--font-data);
    font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
    color: #6B7793;
    padding: 14px 10px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: #C6CEDE;
    font-size: 13.5px;
    position: relative;
    transition: background var(--speed), color var(--speed);
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.is-active { background: rgba(255, 255, 255, .07); color: #fff; font-weight: 500; }

/* Rail dourado: a marca de "activo" — o único acento na navegação. */
.nav-item.is-active::before {
    content: '';
    position: absolute; left: -10px; top: 6px; bottom: 6px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--gold-lift), var(--gold));
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-item .badge-count {
    margin-left: auto;
    font-family: var(--font-data); font-size: 10.5px;
    background: rgba(255, 255, 255, .1); color: #E6EBF3;
    padding: 1px 6px; border-radius: 20px;
}

.sidebar-foot { border-top: 1px solid var(--ink-line); padding: 10px; }
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    transition: background var(--speed);
}
.sidebar-user:hover { background: rgba(255, 255, 255, .05); }
.sidebar-user .meta { min-width: 0; }
.sidebar-user .who { color: #fff; font-size: 13px; font-weight: 500; }
.sidebar-user .role {
    font-family: var(--font-data); font-size: 9.5px;
    letter-spacing: .08em; text-transform: uppercase; color: var(--slate-soft);
}
.sidebar-logout {
    background: none; border: 0; color: var(--slate-soft);
    padding: 6px; border-radius: var(--radius-sm); display: grid; place-items: center;
    margin-left: auto;
}
.sidebar-logout:hover { color: #fff; background: rgba(255, 255, 255, .07); }

/* ---------- Conteúdo ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex; flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 50;
}

.search {
    flex: 1; max-width: 420px; position: relative;
}
.search input {
    width: 100%; height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 12px 0 34px;
    font-family: inherit; font-size: 13.5px;
    background: var(--paper);
    transition: border-color var(--speed), background var(--speed);
}
.search input:focus { outline: none; border-color: var(--gold); background: var(--surface); }
.search svg { position: absolute; left: 11px; top: 10px; width: 15px; height: 15px; color: var(--slate-soft); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: none; color: var(--slate); position: relative;
    transition: background var(--speed), color var(--speed);
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot {
    position: absolute; top: 6px; right: 6px;
    min-width: 15px; height: 15px; padding: 0 3px;
    background: var(--halt); color: #fff;
    font-family: var(--font-data); font-size: 9px;
    border-radius: 8px; display: grid; place-items: center;
    border: 2px solid var(--surface);
}

.page { padding: 22px; max-width: 1480px; width: 100%; }

.page-head {
    display: flex; align-items: flex-start; gap: 16px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.page-head .eyebrow {
    font-family: var(--font-data);
    font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--slate-soft); margin-bottom: 3px;
}
.page-head p.lede { color: var(--slate); margin: 4px 0 0; font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* =====================================================================
   Componentes
   ===================================================================== */

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink);
    font-size: 13.5px; font-weight: 500;
    transition: background var(--speed), border-color var(--speed), color var(--speed);
    white-space: nowrap;
}
.btn:hover { background: var(--paper); border-color: #D3D9E4; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #1A2947; border-color: #1A2947; }

.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #9C6E38; border-color: #9C6E38; }

.btn-ghost { border-color: transparent; background: none; color: var(--slate); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); }

.btn-danger { color: var(--halt); border-color: #F0D2CF; background: var(--halt-wash); }
.btn-danger:hover { background: #F7DFDD; border-color: #E5BAB6; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cartões ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ---------- Grelhas ---------- */
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 336px; align-items: start; }

/* ---------- KPI ---------- */
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
}
.kpi .kpi-label {
    font-family: var(--font-data);
    font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase;
    color: var(--slate-soft);
}
.kpi .kpi-value {
    font-size: 27px; font-weight: 600; line-height: 1.15; margin-top: 6px;
    letter-spacing: -.02em;
}
.kpi .kpi-foot { font-size: 12px; color: var(--slate); margin-top: 2px; }
.kpi::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent, var(--line));
}
.kpi[data-tone="go"]   { --accent: var(--go); }
.kpi[data-tone="flow"] { --accent: var(--flow); }
.kpi[data-tone="halt"] { --accent: var(--halt); }
.kpi[data-tone="warn"] { --accent: var(--warn); }
.kpi[data-tone="gold"] { --accent: var(--gold); }

/* ---------- Pulse meter: a assinatura visual ----------
   Dez segmentos em vez de uma barra contínua. Cada segmento vale 10%,
   por isso o progresso lê-se sem ter de interpretar uma percentagem. */
.meter { display: flex; align-items: center; gap: 8px; }
.meter-track { display: flex; gap: 2px; flex: 1; }
.meter-seg {
    flex: 1; height: 6px; border-radius: 1px;
    background: var(--line);
    transition: background var(--speed);
}
.meter-seg.on { background: linear-gradient(180deg, var(--gold-lift), var(--gold)); }
.meter-seg.on.go { background: linear-gradient(180deg, #47A47A, var(--go)); }
.meter-label { font-size: 11.5px; color: var(--slate); min-width: 32px; text-align: right; }

.meter-sm .meter-seg { height: 4px; }

/* ---------- Avatares ---------- */
.avatar {
    width: 28px; height: 28px; flex: none;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-size: 10.5px; font-weight: 600;
    font-family: var(--font-body);
    letter-spacing: .02em;
    background: var(--ink-soft);
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -7px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .more {
    background: var(--idle-wash); color: var(--slate);
    font-family: var(--font-data); font-size: 9px;
}

/* ---------- Etiquetas ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 21px; padding: 0 8px;
    border-radius: 4px;
    font-size: 11.5px; font-weight: 500;
    background: var(--idle-wash); color: var(--slate);
    white-space: nowrap;
}
.badge .bullet { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.badge-go   { background: var(--go-wash);   color: var(--go); }
.badge-flow { background: var(--flow-wash); color: var(--flow); }
.badge-halt { background: var(--halt-wash); color: var(--halt); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-gold { background: var(--gold-wash); color: #8E6532; }

.tag-chip {
    display: inline-flex; align-items: center;
    height: 19px; padding: 0 7px; border-radius: 3px;
    font-family: var(--font-data); font-size: 10px;
    letter-spacing: .02em;
    background: var(--paper); color: var(--slate);
    border: 1px solid var(--line);
}

/* Prioridade: um traço vertical, não um autocolante colorido. */
.prio {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font-data); font-size: 10px;
    letter-spacing: .08em; text-transform: uppercase; color: var(--slate);
}
.prio::before { content: ''; width: 3px; height: 11px; border-radius: 2px; background: var(--slate-soft); }
.prio-urgent { color: var(--halt); } .prio-urgent::before { background: var(--halt); }
.prio-high   { color: var(--warn); } .prio-high::before   { background: var(--warn); }
.prio-medium { color: var(--flow); } .prio-medium::before { background: var(--flow); }
.prio-low    { color: var(--slate-soft); } .prio-low::before { background: var(--slate-soft); }

/* =====================================================================
   Kanban
   ===================================================================== */

.board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(272px, 1fr);
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    align-items: start;
}

.column {
    background: #EEF0F4;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    min-height: 180px;
    max-height: calc(100vh - var(--topbar-h) - 190px);
}
.column-head {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 13px;
    border-bottom: 1px solid #E1E5EC;
    position: sticky; top: 0;
    background: #EEF0F4;
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 2;
}
.column-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.column-head .title {
    font-family: var(--font-data);
    font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
    font-weight: 500; color: var(--ink);
}
.column-head .count {
    margin-left: auto; font-size: 11px; color: var(--slate);
    background: rgba(14, 24, 48, .06); padding: 1px 7px; border-radius: 10px;
}
.column-body {
    padding: 9px; display: flex; flex-direction: column; gap: 8px;
    overflow-y: auto; flex: 1; min-height: 60px;
}

/* ---------- Cartão de tarefa ---------- */
.task-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow var(--speed), border-color var(--speed), transform var(--speed);
    display: block;
}
.task-card:hover { box-shadow: var(--shadow); border-color: #D3D9E4; }
.task-card:active { cursor: grabbing; }

.task-card .row { display: flex; align-items: center; gap: 8px; }
.task-card .title {
    font-size: 13.5px; font-weight: 500; line-height: 1.4;
    color: var(--ink); margin: 6px 0 8px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card .project-ref {
    font-family: var(--font-data); font-size: 9.5px;
    letter-spacing: .06em; color: var(--slate-soft); text-transform: uppercase;
}
.task-card .foot {
    display: flex; align-items: center; gap: 10px;
    margin-top: 9px; padding-top: 9px;
    border-top: 1px solid var(--line-soft);
}
.task-card .meta {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: var(--font-data); font-size: 10.5px; color: var(--slate);
}
.task-card .meta svg { width: 12px; height: 12px; }
.task-card .meta.late { color: var(--halt); font-weight: 500; }
.task-card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }

/* Estados do arrastar */
.task-card.is-dragging { opacity: .45; transform: rotate(-.6deg); }
.task-ghost { border: 1px dashed var(--gold); background: var(--gold-wash); }
.column-body.drop-target { background: rgba(176, 127, 68, .05); border-radius: 6px; }
.task-card.just-moved { animation: settle 500ms ease; }
@keyframes settle {
    0%   { box-shadow: 0 0 0 2px var(--gold-lift); }
    100% { box-shadow: var(--shadow-sm); }
}

/* =====================================================================
   Tabelas e listas
   ===================================================================== */

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-family: var(--font-data);
    font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--slate-soft); font-weight: 500;
    padding: 10px 14px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background var(--speed); }
.table tbody tr:hover { background: #FAFBFC; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-actions { text-align: right; white-space: nowrap; }

.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--speed);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #FAFBFC; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-weight: 500; font-size: 13.5px; }
.list-row .sub { font-size: 12px; color: var(--slate); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cabeçalho de secção dentro de listas (Hoje / Atrasadas / ...) */
.section-head {
    display: flex; align-items: center; gap: 9px;
    padding: 13px 14px 9px;
    font-family: var(--font-data);
    font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
    color: var(--slate-soft);
}
.section-head svg { width: 14px; height: 14px; flex: none; }
.section-head .count { color: var(--slate); }
.section-head .rule { flex: 1; height: 1px; background: var(--line); }

/* ---------- Actividade ---------- */
.feed-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .text { font-size: 13px; line-height: 1.5; }
.feed-item .text strong { font-weight: 600; }
.feed-item time { display: block; font-size: 10.5px; color: var(--slate-soft); margin-top: 2px; }

/* =====================================================================
   Formulários
   ===================================================================== */

.field { margin-bottom: 14px; }
.field label {
    display: block; margin-bottom: 5px;
    font-size: 12.5px; font-weight: 500; color: var(--ink);
}
.field .hint { font-size: 11.5px; color: var(--slate-soft); margin-top: 4px; }

.input, .select, .textarea {
    width: 100%;
    min-height: 36px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13.5px;
    color: var(--ink); background: var(--surface);
    transition: border-color var(--speed), box-shadow var(--speed);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(176, 127, 68, .12);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6884' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    padding-right: 30px;
}
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--halt); }
.error-text { color: var(--halt); font-size: 11.5px; margin-top: 4px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Selector de pessoas / etiquetas por caixas de selecção */
.checkset {
    display: flex; flex-wrap: wrap; gap: 6px;
    max-height: 168px; overflow-y: auto;
    padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper);
}
.checkset label {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 10px 5px 7px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 20px; font-size: 12.5px; font-weight: 400;
    cursor: pointer; margin: 0;
    transition: border-color var(--speed), background var(--speed);
}
.checkset label:hover { border-color: var(--gold-lift); }
.checkset input { position: absolute; opacity: 0; pointer-events: none; }
.checkset input:checked + .chip-inner { color: var(--ink); font-weight: 500; }
.checkset label:has(input:checked) { border-color: var(--gold); background: var(--gold-wash); }
.checkset label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 1px; }
.chip-inner { display: inline-flex; align-items: center; gap: 6px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }

/* ---------- Filtros ---------- */
.filters {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.filters .input, .filters .select { width: auto; min-width: 132px; height: 34px; min-height: 34px; }
.filters .search-inline { flex: 1; min-width: 180px; }

/* =====================================================================
   Modais, painéis e avisos
   ===================================================================== */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(14, 24, 48, .42);
    display: none; align-items: flex-start; justify-content: center;
    padding: 36px 16px; overflow-y: auto;
    backdrop-filter: blur(1.5px);
}
.modal-backdrop.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px;
    animation: rise 160ms ease;
}
.modal-lg { max-width: 720px; }
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-head {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px; }
.modal-foot {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 14px 18px; border-top: 1px solid var(--line);
    background: #FBFCFD; border-radius: 0 0 12px 12px;
}

/* ---------- Menus suspensos ---------- */
.dropdown { position: relative; }
.dropdown-panel {
    position: absolute; right: 0; top: calc(100% + 7px);
    width: 322px; max-height: 400px; overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 70; display: none;
}
.dropdown-panel.open { display: block; }
.dropdown-head {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
    font-family: var(--font-data); font-size: 10px;
    letter-spacing: .12em; text-transform: uppercase; color: var(--slate-soft);
}
.dropdown-head .link { margin-left: auto; text-transform: none; letter-spacing: 0; color: var(--gold); font-size: 11.5px; cursor: pointer; }
.avatar-btn { background: none; border: 0; padding: 0; display: flex; cursor: pointer; }
.dropdown-panel.menu { width: 220px; padding: 6px; max-height: none; }
.menu-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px 12px; margin-bottom: 4px;
    border-bottom: 1px solid var(--line-soft);
}
.menu-head .meta { min-width: 0; }
.menu-head .who { font-size: 13px; font-weight: 500; color: var(--ink); }
.menu-head .role {
    font-family: var(--font-data); font-size: 9.5px;
    letter-spacing: .08em; text-transform: uppercase; color: var(--slate-soft);
}
.menu-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 9px 8px; border-radius: var(--radius-sm); border: 0;
    background: none; font-size: 13px; color: var(--ink); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--paper); }
.menu-item svg { width: 15px; height: 15px; flex: none; color: var(--slate); }
.menu-item.danger { color: var(--halt); }
.menu-item.danger svg { color: var(--halt); }
.menu-item.danger:hover { background: var(--halt-wash); }
.dropdown-panel.menu form { margin: 0; }
.notif {
    display: flex; gap: 10px; padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--speed);
}
.notif:hover { background: var(--paper); }
.notif.unread { background: var(--gold-wash); }
.notif .t { font-size: 13px; font-weight: 500; }
.notif .b { font-size: 12px; color: var(--slate); line-height: 1.45; }
.notif time { font-size: 10px; color: var(--slate-soft); }

/* ---------- Avisos e mensagens ---------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert svg { width: 17px; height: 17px; flex: none; }
.alert-success { background: var(--go-wash);   color: #1F5C42; border-color: #C9E3D6; }
.alert-error   { background: var(--halt-wash); color: #93332C; border-color: #EFCCC9; }
.alert-warning { background: var(--warn-wash); color: #8E5F13; border-color: #F0DDBB; }
.alert-info    { background: var(--flow-wash); color: #2C4577; border-color: #CFDBF0; }

/* ---------- Notificações efémeras ---------- */
.toast-stack {
    position: fixed; right: 18px; bottom: 18px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    display: flex; align-items: center; gap: 9px;
    background: var(--ink); color: #fff;
    padding: 11px 15px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); font-size: 13px;
    animation: slide-in 180ms ease;
    max-width: 340px;
}
.toast.error { background: var(--halt); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------- Estados vazios ---------- */
.empty {
    text-align: center; padding: 40px 20px; color: var(--slate);
}
.empty .glyph {
    width: 42px; height: 42px; margin: 0 auto 12px;
    border-radius: 10px; display: grid; place-items: center;
    background: var(--paper); border: 1px dashed var(--line);
    color: var(--slate-soft);
}
.empty h3 { color: var(--ink); margin-bottom: 5px; }
.empty p { margin: 0 0 14px; font-size: 13px; }
.empty-sm { padding: 26px 16px; }

/* =====================================================================
   Autenticação
   ===================================================================== */

.auth-shell {
    min-height: 100vh; display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-aside {
    background: var(--ink);
    color: #fff; padding: 44px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
/* Eco do logótipo: a curva do "P" como forma de fundo, muito discreta. */
.auth-aside::after {
    content: '';
    position: absolute; right: -110px; bottom: -90px;
    width: 380px; height: 380px; border-radius: 50% 50% 50% 8%;
    background: linear-gradient(140deg, rgba(255,255,255,.045), rgba(176,127,68,.16));
}
.auth-aside .headline {
    font-family: var(--font-display); font-size: 28px; font-weight: 600;
    line-height: 1.28; letter-spacing: -.02em; max-width: 380px; position: relative;
}
.auth-aside .sub { color: #A7B2C6; font-size: 14px; max-width: 340px; margin-top: 14px; position: relative; }
.auth-aside .pillars { display: flex; gap: 26px; position: relative; }
.auth-aside .pillar .k {
    font-family: var(--font-data); font-size: 10px;
    letter-spacing: .14em; text-transform: uppercase; color: var(--gold-lift);
}
.auth-aside .pillar .v { font-size: 12.5px; color: #C6CEDE; margin-top: 3px; }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 344px; }
.auth-form .brand-row { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }

/* =====================================================================
   Utilitários
   ===================================================================== */

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.gap-4   { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10  { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-4    { margin-top: 4px; }  .mt-8  { margin-top: 8px; }
.mt-12   { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8    { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.wrap    { flex-wrap: wrap; }
.muted   { color: var(--slate); }
.dim     { color: var(--slate-soft); }
.small   { font-size: 12px; }
.tiny    { font-size: 11px; }
.strong  { font-weight: 600; }
.late    { color: var(--halt); }
.center  { text-align: center; }
.hidden  { display: none !important; }
.scroll-x { overflow-x: auto; }

/* Botão do menu móvel — escondido em ecrãs largos */
.menu-toggle { display: none; }

/* =====================================================================
   Adaptação a ecrãs pequenos
   ===================================================================== */

@media (max-width: 1100px) {
    .grid-main { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 200ms ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .page { padding: 16px; }
    .field-row { grid-template-columns: 1fr; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .board { grid-auto-columns: 84vw; }
    .column { max-height: none; }
    .search { max-width: none; }
    .topbar { padding: 0 14px; gap: 8px; }
    .page-head .actions { width: 100%; }
}

.scrim {
    position: fixed; inset: 0; background: rgba(14, 24, 48, .35);
    z-index: 55; display: none;
}
.scrim.open { display: block; }
@media (min-width: 861px) { .scrim { display: none !important; } }

/* Impressão e movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
