/* Berrios Payment Portal Styles */
:root {
    --primary-color: #336489;
    --primary-hover: #274f6b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --text-color: #222321;
    --text-muted: #6b7280;
    --border-color: #d5d5d5;
    --bg-color: #ececec;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 14px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 0;
    overflow: hidden;
}

.header-subtitle {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-logo {
    height: 32px;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

/* Report Issue Button */
.btn-report-issue {
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 6px;
    background: var(--border-color, #e5e7eb);
    color: var(--text-light, #6b7280);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-report-issue:hover:not(:disabled) {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.btn-report-issue:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Icon-only header buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    border-radius: 6px;
    background: var(--border-color, #e5e7eb);
    color: var(--text-light, #6b7280);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btn-icon:hover:not(:disabled) {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.btn-icon:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-icon svg {
    flex-shrink: 0;
}

.btn-icon .report-label {
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Report Toast */
.report-toast {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    background: #065f46;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 9999;
}

.report-toast-error {
    background: #991b1b;
}

.report-toast-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Health Badge */
.health-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #dbeafe;
    color: #1e40af;
}

.health-badge:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

.health-badge.healthy {
    background: #dcfce7;
    color: #166534;
}

.health-badge.degraded {
    background: #fef3c7;
    color: #92400e;
}

.health-badge.unknown {
    background: #f3f4f6;
    color: #6b7280;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    margin-bottom: 0;
}

/* Forms */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-large {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    margin-top: 16px;
}

/* Quick Amount Buttons */
.quick-amounts {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.quick-amounts span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.quick-amount-btn {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-amount-btn:hover {
    background: #e5e7eb;
    border-color: var(--primary-color);
}

/* Payment minimum hint */
.payment-min-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.payment-min-hint.below-min {
    color: var(--danger-color);
    font-weight: 500;
}

/* Customer Info Grid */
.customer-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.info-item {
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 4px;
}

.info-item label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.info-item-full {
    grid-column: 1 / -1;
}

.info-item span {
    font-weight: 500;
    color: var(--text-color);
}

/* Financial Summary */
.financial-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 8px;
    margin-bottom: 16px;
}

.financial-item {
    text-align: center;
    min-width: 100px;
}

.financial-item.hidden {
    display: none;
}

.financial-item label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.financial-item .amount {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

.financial-item.past-due .amount {
    color: var(--danger-color);
}

.financial-item.minimum-due .amount {
    color: var(--primary-color);
    font-weight: 700;
}

.financial-item.current-due .amount {
    color: var(--primary-color);
    font-weight: 700;
}

/* Plan Breakdown */
.plan-breakdown-section {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.plan-breakdown-header {
    padding: 10px 16px;
    background: var(--bg-secondary, #f8f9fa);
    border-bottom: 1px solid var(--border-color);
}

.plan-breakdown-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.plan-breakdown-list {
    max-height: 340px;
    overflow-y: auto;
}

.plan-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.plan-item:last-child {
    border-bottom: none;
}

.plan-item:hover {
    background: #f0f9ff;
}

.plan-item.selected {
    background: #e0f2fe;
}

.plan-item.plan-mora {
    border-left: 3px solid var(--danger-color, #dc3545);
}

.plan-item input[type="radio"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.plan-item-details {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(80px, 1fr) repeat(4, minmax(70px, auto));
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
}

.plan-item-id {
    font-weight: 600;
    color: var(--text-color);
}

.plan-item-desc {
    color: var(--text-muted);
    font-size: 0.7rem;
    display: block;
}

.plan-item-field {
    text-align: right;
}

.plan-item-field .field-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.plan-item-field .field-value {
    font-weight: 600;
    color: var(--text-color);
}

.plan-item-field.past-due .field-value {
    color: var(--danger-color, #dc3545);
}

/* Agent two-row card layout */
.plan-item-details-agent {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plan-item-row-primary {
    display: grid;
    grid-template-columns: minmax(80px, 1.2fr) repeat(4, minmax(65px, auto));
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
}

.plan-item-row-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-top: 2px;
    border-top: 1px dashed var(--border-color);
    margin-top: 2px;
}

.plan-item-row-secondary span {
    white-space: nowrap;
}

.plan-item-allplans .plan-item-details {
    grid-template-columns: 1fr;
}

.plan-item-allplans .plan-item-id {
    color: var(--primary-color);
}

/* Plan Summary Footer Row */
.plan-summary-row {
    padding: 10px 16px 12px 44px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-top: 2px solid var(--primary-color, #2563eb);
    position: sticky;
    bottom: 0;
}

.plan-summary-columns {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) repeat(4, minmax(70px, auto));
    gap: 8px;
    align-items: center;
    font-size: 0.8rem;
}

.plan-summary-label {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.plan-summary-total-due {
    text-align: right;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

.plan-summary-total-due .field-label {
    display: inline;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--primary-color, #2563eb);
    font-weight: 600;
    margin-right: 8px;
}

.plan-summary-total-due .field-value {
    color: var(--primary-color, #2563eb);
    font-weight: 700;
    font-size: 1.1rem;
}

.plan-summary-row-standalone {
    padding-left: 16px;
    border-top: none;
}

/* Customer Type Badge */
.customer-type-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.customer-type-badge.storis {
    background: #dbeafe;
    color: #1e40af;
}

.customer-type-badge.loans {
    background: #fef3c7;
    color: #92400e;
}

/* Data Source Banner */
.data-source-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

.data-source-banner .btn {
    flex-shrink: 0;
}

.data-source-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.data-source-message {
    flex: 1;
}

/* Live balance (green) */
.data-source-live {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.data-source-live .data-source-icon {
    color: #059669;
}

/* Stale balance (yellow/orange) */
.data-source-stale {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    color: #92400e;
}

.data-source-stale .data-source-icon {
    color: #d97706;
}

/* Unified Lookup Form */
.lookup-form {
    animation: fadeIn 0.2s ease-out;
}

.lookup-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.lookup-row:has(.field-or-divider) {
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
}

.lookup-row-ssn {
    grid-template-columns: 1fr auto;
    align-items: flex-end;
}

.lookup-row-ssn .btn {
    height: 42px;
    white-space: nowrap;
}

.lookup-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Lookup step-by-step instructions */
.lookup-instructions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: #f0f5fa;
    border-left: 3px solid var(--primary-color);
    border-radius: 0 6px 6px 0;
}

.lookup-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-color);
    line-height: 1.4;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
}

.field-or-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 2px;
}

/* Mutual exclusion: dimmed disabled field */
input.field-disabled {
    background: var(--bg-color);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Phone Input Formatting */
#phoneInput {
    letter-spacing: 0.5px;
}

/* SSN Input Masking */
#ssnInput {
    letter-spacing: 2px;
    text-align: center;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Collapsible Section */
.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.collapsible-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-title h2 {
    margin-bottom: 0;
}

.collapse-icon {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.collapsible-header.expanded .collapse-icon {
    transform: rotate(90deg);
}

/* History Table */
.history-table-wrapper {
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.history-table-wrapper.collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.history-table th,
.history-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.history-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}

.history-table .empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}

.status-badge.success {
    background: #dcfce7;
    color: #166534;
}

.status-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

/* Info Button in History Table */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #dbeafe;
    border: none;
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #1e40af;
}

.info-btn:hover {
    background: #bfdbfe;
    transform: scale(1.1);
}

.no-details {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Activity Details Modal */
.activity-overview {
    padding: 8px 0;
}

.activity-status-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-status-row:last-child {
    border-bottom: none;
}

.activity-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.875rem;
    min-width: 140px;
    flex-shrink: 0;
}

.activity-value {
    text-align: right;
    font-weight: 500;
    color: var(--text-color);
    word-break: break-word;
}

.activity-value.mono {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
}

.activity-value.amount {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.activity-value.success {
    color: var(--success-color);
}

.activity-value.error {
    color: var(--danger-color);
}

.activity-value.warning {
    color: var(--warning-color);
}

.error-row {
    background: #fef2f2;
    margin: 8px -20px;
    padding: 10px 20px;
    border-radius: 6px;
}

/* WebPay Container */
.webpay-customer-context {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--text-color);
    text-align: center;
}

.webpay-ctx-label {
    font-weight: 400;
}

.webpay-ctx-id {
    color: var(--text-muted);
    font-weight: 400;
}

.webpay-ctx-amount {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 10px;
    border-radius: 4px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.webpay-container {
    width: 100%;
    min-height: 700px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.webpay-container iframe {
    width: 100%;
    height: 700px;
    border: none;
}

/* Result Section */
.result-content {
    text-align: center;
    padding: 24px;
}

.result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.result-icon.error {
    background: var(--danger-color);
}

.result-content h2 {
    margin-bottom: 8px;
}

.result-content > p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 24px;
}

.result-details .detail-item {
    text-align: center;
}

.result-details .detail-item label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-details .detail-item span {
    font-weight: 600;
}

/* Full-screen Result Section */
.result-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.result-fullscreen .result-content {
    max-width: 500px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

/* Fade-in animation */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Result customer context */
.result-customer-context {
    margin-bottom: 8px;
}

/* Customer context badge in result */
.customer-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Result action buttons container */
.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

/* Large outline button for secondary action */
.btn-large-outline {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    margin-top: 0;
}

.btn-large-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

/* Error Message */
.error-message {
    padding: 12px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 0.875rem;
    margin-top: 12px;
}

.payment-not-allowed-banner {
    padding: 12px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.875rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.payment-block-override-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    background: #92400e;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.payment-block-override-btn:hover {
    background: #78350f;
}

.payment-not-allowed-banner.payment-warning-banner {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.payment-target-group {
    margin-bottom: 14px;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
}

.payment-target-group > label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.payment-target-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 12px;
}

.payment-target-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary, #1e293b);
}

.payment-target-label input[type="radio"] {
    accent-color: #16a34a;
}

.payment-target-badcheck {
    grid-column: 1;
}

.payment-target-hint {
    grid-column: 2 / -1;
    margin-top: 0;
    font-size: 0.72rem;
    color: #b45309;
    font-style: italic;
    align-self: center;
}

.error-message-text {
    margin-bottom: 8px;
}

/* Error Details Section - For Storis Escalation */
.error-details-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #fecaca;
}

.error-details-toggle {
    background: transparent;
    border: none;
    color: #991b1b;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-weight: 500;
}

.error-details-toggle:hover {
    color: #7f1d1d;
}

.error-details-content {
    margin-top: 10px;
    background: #1f2937;
    border-radius: 6px;
    padding: 12px;
    overflow: hidden;
}

.error-details-content pre {
    color: #f9fafb;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.7rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.copy-error-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-error-btn:hover {
    background: #2563eb;
}

.copy-error-btn.copy-success {
    background: #059669;
}

.retry-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.retry-btn:hover {
    background: var(--primary-hover);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
}

.loading-content p {
    margin-top: 16px;
    color: var(--text-muted);
}

/* Health Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Health Overview */
.health-overview {
    margin-bottom: 20px;
}

.health-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.health-status-row:last-child {
    border-bottom: none;
}

.health-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.modal-body h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.service-item {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 12px;
}

.service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.service-name {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-color);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.status-up {
    background: var(--success-color);
}

.status-indicator.status-degraded {
    background: var(--warning-color);
}

.status-indicator.status-down {
    background: var(--danger-color);
}

.status-indicator.status-disabled {
    background: #9ca3af;
}

.status-indicator.status-unknown {
    background: #d1d5db;
}

.service-status-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.service-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.service-detail {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.service-detail.error {
    color: var(--danger-color);
}

/* Status badges in modal */
.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

/* Payment Report Section (inside Health Modal) */
.report-section {
    padding: 0 20px 20px;
}

.report-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0 0 16px;
}

.report-heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.report-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-field label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.report-field select,
.report-field input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
}

.report-field select {
    min-width: 170px;
}

.report-field input {
    width: 80px;
}

.report-section .success-message {
    color: #166534;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-top: 10px;
}

.report-section .error-message {
    margin-top: 10px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-top-color: var(--primary-color);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Test Payment Mode */
.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #b45309;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.modal-large {
    max-width: 650px;
}

/* Payment Disclosure Modal */
.modal-disclosure {
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.disclosure-body {
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.disclosure-text {
    flex: 1;
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 8px;
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 0.9rem;
}

.disclosure-text h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 1em 0 0.4em;
}

.disclosure-text h4:first-child {
    margin-top: 0;
}

.disclosure-text p {
    margin: 0 0 0.75em;
    color: var(--text-color);
}

.disclosure-confirm-row {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.disclosure-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 44px;
    padding: 4px 0;
}

.disclosure-checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.disclosure-confirm-row .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.test-warning {
    padding: 12px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.875rem;
    margin-bottom: 16px;
    font-weight: 500;
}

#testWebpayJson {
    width: 100%;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    resize: vertical;
    min-height: 200px;
}

#testWebpayJson:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

#testResponseSection {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

#testResponseSection h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

#testResponseJson {
    background: #1f2937;
    color: #f9fafb;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}


/* Responsive */
@media (max-width: 600px) {
    .lookup-row,
    .lookup-row:has(.field-or-divider) {
        grid-template-columns: 1fr;
    }

    .field-or-divider {
        padding: 0;
        font-size: 0.7rem;
    }
    
    .lookup-row-ssn {
        grid-template-columns: 1fr;
    }
    
    .lookup-row-ssn .btn {
        width: 100%;
        margin-top: 4px;
    }

    #loginSection .lookup-row {
        grid-template-columns: 1fr;
    }

    #loginSection .lookup-row .btn {
        width: 100%;
        margin-top: 4px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .financial-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .financial-item {
        min-width: 0;
    }
    
    .customer-info-grid {
        grid-template-columns: 1fr;
    }
    
    .result-details {
        grid-template-columns: 1fr;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .result-fullscreen {
        padding: 16px;
    }
    
    .result-fullscreen .result-content {
        padding: 24px 20px;
    }
    
    .result-icon {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }

    /* Header mobile adjustments */
    .header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .header h1 {
        flex: 0 0 100%;
        margin-bottom: 2px;
    }

    .header-logo {
        height: 28px;
    }

    .header-subtitle {
        display: none;
    }

    .auth-user-badge {
        max-width: 45%;
        font-size: 0.7rem;
    }

    .btn-icon .report-label {
        display: none;
    }
}

/* ========== Auth / Login Gate ========== */

.auth-user-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f0f4f8;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    max-width: 200px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-warning-banner {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    gap: 8px;
}
.session-warning-banner.hidden { display: none; }
.session-warning-banner .btn-sm {
    padding: 3px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ========== Portal Alert Banners ========== */

.portal-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid;
    margin-bottom: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
}
.portal-alert-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
    line-height: 1.4;
}
.portal-alert-content {
    flex: 1;
    min-width: 0;
}
.portal-alert-title {
    font-weight: 600;
    margin-bottom: 2px;
}
.portal-alert--info {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}
.portal-alert--warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}
.portal-alert--critical {
    background: #fee2e2;
    border-color: #f87171;
    color: #991b1b;
    animation: criticalPulse 2s ease-in-out infinite;
}

#loginSection h2 {
    margin-bottom: 4px;
}

#loginSection .lookup-row {
    grid-template-columns: 1fr auto;
    align-items: end;
}

#loginSection .lookup-row .form-group {
    margin-bottom: 0;
}

#loginSection .lookup-row .btn {
    height: 42px;
    white-space: nowrap;
    margin-bottom: 0;
}

.success-message {
    padding: 10px 12px;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    color: #166534;
    font-size: 0.85rem;
}

.success-message small {
    display: block;
    margin-top: 4px;
    color: #15803d;
    font-size: 0.78rem;
}

/* ========== Resend OTP Row ========== */

.resend-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.btn-link {
    background: none;
    border: none;
    color: #336489;
    cursor: pointer;
    font-size: 0.82rem;
    padding: 4px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link:hover:not(:disabled) {
    color: #1e3a5f;
}

.btn-link:disabled {
    color: #9ca3af;
    cursor: default;
    text-decoration: none;
}

.btn-link #resendCountdown {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.78rem;
    color: #9ca3af;
}

/* ========== Warning & Lockout States ========== */

.warning-message {
    padding: 12px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.875rem;
    margin-top: 12px;
}

.warning-message .warning-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.critical-warning {
    padding: 12px;
    background: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 6px;
    color: #78350f;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 12px;
    animation: criticalPulse 2s ease-in-out infinite;
}

@keyframes criticalPulse {
    0%, 100% { border-color: #f59e0b; }
    50% { border-color: #d97706; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
}

.attempt-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 6px;
}

.attempt-indicator.ok {
    background: #fee2e2;
    color: #991b1b;
}

.attempt-indicator.warn {
    background: #fef3c7;
    color: #92400e;
}

.attempt-indicator.critical {
    background: #fde68a;
    color: #78350f;
}

.lockout-banner {
    text-align: center;
    padding: 32px 24px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-radius: 8px;
    margin-top: 12px;
}

.lockout-banner .lockout-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.lockout-banner h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #78350f;
    margin-bottom: 8px;
}

.lockout-banner p {
    color: #92400e;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.lockout-timer {
    font-size: 1rem;
    font-weight: 600;
}

.lockout-timer .countdown {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #78350f;
    letter-spacing: 1px;
}

.lockout-banner .lockout-help {
    font-size: 0.8rem;
    color: #a16207;
    margin-top: 12px;
}

.lockout-banner .btn {
    margin-top: 16px;
}

/* Supervisor Unlock */
.supervisor-unlock {
    margin-top: 20px;
    text-align: center;
}

.lockout-divider {
    border: none;
    border-top: 1px solid #d4a843;
    margin: 20px 0;
}

.supervisor-unlock h4 {
    color: #78350f;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.supervisor-help {
    font-size: 0.8rem;
    color: #a16207;
    margin-bottom: 12px;
}

.supervisor-unlock input {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.supervisor-unlock input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(51, 100, 137, 0.15);
}

.supervisor-unlock .btn {
    margin-top: 4px;
    margin-bottom: 0;
}

.supervisor-unlock .btn-secondary {
    background: #92400e;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.supervisor-unlock .btn-secondary:hover {
    background: #78350f;
}

.version-tag {
    position: fixed;
    bottom: 4px;
    right: 8px;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.18);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    pointer-events: none;
    z-index: 1;
    user-select: none;
}
