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

:root {
    --primary: #1976d2;
    --success: #4caf50;
    --error: #f44336;
    --bg: #f5f5f5;
    --card-bg: #fff;
    --text: #212121;
    --border: #e0e0e0;
}

/* Flexbox layout for sticky footer */
body.d-flex {
    display: flex;
    min-height: 100vh;
}

body.flex-column {
    flex-direction: column;
}

.min-vh-100 {
    min-height: 100vh;
}

.flex-grow-1 {
    flex: 1 0 auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 0 15px;
}

/* Navigation */
.navbar {
    padding: 0.5rem 0;
}

.navbar-expand-lg {
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.navbar-dark {
    background-color: var(--primary) !important;
}

.bg-primary {
    background-color: #0d6efd !important;
}

.navbar-brand {
    font-size: 1.5rem;
    color: white !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    margin-right: 1rem;
}

.fw-bold {
    font-weight: 700 !important;
}

main.mt-4 {
    margin-top: 1.5rem !important;
}

/* Cards and Content */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card-bg);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-header h1,
.card-header h2 {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.card-body {
    padding: 1.25rem;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.text-center {
    text-align: center !important;
}

.text-muted {
    color: #6c757d !important;
}

.text-success {
    color: #198754 !important;
}

.text-warning {
    color: #ffc107 !important;
}

.display-1 {
    font-size: 5rem;
    font-weight: 300;
    line-height: 1.2;
}

.list-unstyled {
    padding-left: 0;
    list-style: none;
}

.ms-3 {
    margin-left: 1rem !important;
}

.offset-md-2 {
    margin-left: 16.666667%;
}

.d-none {
    display: none !important;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.btn-lg {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border-radius: 0.5rem;
}

/* Feature Category Styling */
.feature-category {
    transition: transform 0.2s ease-in-out;
}

.feature-category:hover {
    transform: translateY(-2px);
}

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input:disabled, .form-group select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.button-group { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover:not(:disabled) {
    background: #1565c0;
    transform: translateY(-2px);
}

.btn-stop {
    background: #f44336;
    color: white;
}

.btn-stop:hover:not(:disabled) {
    background: #d32f2f;
    transform: translateY(-2px);
}

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

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

.status {
    padding: 10px;
    margin-top: 10px;
    border-radius: 4px;
    display: none;
}

.status.info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid var(--primary);
    display: block;
}

.status.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid var(--success);
    display: block;
}

.status.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid var(--error);
    display: block;
}

.status.warning {
    background: #fff3e0;
    color: #e65100;
    border-left: 4px solid #ff9800;
    display: block;
}

.progress-container { margin-top: 15px; }

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #1565c0);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.85em;
}

.progress-text {
    text-align: center;
    color: #757575;
    font-size: 0.85em;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-group { display: flex; gap: 10px; }
.filter-group input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 300px;
}

.scan-results-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.no-scans {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

.scan-result-section {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: white;
}

.scan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.scan-header:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
}

.scan-header.collapsed {
    border-bottom: none;
}

.scan-header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.scan-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--primary);
}

.scan-meta {
    font-size: 0.85em;
    color: #666;
}

.scan-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.scan-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.3em;
    font-weight: 700;
}

.stat-value.open { color: var(--success); }
.stat-value.blocked { color: #999; }
.stat-value.closed { color: #f44336; }

.stat-label {
    font-size: 0.8em;
    color: #666;
}

.collapse-icon {
    font-size: 1.5em;
    color: #666;
    transition: transform 0.3s;
}

.scan-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.scan-content {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    width: 100%;
}

.scan-content.collapsed {
    max-height: 0;
}

.scan-filters {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.scan-filters input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 250px;
    font-size: 0.9em;
}

.port-state-filters {
    display: flex;
    gap: 10px;
}

.port-state-filter {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
}

.port-state-filter input[type="checkbox"] {
    cursor: pointer;
}

.table-container {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    width: 100%;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    table-layout: auto;
}

#resultsTable thead {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#resultsTable th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--primary);
    background: #f8f9fa;
    white-space: nowrap;
}

#resultsTable th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

#resultsTable th.sortable:hover {
    background: #e9ecef;
}

