:root {
    --brand-50: #eff8ff;
    --brand-100: #dbeefe;
    --brand-500: #0784cf;
    --brand-600: #006fba;
    --brand-700: #075c96;
    --ink-900: #172033;
    --ink-700: #3f4b5f;
    --ink-500: #68758a;
    --line: #dce3ec;
    --surface: #ffffff;
    --surface-soft: #f6f8fb;
    --success: #16855b;
    --danger: #c53b4c;
    --shadow-sm: 0 1px 2px rgba(17, 32, 51, 0.06);
    --shadow-lg: 0 24px 60px rgba(17, 32, 51, 0.16);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    color-scheme: light;
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    background: var(--surface-soft);
    color: var(--ink-900);
    margin: 0;
    min-height: 100vh;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.button {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink-700);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 650;
    justify-content: center;
    min-height: 40px;
    padding: 0.65rem 1rem;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover,
.button:hover {
    background: var(--brand-50);
    border-color: var(--brand-500);
    color: var(--brand-700);
}

button:active,
.button:active {
    transform: translateY(1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button--primary,
button[type="submit"] {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

.button--primary:hover,
button[type="submit"]:hover {
    background: var(--brand-700);
    color: #fff;
}

.button--secondary {
    background: var(--surface);
}

.button--success {
    background: #e9f8f1;
    border-color: #99ddc2;
    color: #08744d;
}

.button--success:hover {
    background: #08744d;
    border-color: #08744d;
    color: #fff;
}

.button--info {
    background: #eaf5ff;
    border-color: #9fd0f4;
    color: #075c96;
}

.button--info:hover {
    background: #075c96;
    border-color: #075c96;
    color: #fff;
}

.button--warning {
    background: #fff6df;
    border-color: #efd18a;
    color: #8a5a00;
}

.button--warning:hover {
    background: #9a6500;
    border-color: #9a6500;
    color: #fff;
}

.button--danger {
    background: #fff0f2;
    border-color: #efb1ba;
    color: #b42338;
}

.button--danger:hover {
    background: #b42338;
    border-color: #b42338;
    color: #fff;
}

:focus-visible {
    outline: 3px solid rgba(7, 132, 207, 0.25);
    outline-offset: 2px;
}

input,
select,
textarea {
    background: var(--surface);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: var(--ink-900);
    min-height: 42px;
    padding: 0.7rem 0.8rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(7, 132, 207, 0.12);
    outline: 0;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

label {
    color: var(--ink-700);
    font-size: 0.875rem;
    font-weight: 650;
}

.search-field {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    max-width: 560px;
    padding: 0 12px;
}

.search-field span {
    color: var(--brand-600);
    font-size: 1.35rem;
    line-height: 1;
}

.search-field input {
    border: 0;
    box-shadow: none;
    flex: 1;
    min-width: 0;
    padding-left: 0;
}

.search-field input:focus {
    box-shadow: none;
}

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

.sidebar {
    background: linear-gradient(180deg, #075c96 0%, #064c7c 100%);
    color: #fff;
    display: flex;
    flex: 0 0 248px;
    flex-direction: column;
    min-height: 100vh;
    padding: 28px 18px;
    position: sticky;
    top: 0;
}

.auth-logout {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    margin: auto 0 0;
    padding: 11px 16px;
    transition: background 160ms ease, border-color 160ms ease;
}

.auth-logout:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(254, 202, 202, 0.55);
}

.auth-logout:disabled {
    cursor: wait;
    opacity: 0.65;
}

.auth-footer {
    align-items: center;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    width: 100%;
}

.sidebar__logo {
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    margin-bottom: 24px;
    padding: 0 12px 22px;
}

.sidebar__title {
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    margin: 0;
}

.sidebar__title::after {
    color: #8ed4ff;
    content: "Gestão de ativos";
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    margin-top: 5px;
    text-transform: uppercase;
}

.sidebar__navigation,
.sidebar__menu {
    display: grid;
    gap: 6px;
}

.sidebar__link {
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 11px 13px;
    text-decoration: none;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(2px);
}

.sidebar__link--active {
    background: #fff;
    box-shadow: var(--shadow-sm);
    color: var(--brand-700);
}

.content {
    min-width: 0;
}

h1,
h2,
h3,
h4,
h5,
p {
    margin-top: 0;
}

h2 {
    font-size: clamp(1.65rem, 2.4vw, 2.15rem);
    letter-spacing: -0.035em;
    margin-bottom: 6px;
}

p {
    color: var(--ink-500);
    line-height: 1.55;
}

.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table th,
.table td {
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: #f8fafc;
    color: var(--ink-500);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.termos-page,
.pessoas-page {
    height: 100vh;
    overflow: hidden;
}

.termos-page .layout,
.pessoas-page .layout {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.termos-page .sidebar,
.pessoas-page .sidebar {
    height: 100vh;
    min-height: 0;
}

.pessoas-page .pessoas {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.pessoas-page .pessoas__content {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.table tbody tr {
    transition: background 140ms ease;
}

.table tbody tr:hover {
    background: var(--brand-50);
}

.table td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.table td:last-child button {
    min-height: 34px;
    padding: 0.45rem 0.7rem;
}

@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .sidebar {
        min-height: auto;
        padding: 14px 18px;
        position: static;
    }

    .sidebar__logo {
        margin-bottom: 10px;
        padding: 0 4px 12px;
    }

    .sidebar__navigation,
    .sidebar__menu {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .sidebar__link {
        flex: 0 0 auto;
    }

    .table {
        min-width: 760px;
    }

    .termos-page,
    .pessoas-page,
    .termos-page .layout,
    .pessoas-page .layout,
    .pessoas-page .pessoas {
        height: auto;
        min-height: 100%;
        overflow: visible;
    }

    .termos-page .sidebar,
    .pessoas-page .sidebar {
        height: auto;
    }

    .equipamentos,
    .pessoas,
    .unidades {
        padding: 26px 16px;
    }
}

@media (max-width: 640px) {
    button,
    .button {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Casca de página compartilhada.

   Antes, cada tela declarava as mesmas regras com nome próprio
   (.pessoas__header, .equipamentos__header, .unidades__header...), o que fazia
   qualquer ajuste de espaçamento precisar ser repetido em cinco arquivos — e
   sair diferente em um deles. Os valores abaixo seguem o dashboard, que é a
   referência visual do sistema.
   ========================================================================== */

.page {
    flex: 1;
    margin: 0 auto;
    max-width: 1600px;
    min-width: 0;
    padding: 42px clamp(22px, 4vw, 58px);
    width: 100%;
}

.page__header {
    align-items: flex-end;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page__intro {
    min-width: 0;
}

.page__eyebrow {
    color: var(--brand-600);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page__title {
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    letter-spacing: -0.03em;
    margin: 5px 0 8px;
}

.page__subtitle {
    color: var(--ink-500);
    margin: 0;
}

.page__actions {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    gap: 12px;
}

/* Informação de apoio no cabeçalho (contagens, data de atualização). */
.page__meta {
    color: var(--ink-500);
    font-size: 0.85rem;
    white-space: nowrap;
}

.page__panel {
    min-height: 0;
    max-height: 80%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: auto;
}

/* Estado vazio: mesma linguagem em todas as listagens. */
.empty-state {
    color: var(--ink-500);
    padding: 32px 24px;
    text-align: center;
}

/* ==========================================================================
   Modal compartilhado
   ========================================================================== */

.modal {
    align-items: center;
    background: rgba(15, 23, 42, 0.58);
    display: flex;
    inset: 0;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 16px;
    position: fixed;
    z-index: 10;
}

.modal[hidden] {
    display: none;
}

.modal__content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 48px);
    max-width: 560px;
    overflow-y: auto;
    padding: 28px;
    width: 100%;
}

.modal__title {
    font-size: 1.35rem;
    letter-spacing: -0.025em;
    margin: 0 0 20px;
}

.modal__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Em telas estreitas o subtítulo quebra em duas linhas e a informação de apoio
   fica na mesma linha visual, parecendo desalinhada. Melhor empilhar. */
@media (max-width: 900px) {
    .page {
        padding: 26px 16px;
    }

    .page__header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    /* O botão de ação principal ocupa a largura toda no celular, para virar um
       alvo de toque confortável. */
    .page__actions,
    .page__actions .button {
        width: 100%;
    }

    .page__meta {
        white-space: normal;
    }
}
