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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Dark mode styles */
body.dark-mode {
    background: linear-gradient(135deg, #2d3748 0%, #2c1a4d 100%);
    color: #e2e8f0;
}

body.dark-mode .navbar {
    background: #2d3748;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .navbar h1 {
    color: #e2e8f0;
}

body.dark-mode #userInfo {
    color: #e2e8f0;
}

body.dark-mode .tabs {
    background: #2d3748;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .tab-btn {
    background: #2d3748;
    color: #e2e8f0;
}

body.dark-mode .tab-btn:hover {
    background: #4a5568;
}

body.dark-mode .tab-btn.active {
    background: #667eea;
    color: white;
}

body.dark-mode .section-header h2 {
    color: #e2e8f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode .endpoints-list {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode th {
    background: #4a5568;
    color: #e2e8f0;
}

body.dark-mode td {
    border-bottom: 1px solid #4a5568;
}

body.dark-mode .status-healthy {
    background: #2f855a;
    color: #c6f6d5;
}

body.dark-mode .status-unhealthy {
    background: #c53030;
    color: #fed7d7;
}

body.dark-mode .status-unknown {
    background: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .action-btn {
    border: 1px solid #4a5568;
    color: #e2e8f0;
    background: #2d3748;
}

body.dark-mode .action-btn:hover {
    background: #4a5568;
}

body.dark-mode .action-btn.delete {
    border-color: #fc8181;
    color: #fed7d7;
}

body.dark-mode .action-btn.delete:hover {
    background: #c53030;
}

body.dark-mode .health-card, 
body.dark-mode .backend-health {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .health-card h3,
body.dark-mode .backend-health h3 {
    color: #e2e8f0;
}

body.dark-mode .backend-service {
    border-bottom: 1px solid #4a5568;
}

body.dark-mode .usage-section h3 {
    color: #e2e8f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode .usage-card {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .usage-card h4 {
    color: #e2e8f0;
}

body.dark-mode .usage-stat-item {
    background: #4a5568;
    border-left: 4px solid #667eea;
}

body.dark-mode .usage-stat-path {
    color: #e2e8f0;
}

body.dark-mode .usage-stat-metrics {
    color: #e2e8f0;
}

body.dark-mode .loading {
    color: #a0aec0;
}

body.dark-mode .analytics-overview .metric-card {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .analytics-overview .metric-card h3 {
    color: #e2e8f0;
}

body.dark-mode .analytics-overview .metric-value {
    color: #667eea;
}

body.dark-mode .analytics-overview .metric-value.error {
    color: #fc8181;
}

body.dark-mode .analytics-overview .metric-value.success {
    color: #68d391;
}

body.dark-mode .analytics-overview .metric-label {
    color: #a0aec0;
}

body.dark-mode .analytics-section h3 {
    color: #e2e8f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode .endpoint-analytics {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .endpoint-item {
    border-bottom: 1px solid #4a5568;
}

body.dark-mode .endpoint-item:first-child {
    background: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .endpoint-name {
    color: #e2e8f0;
}

body.dark-mode .response-time {
    background: #4a5568;
    color: #e2e8f0;
}

body.dark-mode .response-time.avg {
    background: #3182ce;
    color: #bee3f8;
}

body.dark-mode .error-rate.low {
    background: #2f855a;
    color: #c6f6d5;
}

body.dark-mode .error-rate.medium {
    background: #dd6b20;
    color: #fed7aa;
}

body.dark-mode .error-rate.high {
    background: #c53030;
    color: #fed7d7;
}

body.dark-mode .traffic-charts {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .chart-title {
    color: #e2e8f0;
}

body.dark-mode .traffic-bar-chart {
    background: #4a5568;
    border: 1px solid #2d3748;
}

body.dark-mode .traffic-bar-label {
    color: #e2e8f0;
}

body.dark-mode .traffic-bar-value {
    color: #e2e8f0;
}

body.dark-mode .geographic-analytics {
    background: #2d3748;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .geo-card {
    background: #4a5568;
    border-left: 4px solid #667eea;
}

body.dark-mode .geo-card h4 {
    color: #e2e8f0;
}

body.dark-mode .geo-item {
    border-bottom: 1px solid #2d3748;
}

body.dark-mode .geo-name {
    color: #e2e8f0;
}

body.dark-mode .geo-count {
    color: #667eea;
}

body.dark-mode .geo-map-container {
    background: #4a5568;
}

body.dark-mode .geo-map-placeholder {
    color: #a0aec0;
}

body.dark-mode .modal-content {
    background: #2d3748;
}

body.dark-mode .modal-header {
    border-bottom: 1px solid #4a5568;
}

body.dark-mode .modal-header h3 {
    color: #e2e8f0;
}

body.dark-mode .close {
    color: #a0aec0;
}

body.dark-mode .close:hover {
    color: #e2e8f0;
}

body.dark-mode #endpointForm input {
    background: #4a5568;
    border: 1px solid #2d3748;
    color: #e2e8f0;
}

body.dark-mode #endpointForm input:focus {
    border-color: #667eea;
}

body.dark-mode .input-group label {
    color: #e2e8f0;
}

/* Theme toggle switch */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-right: 15px;
}

.theme-toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.theme-toggle-slider {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.theme-toggle-checkbox:checked + .theme-toggle-label {
    background-color: #667eea;
}

.theme-toggle-checkbox:checked + .theme-toggle-label .theme-toggle-slider {
    transform: translateX(26px);
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 2rem;
}

.login-container h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.login-container h2 {
    color: rgba(255,255,255,0.9);
    font-size: 1.2rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

#loginForm {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

#loginForm button {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-top: 1rem;
}

.error-message {
    color: #e53e3e;
    text-align: center;
    margin-top: 1rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Dashboard */
.navbar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    color: #2d3748;
    font-size: 1.5rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#userInfo {
    color: #4a5568;
    font-weight: 500;
}

.main-content {
    padding: 2rem;
    background: rgba(255,255,255,0.1);
    min-height: calc(100vh - 80px);
}

.tabs {
    display: flex;
    margin-bottom: 2rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-btn {
    padding: 1rem 2rem;
    background: white;
    color: #4a5568;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
}

.tab-btn:hover {
    background: #f7fafc;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.section-header h2 {
    color: white;
    font-size: 1.8rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* Endpoints Table */
.endpoints-list {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    font-weight: 600;
    color: #2d3748;
}

.status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-healthy {
    background: #c6f6d5;
    color: #22543d;
}

.status-unhealthy {
    background: #fed7d7;
    color: #742a2a;
}

.status-unknown {
    background: #e2e8f0;
    color: #4a5568;
}

.action-btn {
    background: none;
    border: 1px solid #cbd5e0;
    color: #4a5568;
    padding: 0.25rem 0.75rem;
    margin: 0 0.25rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.action-btn:hover {
    background: #f7fafc;
}

.action-btn.delete {
    border-color: #fc8181;
    color: #c53030;
}

.action-btn.delete:hover {
    background: #fed7d7;
}

/* Health Monitor */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.health-card, .backend-health {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.health-card h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.backend-health h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.backend-service {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.backend-service:last-child {
    border-bottom: none;
}

/* Usage Statistics */
.usage-section {
    margin-top: 2rem;
}

.usage-section h3 {
    color: white;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.usage-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.usage-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.usage-card h4 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.usage-stats {
    display: grid;
    gap: 0.75rem;
}

.usage-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.usage-stat-path {
    font-weight: 600;
    color: #2d3748;
    font-family: 'Courier New', monospace;
}

.usage-stat-metrics {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.usage-stat-count {
    font-size: 1.2rem;
    font-weight: bold;
    color: #667eea;
}

.usage-stat-avg {
    font-size: 0.875rem;
    color: #718096;
}

.usage-stat-last {
    font-size: 0.75rem;
    color: #a0aec0;
}

.loading {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 2rem;
}

/* Analytics Dashboard */
.analytics-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

.metric-card h3 {
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.25rem;
    line-height: 1;
}

.metric-value.error {
    color: #e53e3e;
}

.metric-value.success {
    color: #38a169;
}

.metric-label {
    color: #718096;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-section {
    margin-top: 2rem;
}

.analytics-section h3 {
    color: white;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.endpoint-analytics {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.endpoint-item {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
}

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

.endpoint-item:first-child {
    background: #f7fafc;
    font-weight: 600;
    color: #2d3748;
    border-radius: 6px;
}

.endpoint-name {
    font-family: 'Courier New', monospace;
    color: #2d3748;
    font-weight: 600;
}

.response-times {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.response-time {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #e2e8f0;
    color: #4a5568;
}

.response-time.avg {
    background: #bee3f8;
    color: #2c5282;
}

.error-stats {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.error-rate {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.error-rate.low {
    background: #c6f6d5;
    color: #22543d;
}

.error-rate.medium {
    background: #fed7aa;
    color: #c05621;
}

.error-rate.high {
    background: #fed7d7;
    color: #742a2a;
}

.traffic-charts {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chart-container {
    margin-bottom: 2rem;
}

.chart-title {
    color: #2d3748;
    margin-bottom: 1rem;
    font-weight: 600;
}

.traffic-bar-chart {
    display: flex;
    align-items: end;
    gap: 2px;
    height: 200px;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f7fafc;
}

.traffic-bar {
    flex: 1;
    background: linear-gradient(to top, #667eea, #764ba2);
    border-radius: 2px 2px 0 0;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.traffic-bar:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.traffic-bar-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #4a5568;
    white-space: nowrap;
}

.traffic-bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #4a5568;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.traffic-bar:hover .traffic-bar-value {
    opacity: 1;
}

.geographic-analytics {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.geo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.geo-card {
    background: #f7fafc;
    border-radius: 6px;
    padding: 1rem;
    border-left: 4px solid #667eea;
}

.geo-card h4 {
    color: #2d3748;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.geo-list {
    max-height: 200px;
    overflow-y: auto;
}

.geo-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.geo-name {
    font-size: 0.875rem;
    color: #4a5568;
}

.geo-count {
    font-weight: 600;
    color: #667eea;
}

.geo-map-container {
    height: 400px;
    background: #f0f4f8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

.geo-map-placeholder {
    text-align: center;
    color: #718096;
}

.geo-map-placeholder .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Map marker styles */
.map-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.7);
    border: 2px solid #667eea;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.map-marker:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
}

/* Leaflet legend */
.info.legend {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: Arial, sans-serif;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    color: #2d3748;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
}

.close:hover {
    color: #2d3748;
}

#endpointForm {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .navbar {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .nav-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
}