.sort-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8em;
    color: #999;
}

#resultsTable th.sort-asc .sort-indicator {
    color: var(--primary);
}

#resultsTable th.sort-desc .sort-indicator {
    color: var(--primary);
}

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

#resultsTable tbody tr:hover {
    background: #f8f9fa;
}

#resultsTable td {
    padding: 12px 8px;
    vertical-align: top;
}

.ip-cell {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary);
    font-size: 1.05em;
}

.ports-services-cell {
    font-family: 'Courier New', monospace;
}

.port-service-badge {
    display: inline-block;
    padding: 3px 8px;
    margin: 2px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.port-service-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

.port-service-badge.http {
    background: #2196F3;
    color: white;
}

.port-service-badge.https {
    background: #4CAF50;
    color: white;
}

.port-service-badge.other {
    background: #FF9800;
    color: white;
}

.port-service-badge.blocked {
    background: #9E9E9E;
    color: white;
    border: 1px dashed #616161;
    cursor: help;
}

.device-info-cell {
    font-size: 0.9em;
}

.device-info-content {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.info-badge {
    display: inline-block;
    padding: 3px 8px;
    background: #f0f0f0;
    color: #555;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
}

.time-cell {
    color: #757575;
    font-size: 0.9em;
    white-space: nowrap;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

.update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.update-notification button {
    background: white;
    color: #4caf50;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.update-notification button:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

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

@media (max-width: 768px) {
    header h1 { font-size: 1.5em; }
    .results-header { flex-direction: column; align-items: stretch; }
    .filter-group { flex-direction: column; }
    .filter-group input { width: 100%; }
    
    .table-container {
        overflow-x: auto;
    }
    
    #resultsTable {
        font-size: 0.8em;
    }
    
    #resultsTable th,
    #resultsTable td {
        padding: 8px 4px;
    }
}

/* Bootstrap Grid System */
.container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.justify-content-center {
    justify-content: center !important;
}

.col-lg-10,
.col-lg-8,
.col-md-6,
.col-md-8 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
}

@media (min-width: 992px) {
    .col-lg-10 {
        flex: 0 0 83.333333%;
        max-width: 83.333333%;
    }
    
    .col-lg-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
}

/* Footer Styles */
footer {
    background-color: #f8f9fa;
    border-top: 1px solid rgba(0, 0, 0, 0.125);
}

footer a {
    transition: all 0.3s ease;
}

footer a:hover {
    text-decoration: underline !important;
    transform: translateY(-1px);
}

footer .text-primary:hover {
    color: #0a58ca !important;
}

footer .bi {
    transition: transform 0.3s ease;
}

footer a:hover .bi {
    transform: scale(1.1);
}

/* Bootstrap utility classes */
.bg-light {
    background-color: #f8f9fa !important;
}

.border-top {
    border-top: 1px solid #dee2e6 !important;
}

.py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.mt-auto {
    margin-top: auto !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-md-0 {
    margin-top: 0 !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.align-items-center {
    align-items: center !important;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding-right: 15px;
    padding-left: 15px;
}

.d-flex {
    display: flex !important;
}

.text-md-end {
    text-align: right !important;
}

.text-primary {
    color: #0d6efd !important;
    text-decoration: none;
}

.me-2 {
    margin-right: 0.5rem !important;
}

/* Responsive footer adjustments */
@media (max-width: 768px) {
    footer .col-md-6 {
        text-align: center !important;
        flex: 0 0 100%;
        max-width: 100%;
    }

    footer .text-md-end {
        text-align: center !important;
        margin-top: 0.5rem !important;
    }
}
