/* Certificados360 — Design System 2026 */
:root {
    --ds-bg: #f8fafc;
    --ds-card: #ffffff;
    --ds-text: #0f172a;
    --ds-text-muted: #64748b;
    --ds-border: #e2e8f0;
    --ds-primary: #2563eb;
    --ds-primary-hover: #1d4ed8;
    --ds-success: #22c55e;
    --ds-warning: #f59e0b;
    --ds-error: #ef4444;
    --ds-sidebar: 15rem;
    --ds-radius: 0.75rem;
    --ds-radius-lg: 1rem;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ds-text);
    background: var(--ds-bg);
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.08);
}

/* Nav */
.nav-link { transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(37, 99, 235, 0.06); color: var(--ds-text); }
.nav-link.active { background: rgba(37, 99, 235, 0.1); color: var(--ds-primary); font-weight: 600; }
.card-elevated { box-shadow: 0 1px 2px rgb(15 23 42 / 0.04); }

/* Botões */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    border: none; border-radius: 0.5rem; background: var(--ds-primary); padding: 0.5rem 1rem;
    font-size: 0.875rem; font-weight: 600; color: #fff; text-decoration: none;
    box-shadow: 0 1px 2px rgb(37 99 235 / 0.2); cursor: pointer;
    transition: background .15s, box-shadow .15s;
}
button.btn-primary, a.btn-primary { color: #fff; }
.btn-primary:hover { background: var(--ds-primary-hover); }

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    border: 1px solid var(--ds-border); border-radius: 0.5rem; background: var(--ds-card); padding: 0.5rem 1rem;
    font-size: 0.875rem; font-weight: 500; color: var(--ds-text); text-decoration: none;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); cursor: pointer;
    transition: background .15s, border-color .15s;
}
button.btn-secondary, a.btn-secondary { color: var(--ds-text); }
.btn-secondary:hover { background: var(--ds-bg); border-color: #cbd5e1; }

.btn-danger-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    border: 1px solid #fecaca; border-radius: 0.5rem; background: #fff; padding: 0.5rem 1rem;
    font-size: 0.875rem; font-weight: 500; color: var(--ds-error); text-decoration: none; cursor: pointer;
}
button.btn-danger-outline, a.btn-danger-outline { color: var(--ds-error); }
.btn-danger-outline:hover { background: #fef2f2; }

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Layout */
.app-main-inner {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    #app-main-column {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        max-width: none;
    }
    .app-main-inner {
        width: 100%;
        max-width: none;
    }
}

.page-shell {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

body.sidebar-open { overflow: hidden; }

#sidebar-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
body.sidebar-open #sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

#app-sidebar {
    width: var(--ds-sidebar);
    transition: transform 0.25s ease;
}

@media (max-width: 1023px) {
    #app-sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-open #app-sidebar {
        transform: translateX(0);
    }
}

.fab-safe {
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    right: max(1rem, env(safe-area-inset-right, 0px));
}
@media (min-width: 1024px) {
    .fab-safe {
        bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
        right: max(1.5rem, env(safe-area-inset-right, 0px));
    }
}

/* Page structure */
.ds-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ds-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.ds-page-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ds-text);
    line-height: 1.25;
}

.ds-page-desc {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ds-text-muted);
    line-height: 1.5;
}

.ds-card {
    background: var(--ds-card);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.ds-table-card {
    overflow: visible;
}

.ds-filter-card {
    padding: 0.75rem 1rem;
}

.ds-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.ds-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 7rem;
}

.ds-filter-field label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ds-text-muted);
}

.ds-input,
.ds-select {
    height: 2.25rem;
    width: 100%;
    border: 1px solid var(--ds-border);
    border-radius: 0.5rem;
    background: var(--ds-card);
    padding: 0 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ds-text);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.02);
    transition: border-color .15s, box-shadow .15s;
}
.ds-input::placeholder { color: #94a3b8; }
.ds-input:focus,
.ds-select:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.ds-filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.ds-table-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-table-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ds-text);
}

.ds-table-card-meta {
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ds-text-muted);
}

/* Badges */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 9999px;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}
.ds-badge-success { background: rgb(34 197 94 / 0.12); color: #15803d; }
.ds-badge-warning { background: rgb(245 158 11 / 0.12); color: #b45309; }
.ds-badge-muted { background: #f1f5f9; color: var(--ds-text-muted); }

.premio-alerta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 9999px;
    background: rgb(245 158 11 / 0.12);
    color: #b45309;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}
a.premio-alerta { text-decoration: none; cursor: pointer; }
a.premio-alerta:hover { background: rgb(245 158 11 / 0.2); }

/* Pagination */
.ds-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}
.ds-pagination a,
.ds-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.ds-pagination a {
    border: 1px solid var(--ds-border);
    background: var(--ds-card);
    color: var(--ds-text);
}
.ds-pagination a:hover { background: var(--ds-bg); }
.ds-pagination .ds-page-active {
    border: 1px solid var(--ds-primary);
    background: var(--ds-primary);
    color: #fff;
    font-weight: 600;
}
.ds-pagination .ds-page-ellipsis {
    color: var(--ds-text-muted);
    min-width: auto;
    padding: 0 0.25rem;
}

/* Table */
.table-scroll-wrap {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg);
    scrollbar-gutter: stable;
}

.table-scroll-wrap table {
    width: 100%;
    min-width: 76rem;
    table-layout: auto;
    border-collapse: collapse;
}

.table-scroll-hint {
    display: none;
    padding: 0.375rem 1.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--ds-text-muted);
    text-align: right;
}
@media (max-width: 1536px) {
    .table-scroll-hint { display: block; }
}

