.sgp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.sgp-modal-overlay.is-open {
    display: flex;
}

.sgp-modal {
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow: auto;
    background: var(--sgp-ura-bg, #ffffff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    transform: translateY(12px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sgp-modal-overlay.is-open .sgp-modal {
    transform: translateY(0);
    opacity: 1;
}

.sgp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid #e5e7eb;
}

.sgp-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

.sgp-modal .sgp-modal-close {
    -webkit-appearance: none;
    appearance: none;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    padding: 0;
    margin: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.sgp-modal .sgp-modal-close:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    transform: translateY(-1px);
}

.sgp-modal .sgp-modal-close:focus-visible {
    outline: 2px solid var(--sgp-ura-primary, #1d4ed8);
    outline-offset: 2px;
}

.sgp-modal .sgp-modal-close-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

.sgp-modal .sgp-modal-close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sgp-modal-body {
    padding: 18px;
}

.sgp-toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(14px);
    opacity: 0;
    pointer-events: none;
    z-index: 100000;
    background: #0f172a;
    color: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.3;
    box-shadow: 0 10px 26px rgba(2, 6, 23, 0.32);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: min(92vw, 420px);
    width: max-content;
}

.sgp-toast.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sgp-toast.is-success {
    background: #14532d;
}

.sgp-toast.is-error {
    background: #7f1d1d;
}

.sgp-module .sgp-card {
    background: #fff;
    padding: 28px;
    border-radius: 24px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
}

.sgp-module .sgp-cpf-area {
    display: grid;
    gap: 12px;
}

.sgp-module .sgp-field {
    margin: 0;
}

.sgp-module .sgp-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #1f2937;
}

.sgp-module .sgp-input,
.sgp-module .sgp-select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 14px;
    font-size: 15px;
    background: #fff;
}

.sgp-module .sgp-select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5' fill='none' stroke='%23475569' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}

