* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-link:hover {
    background-color: #34495e;
}

.nav-link.active {
    background-color: #3498db;
}

.nav-link.logout-link {
    background-color: #e74c3c;
}

.nav-link.logout-link:hover {
    background-color: #c0392b;
}

.nav-language select {
    padding: 0.5rem;
    border: none;
    border-radius: 4px;
    background-color: #34495e;
    color: white;
    cursor: pointer;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Panel */
.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.panel-body {
    padding: 1.5rem;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #3498db;
}

/* Table */
.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table thead,
.data-table thead {
    background-color: #f8f9fa;
}

.table th,
.table td,
.data-table th,
.data-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.table td.actions {
    padding: 0.5rem !important;
    vertical-align: middle !important;
}

/* Fix actions column alignment */
.table th:last-child,
.table td:last-child {
    text-align: left;
    vertical-align: middle;
}

.table tbody tr:hover,
.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.table .actions {
    /* Flexbox removed to prevent cell height issues */
}

.table .actions form {
    margin: 0;
    display: inline-block;
}

.table .actions .btn {
    margin: 0 0.25rem 0 0;
}

.text-center {
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #6c757d;
    color: white;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #5a6268;
}

.btn-primary {
    background-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: #f39c12;
}

.btn-warning:hover {
    background-color: #e67e22;
}

.btn-info {
    background-color: #3498db;
}

.btn-info:hover {
    background-color: #2980b9;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background-color: #6c757d;
    color: white;
    white-space: nowrap;
}

/* Status, Inet, Ping columns - ultra compact spacing */
.table td:nth-child(2),
.table th:nth-child(2),
.table td:nth-child(3),
.table th:nth-child(3),
.table td:nth-child(4),
.table th:nth-child(4) {
    padding: 0.5rem 0.15rem !important;
    text-align: center;
}

/* Status column fixed width */
.table td:nth-child(2),
.table th:nth-child(2) {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-box {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.stat-detail {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 0.5rem;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-online {
    background-color: #d4edda;
    color: #155724;
}

.status-offline {
    background-color: #f8d7da;
    color: #721c24;
}

.status-error {
    background-color: #f8d7da;
    color: #721c24;
}

.status-running {
    background-color: #d4edda;
    color: #155724;
}

.status-stopped {
    background-color: #fff3cd;
    color: #856404;
}

/* Service List */
.service-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.service-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.service-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.service-hostname {
    font-size: 0.875rem;
    color: #6c757d;
}

.service-status {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.service-actions {
    display: flex;
    gap: 0.5rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
}

/* Form small text */
.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Drag & Drop Area */
#keyDropArea.drag-over {
    border-color: #3498db !important;
    background: #e3f2fd !important;
    transform: scale(1.02);
}

#keyDropArea:hover {
    border-color: #95a5a6;
    background: #f0f0f0;
}

.badge-success {
    background-color: #27ae60;
}

.badge-secondary {
    background-color: #95a5a6;
}

.badge-gray {
    background-color: #bdc3c7;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-running {
    background-color: #27ae60;
}

.status-stopped {
    background-color: #e74c3c;
}

.status-text {
    font-size: 1.125rem;
    font-weight: 500;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Login page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.login-box h1 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: #2c3e50;
}

.language-switcher {
    margin-top: 1rem;
    text-align: center;
}

.language-switcher select {
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

/* Modal */
/* Sync Modal Styles */
.sync-file-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sync-file-synced {
    background-color: #d4edda;
    border-left: 4px solid #28a745;
}

.sync-file-outdated {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

.sync-file-missing {
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
}

.sync-file-syncing {
    background-color: #d1ecf1;
    border-left: 4px solid #17a2b8;
}

.sync-file-error {
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
}

.sync-file-icon {
    margin-right: 0.5rem;
    font-weight: bold;
    width: 20px;
    text-align: center;
}

.sync-file-name {
    flex: 1;
    font-weight: 500;
}

.sync-file-path {
    flex: 2;
    color: #6c757d;
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.sync-file-progress {
    margin-left: 0.5rem;
    color: #3498db;
    font-weight: bold;
}

/* Sync Button Animation */
.btn.sync-needed {
    animation: syncPulse 2s infinite;
    position: relative;
}

@keyframes syncPulse {
    0%, 100% {
        background-color: #27ae60;
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    50% {
        background-color: #f39c12;
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
}

.modal-body {
    padding: 2rem;
}

.modal-large {
    max-width: 700px;
    padding: 2rem;
}

.modal-content hr {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid #dee2e6;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-content h3 {
    margin: 1rem 0 1rem 0;
    font-size: 1.1rem;
    color: #495057;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

/* Logs */
.logs-container {
    max-height: 600px;
    overflow-y: auto;
}

.log-event {
    font-family: monospace;
    font-size: 0.875rem;
    word-break: break-all;
}

/* Error pages */
.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.error-container {
    padding: 2rem;
}

.error-container h1 {
    font-size: 6rem;
    color: #3498db;
    margin-bottom: 1rem;
}

.error-container p {
    font-size: 1.25rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.error-container pre {
    text-align: left;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

/* Traffic cell */
.traffic-cell {
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 0.5rem !important;
}

.traffic-cell small {
    display: block;
    line-height: 1.2;
    color: #6c757d;
}

.traffic-cell .traffic-down,
.traffic-cell .traffic-up {
    white-space: nowrap;
    display: block;
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

.traffic-cell .traffic-down {
    color: #27ae60;
    margin-bottom: 2px;
}

.traffic-cell .traffic-up {
    color: #e67e22;
}

/* Info and warning text */
.info-text {
    padding: 0.75rem 1rem;
    background-color: #e7f3ff;
    border-left: 3px solid #4dabf7;
    margin: 1rem 0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.info-text code {
    background-color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #495057;
    border: 1px solid #dee2e6;
}

.warning-text {
    padding: 0.75rem 1rem;
    background-color: #fff4e6;
    border-left: 3px solid #fd7e14;
    margin: 1rem 0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.warning-text code {
    background-color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #495057;
    border: 1px solid #dee2e6;
}

/* Internet Access Globe Icons */
.internet-status {
    text-align: center;
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    padding: 0.5rem 0.25rem !important;
}

.globe-icon {
    font-size: 1.5rem;
    display: inline-block;
    cursor: help;
    transition: transform 0.2s;
}

.globe-icon:hover {
    transform: scale(1.2);
}

/* Включен (синий, без заливки) */
.globe-enabled {
    color: #3498db;
}

/* Выключен у клиента (серый, opacity 0.25, перечеркнутый) */
.globe-disabled {
    color: #95a5a6;
    opacity: 0.25;
    position: relative;
}

.globe-disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 2px;
    background-color: #e74c3c;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Глобально выключен, но у клиента был включен (полная яркость, перечеркнутый) */
.globe-disabled-global {
    color: #3498db;
    opacity: 1;
    position: relative;
}

.globe-disabled-global::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 2px;
    background-color: #e74c3c;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Глобально выключен и у клиента тоже выключен (серый, opacity 0.25) */
.globe-disabled-both {
    color: #95a5a6;
    opacity: 0.25;
}

/* Custom Internet Settings Toggle */
#custom_internet_settings,
#custom_internet_fields {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

#custom_internet_fields {
    border-left-color: #f39c12;
}

/* Form group small text */
.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Settings panel headings */
.panel-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

/* Auto-refresh toggle */
.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.auto-refresh-toggle input[type="checkbox"] {
    cursor: pointer;
}

.auto-refresh-toggle span {
    font-size: 0.875rem;
}

/* Date cell formatting */
.date-cell {
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: nowrap;
}

.date-line {
    font-weight: 500;
    margin-bottom: 2px;
}

.time-line {
    color: #6c757d;
    font-size: 0.75rem;
}

/* Ping cell */
.ping-cell {
    text-align: center;
    font-weight: 500;
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    padding: 0.5rem 0.25rem !important;
}

.ping-value {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 50px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.ping-checking {
    color: #6c757d;
}

.ping-good {
    color: #27ae60;
    background-color: #d4edda;
}

.ping-ok {
    color: #f39c12;
    background-color: #fff4e6;
}

.ping-bad {
    color: #e74c3c;
    background-color: #f8d7da;
}

.ping-offline,
.ping-error {
    color: #95a5a6;
}

/* Panel header with multiple items */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #27ae60;
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #27ae60;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
    background-color: #e74c3c;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Expiry Date Cell */
.expiry-date-cell:hover {
    background-color: #f0f0f0;
}

/* Sort icon */
.sort-icon {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.875rem;
    color: #6c757d;
    transition: color 0.2s;
}

th:hover .sort-icon {
    color: #3498db;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table .actions {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

