/* =========================================================================
   Falkuslog · Registo · CSS base
   ========================================================================= */

:root {
    --bg:            #f5f5f3;
    --bg-card:       #ffffff;
    --bg-muted:      #efeee9;
    --border:        rgba(0, 0, 0, 0.10);
    --border-strong: rgba(0, 0, 0, 0.18);

    --text:          #1c1c1a;
    --text-muted:    #6b6b66;
    --text-dim:      #9a9a93;

    --primary:       #185fa5;
    --primary-bg:    #e6f1fb;
    --primary-dark:  #0c447c;

    --success:       #1d9e75;
    --success-bg:    #e1f5ee;

    --warning:       #ba7517;
    --warning-bg:    #faeeda;

    --danger:        #a32d2d;
    --danger-bg:     #fcebeb;

    --info:          #185fa5;
    --info-bg:       #e6f1fb;

    --radius-sm: 4px;
    --radius:    8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:            #1a1a18;
        --bg-card:       #25241f;
        --bg-muted:      #2e2d28;
        --border:        rgba(255, 255, 255, 0.08);
        --border-strong: rgba(255, 255, 255, 0.18);
        --text:          #ebebe6;
        --text-muted:    #a3a39a;
        --text-dim:      #6e6e66;
        --primary-bg:    #0c447c;
        --success-bg:    #085041;
        --warning-bg:    #633806;
        --danger-bg:     #791f1f;
        --info-bg:       #0c447c;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 500; line-height: 1.3; margin: 0 0 0.5rem; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }

/* === Topbar ============================================================= */

.topbar {
    background: var(--bg-card);
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 500;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 12px;
}
.brand-mark.large {
    width: 56px;
    height: 56px;
    font-size: 20px;
    border-radius: var(--radius);
}

.brand-text { font-size: 14px; }

.mainnav {
    display: flex;
    gap: 4px;
    margin-left: 16px;
}
.mainnav a {
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.mainnav a:hover {
    background: var(--bg-muted);
    text-decoration: none;
}
.mainnav a.active {
    color: var(--text);
    background: var(--bg-muted);
}

.userbox {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}
.link-logout {
    color: var(--text-muted);
    display: inline-flex;
    padding: 6px;
    border-radius: var(--radius-sm);
}
.link-logout:hover { background: var(--bg-muted); color: var(--text); }

/* === Content ============================================================ */

.content {
    max-width: 1920px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

.page-header {
    margin-bottom: 20px;
}
.page-header h1 { margin-bottom: 4px; }

.card {
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.card ul { margin: 8px 0; padding-left: 20px; }
.card li { margin: 4px 0; }

/* === Footer ============================================================= */

.bottombar {
    border-top: 0.5px solid var(--border);
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
}

/* === Largura de admin (1800px) ========================================= */
/* Admins têm um espaço de trabalho uniforme de 1800px no PC; aplica-se via
   classe .is-admin no <body>. Outros utilizadores mantêm as larguras acima. */
body.is-admin .topbar-inner,
body.is-admin .content,
body.is-admin .bottombar {
    max-width: 1800px;
}

/* === Forms ============================================================== */

.field {
    display: block;
    margin-bottom: 14px;
}
.field span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

input[readonly] { background: var(--bg-muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    color: var(--text);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--bg-muted); text-decoration: none; }
.btn:active { transform: scale(0.98); }

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

.btn-full { width: 100%; padding: 10px; }

/* === Alerts ============================================================= */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info    { background: var(--info-bg);    color: var(--info);    }

/* === Login page ========================================================= */

.login-page {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}
.login-brand h1 { margin: 12px 0 4px; }
.login-brand p { margin: 0; font-size: 13px; }

.login-foot {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
}

/* === Utilities ========================================================== */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.mono { font-family: var(--font-mono); }
.small { font-size: 12px; }
.bold { font-weight: 500; }

.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

/* === Badges ============================================================= */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
}
.badge-fl       { background: var(--primary-bg); color: var(--primary); }
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger);  }
.badge-info     { background: var(--info-bg);    color: var(--info);    }
.badge-neutral  { background: var(--bg-muted);   color: var(--text-muted); }

/* === Tables ============================================================= */

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: 13px;
}

table.data thead {
    background: var(--bg-muted);
}

table.data th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 0.5px solid var(--border);
}

table.data td {
    padding: 12px;
    border-bottom: 0.5px solid var(--border);
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-muted); }

