/* ============================================================
   Convênios Estaduais — Layout idêntico ao Portal da Transparência
   ============================================================ */
.ce-wrap, .ce-wrap * { box-sizing: border-box; }
.ce-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #F3F5F7;
    border-radius: 14px;
    padding: 0;
    max-width: 1280px;
    margin: 16px auto;
    color: #1F2937;
    overflow: hidden;
    border: 1px solid #E5E7EB;
}

/* HEADER */
.ce-header {
    background: linear-gradient(180deg, #0F6A5C 0%, #0C5B50 100%);
    color: #fff;
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.ce-header-title {
    display: flex; align-items: center; gap: 12px;
}
.ce-header-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .2px;
}
.ce-header-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    opacity: .9;
}
.ce-header-right {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
}
.ce-header-label { color: rgba(255,255,255,.85); }
.ce-header-right .ce-input {
    background: #fff;
    color: #111827;
    border: none;
    border-radius: 8px;
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    min-width: 110px;
}

/* FILTROS */
.ce-filters {
    background: #fff;
    padding: 18px 22px 14px;
}
.ce-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.ce-row-4 {
    grid-template-columns: repeat(4, 1fr);
}
.ce-row-end {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0;
}
.ce-field { display: flex; flex-direction: column; gap: 6px; }
.ce-field label {
    font-size: 11px;
    font-weight: 600;
    color: #6B7280;
    letter-spacing: .04em;
}
.ce-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 13px;
    color: #111827;
    background: #fff;
    outline: none;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.ce-input:focus { border-color: #0F6A5C; box-shadow: 0 0 0 3px rgba(15,106,92,.12); }
select.ce-input { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* BUTTONS */
.ce-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
    background: #fff;
}
.ce-btn-light {
    background: #fff !important;
    color: #374151 !important;
    border-color: #D1D5DB !important;
}
.ce-btn-light:hover { background: #F9FAFB !important; border-color: #9CA3AF !important; }
.ce-btn-primary {
    background: #0F6A5C !important;
    color: #fff !important;
    border-color: #0F6A5C !important;
}
.ce-btn-primary:hover { background: #0C5B50 !important; }
.ce-btn-csv    { background: #0F6A5C !important; color: #fff !important; border-color: #0C5B50 !important; }
.ce-btn-excel  { background: #0F6A5C !important; color: #fff !important; border-color: #0C5B50 !important; }
.ce-btn-json   { background: #0F6A5C !important; color: #fff !important; border-color: #0C5B50 !important; }
.ce-btn-pdf    { background: #0F6A5C !important; color: #fff !important; border-color: #0C5B50 !important; }
.ce-btn-csv:hover{background:#0C5B50}
.ce-btn-excel:hover{background:#0C5B50}
.ce-btn-json:hover{background:#0C5B50}
.ce-btn-pdf:hover{background:#0C5B50}

/* LINK DA CONSULTA */
.ce-consulta {
    background: #F3F5F7;
    border-top: 1px solid #E5E7EB;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
}
.ce-consulta-label {
    color: #6B7280;
    font-weight: 600;
    letter-spacing: .04em;
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
}
.ce-consulta-icon { color: #0F6A5C; }
.ce-consulta-input {
    flex: 1;
    min-width: 260px;
    padding: 8px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 12px;
    color: #4B5563;
    background: #fff;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.ce-pill {
    display: inline-flex;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
}
.ce-pill-muted { background: #E5E7EB; color: #6B7280; }
.ce-pill-active { background: #0F6A5C; color: #fff; }
.ce-consulta-hint { font-size: 11px; color: #6B7280; }

/* STATS */
.ce-stats {
    background: #fff;
    padding: 16px 22px;
    border-top: 1px solid #E5E7EB;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 22px;
}
.ce-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: #6B7280;
    letter-spacing: .06em;
    margin-bottom: 4px;
}
.ce-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #0F6A5C;
    line-height: 1.1;
}

/* EXPORT BAR */
.ce-export-bar {
    background: #fff;
    padding: 12px 22px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ce-export-label {
    font-size: 11px;
    font-weight: 700;
    color: #6B7280;
    letter-spacing: .06em;
    margin-right: 4px;
}
.ce-count-info {
    margin-left: auto;
    font-size: 12px;
    color: #6B7280;
}
.ce-count-info span { font-weight: 600; color: #111827; }

/* TABLE */
.ce-table-wrap {
    background: #fff;
    overflow-x: auto;
    border-top: 1px solid #E5E7EB;
}
.ce-table {
    width: 100%;
    border-collapse: collapse;
}
.ce-table th {
    background: #F9FAFB;
    padding: 11px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid #E5E7EB;
    white-space: nowrap;
}
.ce-table td {
    padding: 16px 14px;
    border-bottom: 1px solid #F3F4F6;
    font-size: 13px;
    color: #374151;
    vertical-align: middle;
}
.ce-table tr:hover td { background: #FAFAFA; }
.ce-table .ce-td-right { text-align: right; white-space: nowrap; }
.ce-table .ce-td-center { text-align: center; }
.ce-table .ce-numero-cell { font-weight: 700; color: #111827; }
.ce-objeto { max-width: 360px; line-height: 1.4; }

/* Badges de situação */
.ce-sit {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.ce-sit-ok      { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.ce-sit-andamento{background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.ce-sit-encerrado{background: #FEE2E2; color: #B91C1C; border-color: #FECACA; }
.ce-sit-neutro  { background: #F3F4F6; color: #4B5563; border-color: #E5E7EB; }

/* Detalhes button */
.ce-detalhes {
    background: #0F6A5C !important;
    color: #fff !important;
    padding: 6px 18px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
}
.ce-detalhes:hover { background: #0C5B50 !important; }

.ce-empty {
    text-align: center;
    padding: 40px;
    color: #9CA3AF;
    font-size: 13px;
}

/* PAGINATION */
.ce-pagination {
    background: #fff;
    padding: 12px 22px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    justify-content: center;
    gap: 6px;
}
.ce-pagination button {
    border: 1px solid #D1D5DB;
    background: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
}
.ce-pagination button.is-active { background: #0F6A5C; color: #fff; border-color: #0F6A5C; }
.ce-pagination button:disabled { opacity: .5; cursor: default; }

/* RESPONSIVO */
@media (max-width: 1024px) {
    .ce-row-4 { grid-template-columns: repeat(2, 1fr); }
    .ce-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
    .ce-row-4 { grid-template-columns: 1fr; }
    .ce-stats { grid-template-columns: repeat(2, 1fr); }
    .ce-header { flex-direction: column; align-items: flex-start; }
    .ce-objeto { max-width: 220px; }
}

/* PRINT */
@media print {
    .ce-filters, .ce-consulta, .ce-export-bar, .ce-pagination, .ce-detalhes { display: none !important; }
    .ce-wrap { box-shadow: none; border: none; }
    .ce-header { background: #0F6A5C !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Modal de detalhes */
.ce-modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99998;
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
}
.ce-modal-bg.is-open { display: flex; }
.ce-modal {
    background: #fff;
    max-width: 760px;
    width: 100%;
    border-radius: 12px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.ce-modal-head {
    background: #0F6A5C;
    color: #fff;
    padding: 14px 20px;
    display: flex; justify-content: space-between; align-items: center;
    border-radius: 12px 12px 0 0;
}
.ce-modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.ce-modal-close {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
}
.ce-modal-body {
    padding: 20px;
    font-size: 13px;
    color: #374151;
}
.ce-modal-body dl { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; margin: 0; }
.ce-modal-body dt { color: #6B7280; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.ce-modal-body dd { margin: 0; color: #111827; }

/* Export bar buttons all teal */
.ce-export-bar .ce-btn {
    background: #0F6A5C !important;
    color: #fff !important;
    border-color: #0C5B50 !important;
}
.ce-export-bar .ce-btn:hover {
    background: #0C5B50;
}
/* Copy link button teal */
.ce-copy-link {
    background: #0F6A5C !important;
    color: #fff !important;
    border-color: #0C5B50 !important;
}
.ce-copy-link:hover {
    background: #0C5B50 !important;
}

/* ===== MODAL COMPLETO ===== */
.ce-modal-bg { display:none; position:fixed; inset:0; z-index:99999; background:rgba(0,0,0,.55); align-items:center; justify-content:center; padding:16px; }
.ce-modal-bg.is-open { display:flex; }
.ce-modal { background:#fff; border-radius:12px; width:100%; max-width:820px; max-height:90vh; overflow:hidden; display:flex; flex-direction:column; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.ce-modal-head { background:#1a6b55; color:#fff; padding:18px 24px; display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
.ce-modal-head h3 { margin:0; font-size:17px; font-weight:700; letter-spacing:.01em; }
.ce-modal-close { background:#4a2fa0; border:none; color:#fff; width:36px; height:36px; border-radius:8px; cursor:pointer; font-size:18px; display:flex; align-items:center; justify-content:center; transition:background .2s; }
.ce-modal-close:hover { background:#3a1f90; }
.ce-modal-body { overflow-y:auto; padding:0; flex:1; }
.ce-modal-section { padding:20px 24px; border-bottom:1px solid #e5e7eb; }
.ce-modal-section:last-child { border-bottom:none; }
.ce-modal-section-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:#1a6b55; margin-bottom:14px; padding-bottom:8px; border-bottom:2px solid #e8f5f0; }
.ce-modal-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px,1fr)); gap:12px 20px; }
.ce-modal-item { display:flex; flex-direction:column; gap:3px; }
.ce-modal-item-full { grid-column:1/-1; }
.ce-modal-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:#6b7280; }
.ce-modal-value { font-size:13.5px; color:#111827; line-height:1.5; word-break:break-word; }
.ce-modal-money { font-size:14px; font-weight:600; color:#1a6b55; }
.ce-modal-link { display:inline-flex; align-items:center; gap:6px; color:#1a6b55; font-size:13px; font-weight:600; text-decoration:none; padding:8px 14px; border:1.5px solid #1a6b55; border-radius:6px; transition:all .2s; }
.ce-modal-link:hover { background:#1a6b55; color:#fff; }
@media(max-width:600px){
  .ce-modal-grid { grid-template-columns:1fr; }
  .ce-modal { max-height:95vh; }
  .ce-modal-section { padding:16px; }
}