:root {
    --ink: #1d2029;
    --muted: #6c7280;
    --line: #d8dce6;
    --line-strong: #c7ccd8;
    --paper: #ffffff;
    --surface: #f4f5f9;
    --wash: #eceef4;
    --brand: #7a1fa2;
    --brand-vivid: #9b28c7;
    --brand-dark: #42145a;
    --brand-deep: #211629;
    --brand-soft: #f0e5f5;
    --success: #117565;
    --gray: #8a92a1;
    --gray-dark: #4c5564;
    --gray-soft: #edf0f5;
    --shadow: 0 18px 44px rgba(23, 26, 34, 0.11);
    --shadow-soft: 0 10px 24px rgba(23, 26, 34, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(66, 20, 90, 0.08) 0 1px, transparent 1px 34px),
        linear-gradient(180deg, #e7e9f0 0%, #f8f8fb 38%, #eceef4 100%);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

body.has-modal-open {
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(115deg, rgba(33, 22, 41, 0.08), transparent 42%),
        linear-gradient(270deg, rgba(122, 31, 162, 0.1), transparent 48%);
}

button,
input,
select,
textarea {
    font: inherit;
}

.page {
    width: min(1400px, calc(100% - 36px));
    margin: 0 auto;
    padding: 30px 0 38px;
}

.masthead {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(292px, 0.34fr);
    gap: 22px;
    align-items: stretch;
    margin-bottom: 22px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 36%),
        linear-gradient(115deg, #211629 0%, #34203f 42%, #5d197a 100%);
    box-shadow: var(--shadow);
}

.masthead::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 6px;
    background: linear-gradient(90deg, #9b28c7, #6e1c92 52%, #c8cbd5);
}

.brand-block {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(214px, 246px) minmax(0, 1fr);
    gap: 26px;
    align-items: center;
}

.logo-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: min(246px, 100%);
    min-height: 136px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 8px;
    padding: 22px 24px;
    background: linear-gradient(180deg, #ffffff, #f5f6fa);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.24);
}

.logo-mark::after {
    content: "";
    position: absolute;
    inset: 9px;
    border: 1px solid rgba(122, 31, 162, 0.16);
    border-radius: 6px;
    pointer-events: none;
}

.logo-mark img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    max-width: 194px;
    max-height: 86px;
    object-fit: contain;
}

.eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: #ddd5e6;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 34px;
    height: 4px;
    border-radius: 999px;
    background: #b95ae0;
}

.masthead h1 {
    max-width: 980px;
    margin: 0;
    color: #ffffff;
    font-size: clamp(32px, 4.2vw, 56px);
    line-height: 1.02;
    text-wrap: balance;
}

.subtitle {
    max-width: 820px;
    margin: 14px 0 0;
    color: #e3dfeb;
    font-size: 17px;
    line-height: 1.5;
}

.live-card {
    position: relative;
    z-index: 1;
    align-self: stretch;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.11);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 900;
}

.status-dot {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--gray);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.14);
}

.is-online .status-dot {
    background: #2be0bb;
    box-shadow: 0 0 0 5px rgba(43, 224, 187, 0.18);
}

.is-offline .status-dot {
    background: #c8cbd5;
    box-shadow: 0 0 0 5px rgba(200, 203, 213, 0.18);
}

.timestamp {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.45;
}

.timestamp + .timestamp {
    margin-top: 6px;
}

.timestamp strong {
    color: #ffffff;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.86fr) minmax(0, 1.44fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel,
.metric,
.table-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-soft);
}

.progress-panel {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 394px;
    overflow: hidden;
    padding: 30px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(246, 247, 251, 0.96)),
        linear-gradient(135deg, rgba(122, 31, 162, 0.12), transparent);
}

.progress-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 7px;
    background: linear-gradient(90deg, var(--brand-vivid), var(--brand-dark), #9aa0ae);
}

.ring {
    --progress: 0deg;
    display: grid;
    place-items: center;
    width: min(330px, 78vw);
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle, #ffffff 0 57%, transparent 58%),
        conic-gradient(var(--brand-vivid) var(--progress), #dfe2eb 0);
    box-shadow: inset 0 0 0 1px rgba(66, 20, 90, 0.12), 0 20px 42px rgba(66, 20, 90, 0.15);
}

.ring-inner {
    display: grid;
    place-items: center;
    width: 74%;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff, #f6f7fb);
    text-align: center;
}

.ring-number {
    color: var(--brand-deep);
    font-size: clamp(52px, 5.4vw, 76px);
    font-weight: 900;
    line-height: 1;
}

.ring-label {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.metric {
    position: relative;
    display: grid;
    align-content: space-between;
    min-height: 188px;
    overflow: hidden;
    padding: 22px;
}

.metric::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--brand-vivid), var(--brand-dark));
}