/* === Voltas list (Excel-like) ========================================== */

.filtros .filtros-grid {
    display: grid;
    grid-template-columns: 90px 80px 1fr 1fr 180px auto;
    gap: 12px;
    align-items: end;
}
.filtros .field { margin-bottom: 0; }
.filtros-btns .flex { padding-top: 2px; }

@media (max-width: 900px) {
    .filtros .filtros-grid { grid-template-columns: 1fr 1fr; }
    .filtros-btns { grid-column: 1 / -1; }
}

.resumo {
    display: flex;
    gap: 32px;
    padding: 12px 20px;
    font-size: 13px;
}
.resumo strong { font-weight: 500; }

.table-wrap {
    overflow-x: auto;
    overflow-y: clip;       /* impede que o wrap se torne contexto de scroll vertical */
    background: #fff;
    border: 1px solid #000;
}

/* === Tabela estilo Excel ================================================ */

.excel-tabela {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    color: #000;
    font-size: 13px;
    line-height: 1.4;
    min-width: 1900px;
    /* table-layout: auto — colunas crescem com o conteúdo, com min-width por coluna */
}

.excel-tabela th,
.excel-tabela td {
    border: 1px solid #000;
    padding: 8px 10px;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Zebra striping subtil */
.excel-tabela tbody tr:nth-child(even) td:not(.empty-leg) { background: #fafbfc; }
.excel-tabela tbody tr:nth-child(odd)  td:not(.empty-leg) { background: #ffffff; }

/* Transp e Saldo mantêm cor própria mesmo em zebra */
.excel-tabela tbody tr td:nth-child(7):not(.empty-leg) { background: #e8e8e8 !important; }
.excel-tabela tbody tr td:nth-child(21):not(.empty-leg) { background: #fff9e6 !important; }
.excel-tabela tbody tr:hover td:nth-child(7):not(.empty-leg) { background: #dcdcdc !important; }

.excel-tabela thead th {
    background: #d9e1f2;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #000;
    letter-spacing: 0;
    text-transform: none;
    border-bottom: 1.5px solid #000;
    padding: 4px 6px;
}

/* Só a linha das colunas (azul, com filtros) fica sticky. A linha do grupo rola normalmente. */
.excel-tabela thead tr:not(.th-group-row) th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 2px 3px rgba(0,0,0,0.08);
}

.excel-tabela th.th-group {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 6px;
    background: #b4c7e7;
}
.excel-tabela th.th-group.g-ida-grp { background: #c6dcec; color: #0c447c; }
.excel-tabela th.th-group.g-volta-grp { background: #f2d8b0; color: #7a4b0a; }
.excel-tabela th.common { background: #d9e1f2; }
.excel-tabela th.common.g-saldo { background: #fff2cc; }
.excel-tabela th.th-group-empty {
    background: #fff;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 1px solid #000;
}
.excel-tabela th.th-group-empty.g-saldo { background: #fff2cc; }

/* Vista checkboxes */
.vista-checks {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 4px;
}
.vista-checks label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.vista-checks input { margin: 0; }

/* Hide IDA columns when Exportação not checked */
.excel-tabela.hide-ida   th.g-ida,
.excel-tabela.hide-ida   td.g-ida,
.excel-tabela.hide-ida   th.g-ida-grp { display: none; }

/* Hide VOLTA columns when Importação not checked */
.excel-tabela.hide-volta th.g-volta,
.excel-tabela.hide-volta td.g-volta,
.excel-tabela.hide-volta th.g-volta-grp { display: none; }

/* AutoFilter — seta de ordenação centrada por cima do título; ▼ no canto */
.excel-tabela thead th[data-col] { position: relative; }
.th-sort-ind {
    display: block;
    height: 14px;
    line-height: 14px;
    font-size: 13px;
    color: #185fa5;
    font-weight: 700;
}
.th-title {
    display: block;
    font-weight: 600;
    text-align: center;
}
.th-flt {
    position: absolute;
    top: 3px;
    right: 3px;
    border: 1px solid #888;
    background: #fff;
    color: #444;
    font-size: 10px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 2px;
    cursor: pointer;
    font-family: inherit;
}
.th-flt:hover { background: #185fa5; color: #fff; border-color: #185fa5; }
.excel-tabela thead th.has-filter .th-flt { background: #ffd966; border-color: #c8a131; color: #000; }
.excel-tabela thead th[data-col].sorted .th-sort-ind { color: #0c447c; }

/* Dropdown do AutoFilter — estilo Excel */
#col-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.22);
    padding: 6px;
    width: 260px;
    z-index: 100;
    font-size: 12px;
    color: #000;
}
#col-dropdown[hidden] { display: none; }
#col-dropdown .cd-section { padding: 4px 0; }
#col-dropdown .cd-section + .cd-section { border-top: 1px solid #ddd; margin-top: 4px; padding-top: 8px; }
#col-dropdown .cd-sort button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border: 0;
    background: transparent;
    font: inherit;
    color: #000;
    cursor: pointer;
    border-radius: 3px;
}
#col-dropdown .cd-sort button:hover { background: #d9e1f2; }
#col-dropdown input[type="search"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #888;
    border-radius: 3px;
    font: inherit;
    font-size: 12px;
    box-sizing: border-box;
    color: #000;
    background: #fff;
}
#col-dropdown input[type="search"]:focus { outline: 2px solid #185fa5; outline-offset: -2px; }

.cd-checklist {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px;
    margin: 8px 0 6px;
    background: #fff;
}
.cd-loading {
    padding: 16px 8px;
    text-align: center;
    color: var(--text-muted, #888);
    font-size: 11px;
    font-style: italic;
}
.cd-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    font-size: 12px;
    color: #000;
    cursor: pointer;
    border-radius: 2px;
}
.cd-item:hover { background: #eaf3ff; }
.cd-item input { margin: 0; flex: 0 0 auto; }
.cd-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cd-item.cd-all {
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
    margin-bottom: 4px;
    font-weight: 600;
}
.cd-item.cd-blank { font-style: italic; color: #777; }

#col-dropdown .cd-actions { display: flex; gap: 6px; margin-top: 6px; padding: 0 4px; }
#col-dropdown .cd-actions button { flex: 1; padding: 5px 10px; border: 1px solid #aaa; border-radius: 3px; text-align: center; background: #fff; cursor: pointer; font: inherit; font-size: 12px; }
#col-dropdown .cd-actions button.cd-primary { background: #185fa5; color: #fff; border-color: #185fa5; }
#col-dropdown .cd-actions button.cd-primary:hover { background: #0c447c; }
#col-dropdown .cd-actions button:not(.cd-primary):hover { background: #f0f4fa; }

.excel-tabela tbody tr { cursor: pointer; }
.excel-tabela tbody tr:hover td:not(.empty-leg) { background: #fff4c2 !important; }

/* Larguras mínimas por coluna — crescem se o conteúdo precisar (table-layout auto) */
.excel-tabela th:nth-child(1),  .excel-tabela td:nth-child(1)  { min-width: 80px;  } /* Processo IDA */
.excel-tabela th:nth-child(2),  .excel-tabela td:nth-child(2)  { min-width: 65px;  } /* Data carga IDA */
.excel-tabela th:nth-child(3),  .excel-tabela td:nth-child(3)  { min-width: 200px; max-width: 320px; } /* Origens IDA */
.excel-tabela th:nth-child(4),  .excel-tabela td:nth-child(4)  { min-width: 110px; max-width: 200px; } /* Cliente IDA */
.excel-tabela th:nth-child(5),  .excel-tabela td:nth-child(5)  { min-width: 70px;  } /* Data descarga IDA */
.excel-tabela th:nth-child(6),  .excel-tabela td:nth-child(6)  { min-width: 130px; max-width: 240px; } /* Obs IDA */
.excel-tabela th:nth-child(7),  .excel-tabela td:nth-child(7)  { min-width: 160px; } /* Transp */
.excel-tabela th:nth-child(8),  .excel-tabela td:nth-child(8)  { min-width: 80px;  } /* Processo VOLTA */
.excel-tabela th:nth-child(9),  .excel-tabela td:nth-child(9)  { min-width: 65px;  }
.excel-tabela th:nth-child(10), .excel-tabela td:nth-child(10) { min-width: 200px; max-width: 320px; }
.excel-tabela th:nth-child(11), .excel-tabela td:nth-child(11) { min-width: 110px; max-width: 200px; }
.excel-tabela th:nth-child(12), .excel-tabela td:nth-child(12) { min-width: 70px;  }
.excel-tabela th:nth-child(13), .excel-tabela td:nth-child(13) { min-width: 130px; max-width: 240px; }
.excel-tabela th:nth-child(14), .excel-tabela td:nth-child(14) { min-width: 45px;  } /* Sem */
.excel-tabela th:nth-child(15), .excel-tabela td:nth-child(15),
.excel-tabela th:nth-child(18), .excel-tabela td:nth-child(18) { min-width: 60px;  } /* KM */
.excel-tabela th:nth-child(16), .excel-tabela td:nth-child(16),
.excel-tabela th:nth-child(17), .excel-tabela td:nth-child(17),
.excel-tabela th:nth-child(19), .excel-tabela td:nth-child(19),
.excel-tabela th:nth-child(20), .excel-tabela td:nth-child(20) { min-width: 80px;  } /* Frete / Mapa */
.excel-tabela th:nth-child(21), .excel-tabela td:nth-child(21) { min-width: 95px; background:#fff2cc; } /* T Saldo */

/* Coluna Transp em 3 linhas, centradas, fundo cinza */
.excel-tabela th:nth-child(7),
.excel-tabela td:nth-child(7) { background: #e8e8e8; }
.excel-tabela tbody tr:hover td:nth-child(7) { background: #dcdcdc; }

.excel-tabela td.transp-cell { padding: 6px 10px; line-height: 1.5; text-align: center; white-space: nowrap; }
.excel-tabela td.transp-cell .t-codigo { font-weight: 700; font-size: 14px; }
.excel-tabela td.transp-cell .t-mat    { font-size: 13px; color: #1c1c1a; }
.excel-tabela td.transp-cell .t-mot    { font-size: 13px; color: #444; font-style: italic; }

/* Edição inline */
.excel-tabela td[data-edit] { cursor: cell; }
.excel-tabela td[data-edit]:hover:not(.editing):not(.empty-leg):not(.cell-selected) { outline: 1px dashed #185fa5; outline-offset: -2px; }
.excel-tabela td.editing { padding: 0; background: #fff9e0; }

/* Célula seleccionada (navegação por setas como Excel) */
.excel-tabela td.cell-selected {
    outline: 2.5px solid #1d6e3a;
    outline-offset: -2px;
    position: relative;
    z-index: 1;
}
.cell-edit {
    width: 100%; height: 100%; min-height: 28px;
    border: 0; outline: 2px solid #185fa5; outline-offset: -2px;
    background: #fff; color: #000;
    font: inherit; font-size: 12px;
    padding: 4px 6px;
    box-sizing: border-box;
    resize: none;
}
textarea.cell-edit { min-height: 60px; line-height: 1.4; }
.cell-edit:focus { outline-color: #0b6e3a; }
.cell-saving { opacity: 0.6; pointer-events: none; }

/* Saldo: cor */
.excel-tabela td.saldo .pos { color: #0b6e3a; font-weight: 600; }
.excel-tabela td.saldo .neg { color: #a32d2d; font-weight: 600; }

/* Numéricos */
.excel-tabela td.num    { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.excel-tabela td.center { text-align: center; }
.excel-tabela td.mono   { font-family: var(--font-mono); font-size: 11px; }

/* Célula "preto" para perna inexistente (volta one-way) — padrão diagonal em cinza-escuro */
.excel-tabela td.empty-leg {
    background:
        repeating-linear-gradient(
            45deg,
            #2a2a2a 0,
            #2a2a2a 6px,
            #1a1a1a 6px,
            #1a1a1a 12px
        );
    color: transparent;
}

/* Link Google Maps */
.link-map {
    display: inline-block;
    padding: 0 4px;
    color: #185fa5;
    text-decoration: none;
    font-size: 11px;
}
.link-map:hover { background: #fff9e0; }

/* Estado da volta — barra fina à esquerda da 1ª célula */
.excel-tabela tbody tr td:first-child { position: relative; }
.excel-tabela tbody tr td:first-child::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px;
}
.excel-tabela tbody tr.estado-aberto    td:first-child::before { background: transparent; }
.excel-tabela tbody tr.estado-concluido td:first-child::before { background: #1d9e75; }
.excel-tabela tbody tr.estado-faturado  td:first-child::before { background: #185fa5; }
.excel-tabela tbody tr.estado-fechado   td:first-child::before { background: #6b6b66; }
.excel-tabela tbody tr.estado-cancelado td:first-child::before { background: #a32d2d; }
.excel-tabela tbody tr.estado-cancelado td:not(.empty-leg) { color: #999; text-decoration: line-through; }

.loading, .empty { text-align: center; padding: 40px 20px !important; color: var(--text-muted); }

.paginacao .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Notas =============================================================== */

.nota-form textarea {
    font-family: var(--font-mono);
    font-size: 13px;
    min-height: 120px;
    resize: vertical;
}
.nota-form input[type="file"] { padding: 6px 0; }

.nota-card { padding: 14px 18px; }
.nota-head { padding-bottom: 8px; border-bottom: 0.5px solid var(--border); margin-bottom: 10px; }
.btn-link-danger {
    background: transparent;
    border: 0;
    color: var(--danger);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
}
.btn-link-danger:hover { background: var(--danger-bg); }

.nota-conteudo {
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 10px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.nota-anexos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.nota-anexo-img {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    max-width: 200px;
    text-align: center;
}
.nota-anexo-img img {
    width: 180px;
    height: 130px;
    object-fit: cover;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
}
.nota-anexo-img:hover img { border-color: var(--primary); }

.nota-anexo-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-muted);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}
.nota-anexo-file:hover { background: var(--primary-bg); color: var(--primary); }

.paste-preview {
    margin-top: 10px;
    padding: 10px;
    background: var(--primary-bg);
    border: 0.5px dashed var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.paste-title { font-size: 12px; color: var(--primary); font-weight: 500; }
.paste-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
}
.paste-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 3px;
    background: var(--bg-muted);
}
.paste-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.paste-rm {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    line-height: 1;
}
.paste-rm:hover { background: var(--danger-bg); }

.nota-resolvida {
    opacity: 0.6;
    background: var(--bg-muted);
}
.nota-resolvida .nota-conteudo { background: var(--bg-card); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.nota-actions .btn-xs { padding: 3px 9px; font-size: 11px; }

.resolvidas-section { margin-top: 24px; }
.resolvidas-section > summary {
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
    list-style: none;
}
.resolvidas-section > summary::before { content: '▶ '; font-size: 10px; }
.resolvidas-section[open] > summary::before { content: '▼ '; }
.resolvidas-section[open] > summary { margin-bottom: 12px; }

/* === Intranet: Dashboard + módulos cards ============================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.module-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.module-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(24, 95, 165, 0.10);
    text-decoration: none;
}
.module-card:active { transform: scale(0.99); }
.module-card .mc-head { display: flex; align-items: center; gap: 12px; }
.module-card .mc-icon {
    width: 42px; height: 42px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-bg); color: var(--primary);
    border-radius: var(--radius); font-size: 18px;
}
.module-card .mc-nome { font-size: 15px; font-weight: 500; }
.module-card .mc-url { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.module-card .mc-desc { font-size: 13px; color: var(--text-muted); line-height: 1.45; }
.module-card .mc-arrow { margin-left: auto; color: var(--text-dim); font-size: 16px; }
.module-card:hover .mc-arrow { color: var(--primary); }

/* Resumo do user na dashboard */
.user-greeting {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--bg-card) 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 0.5px solid var(--border);
}
.user-greeting h1 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.user-greeting p { margin: 0; color: var(--text-muted); font-size: 13px; }

/* Cards de stats (admin) */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 24px 0 16px;
}
.stat-card {
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 22px; font-weight: 500; margin-top: 4px; }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

/* Tabela compacta para utilizadores e audit */
.intranet-table { width: 100%; font-size: 13px; }
.intranet-table thead th { background: var(--bg-muted); color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.intranet-table tbody tr:hover { background: var(--bg-muted); }
.intranet-table .col-actions { width: 1%; white-space: nowrap; }
.intranet-table .col-actions .btn { padding: 4px 10px; font-size: 12px; }

/* Modal genérico */
.modal-bg {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 600;
    align-items: center; justify-content: center;
}
.modal-bg.open { display: flex; }
.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    width: 460px; max-width: 96vw; max-height: 90vh;
    overflow-y: auto;
    border: 0.5px solid var(--border);
}
.modal-card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 500; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 0.5px solid var(--border); }

/* Filtros de audit */
.audit-filters {
    display: grid;
    grid-template-columns: 100px 110px 1fr 150px auto;
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
}
.audit-filters label.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.success-text { color: var(--success); font-weight: 500; }
.danger-text  { color: var(--danger);  font-weight: 500; }
