:root {
  --tit-border: #cbd9ec;
  --tit-soft: #f5f8fc;
  --tit-blue: #1954c7;
  --tit-text: #152238;
  --tit-muted: #64748b;
}

.titulares-page { min-height: 100vh; background: #edf3fa; color: var(--tit-text); }
.titulares-content { width: min(1500px, calc(100% - 40px)); margin: 22px auto; }
.titulares-card { background: #fff; border: 1px solid var(--tit-border); border-radius: 8px; padding: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 5px 0 0; font-size: 22px; letter-spacing: 0; }
.eyebrow { display: inline-block; border: 1px solid #9fc2ff; background: #eaf2ff; color: #1748a8; border-radius: 999px; padding: 5px 10px; font-weight: 800; font-size: 11px; }
.updated-chip, .row-count { color: #1748a8; border: 1px solid #b9d1f5; background: #f2f7ff; padding: 8px 12px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.scope-modes { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border: 1px solid var(--tit-border); border-radius: 7px; background: var(--tit-soft); }
.scope-mode { min-height: 44px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #334155; font-weight: 800; cursor: pointer; box-shadow: none; }
.scope-mode:hover { border-color: #a9c4ed; background: #f1f6fd; }
.scope-mode.active { border-color: #3f78e5; background: #eaf2ff; color: #123f9d; }
.scope-panel { margin-top: 16px; border: 1px solid var(--tit-border); border-radius: 7px; background: var(--tit-soft); padding: 14px; }
.select-all-row { display: flex; align-items: center; justify-content: flex-start; gap: 9px; width: max-content; max-width: 100%; font-weight: 800; margin: 0 0 12px; cursor: pointer; }
.source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.source-item { display: flex; align-items: flex-start; justify-content: flex-start; gap: 10px; min-width: 0; min-height: 64px; padding: 11px 12px; border: 1px solid var(--tit-border); border-radius: 6px; background: #fff; cursor: pointer; }
.source-item:hover { border-color: #83a9e6; background: #f8fbff; }
.source-item:has(input:checked) { border-color: #3f78e5; background: #edf4ff; }
.select-all-row input,
.source-item input { appearance: auto; flex: 0 0 17px; width: 17px; min-width: 17px; height: 17px; margin: 2px 0 0; padding: 0; border-radius: 4px; box-shadow: none; accent-color: #2158d9; }
.select-all-row input:focus,
.source-item input:focus { box-shadow: 0 0 0 3px rgba(33, 88, 217, .16); }
.source-item > span { display: block; min-width: 0; text-align: left; line-height: 1.25; }
.source-item strong, .source-item small { display: block; overflow-wrap: anywhere; }
.source-item strong { color: var(--tit-text); font-size: 13px; }
.source-item small { color: var(--tit-muted); margin-top: 4px; font-weight: 600; }
.muted { color: var(--tit-muted); }
.file-drop { min-height: 92px; border: 1px dashed #6d99df; border-radius: 7px; display: grid; place-items: center; color: #164da9; cursor: pointer; background: #fff; }
.file-drop input { position: absolute; opacity: 0; pointer-events: none; }
.location-list { display: grid; gap: 9px; }
.location-row { display: grid; grid-template-columns: 130px 1fr 1fr 38px; gap: 9px; align-items: end; }
.location-row label, .filters-grid label { display: grid; gap: 6px; font-size: 12px; font-weight: 800; }
.location-row input, .filters-grid input, .filters-grid select, .pagination-bar select { width: 100%; min-height: 42px; border: 1px solid var(--tit-border); border-radius: 6px; padding: 9px 11px; background: #fff; color: var(--tit-text); }
.remove-location { width: 38px; height: 42px; border: 1px solid #efb0b0; background: #fff5f5; color: #b91c1c; border-radius: 6px; font-size: 20px; cursor: pointer; }
.query-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.primary-action, .secondary-action, .danger-action { min-height: 42px; padding: 9px 16px; border-radius: 6px; font-weight: 800; cursor: pointer; box-shadow: none; }
.primary-action { border: 1px solid #164abe; background: #2158d9; color: #fff; }
.secondary-action { border: 1px solid #a9bbd2; background: #fff; color: #27415f; }
.danger-action { border: 1px solid #b91c1c; background: #c91f25; color: #fff; }
button:disabled { opacity: .55; cursor: default; }
.status-message { margin-top: 14px; border: 1px solid var(--tit-border); background: var(--tit-soft); padding: 12px; border-radius: 6px; }
.status-message.error { color: #b91c1c; border-color: #efb0b0; background: #fff4f4; }
.status-message.success { color: #087443; border-color: #9bdfbd; background: #effcf5; }
.progress-wrap { margin-top: 14px; }
.progress-track { position: relative; height: 24px; border-radius: 6px; overflow: hidden; background: #dce5f1; }
.progress-fill { height: 100%; width: 0; background: #179b55; transition: width .25s ease; }
.progress-track strong { position: absolute; inset: 0; display: grid; place-items: center; color: #142033; }
.progress-wrap p { margin: 7px 0 0; color: var(--tit-muted); font-size: 13px; }
.results-section { margin-top: 16px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.summary-grid article { border: 1px solid var(--tit-border); border-radius: 7px; background: #fff; padding: 14px; text-align: center; }
.summary-grid span { display: block; color: var(--tit-muted); font-size: 12px; font-weight: 700; }
.summary-grid strong { display: block; margin-top: 5px; font-size: 26px; }
.summary-grid .summary-ok { background: #effcf5; border-color: #a9e4c3; }
.summary-grid .summary-warn { background: #fff9e9; border-color: #efd787; }
.summary-grid .summary-empty { background: #fff1f1; border-color: #efb4b4; }
.table-heading { margin-bottom: 13px; }
.table-heading-actions { display: flex; align-items: center; gap: 9px; }
.filters-grid { display: grid; grid-template-columns: 90px 110px 100px 1fr 150px 1.5fr auto; gap: 9px; align-items: end; margin-bottom: 14px; }
.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--tit-border); border-radius: 6px; }
.titulares-table { width: 100%; min-width: 1120px; border-collapse: collapse; font-size: 12px; }
.titulares-table th { position: sticky; top: 0; background: #edf4fd; color: #17365f; font-weight: 800; text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--tit-border); }
.titulares-table td { padding: 9px 8px; border-bottom: 1px solid #dce5f1; vertical-align: top; }
.titulares-table tr:last-child td { border-bottom: 0; }
.titulares-table .holder-name { min-width: 230px; font-weight: 700; }
.titulares-table tr.row-empty td { background: #fff3f3; }
.titulares-table tr.row-nn td { background: #fff9e6; }
.state-badge { display: inline-block; border: 1px solid currentColor; border-radius: 999px; padding: 3px 7px; font-size: 10px; font-weight: 800; }
.state-badge.identified { color: #087443; }
.state-badge.nn { color: #9a6500; }
.state-badge.empty { color: #b91c1c; }
.empty-table { text-align: center; color: var(--tit-muted); padding: 30px !important; }
.pagination-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 12px; }
.pagination-bar label, .pagination-bar div { display: flex; align-items: center; gap: 9px; }
.pagination-bar select { width: 76px; min-height: 36px; }
.pagination-bar button { min-height: 36px; border: 1px solid var(--tit-border); background: #fff; color: #234264; border-radius: 5px; padding: 7px 11px; font-weight: 700; }

body.dark-theme.titulares-page { --tit-border: #344762; --tit-soft: #111c2d; --tit-text: #e6eef9; --tit-muted: #9fb0c7; background: #0c1422; }
body.dark-theme .titulares-card, body.dark-theme .source-item, body.dark-theme .summary-grid article { background: #101a2b; }
body.dark-theme .source-item:hover, body.dark-theme .source-item:has(input:checked) { background: #172d50; }
body.dark-theme .location-row input, body.dark-theme .filters-grid input, body.dark-theme .filters-grid select, body.dark-theme .pagination-bar select, body.dark-theme .pagination-bar button { background: #0b1422; color: #e6eef9; }
body.dark-theme .scope-mode { color: #cbd7e7; }
body.dark-theme .scope-mode:hover { background: #17263b; }
body.dark-theme .scope-mode.active { background: #17376b; color: #fff; }
body.dark-theme .file-drop { background: #0b1422; }
body.dark-theme .titulares-table th { background: #182a42; color: #e6eef9; }
body.dark-theme .titulares-table td { border-color: #2c3d56; }
body.dark-theme .titulares-table tr.row-empty td { background: #391d25; }
body.dark-theme .titulares-table tr.row-nn td { background: #352b14; }
body.dark-theme .summary-grid .summary-ok { background: #102d24; }
body.dark-theme .summary-grid .summary-warn { background: #302812; }
body.dark-theme .summary-grid .summary-empty { background: #351d24; }

@media (max-width: 900px) {
  .titulares-content { width: min(100% - 18px, 1500px); margin: 10px auto; }
  .titulares-card { padding: 14px; }
  .scope-modes, .summary-grid { grid-template-columns: 1fr; }
  .source-list { grid-template-columns: 1fr; }
  .location-row { grid-template-columns: 1fr 1fr; }
  .location-row .remove-location { align-self: end; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .search-filter { grid-column: 1 / -1; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .table-heading-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 520px) {
  .location-row, .filters-grid { grid-template-columns: 1fr; }
  .query-actions > button { width: 100%; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .pagination-bar { align-items: stretch; flex-direction: column; }
  .table-heading-actions { align-items: stretch; flex-direction: column; }
  .pagination-bar div { justify-content: space-between; }
}