.metric.pending::before {
    background: linear-gradient(90deg, #717887, #4c5564);
}

.metric.observed::before {
    background: linear-gradient(90deg, #5b6070, #2d313a);
}

.metric.total::before {
    background: linear-gradient(90deg, #8e36b2, #c8cbd5);
}

.metric::after {
    content: "";
    position: absolute;
    inset: auto 20px 18px auto;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(122, 31, 162, 0.18);
}

.metric-label {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.metric-value {
    margin: 0;
    color: var(--brand-deep);
    font-size: clamp(42px, 5vw, 58px);
    font-weight: 900;
    line-height: 1;
}

.metric-note {
    max-width: 92%;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 21px 22px 0;
}

.section-title {
    margin: 0;
    color: var(--brand-deep);
    font-size: 22px;
    line-height: 1.15;
}

.section-meta {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.bars {
    display: grid;
    gap: 12px;
    padding: 20px 22px 22px;
}

.bar-item {
    display: grid;
    gap: 9px;
}

.district-button {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    background: #ffffff;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.district-button:hover,
.district-button:focus {
    border-color: rgba(122, 31, 162, 0.35);
    background: #fbf8fd;
    box-shadow: 0 12px 26px rgba(66, 20, 90, 0.09);
    outline: none;
    transform: translateY(-1px);
}

.bar-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--ink);
    font-weight: 900;
}

.bar-top span:last-child {
    color: var(--brand-dark);
    white-space: nowrap;
}

.bar-name {
    overflow-wrap: anywhere;
}

.track {
    width: 100%;
    height: 13px;
    overflow: hidden;
    border: 1px solid #d8dce6;
    border-radius: 999px;
    background: #edf0f5;
}

.fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-dark), var(--brand-vivid));
    transition: width 320ms ease;
}

.municipality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.municipality-grid .bar-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    background: #ffffff;
}

.bar-detail {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.status-list {
    display: grid;
    gap: 12px;
    padding: 20px 22px 22px;
}

.status-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.status-item:last-child {
    border-bottom: 0;
}

.status-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
}

.status-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-dark);
}

.status-mark.recibido {
    background: var(--brand);
}

.status-mark.pendiente {
    background: var(--gray);
}

.status-mark.observado {
    background: var(--gray-dark);
}

.status-count {
    color: var(--brand-deep);
    font-size: 22px;
    font-weight: 900;
}

.table-panel {
    margin-top: 18px;
    overflow: hidden;
}

.detail-panel {
    margin-bottom: 18px;
}

.ghost-button {
    min-height: 38px;
    border: 1px solid rgba(122, 31, 162, 0.32);
    border-radius: 8px;
    padding: 0 15px;
    background: #ffffff;
    color: var(--brand-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.ghost-button:hover,
.ghost-button:focus {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
    outline: none;
}

.detail-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 20px 22px 0;
}

.detail-summary article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
    background: linear-gradient(180deg, #ffffff, #f7f8fb);
}

.detail-summary span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.detail-summary strong {
    color: var(--brand-deep);
    font-size: 30px;
}

.detail-tools {
    display: grid;
    grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    padding: 18px 22px 0;
}

.search-box {
    display: grid;
    gap: 7px;
    align-content: start;
}

.search-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.search-input-wrap {
    position: relative;
}

.search-input-wrap::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 15px;
    width: 14px;
    height: 14px;
    border: 2px solid #707a8e;
    border-radius: 50%;
    transform: translateY(-58%);
    pointer-events: none;
}

.search-input-wrap::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 29px;
    width: 8px;
    height: 2px;
    border-radius: 999px;
    background: #707a8e;
    transform: translateY(4px) rotate(45deg);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 16px 0 44px;
    background: #ffffff;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.search-box input::placeholder {
    color: #8b92a1;
    font-weight: 600;
}

.search-box input:focus {
    border-color: rgba(122, 31, 162, 0.45);
    box-shadow: 0 0 0 4px rgba(122, 31, 162, 0.12);
    background: #fcfaff;
    outline: none;
}

.detail-tools-note {
    display: flex;
    align-items: center;
    min-height: 50px;
    margin: 0;
    border: 1px dashed rgba(122, 31, 162, 0.2);
    border-radius: 8px;
    padding: 0 16px;
    background: rgba(122, 31, 162, 0.04);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.package-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px 22px 22px;
}

.package-grid h3 {
    margin: 0 0 12px;
    color: var(--brand-deep);
    font-size: 17px;
}

