/* =========================================================
   RUI SERVICE — CSS geral + ecrã de autenticação
   As regras do login ficam isoladas das áreas administrativas.
   Imagens: /assets/imagens/bgk.jpg e /assets/imagens/logo.png
   ========================================================= */

:root {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: #1b2737;
    background: #f3f6fb;
    --rui-navy: #172b3d;
    --rui-blue: #168be0;
}

* { box-sizing: border-box; }
body { margin: 0; }

/* Cabeçalho e navegação */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 4%;
    background: #14273d;
    color: #fff;
}
header a { color: #fff; }
header span { font-size: 13px; }
.brand { font-size: 20px; font-weight: 750; text-decoration: none; }

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 12px 4%;
    background: #fff;
    border-bottom: 1px solid #dce2e9;
}
nav a {
    padding: 9px 13px;
    border-radius: 6px;
    color: #263648;
    text-decoration: none;
}
nav a:hover { background: #e9f0f8; }

/* Layout geral */
main { max-width: 1450px; min-height: 65vh; margin: 30px auto; padding: 0 4%; }
h1 { margin: 0 0 22px; font-size: 27px; }
h2 { margin-top: 30px; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}
.card, .panel, .login {
    padding: 22px;
    border: 1px solid #e0e6ee;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px #1528420a;
}
.card strong { display: block; font-size: 38px; color: #1771b8; }
.card small { color: #637287; font-size: 13px; }
.panel { margin: 20px 0; }
.fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* Formulários */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 650; }
input, textarea, select {
    width: 100%;
    min-height: 42px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #1e293b;
    font: inherit;
}
textarea { min-height: 85px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible {
    outline: 3px solid rgba(22, 139, 224, .35);
    outline-offset: 2px;
}
button, .button {
    display: inline-block;
    padding: 11px 18px;
    border: 0;
    border-radius: 7px;
    background: #176bb1;
    color: #fff;
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}
button:hover, .button:hover { background: #10588f; }
.danger { padding: 6px 12px; background: #bb3344; }

/* Tabelas */
.tablewrap {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid #e0e6ee;
    border-radius: 10px;
    background: #fff;
}
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px; border-bottom: 1px solid #e6ebf1; text-align: left; }
th { background: #eef3f9; font-size: 12px; }
td { font-size: 13px; }
tr.highlight { background: #e5f8e7; }

/* Mensagens e rodapé */
.alert { margin-bottom: 20px; padding: 14px; border-radius: 8px; background: #e3f5e5; color: #176436; }
.alert.error { background: #fee3e2; color: #962f31; }
.total { margin: 18px 0; text-align: right; font-size: 17px; }
.hint, footer { color: #69798c; font-size: 12px; }
footer { padding: 20px; text-align: center; }

/* =========================================================
   LOGIN — apenas quando o body contém o cartão .login
   ========================================================= */
body:has(.login) {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background-color: #14273d;
    background-image: linear-gradient(rgba(8, 22, 37, .40), rgba(8, 22, 37, .54)), url('/assets/imagens/bgk.jpg');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
}
.login {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 34px 32px 32px;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 15px;
    background: #172b3d;
    box-shadow: 0 18px 55px rgba(0, 0, 0, .48);
    color: #fff;
}
.login-brand { margin: 0 0 30px; text-align: center; }
.login-logo {
    display: block;
    width: 100%;
    max-width: 340px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}
.login-setup-title { margin: -5px 0 22px; color: #fff; font-size: 20px; text-align: center; }
.login label { margin-bottom: 17px; color: #f3f7fb; }
.login input {
    min-height: 44px;
    margin-top: 2px;
    border-color: #b8c7d6;
    background: #fff;
    color: #14273d;
}
.login button {
    width: 100%;
    min-height: 44px;
    background: #168be0;
    color: #fff;
    transition: background-color .2s ease;
}
.login button:hover { background: #0872c1; }
.login .alert.error { margin-bottom: 20px; }

@media (max-width: 600px) {
    header { flex-direction: column; align-items: flex-start; }
    nav { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
    main { margin-top: 18px; }
    h1 { font-size: 23px; }
    .fields { grid-template-columns: 1fr; }
    .login { max-width: 420px; padding: 28px 22px; }
    .login-logo { max-width: 300px; }
}


/* ====================================
   RUI SERVICE - FUNDO DO BACKOFFICE
   ==================================== */

body {
    background: #f3f6fb;
}

main {
    position: relative;
    z-index: 0;
    isolation: isolate;
    min-height: 80vh;
}

/* Fundo da oficina muito esbatido */
main::before {
    content: "";
    position: fixed;
    inset: 0;

    background:
        linear-gradient(
            rgba(243, 246, 251, 0.88),
            rgba(243, 246, 251, 0.88)
        ),
        url('/assets/imagens/bgk.jpg')
        center center / cover no-repeat;

    z-index: -1;
    pointer-events: none;
}