:root {
    --lime-bright: #93E01B;  
    --lime-gloss-top: #B7F554;
    --lime-gloss-mid: #93E01B;
    --lime-gloss-mid-dark: #7DC90F;
    --lime-gloss-bottom: #6AB300;
    
    --silver-light: #F5F5F7; 
    --silver-dark: #E1E1E6;
    
    --text-main: #1D1D1F;
    --text-muted: #515154;
    
    --card-bg: rgba(255, 255, 255, 0.85); 
    --border: #D2D2D7;
    --row-hover: rgba(147, 224, 27, 0.1); 
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #F5F5F7;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(147, 224, 27, 0.25) 0%, transparent 60%),
        radial-gradient(circle at 90% 80%, rgba(147, 224, 27, 0.20) 0%, transparent 60%),
        linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
}

header {
    width: 100%;
    padding: 2.5rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-content {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    text-align: center;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

h1 span {
    color: var(--lime-gloss-bottom);
}

.search-container {
    width: 100%;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.9rem 1.5rem 0.9rem 3.2rem;
    font-size: 1.05rem;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 5px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--lime-bright);
    box-shadow: 0 0 0 4px rgba(147, 224, 27, 0.3), inset 0 1px 3px rgba(0,0,0,0.05);
}

.action-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 0.5rem;
}

.display-count {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.7);
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.8), 0 2px 4px rgba(0,0,0,0.02);
    white-space: nowrap;
}

.display-count span {
    font-weight: 700;
    color: var(--lime-gloss-bottom);
}

.filters-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.filter-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.filter-toggle input {
    display: none;
}

.toggle-text {
    padding: 0.5rem 1.4rem;
    border-radius: 999px;
    background-color: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    white-space: nowrap;
}

.filter-toggle input:checked + .toggle-text {
    background: linear-gradient(180deg, var(--lime-gloss-top) 0%, var(--lime-gloss-mid) 49%, var(--lime-gloss-mid-dark) 51%, var(--lime-gloss-bottom) 100%);
    color: white;
    border-color: #63A300;
    box-shadow: inset 0px 1px 1px rgba(255,255,255,0.6), 0 2px 4px rgba(147, 224, 27, 0.3);
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 0 1.5rem 2rem;
    flex: 1;
}

.table-wrapper {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), inset 0 0 0 1px rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    white-space: nowrap;
}

/* --- THE UNIFIED LIMEWARE SORT BAR --- */
/* --- IMPROVED LIMEWARE SORT BAR TEXT --- */
th {
    position: sticky;
    top: 0; 
    z-index: 90;
    background: linear-gradient(180deg, var(--lime-gloss-top) 0%, var(--lime-gloss-mid) 49%, var(--lime-gloss-mid-dark) 51%, var(--lime-gloss-bottom) 100%);
    padding: 1.2rem 1.5rem;
    font-size: 0.9rem; /* Slightly smaller for a cleaner look */
    font-weight: 800; 
    text-transform: uppercase;
    letter-spacing: 0.12em; /* More breathing room between letters */
    color: #FFFFFF;
    
    /* Chiseled effect: 1px dark shadow for depth + 1px light glow for "pop" */
    text-shadow: 
        0 1px 0 rgba(0, 0, 0, 0.3), 
        0 2px 4px rgba(0, 0, 0, 0.4),
        0 0 8px rgba(255, 255, 255, 0.2); 
    
    border: none;
    border-bottom: 3px solid #63A300;
    box-shadow: 0 4px 12px rgba(147, 224, 27, 0.3);
    user-select: none;
    transition: all 0.2s ease;
}

th.sortable:hover {
    background: linear-gradient(180deg, #C4F773 0%, #A5ED29 49%, #8ED915 51%, #79C200 100%);
    color: #F0FFF0; /* Very slight green tint on hover */
    /* Enhance glow on hover */
    text-shadow: 
        0 1px 0 rgba(0, 0, 0, 0.4), 
        0 0 12px rgba(255, 255, 255, 0.5);
}

.sort-icon {
    display: flex;
    flex-direction: column;
    font-size: 0.65rem;
    line-height: 0.8;
    color: #FFFFFF;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.sort-icon .inactive {
    opacity: 0.3;
}

/* Table Rows */
td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(210, 210, 215, 0.5);
    font-size: 0.95rem;
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--row-hover);
}

