@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

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

:root {
    --white: #FFFFFF;
    --gray-50: #F7F7F5;
    --gray-100: #ECECE8;
    --gray-200: #D9D8CF;
    --gray-300: #C0C0B1;
    --gray-500: #94907B;
    --gray-700: #716C5D;
    --gray-950: #282622;
    --zomp-50: #F2FBF8;
    --zomp-200: #A9E6D2;
    --zomp-500: #32A287;
    --zomp-700: #216456;
    --teal-blue-50: #EBFFFF;
    --teal-blue-200: #A1F8FF;
    --teal-blue-700: #087996;
    --blue-lagoon-50: #E8FFFC;
    --blue-lagoon-200: #94FFF1;
    --blue-lagoon-700: #0099AA;
    --orange-50: #FFF3F1;
    --orange-200: #FECDCA;
    --orange-700: #C52E10;
    --orange: #FF8C00;
    --lime: #C7FF28;
    --deep-cyprus: #224C4D;
    --success-green: #10B981;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-950);
    padding: 40px 60px;
    line-height: 1.5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* Header with Save Button */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 24px 0;
}

.page-title {
    font-size: 32px;
    font-weight: 600;
    color: var(--gray-950);
}

.save-button {
    padding: 12px 24px;
    background: var(--deep-cyprus);
    border: none;
    border-radius: 8px;
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.save-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.save-button.has-changes {
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 140, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 140, 0, 0.8);
    }
}

.save-button:hover:not(:disabled) {
    background: #1a3d3e;
}

.changes-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--orange);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding: 16px 0;
    background: var(--white);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--white);
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-950);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0px 1px 2px rgba(40, 38, 34, 0.05);
}

.btn:hover {
    background: var(--gray-50);
}

.btn.active {
    background: var(--deep-cyprus);
    color: white;
    border-color: var(--deep-cyprus);
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-950);
    box-shadow: 0px 1px 2px rgba(40, 38, 34, 0.05);
}

.search-input::placeholder {
    color: var(--gray-500);
}

/* Filter Dropdown */
.filter-dropdown {
    position: relative;
}

.filter-menu {
    position: absolute;
    top: 48px;
    left: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 100;
}

.filter-menu.active {
    display: block;
}

.filter-option {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-option:hover {
    background: var(--gray-50);
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Bulk Action Bar */
.bulk-action-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--gray-100);
    border-radius: 12px;
    margin-bottom: 24px;
}

.bulk-action-bar.active {
    display: flex;
}

.bulk-actions-left {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-950);
}

.bulk-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bulk-btn {
    padding: 10px 16px;
    background: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-950);
    cursor: pointer;
    transition: all 0.2s;
}

.bulk-btn:hover {
    background: var(--gray-200);
}

.clear-btn {
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

/* Table Container */
.table-wrapper {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0px 2px 8px rgba(40, 38, 34, 0.08);
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background: var(--gray-100);
}

tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--gray-50);
}

tbody tr.has-changes {
    background: #FFF9E6;
}

tbody tr.expanded {
    background: var(--gray-50);
}

td {
    padding: 20px 16px;
    font-size: 14px;
    color: var(--gray-950);
    position: relative;
}

.change-indicator {
    width: 8px;
    height: 8px;
    background: var(--orange);
    border-radius: 50%;
    position: absolute;
    top: 12px;
    left: 8px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.checkbox-cell {
    width: 40px;
    text-align: center;
}

.checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--deep-cyprus);
}

.partner-name-cell {
    min-width: 300px;
}

.partner-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-950);
    margin-bottom: 4px;
}

.partner-email {
    font-size: 13px;
    color: var(--gray-700);
}

.partner-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
}

.badge-agency {
    background: var(--zomp-50);
    border-color: var(--zomp-200);
    color: var(--zomp-700);
}

.badge-aggregator {
    background: var(--teal-blue-50);
    border-color: var(--teal-blue-200);
    color: var(--teal-blue-700);
}

.badge-lender {
    background: var(--blue-lagoon-50);
    border-color: var(--blue-lagoon-200);
    color: var(--blue-lagoon-700);
}

/* Program Columns */
.program-cell {
    text-align: center;
    min-width: 120px;
}

.program-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.program-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: .3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--zomp-500);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Expand Button */
.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

.expand-btn.expanded {
    transform: rotate(180deg);
}

/* Nested Program Row */
.program-detail-row {
    display: none;
    background: var(--gray-50);
}

.program-detail-row.active {
    display: table-row;
}

.program-detail-cell {
    padding: 24px 60px !important;
    border-bottom: 2px solid var(--gray-200);
}

.program-detail-content {
    background: white;
    border-radius: 8px;
    padding: 24px;
    border-left: 4px solid var(--lime);
}

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

.program-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-950);
}

.states-grid-toggle {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.states-grid-toggle:hover {
    background: var(--gray-50);
}

.states-grid-container {
    display: none;
    margin-top: 16px;
}

.states-grid-container.active {
    display: block;
}

.states-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 6px;
}

.states-bulk-actions {
    display: flex;
    gap: 8px;
}

.states-bulk-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.states-bulk-btn:hover {
    background: var(--gray-100);
}

.states-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.state-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
}

.state-item:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.state-item.changed {
    background: #FFF9E6;
    border-color: var(--orange);
}

.state-name {
    font-weight: 600;
    color: var(--gray-950);
}

.state-checkboxes {
    display: flex;
    gap: 12px;
}

