:root {
    --primary-color: #dc0018;
    --text-color: #15141A;
    --secondary-text: #5B5B66;
    --background-light: #F0F0F4;
    --border-color: #e0e0e0;
    --header-height: 64px;
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f4 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    background: white;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 5px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-wrapper {
    max-width: none;
    width: 100%;
    height: 83px;
    margin: 0;
    padding: 10px 24px; /* symmetric horizontal padding */
}

.layout-brand {
    display: flex;
    align-items: left;
    justify-content: space-between;
    height: var(--header-height);
    width: 100%;
}

.brand-left {
    display: flex;
    align-items: center;
}

.brand-logo {
    height: auto;
    width: 125px;
    margin-right: 0;
    padding: 20px 15px;
}

.header-title {
    font-family: Roboto, sans-serif;
    font-size: 26.4px;
    color: rgb(117, 117, 117);
    margin: 0;
    padding-left: 20px;
    border-left: 1px solid lightgrey;
    font-weight: 400;
}

.title-info-toggle {
    margin-left: 0.45rem;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    font-size: 1.15rem;
    line-height: 1;
    cursor: help;
    position: relative;
    padding: 0 0.1rem;
}

.title-info-toggle:hover,
.title-info-toggle:focus-visible {
    color: var(--primary-color);
}

.title-info-toggle::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 82vw);
    background: #fff;
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: left;
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.title-info-toggle:hover::after,
.title-info-toggle:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

main {
    margin-top: var(--header-height);
    padding-top: 32px;
    min-height: calc(100vh - var(--header-height));
}

.container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 3rem 48px 1.5rem;
}

.page-header {
    margin-bottom: 1rem;
    position: relative;
}

.page-header-actions {
    display: flex;
    justify-content: flex-end;
}

.service-status-banner {
    margin: 0.5rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid #ffd9b3;
    background: #fff4e8;
    color: #7a4b00;
    font-size: 0.95rem;
    line-height: 1.45;
}

.page-header h1 {
    font-family: Roboto, sans-serif;
    font-size: 2.5rem;
    line-height: 1.2;
    font-weight: 400;
    margin: 0;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--secondary-text);
    padding: 0 0.1rem;
    vertical-align: middle;
    transition: color 0.15s ease;
}

.info-toggle:hover,
.info-toggle[aria-expanded="true"] {
    color: var(--primary-color);
}

.lead-popover {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    z-index: 200;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    padding: 1rem 1.25rem;
    max-width: 680px;
}

.lead-popover[hidden] {
    display: none;
}

.page-lead {
    font-size: 1.05em;
    color: var(--secondary-text);
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #e9e9ee;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffffff 0%, #f7f7fb 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
    position: relative;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    outline: none;
    overflow: hidden;
}

.stat-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    border: 1px solid rgba(220, 0, 24, 0.08);
    pointer-events: none;
}

/* Icon container for tiles */
.stat-icon {
    height: 52px;
    width: 52px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,0.03);
    flex: 0 0 auto;
}

.stat-icon svg {
    width: 36px;
    height: 36px;
    display: block;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border-color: rgba(220, 0, 24, 0.2);
}

.stat-item:focus-visible {
    box-shadow: 0 0 0 3px rgba(220, 0, 24, 0.2);
}

.stat-item.active {
    border-color: rgba(220, 0, 24, 0.4);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: #222;
    font-family: 'Roboto Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    text-shadow: 0 0 12px rgba(220, 0, 24, 0.08);
    letter-spacing: 0.03em;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.55px;
    font-weight: 600;
}

.graph-controls {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin: -0.75rem 0 1rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 20;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid #e3e3ea;
    background: #fff;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.toggle-pill input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.toggle-slider {
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #c8c9d1;
    position: relative;
    transition: background-color 0.2s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.toggle-pill input:checked + .toggle-slider {
    background: #dc0018;
}

.toggle-pill input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle-pill input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(220, 0, 24, 0.2);
}

.toggle-label {
    font-size: 0.92rem;
    color: var(--text-color);
    font-weight: 600;
}

.org-filter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 1 auto;
    position: relative;
    z-index: 21;
}

.org-filter-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

.org-select {
    border: 1px solid #e3e3ea;
    border-radius: 6px;
    padding: 0.5rem 0.58rem;
    background: #fff;
    font-size: 0.92rem;
    color: var(--text-color);
    cursor: pointer;
    min-width: 200px;
    position: relative;
    z-index: 22;
    pointer-events: auto;
    appearance: auto;
    -moz-appearance: menulist;
}

.org-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 0, 24, 0.15);
    border-color: rgba(220, 0, 24, 0.5);
}

.org-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.main-content {
    display: flex;
    height: calc(100vh - 290px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative; /* for overlay positioning */
    z-index: 1;
}

#cy {
    flex: 1;
    min-width: 0;
    background: white;
}

/* Loading overlay */
.graph-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(1px);
    z-index: 10;
}

.graph-loading.visible {
    display: flex;
}

.graph-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e6;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-right: 12px;
}

.graph-loading .loading-text {
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: 0.02em;
}

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

.info-panel {
    width: 350px;
    background: #fafafa;
    padding: 1.5rem;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.info-panel.visible {
    opacity: 1;
}

.info-panel h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 600;
}

.info-content {
    color: var(--text-color);
    line-height: 1.6;
}

.info-content p {
    margin-bottom: 0.75rem;
}

.info-content h4 {
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.property-list {
    max-height: none;
    overflow-y: auto;
    margin-top: 0.5rem;
    flex: 1;
}

.property-item {
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 1.75rem;
    background: white;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.property-item::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15);
}

.property-item.linked::before {
    background: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.15);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
    font-weight: 600;
}

.badge.success {
    background: #4caf50;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--secondary-text);
}

footer {
    background: #f7f7f7;
    padding: 2rem 0;
    margin-top: 1.5rem; /* reduce gap above footer */
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.footer-content {
    width: 100%;
    margin: 0 auto;
    padding: 0 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-links h3 {
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.footer-links a {
    color: #333;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-info {
    margin-left: auto;
    color: #666;
    font-size: 0.875rem;
}

.footer-info p {
    margin: 0;
    align-self: flex-end;
}

/* Responsive layout: stack info below graph on narrow screens */
@media (max-width: 960px) {
    .graph-controls {
        margin-top: 0;
    }

    .main-content {
        flex-direction: column;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    #cy {
        width: 100%;
        flex: 0 0 auto;
        height: 62vh;
        min-height: 60vh;
    }

    .info-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: none;
    }
}

/* Beta Badge */
.beta-badge {
    position: fixed;
    top: 50px;
    right: -5px;
    z-index: 10000;
    background-color: #dc0018;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 8px 40px;
    text-transform: uppercase;
    box-shadow: -3px 3px 8px rgba(0, 0, 0, 0.3);
    transform: translateX(20%) translateY(20%) rotate(45deg);
    transform-origin: top right;
    letter-spacing: 1px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .beta-badge {
        font-size: 1rem;
        padding: 6px 30px;
    }
}