/* ============================================
   Qualité Benefícios — Base de Contratos · ADMIN
   Estilos do dashboard administrativo (contratos + síndicos).
   ============================================ */

.admin-body { background: #F5F1EB; }

/* ========== Header com user info ========== */
.admin-header {
    background: var(--navy);
    color: #fff;
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-md);
}
.admin-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.admin-user {
    display: flex;
    align-items: center;
    gap: 14px;
}
.admin-user .badge {
    background: var(--orange);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 3px 10px;
    border-radius: 999px;
}
.admin-user .who { font-size: 0.85rem; color: rgba(255, 255, 255, 0.85); }
.btn-logout {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    background: transparent;
    transition: background 0.2s var(--ease);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.1); }

/* ========== Layout principal ========== */
.admin-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ========== Login ========== */
.login-shell-admin {
    min-height: calc(100vh - 56px);
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card-admin {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--line-soft);
}
.login-card-admin h1 {
    font-size: 1.5rem;
    margin-bottom: 6px;
}
.login-card-admin .subtitle {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 24px;
}

/* ========== Stats cards ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.stat-card .stat-value {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
}
.stat-card.stat-ativo     .stat-value { color: var(--success); }
.stat-card.stat-suspenso  .stat-value { color: #C7891A; }
.stat-card.stat-cancelado .stat-value { color: var(--muted); }
.stat-card.stat-total     .stat-value { color: var(--navy); }
.stat-card.stat-sindicos  .stat-value { color: var(--orange); }

/* ========== Toolbar (filtros + ações) ========== */
.toolbar {
    background: var(--white);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.toolbar .filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.toolbar label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--navy);
}
.toolbar select,
.toolbar input[type="text"],
.toolbar input[type="date"] {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
}
.toolbar select:focus,
.toolbar input:focus { outline: none; border-color: var(--orange); }
.toolbar .filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: flex-end;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.82rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.btn-primary.btn-sm {
    background: var(--orange);
    color: #fff;
    border: none;
}
.btn-primary.btn-sm:hover { background: var(--orange-dark); }
.btn-ghost.btn-sm {
    background: transparent;
    color: var(--navy);
    border: 1px solid var(--line);
}
.btn-ghost.btn-sm:hover { background: var(--cream); border-color: var(--navy); }

/* ========== Tabela ========== */
.list-card {
    background: var(--white);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.list-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--cream);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--navy);
    font-weight: 700;
    border-bottom: 2px solid var(--line);
}
.list-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr.row-link { cursor: pointer; transition: background 0.15s var(--ease); }
.list-table tr.row-link:hover { background: var(--cream); }
.list-table .protocolo {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--orange-dark);
}
.list-table .empresa { color: var(--navy); font-weight: 500; }
.list-table .data-cell { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.empty-row td {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-style: italic;
}

/* ========== Status badge ========== */
.status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.status-ativo      { background: rgba(46, 139, 87, 0.12);  color: var(--success); }
.status-suspenso   { background: rgba(199, 137, 26, 0.14); color: #8C5C0E; }
.status-cancelado  { background: rgba(91, 107, 134, 0.12); color: var(--muted); }
.status-inativo    { background: rgba(91, 107, 134, 0.12); color: var(--muted); }
.status-cliente    { background: rgba(46, 139, 87, 0.12);  color: var(--success); }
.status-prospect   { background: rgba(232, 119, 34, 0.12); color: var(--orange-dark); }

.modo-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--cream);
    color: var(--muted);
}
.modo-anonimo      { background: rgba(91, 107, 134, 0.10); color: var(--muted); }
.modo-confidencial { background: rgba(199, 137, 26, 0.10); color: #8C5C0E; }
.modo-identificado { background: rgba(46, 139, 87, 0.10); color: var(--success); }

/* ========== Paginação ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding: 0 4px;
    font-size: 0.85rem;
    color: var(--muted);
}
.pagination .nav-buttons { display: flex; gap: 8px; }
.pagination button {
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: 999px;
    background: var(--white);
    border: 1px solid var(--line);
    color: var(--navy);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s var(--ease);
}
.pagination button:hover:not(:disabled) { background: var(--cream); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   PÁGINA DE DETALHE
   ============================================ */
.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 18px;
    text-decoration: none;
}
.detail-back:hover { color: var(--navy); }

.detail-header {
    margin-bottom: 24px;
}
.detail-header .protocolo-big {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: 0.03em;
}
.detail-header .meta {
    display: flex;
    gap: 14px;
    margin-top: 8px;
    flex-wrap: wrap;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
}
.detail-header .meta strong { color: var(--navy); font-weight: 600; }

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--white);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}
.panel h3 {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--navy);
    font-weight: 700;
    margin-bottom: 14px;
}