.data-table-cert {
    width: 100%;
    min-width: 76rem;
    table-layout: auto;
    border-collapse: collapse;
}

.data-table-cert th,
.data-table-cert td {
    vertical-align: middle;
    padding: 0.75rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
}

.data-table-cert thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ds-text-muted);
    background: var(--ds-bg);
    border-bottom: 1px solid var(--ds-border);
    white-space: nowrap;
    user-select: none;
}

.data-table-cert thead th[data-sort] {
    cursor: pointer;
}
.data-table-cert thead th[data-sort]:hover {
    color: var(--ds-text);
}
.data-table-cert thead th[data-sort]::after {
    content: '';
    display: inline-block;
    width: 0.75rem;
    margin-left: 0.25rem;
    opacity: 0.35;
}
.data-table-cert thead th.ds-sort-asc::after { content: '↑'; opacity: 1; }
.data-table-cert thead th.ds-sort-desc::after { content: '↓'; opacity: 1; }

.data-table-cert tbody td {
    border-bottom: 1px solid #f1f5f9;
    color: var(--ds-text-muted);
}

.data-table-cert tbody tr {
    transition: background .12s;
}
.data-table-cert tbody tr:hover td {
    background: #f8fafc;
}

.data-table-cert .col-nome {
    min-width: 13rem;
    font-weight: 600;
    color: var(--ds-text);
    white-space: nowrap;
}

.data-table-cert .col-cpf {
    min-width: 8.5rem;
    white-space: nowrap;
}

.data-table-cert .col-contrato {
    min-width: 5.5rem;
    font-weight: 600;
    color: var(--ds-text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table-cert .col-date {
    min-width: 6.25rem;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table-cert .col-premio {
    min-width: 6.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--ds-text);
}

.data-table-cert .col-bolsao {
    min-width: 6.5rem;
    text-align: center;
    white-space: nowrap;
}

.data-table-cert .col-endereco {
    min-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ds-text-muted);
}

.data-table-cert th.col-acoes,
.data-table-cert td.col-acoes {
    position: sticky;
    right: 0;
    z-index: 5;
    width: 2.75rem;
    min-width: 2.75rem;
    padding-left: 0.25rem;
    padding-right: 0.625rem;
    background: var(--ds-card);
    box-shadow: -6px 0 10px -8px rgba(15, 23, 42, 0.25);
    overflow: visible;
    text-align: center;
}

.data-table-cert thead th.col-acoes {
    z-index: 6;
    background: var(--ds-bg);
}
.data-table-cert tbody tr:hover td.col-acoes {
    background: #f8fafc;
}

/* legado — removido col-check, col-num genérico */
.data-table-cert .col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--ds-text);
    white-space: nowrap;
}

.data-table-cert .col-center {
    text-align: center;
    white-space: nowrap;
}

/* Row actions menu */
.ds-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--ds-text-muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.ds-icon-btn:hover {
    background: var(--ds-bg);
    border-color: var(--ds-border);
    color: var(--ds-text);
}

.ds-acoes-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 30;
    min-width: 11rem;
    border-radius: 0.625rem;
    border: 1px solid var(--ds-border);
    background: var(--ds-card);
    padding: 0.25rem;
    box-shadow: 0 10px 25px -5px rgb(15 23 42 / 0.12), 0 4px 6px -4px rgb(15 23 42 / 0.08);
}

.ds-menu-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ds-text);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}
.ds-menu-item:hover { background: var(--ds-bg); }
.ds-menu-item svg { flex-shrink: 0; color: var(--ds-text-muted); }

/* legado — tabelas gerais do sistema */
.data-table-fluid {
    width: 100%;
    min-width: 64rem;
    table-layout: auto;
    border-collapse: collapse;
}
.data-table-fluid th,
.data-table-fluid td {
    vertical-align: middle;
    word-break: break-word;
    overflow-wrap: anywhere;
    padding: 0.5rem 0.375rem;
    font-size: 0.8125rem;
}
.data-table-fluid thead th {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.data-table-fluid tbody td {
    border-top: 1px solid #f1f5f9;
}
.data-table-fluid tbody tr:hover {
    background: #f8fafc;
}
.data-table-fluid .col-acoes {
    width: 9%;
    min-width: 6.5rem;
    white-space: nowrap;
}

/* Filtros multi-seleção (relatório robô) */
.filter-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}
@media (min-width: 640px) {
    .filter-checkbox-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
.filter-checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.filter-checkbox-grid label:has(input:checked) {
    border-color: var(--ds-primary);
    background: rgb(37 99 235 / 0.06);
    color: var(--ds-text);
    font-weight: 600;
}
.filter-checkbox-grid input { flex-shrink: 0; }
.filter-imob-list {
    max-height: 12rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) {
    .filter-imob-list { max-height: 10rem; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 1280px) {
    .ds-filter-field--wide { flex: 1.4 1 9rem; }
    .ds-filter-field--nome { flex: 1.6 1 10rem; }
}