.sgp-module .sgp-btn,
.sgp-module .sgp-actions button {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    background: var(--sgp-ura-primary, #1d4ed8);
    color: #fff;
    transition: background 0.2s ease, transform 0.1s ease;
}

.sgp-module .sgp-btn-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sgp-module .sgp-btn-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

.sgp-module .sgp-btn-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sgp-module .sgp-btn:hover,
.sgp-module .sgp-actions button:hover {
    background: var(--sgp-ura-primary-dark, #1e40af);
    transform: translateY(-1px);
}

.sgp-module .sgp-btn:disabled,
.sgp-module .sgp-actions button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.sgp-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #334155;
}

.sgp-status.is-error {
    border-color: #fecaca;
    background: #fef2f2;
    color: var(--sgp-ura-alert, #b91c1c);
}

.sgp-status.is-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.sgp-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.sgp-card h4 {
    margin: 0 0 8px 0;
    font-size: 15px;
}

.sgp-muted {
    color: #6b7280;
}

.sgp-module .sgp-header h3 {
    margin: 0 0 14px 0;
    font-size: 24px;
    line-height: 1.2;
}

.sgp-module .sgp-contrato-wrap {
    margin-bottom: 14px;
}

.sgp-module .sgp-cliente-head {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.sgp-module .sgp-head-item {
    background: #f3f6ff;
    border: 1px solid #e6ebff;
    border-radius: 14px;
    padding: 12px;
}

.sgp-module .sgp-head-item-full {
    grid-column: 1 / -1;
}

.sgp-module .sgp-head-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sgp-module .sgp-head-item strong {
    display: block;
    font-size: 14px;
    color: #0f172a;
    word-break: break-word;
}

.sgp-module [data-sgp-head-status] {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    line-height: 1.1;
}

.sgp-module [data-sgp-head-status].sgp-service-active {
    background: #ecfdf3;
    border-color: #86efac;
    color: #166534;
}

.sgp-module [data-sgp-head-status].sgp-service-inactive {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #a16207;
}

.sgp-module [data-sgp-head-status].sgp-service-reduced {
    background: #f3e8ff;
    border-color: #d8b4fe;
    color: #7e22ce;
}

.sgp-module [data-sgp-head-status].sgp-service-suspended {
    background: #ffedd5;
    border-color: #fdba74;
    color: #c2410c;
}

.sgp-module .sgp-tabs {
    display: flex;
    background: #eef3ff;
    padding: 6px;
    border-radius: 50px;
    gap: 6px;
    margin: 20px 0 25px 0;
}

.sgp-module .sgp-tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    color: #555;
}

.sgp-module .sgp-tab.active {
    background: var(--sgp-ura-primary, #2e5aac);
    color: #fff;
}

.sgp-module .sgp-item {
    background: #f6f8fc;
    padding: 22px;
    border-radius: 20px;
    margin-bottom: 18px;
}

.sgp-module .sgp-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sgp-module .sgp-item-main {
    flex: 1;
    min-width: 0;
}

.sgp-module .sgp-item-side-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.sgp-module .sgp-item-vencida {
    border-left: 4px solid #fca5a5;
    padding-left: 18px;
}

.sgp-module .sgp-item-badge-vencida {
    display: inline-block;
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.sgp-module .sgp-valor {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.sgp-module .sgp-valor-aberta {
    color: #111827;
}

.sgp-module .sgp-valor-vencida {
    color: #dc2626;
}

.sgp-module .sgp-valor-paga {
    color: #15803d;
}

.sgp-module .sgp-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 6px;
}

.sgp-module .sgp-info-atraso {
    color: #dc2626;
    font-weight: 700;
    margin-bottom: 2px;
}

.sgp-module .sgp-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
}

.sgp-module .sgp-btn-nfe {
    min-height: 44px;
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: var(--sgp-ura-primary, #1d4ed8);
    color: #fff;
    transition: background 0.2s ease, transform 0.1s ease;
}

.sgp-module .sgp-btn-nfe:hover {
    background: var(--sgp-ura-primary-dark, #1e40af);
    transform: translateY(-1px);
}

.sgp-module .sgp-nfe-status {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    line-height: 1.3;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #334155;
}

.sgp-module .sgp-nfe-status.is-missing {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.sgp-module .sgp-nfe-status.is-warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.sgp-module .sgp-action-feedback {
    margin-top: -4px;
    margin-bottom: 2px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.sgp-module [data-sgp-mostrar-mais] {
    margin-top: 15px;
}

.sgp-module button.sgp-btn[data-sgp-mostrar-mais] {
    background: var(--sgp-ura-primary, #1d4ed8) !important;
    background-color: var(--sgp-ura-primary, #1d4ed8) !important;
    color: #fff !important;
    border: none !important;
}

.sgp-module button.sgp-btn[data-sgp-mostrar-mais]:hover {
    background: var(--sgp-ura-primary-dark, #1e40af) !important;
    background-color: var(--sgp-ura-primary-dark, #1e40af) !important;
}

.sgp-modal .sgp-module .sgp-card button.sgp-btn[data-sgp-mostrar-mais] {
    background: var(--sgp-ura-primary, #1d4ed8) !important;
    background-color: var(--sgp-ura-primary, #1d4ed8) !important;
}

@media (max-width: 640px) {
    .sgp-modal {
        max-width: 100%;
        border-radius: 12px;
    }

    .sgp-modal-body,
    .sgp-modal-header {
        padding: 14px;
    }

    .sgp-module .sgp-card {
        padding: 18px;
        border-radius: 18px;
    }

    .sgp-module .sgp-cliente-head {
        grid-template-columns: 1fr;
    }

    .sgp-module .sgp-head-item-full {
        grid-column: auto;
    }

    .sgp-toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
        transform: translateY(14px);
    }

    .sgp-toast.is-show {
        transform: translateY(0);
    }

    .sgp-module .sgp-item-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sgp-module .sgp-item-side-action {
        width: 100%;
    }

    .sgp-module .sgp-btn-nfe {
        width: 100%;
    }
}