.package-list {
    display: grid;
    max-height: 440px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.package-item {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.package-button {
    width: 100%;
    border: 0;
    background: #ffffff;
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 180ms ease, box-shadow 180ms ease;
}

.package-button:hover,
.package-button:focus {
    background: #faf7fc;
    box-shadow: inset 0 0 0 1px rgba(122, 31, 162, 0.24);
    outline: none;
}

.package-button.is-active {
    background: linear-gradient(180deg, #fbf8fd, #f4eef8);
    box-shadow: inset 0 0 0 2px rgba(122, 31, 162, 0.3);
}

.package-button strong,
.package-button span,
.package-button small {
    pointer-events: none;
}

.package-item:last-child {
    border-bottom: 0;
}

.package-item strong {
    color: var(--brand-dark);
}

.package-item span {
    color: var(--muted);
    font-size: 13px;
}

.package-item small {
    color: var(--gray-dark);
    font-size: 12px;
    font-weight: 800;
}

.package-detail-empty {
    padding: 30px 22px;
    color: var(--muted);
    text-align: center;
}

.package-detail-body {
    display: grid;
    gap: 18px;
    padding: 20px 22px 22px;
}

.package-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.package-detail-kicker {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.package-detail-head h3 {
    margin: 0;
    color: var(--brand-deep);
    font-size: 28px;
    line-height: 1.05;
}

.package-detail-meta {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.package-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.package-detail-grid article,
.package-detail-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.package-detail-grid article {
    padding: 15px;
}

.package-detail-grid span,
.package-detail-block dt,
.package-condition-grid span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.package-detail-grid strong,
.package-condition-grid strong {
    color: var(--brand-deep);
    font-size: 18px;
}

.package-detail-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.package-detail-block {
    padding: 16px;
}

.package-detail-block h4 {
    margin: 0 0 14px;
    color: var(--brand-deep);
    font-size: 16px;
}

.package-detail-block dl {
    display: grid;
    gap: 14px;
    margin: 0;
}

.package-detail-block dd {
    margin: 0;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.4;
    font-weight: 700;
}

.package-condition-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.package-condition-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, #f8f9fc);
}

.package-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
}

.package-modal[hidden] {
    display: none;
}

.package-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 18, 29, 0.56);
    backdrop-filter: blur(4px);
}

.package-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(245, 246, 251, 0.98)),
        linear-gradient(135deg, rgba(122, 31, 162, 0.08), transparent);
    box-shadow: 0 28px 70px rgba(15, 18, 24, 0.32);
    outline: none;
}

.package-modal-shell {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.package-modal-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(122, 31, 162, 0.12);
}

.package-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.package-modal-actions .pill {
    min-height: 34px;
    padding-inline: 14px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

td {
    font-size: 14px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    background: #e8ebf1;
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.pill.recibido {
    background: rgba(122, 31, 162, 0.12);
    color: var(--brand-dark);
}

.pill.pendiente {
    background: var(--gray-soft);
    color: var(--gray-dark);
}

.pill.observado {
    background: #e1e4eb;
    color: var(--gray-dark);
}

.empty {
    padding: 28px 22px;
    color: var(--muted);
    text-align: center;
}

.error-box {
    display: none;
    margin-bottom: 18px;
    border: 1px solid rgba(122, 31, 162, 0.28);
    border-radius: 8px;
    padding: 16px 18px;
    background: #f7edf9;
    color: var(--brand-dark);
    font-weight: 900;
}

.is-error-visible {
    display: block;
}

.institutional-note {
    margin-top: 22px;
    border-top: 1px solid var(--line-strong);
    padding-top: 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 1080px) {
    .masthead,
    .hero-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .live-card {
        width: 100%;
    }

    .municipality-grid {
        grid-template-columns: 1fr;
    }

    .detail-tools,
    .detail-summary,
    .package-grid,
    .package-detail-grid,
    .package-detail-columns,
    .package-condition-grid {
        grid-template-columns: 1fr;
    }

    .package-modal-head,
    .package-modal-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 720px) {
    .page {
        width: min(100% - 20px, 1400px);
        padding-top: 14px;
    }

    .masthead {
        padding: 18px;
    }

    .brand-block {
        grid-template-columns: 1fr;
        gap: 16px;
        text-align: center;
    }

    .logo-mark {
        justify-self: center;
        width: min(260px, 100%);
        min-height: 108px;
        padding: 18px 22px;
    }

    .logo-mark img {
        max-width: 204px;
        max-height: 78px;
    }

    .eyebrow {
        justify-content: center;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .progress-panel {
        min-height: 308px;
        padding: 22px;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .bar-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .package-detail-head {
        flex-direction: column;
    }

    .package-modal {
        padding: 12px;
    }

    .package-modal-dialog {
        width: min(100vw - 16px, 1120px);
        max-height: calc(100vh - 16px);
    }

    .package-modal-shell {
        padding: 16px;
    }
}

@media (max-width: 460px) {
    .masthead h1 {
        font-size: 30px;
    }

    .subtitle {
        font-size: 15px;
    }

    .ring {
        width: min(260px, 76vw);
    }

    .ring-label {
        font-size: 12px;
    }

    .metric {
        min-height: 166px;
    }
}