.state-checkbox-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.state-checkbox-label {
    font-size: 10px;
    color: var(--gray-700);
    text-transform: uppercase;
    font-weight: 600;
}

.state-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Success Flash */
.success-flash {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--success-green);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Aggregator Children */
.aggregator-child-row {
    background: #FAFFFE !important;
}

.aggregator-child-row td:first-child {
    padding-left: 60px !important;
}

.child-indicator {
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--teal-blue-200);
    margin-right: 8px;
    border-radius: 2px;
}

/* Programs List Column */
.programs-list-header {
    min-width: 400px;
    text-align: left;
}

.programs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.product-line-pill {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid;
    white-space: nowrap;
    transition: all 0.2s;
    cursor: pointer;
}

.product-line-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Carrier colors - Obie palette */
.carrier-evanston {
    background: #E6F7F2;
    border-color: #32A287;
    color: #216456;
}

.carrier-hadron {
    background: #FFF3E6;
    border-color: #FF8C00;
    color: #B35F00;
}

.carrier-allstate {
    background: #E8F0F0;
    border-color: #224C4D;
    color: #1A3838;
}

.more-programs {
    font-size: 13px;
    color: var(--gray-700);
    font-weight: 500;
}

.programs-list-text {
    font-size: 14px;
    color: var(--gray-950);
    font-weight: 500;
}

.programs-list-text.none {
    color: var(--gray-500);
    font-style: italic;
}

.agency-count {
    font-size: 13px;
    color: var(--gray-700);
    margin-top: 2px;
}

/* Expanded Detail Panel */
.expanded-detail-panel {
    padding: 32px;
    background: white;
}

.detail-section {
    margin-bottom: 32px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.section-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-950);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}

.product-lines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

.product-line-card {
    background: white;
    border: 1px solid #ECECE8;
    border-radius: 12px;
    padding: 24px;
    transition: all 0.2s;
}

.product-line-card.enabled {
    background: white;
    border: 2px solid #32A287;
    box-shadow: 0 0 0 3px rgba(50, 162, 135, 0.08);
}

.product-line-card.disabled {
    background: #FAFAFA;
    border: 1px solid #ECECE8;
}

.product-line-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.product-line-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.product-line-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-line-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-950);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.enabled {
    background: #E6F7F2;
    color: #216456;
}

.status-badge.disabled {
    background: #F0F0ED;
    color: #716C5D;
}

.includes-text {
    font-size: 13px;
    color: #716C5D;
    margin-bottom: 16px;
}

.product-line-action-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.product-line-action-btn.enable {
    background: #32A287;
    color: white;
}

.product-line-action-btn.enable:hover {
    background: #2A8A73;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(50, 162, 135, 0.2);
}

.product-line-action-btn.disable {
    background: white;
    color: #716C5D;
    border: 2px solid #ECECE8;
}

.product-line-action-btn.disable:hover {
    background: #F7F7F5;
    border-color: #D4D4CC;
}

.states-summary {
    font-size: 13px;
    color: #716C5D;
    margin-bottom: 10px;
    font-weight: 500;
}

.clone-dropdown {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #ECECE8;
}

.clone-dropdown-label {
    font-size: 13px;
    font-weight: 600;
    color: #716C5D;
    margin-bottom: 8px;
    display: block;
}

.clone-dropdown select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ECECE8;
    border-radius: 8px;
    font-size: 13px;
    color: #282622;
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.clone-dropdown select:hover {
    border-color: #D4D4CC;
}

.clone-dropdown select:focus {
    outline: none;
    border-color: #32A287;
    box-shadow: 0 0 0 3px rgba(50, 162, 135, 0.1);
}

/* Regions UI */
.regions-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.regions-section {
    margin-bottom: 16px;
}

.regions-section:last-child {
    margin-bottom: 0;
}

.regions-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-950);
    margin-bottom: 10px;
}

.region-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.region-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.region-option:hover {
    background: var(--gray-100);
}

.region-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.region-option-label {
    font-size: 13px;
    color: var(--gray-950);
    font-weight: 500;
}

.region-option-count {
    font-size: 12px;
    color: var(--gray-600);
    margin-left: auto;
}

.view-states-link {
    font-size: 13px;
    color: #224C4D;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.view-states-link:hover {
    color: #32A287;
}

.selected-states-summary {
    font-size: 12px;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.selected-states-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.selected-states-empty {
    font-size: 12px;
    color: var(--gray-500);
    font-style: italic;
}

.selected-state-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-950);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.selected-state-pill:hover {
    border-color: var(--orange);
    color: var(--orange-700);
    background: var(--orange-50);
}

.remove-state {
    font-size: 14px;
    line-height: 1;
    color: var(--orange-700);
}

.state-add-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.state-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    color: var(--gray-950);
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
}

.state-select:hover {
    border-color: var(--gray-300);
}

.state-select:focus {
    outline: none;
    border-color: var(--zomp-500);
    box-shadow: 0 0 0 3px rgba(50, 162, 135, 0.12);
}

/* Child Agencies in Expanded View */
.child-agencies-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.child-agency-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    transition: all 0.2s;
}

.child-agency-item:hover {
    border-color: var(--gray-300);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.child-agency-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.child-agency-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-950);
}

.child-agency-email {
    font-size: 13px;
    color: var(--gray-700);
}

.child-agency-programs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.expand-child-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-950);
    cursor: pointer;
    transition: all 0.2s;
}

.expand-child-btn:hover {
    background: var(--gray-50);
}