.agency-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.agency-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    background-color: #ffffff;
    border: 1px solid var(--border);
    padding: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.agency-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.portal-icon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    object-fit: contain;
}

.link-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1.2rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: inset 0px 1px 1px rgba(255,255,255,0.6), 0 2px 4px rgba(0,0,0,0.1);
}

.btn-web {
    background: linear-gradient(180deg, var(--lime-gloss-top) 0%, var(--lime-gloss-mid) 49%, var(--lime-gloss-mid-dark) 51%, var(--lime-gloss-bottom) 100%);
    color: white;
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
    border: 1px solid #63A300;
}

.btn-web:hover {
    background: linear-gradient(180deg, #C4F773 0%, #A5ED29 49%, #8ED915 51%, #79C200 100%);
    transform: translateY(-1px);
    box-shadow: inset 0px 1px 1px rgba(255,255,255,0.8), 0 3px 6px rgba(147, 224, 27, 0.3);
}
        
.btn-web:active {
    transform: translateY(1px);
    box-shadow: inset 0px 2px 4px rgba(0,0,0,0.2);
    background: linear-gradient(180deg, var(--lime-gloss-bottom) 0%, var(--lime-gloss-mid-dark) 100%);
}

.btn-profile {
    background: linear-gradient(180deg, #FFFFFF 0%, #F0F0F0 49%, #E0E0E0 51%, #D0D0D0 100%);
    color: #333;
    text-shadow: 0 1px 1px rgba(255,255,255,0.8);
    border: 1px solid #A0A0A0;
}

.btn-profile:hover {
    background: linear-gradient(180deg, #FFFFFF 0%, #F5F5F5 49%, #E8E8E8 51%, #D8D8D8 100%);
    transform: translateY(-1px);
    box-shadow: inset 0px 1px 1px rgba(255,255,255,1), 0 3px 6px rgba(0,0,0,0.1);
}
        
.btn-profile:active {
    transform: translateY(1px);
    box-shadow: inset 0px 2px 4px rgba(0,0,0,0.15);
    background: linear-gradient(180deg, #D0D0D0 0%, #E0E0E0 100%);
}

.no-link {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
    opacity: 0.7;
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.no-results svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--lime-gloss-bottom);
}

/* --- UNIFIED MOBILE VIEW --- */
@media (max-width: 768px) {
    /* Header & Action Bar adjustments */
    h1 { 
        font-size: 2.2rem; 
        margin-bottom: 1rem; 
    }
    
    .action-bar { 
        justify-content: center; 
    }

    .container {
        padding: 0 0.5rem 1rem;
    }

    /* Hide table headers except Agency Name */
    th:not(:first-child) { 
        display: none; 
    }
    
    th:first-child {
        width: 100%;
        border-radius: 12px 12px 0 0;
        font-size: 0.85rem;
    }

    /* Stack cells vertically inside the row */
    tr {
        display: flex;
        flex-direction: column;
        cursor: pointer;
        border-bottom: 1px solid var(--border);
        transition: background 0.2s ease;
        background: #fff;
        padding: 0; /* Resetting padding for flex layout */
    }

    /* Column 1: Agency Name (Always Visible) */
    td:first-child {
        display: flex;
        width: 100%;
        padding: 1.2rem 1rem;
        border: none;
    }

    /* Hide Portal, Website, and Profile by default */
    td:nth-child(n+2) {
        display: none; 
        padding: 0.4rem 1rem;
        border: none;
        background: rgba(0, 0, 0, 0.01);
    }

    /* STRICT ORDER: Portal first, Website second, Profile third */
    tr.expanded td:nth-child(2) { display: flex; order: 1; } /* Portal column */
    tr.expanded td:nth-child(3) { display: flex; order: 2; } /* Website column */
    tr.expanded td:nth-child(4) { display: flex; order: 3; } /* Profile column */

    /* Animation for expanding links */
    tr.expanded td:nth-child(n+2) {
        animation: mobileSlideIn 0.25s ease-out forwards;
    }

    /* Full-width tap targets for mobile buttons */
    .link-badge, .portal-badge {
        width: 100%;
        margin: 4px 0;
        justify-content: center;
        box-sizing: border-box;
    }
    
    tr.expanded {
        background: var(--row-hover);
        padding-bottom: 0.8rem;
    }
}

/* Updated Animation Name to match the new block */
@keyframes mobileSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}