.field-list dt {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.field-list dd {
    margin-bottom: 14px;
    color: var(--ink);
    font-size: 0.92rem;
    line-height: 1.55;
}
.field-list dd:last-child { margin-bottom: 0; }
.field-list .descricao-box {
    background: var(--cream);
    padding: 14px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    line-height: 1.6;
    border-left: 3px solid var(--orange);
}
.field-list .empty-value { color: var(--muted); font-style: italic; }

/* ========== Painel de ações ========== */
.actions-panel form { display: flex; flex-direction: column; gap: 14px; }
.actions-panel select,
.actions-panel textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--cream);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
}
.actions-panel textarea { min-height: 100px; resize: vertical; }
.actions-panel select:focus,
.actions-panel textarea:focus { outline: none; border-color: var(--orange); }
.actions-panel .btn-primary {
    align-self: flex-end;
    padding: 10px 20px;
    font-size: 0.88rem;
    border-radius: 999px;
    background: var(--orange);
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.actions-panel .btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.actions-panel .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.actions-panel .help {
    font-size: 0.78rem;
    color: var(--muted);
}
.save-msg {
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: none;
}
.save-msg.show { display: block; }
.save-msg.success { background: rgba(46, 139, 87, 0.10); color: var(--success); }
.save-msg.error { background: rgba(196, 95, 18, 0.10); color: var(--orange-dark); }

/* ========== Timeline de eventos ========== */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}
.timeline li {
    position: relative;
    padding-left: 22px;
    padding-bottom: 18px;
    border-left: 2px solid var(--line);
}
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 4px;
    width: 12px; height: 12px;
    background: var(--white);
    border: 2px solid var(--orange);
    border-radius: 50%;
}
.timeline .ev-status::before { border-color: var(--navy); }
.timeline .ev-comment::before { border-color: #C7891A; }
.timeline .ev-time {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}
.timeline .ev-actor { font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
.timeline .ev-content {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.5;
    white-space: pre-wrap;
}

.error-msg {
    background: rgba(196, 95, 18, 0.08);
    border: 1px solid rgba(196, 95, 18, 0.25);
    color: var(--orange-dark);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-top: 12px;
}

/* ============================================
   Responsivo
   ============================================ */
@media (max-width: 960px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .admin-header-inner { padding: 0 16px; }
    .admin-shell { padding: 24px 16px 48px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar .filter-actions { margin-left: 0; }
    .list-table { font-size: 0.8rem; }
    .list-table th, .list-table td { padding: 10px 12px; }
    .stats-row { grid-template-columns: 1fr; }
    .tab-nav { flex-wrap: wrap; }
}

/* ============================================
   TABS (contratos | sindicos)
   ============================================ */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--line);
}
.tab-nav .tab {
    background: none;
    border: none;
    padding: 12px 22px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tab-nav .tab:hover { color: var(--navy); }
.tab-nav .tab.active {
    color: var(--navy);
    border-bottom-color: var(--orange);
}
.tab-nav .tab .badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7rem;
    background: var(--cream);
    color: var(--muted);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}
.tab-nav .tab.active .badge { background: var(--orange); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================
   MODAL (importação CSV + form de criação)
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 30, 63, 0.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 32px;
}
.modal.modal-wide { max-width: 800px; }
.modal h2 {
    font-size: 1.3rem;
    margin-bottom: 6px;
}
.modal .modal-subtitle {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 22px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}
.modal-actions .btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 9px 18px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}
.modal-actions .btn-ghost:hover { background: var(--cream); color: var(--navy); }
.modal-actions .btn-primary {
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 9px 22px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}
.modal-actions .btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.modal-actions .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.modal-actions .btn-danger {
    background: #C45F12;
    color: #fff;
    border: none;
    padding: 9px 22px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}

/* Drop zone */
.csv-drop {
    border: 2px dashed var(--line);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
    cursor: pointer;
}
.csv-drop:hover, .csv-drop.dragging {
    border-color: var(--orange);
    background: var(--orange-soft);
}
.csv-drop .icon {
    font-size: 2rem;
    color: var(--orange);
    margin-bottom: 8px;
}
.csv-drop .hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 6px;
}
.csv-drop input[type="file"] { display: none; }

.import-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--cream);
    border-radius: var(--radius-sm);
}
.import-preview h4 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--navy);
    margin-bottom: 10px;
}
.import-preview .totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.import-preview .tot {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
}
.import-preview .tot .label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
}
.import-preview .tot .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--navy);
}
.import-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: var(--white);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.import-preview th, .import-preview td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
}
.import-preview th { background: var(--cream); font-size: 0.7rem; text-transform: uppercase; }

/* Formulário CRUD (modal de criar/editar contrato) */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .form-field { display: flex; flex-direction: column; gap: 4px; }
.form-grid label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--navy);
    font-weight: 600;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
    padding: 9px 12px;
    font-size: 0.88rem;
    font-family: inherit;
    background: var(--cream);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { outline: none; border-color: var(--orange); }
.form-grid textarea { resize: vertical; min-height: 70px; }

/* Sindicos sub-tabela no detalhe do contrato */
.sindicos-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sindicos-list li {
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
}
.sindicos-list .sind-nome { font-weight: 600; color: var(--navy); }
.sindicos-list .sind-meta {
    font-size: 0.8rem;
    color: var(--muted);
}
.sindicos-list .sind-cargo {
    font-size: 0.68rem;
    background: var(--cream);
    color: var(--navy);
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.sindicos-list .sind-empty {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 14px;
}

/* Botão de header com ação primária (Novo contrato, Importar) */
.header-action {
    background: var(--orange);
    color: #fff !important;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
}
.header-action:hover { background: var(--orange-dark); }
.header-action.secondary {
    background: transparent;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.3);
}
.header-action.secondary:hover { background: rgba(255,255,255,0.08); }

.toolbar-right {
    display: flex;
    gap: 10px;
    margin-left: auto;
    align-items: flex-end;
}

/* Botão de ação inline na tabela */
.btn-inline-status {
    background: transparent;
    border: 1px solid var(--line);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--navy);
    margin-right: 4px;
}
.btn-inline-status:hover { background: var(--cream); }

/* Notificação toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--navy);
    color: #fff;
    padding: 14px 22px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    z-index: 200;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: #C45F12; }
