/* Paleta XP Telecom (extraida do logo) */
:root {
    --xp-orange: #f58634;
    --xp-amber: #f9a729;
    --xp-yellow: #ffe919;
    --xp-navy: #2e3257;
    --xp-navy-deep: #1f2240;
    --xp-gray: #a8a8b4;

    --bg: #f6f6f9;
    --paper: rgba(255, 255, 255, 0.94);
    --paper-strong: #ffffff;
    --ink: #1f2240;
    --muted: #5d6180;
    --line: rgba(46, 50, 87, 0.12);
    --accent: var(--xp-orange);
    --accent-strong: #b9530e; /* laranja escuro: texto branco com contraste 4.8:1 */
    --accent-hover: #a2480b;
    --warm: var(--xp-orange);
    --success: #15803d;
    --error: #b91c1c;
    --shadow: 0 1px 2px rgba(31, 34, 64, 0.06), 0 1px 3px rgba(31, 34, 64, 0.04);
    --shadow-pop: 0 8px 24px rgba(31, 34, 64, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --focus: 0 0 0 3px rgba(245, 134, 52, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Source Sans 3", sans-serif;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    accent-color: var(--accent-strong);
}

::selection {
    background: rgba(245, 134, 52, 0.25);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--xp-orange);
    box-shadow: var(--focus);
}

.page-shell {
    width: min(1200px, calc(100% - 24px));
    margin: 0 auto;
    padding: 16px 0 40px;
}

.card,
.flash,
.hero-card {
    border: 1px solid var(--line);
    background: var(--paper-strong);
    box-shadow: var(--shadow);
}

.card {
    border-radius: var(--radius);
    padding: 18px;
}

.app-header {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    border: 0;
    color: #fff;
    background: var(--xp-navy);
}

/* faixa com o degrade do anel do logo */
.app-header::after,
.auth-brand::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--xp-orange);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    height: 56px;
    width: auto;
    display: block;
}

.app-header .eyebrow {
    color: var(--xp-amber);
    margin-bottom: 2px;
}

.app-header .user-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.app-header .user-badge span {
    color: rgba(255, 255, 255, 0.7);
}

.app-header .button-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
}

.app-header .button-ghost:hover {
    border-color: var(--xp-amber);
    color: var(--xp-amber);
}

.app-header .button-link {
    color: #ffb4a8;
}

@media (min-width: 901px) {
    .app-header {
        grid-template-columns: auto 1fr;
        align-items: center;
        padding: 18px 24px 22px;
    }

    .app-header .header-actions {
        grid-auto-flow: column;
        justify-content: end;
        align-items: center;
    }
}

/* Login / primeiro acesso */
.auth-card {
    padding: 0;
    overflow: hidden;
}

.auth-brand {
    position: relative;
    display: grid;
    place-items: center;
    padding: 28px 20px 24px;
    background: var(--xp-navy);
}

.auth-brand img {
    width: min(220px, 70%);
    height: auto;
}

.auth-body {
    padding: 20px 18px 22px;
    display: grid;
    gap: 10px;
}

.brand-title,
h1,
h2,
h3,
.hero-card strong {
    font-family: "Space Grotesk", sans-serif;
}

.brand-title {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.header-actions {
    display: grid;
    gap: 12px;
}

.user-badge {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.55);
}

.top-nav,
.toolbar-actions,
.form-actions,
.section-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.top-nav form {
    margin: 0;
}

.eyebrow {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 4px;
}

h2 {
    margin: 0 0 6px;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.hero {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.hero-card {
    border-radius: var(--radius);
    padding: 20px;
    display: grid;
    gap: 10px;
}

.toolbar,
.search-inline,
.inline-form,
.codigo-row,
.user-grid {
    display: grid;
    gap: 12px;
}

.toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.search-inline {
    grid-template-columns: 1fr auto;
}

.single-column,
.stack,
.table-stack,
.log-stack {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
textarea,
select,
button {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid rgba(46, 50, 87, 0.22);
    border-radius: var(--radius-sm);
    min-height: 40px;
    padding: 8px 12px;
    background: #fff;
    color: var(--ink);
}

textarea {
    min-height: 80px;
}

button,
.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0 16px;
    background: var(--accent-strong);
    color: white;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out, transform 100ms ease-out;
}

/* hover escurece qualquer fundo (botoes com cor propria continuam com a cor deles) */
button:hover,
.button-primary:hover {
    box-shadow: inset 0 0 0 100vmax rgba(0, 0, 0, 0.10);
}

button:active,
.button-primary:active,
.button-ghost:active {
    transform: scale(0.97);
}

.button-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid rgba(46, 50, 87, 0.22);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    transition: background-color 120ms ease-out, border-color 120ms ease-out, transform 100ms ease-out;
}

.button-ghost:hover {
    border-color: var(--xp-navy);
    background: rgba(46, 50, 87, 0.04);
}

.button-link {
    min-height: auto;
    padding: 0;
    background: transparent;
    box-shadow: none;
    color: var(--error);
}

.button-link:hover {
    background: transparent;
    text-decoration: underline;
}

.button-fit,
.status-pill {
    width: fit-content;
}

.button-inline {
    min-height: 20px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.align-start-mobile {
    align-items: flex-start;
}

.cto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.cto-square {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 230px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--paper-strong);
    text-decoration: none;
    color: inherit;
}

.cto-thumb {
    min-height: 150px;
    background: rgba(46, 50, 87, 0.05);
}

.thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-placeholder {
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 700;
}

.cto-square-body {
    display: grid;
    gap: 4px;
    padding: 14px;
    text-align: left;
}

.cto-square-body span,
.cto-square-body small,
.muted,
.code-address,
.code-meta small {
    color: var(--muted);
}

.chip {
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(245, 134, 52, 0.14);
    color: #b4500f;
    font-weight: 700;
    white-space: nowrap;
}

.cto-image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    margin-top: 8px;
}

.code-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.code-list li,
.user-card,
.log-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: var(--paper-strong);
}

.code-line {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.code-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.status-pill {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.status-ativo {
    background: rgba(22, 101, 52, 0.12);
    color: var(--success);
}

.status-bloqueado {
    background: rgba(153, 27, 27, 0.12);
    color: var(--error);
}

.status-cancelado {
    background: rgba(107, 114, 128, 0.15);
    color: #4b5563;
}

.status-negativado {
    background: rgba(153, 27, 27, 0.18);
    color: #7f1d1d;
}

.status-info {
    background: rgba(46, 50, 87, 0.12);
    color: var(--xp-navy);
}

.status-pre-contrato,
.status-aguardando_assinatura,
.status-desconhecido {
    background: rgba(249, 167, 41, 0.18);
    color: #b4500f;
}

.candidate-box {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    padding: 10px;
    border: 1px dashed var(--line);
    border-radius: 14px;
}

.candidate-form {
    display: grid;
    gap: 10px;
}

.inline-form {
    grid-template-columns: 170px 1fr auto;
    align-items: end;
}

.codigo-row {
    grid-template-columns: 160px 1fr auto;
    align-items: end;
}

.user-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.info-badge {
    display: grid;
    gap: 4px;
    align-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: var(--paper-strong);
}

.log-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.json-block {
    margin: 0;
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--xp-navy-deep);
    color: #ffe9c7;
    overflow: auto;
    font-size: 0.88rem;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.flash {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-weight: 600;
}

.flash-success {
    color: var(--success);
    background: #f0f9f3;
    border-color: rgba(21, 128, 61, 0.3);
}

.flash-error {
    color: var(--error);
    background: #fdf3f3;
    border-color: rgba(185, 28, 28, 0.3);
}

.empty-state {
    border: 1px dashed rgba(46, 50, 87, 0.2);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--muted);
    background: var(--paper-strong);
}

.section-divider {
    display: grid;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.checkbox {
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 10px;
}

.checkbox input {
    width: auto;
    margin-top: 3px;
}

.hidden {
    visibility: hidden;
}

.top-gap {
    margin-top: 16px;
}

.auth-shell {
    min-height: calc(100vh - 32px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 420px);
}

@media (max-width: 900px) {
    .hero,
    .toolbar,
    .search-inline,
    .inline-form,
    .codigo-row,
    .user-grid {
        grid-template-columns: 1fr;
    }

    .mobile-toolbar,
    .stacked-on-mobile,
    .header-actions {
        align-items: stretch;
    }

    .section-heading.stacked-on-mobile {
        flex-direction: column;
        align-items: stretch;
    }

    .top-nav,
    .toolbar-actions,
    .code-actions,
    .section-actions,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .top-nav form,
    .top-nav form button,
    .toolbar-actions form,
    .toolbar-actions form button,
    .code-actions form,
    .code-actions form button,
    .form-actions button,
    .form-actions .button-ghost {
        width: 100%;
    }

    .page-shell {
        width: min(100% - 16px, 1200px);
        padding-top: 12px;
    }

    .card {
        padding: 16px;
    }

    .auth-shell {
        min-height: calc(100vh - 16px);
    }
}
