:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-input: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --accent: #00ff88;
    --online: #3fb950;
    --warning: #d29922;
    --offline: #f85149;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-dark); color: var(--text); min-height: 100vh; }

/* Login */
.screen { min-height: 100vh; }
#login-screen { display: flex; justify-content: center; align-items: center; }
.login-box { background: var(--bg-card); padding: 40px; border-radius: 12px; border: 1px solid var(--border); width: 100%; max-width: 400px; }
.login-box h1 { text-align: center; margin-bottom: 30px; color: var(--accent); }
.login-box input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); }
.login-box button { width: 100%; padding: 12px; background: var(--accent); color: var(--bg-dark); border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.login-box button:hover { opacity: 0.9; }
.error { color: var(--offline); text-align: center; margin-top: 10px; }
.hidden { display: none !important; }

/* Header */
header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 15px; }
.header-left h1 { color: var(--accent); font-size: 1.5rem; }
.main-nav { display: flex; gap: 5px; }
.nav-item { padding: 8px 16px; color: var(--text-dim); text-decoration: none; border-radius: 6px; transition: all 0.2s; }
.nav-item:hover { background: var(--bg-input); color: var(--text); }
.nav-item.active { background: var(--accent); color: var(--bg-dark); }
.header-right { display: flex; align-items: center; gap: 15px; }
#user-info { color: var(--text-dim); }
#logout-btn { color: var(--offline); text-decoration: none; }

/* Main Content */
main { padding: 30px; max-width: none; width: 100%; margin: 0; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.tab-header h2 { color: var(--text); }

/* Stats */
.stats { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.stat-card { background: var(--bg-card); padding: 20px 30px; border-radius: 10px; border: 1px solid var(--border); text-align: center; min-width: 120px; }
.stat-card.online { border-color: var(--online); }
.stat-card.warning { border-color: var(--warning); }
.stat-card.offline { border-color: var(--offline); }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { color: var(--text-dim); font-size: 0.85rem; }

/* Server Grid - CLEANER */
#server-grid { display: block !important; width: 100% !important; }
.data-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

.data-card { 
    background: var(--bg-card); 
    border-radius: 12px; 
    border: 1px solid var(--border); 
    overflow: hidden;
    transition: border-color 0.2s;
}
.data-card:hover { border-color: var(--accent); }

.card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 16px 20px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
}
.card-title { font-weight: 600; font-size: 1.1rem; }
.card-status { 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-size: 0.75rem; 
    font-weight: 600;
    text-transform: uppercase;
}
.status-online { background: var(--online); color: #fff; }
.status-warning { background: var(--warning); color: #000; }
.status-offline { background: var(--offline); color: #fff; }
.status-unknown { background: var(--text-dim); color: #000; }

/* Card Body - ZWEI SPALTEN */
.card-body {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.card-row.full {
    grid-column: 1 / -1;
}

.card-row .icon {
    width: 18px;
    text-align: center;
}

.card-row .value {
    color: var(--text);
}

/* Update Status */
.update-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
}
.update-ok { background: rgba(63, 185, 80, 0.2); color: var(--online); }
.update-warn { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.update-crit { background: rgba(248, 81, 73, 0.2); color: var(--offline); }

/* Tags */
.card-tags { 
    padding: 12px 20px; 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px;
    border-top: 1px solid var(--border);
}
.tag { 
    background: var(--bg-input); 
    padding: 4px 10px; 
    border-radius: 4px; 
    font-size: 0.8rem; 
    color: var(--text-dim);
}

/* Card Actions */
.card-actions { 
    display: flex; 
    gap: 10px; 
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-input);
}
.card-actions button { 
    flex: 1; 
    padding: 8px; 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    background: transparent; 
    color: var(--text); 
    cursor: pointer;
    font-size: 0.85rem;
}
.card-actions button:hover { border-color: var(--accent); color: var(--accent); }
.card-actions .btn-delete:hover { border-color: var(--offline); color: var(--offline); }

/* Buttons */
.btn-primary { background: var(--accent); color: var(--bg-dark); border: none; padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { opacity: 0.9; }
.btn-cancel { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 10px 20px; border-radius: 6px; cursor: pointer; }

/* Modals */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.modal-content { background: var(--bg-card); padding: 30px; border-radius: 12px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-bottom: 20px; color: var(--accent); }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; color: var(--text-dim); font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Logs */
.log-filters { display: flex; gap: 15px; margin-bottom: 20px; }
.log-filters input { padding: 10px 15px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); flex: 1; max-width: 250px; }
.log-table-wrapper { overflow-x: auto; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border); }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.log-table th, .log-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border); }
.log-table th { background: var(--bg-input); color: var(--accent); font-weight: 600; }
.log-table tr:hover { background: rgba(0,255,136,0.05); }
.log-table .status-ok { color: var(--online); }
.log-table .status-error { color: var(--offline); }
.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
.pagination button { padding: 8px 15px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
.pagination button:hover:not(:disabled) { border-color: var(--accent); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Command Buttons */
.card-actions button {
    min-width: 40px;
    font-size: 1rem;
}

.card-actions button:nth-child(3):hover {
    border-color: #ff9800;
    color: #ff9800;
}
/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.05), rgba(0, 136, 255, 0.05));
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.filter-input, .filter-select {
    flex: 1;
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s;
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.filter-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.btn-filter-reset {
    padding: 12px 25px;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-filter-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 68, 68, 0.4);
}

/* Server Liste (Linien-Design) */
.server-list {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

.server-line {
    padding: 18px 25px;
    transition: all 0.3s;
}

.server-line:hover {
    background: rgba(0, 255, 136, 0.05);
}

.server-line-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.server-line-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.server-hostname {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
    font-family: 'Courier New', monospace;
    min-width: 200px;
}

.server-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.server-update {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
}

.server-line-right {
    display: flex;
    gap: 20px;
    align-items: center;
    color: var(--text-dim);
    font-size: 14px;
}

.server-info {
    display: inline-block;
    min-width: 140px;
}

.server-line-tags {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.tag-small {
    padding: 4px 10px;
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 4px;
    font-size: 11px;
    color: var(--accent);
}

.server-line-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.server-line-actions button {
    padding: 8px 14px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.server-line-actions button:hover {
    background: rgba(0, 255, 136, 0.2);
    transform: translateY(-2px);
}

.server-line-actions .btn-delete {
    background: rgba(255, 68, 68, 0.1);
    border-color: rgba(255, 68, 68, 0.3);
}

.server-line-actions .btn-delete:hover {
    background: rgba(255, 68, 68, 0.2);
}

/* Trennlinie */
.server-divider {
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        rgba(0, 255, 136, 0.3) 20%,
        rgba(0, 255, 136, 0.3) 80%,
        transparent
    );
    margin: 0 25px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 18px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(0, 255, 136, 0.3);
    border-radius: 12px;
}

/* Responsive */
@media (max-width: 1200px) {
    .server-line-right {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
    }
    
    .server-line-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .server-line-right {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .server-hostname {
        min-width: auto;
    }
}

/* Server-Liste über volle Breite */
.server-list {
    width: 100%;
    max-width: none !important;
}

.server-line {
    width: 100%;
}

.server-line-main {
    width: 100%;
}

.server-line-left {
    min-width: 0;
}

.server-line-right {
    flex: 1;
    justify-content: flex-end;
}

/* Data Grid auf volle Breite */
#server-grid {
    width: 100%;
    max-width: none !important;
}

.data-grid {
    width: 100%;
    max-width: none !important;
}

.tab-content {
    max-width: none !important;
    width: 100%;
}

/* Dashboard Content */
#dashboard {
    width: 100%;
    max-width: none !important;
}

.dashboard-content {
    max-width: none !important;
    width: 100%;
    padding: 20px;
}

/* === FORCE FULL WIDTH === */
main, .dashboard-content, .tab-content, #tab-servers, #server-grid, .server-list, .data-grid {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.server-line {
    width: 100% !important;
    display: block !important;
}

.server-line-main {
    display: flex !important;
    width: 100% !important;
    justify-content: space-between !important;
}

.filter-bar {
    width: 100% !important;
    max-width: 100% !important;
}

/* FIX: Disable grid when using server-list */
#server-grid:has(.server-list) {
    display: block !important;
    grid-template-columns: none !important;
}

#server-grid .server-list {
    display: block !important;
    width: 100% !important;
}

/* Disk & Memory Status Colors */
.disk-ok, .mem-ok { color: var(--online); }
.disk-warning, .mem-warning { color: var(--warning); }
.disk-critical, .mem-critical { color: var(--offline); font-weight: bold; }

/* Resource Bars (Disk + Memory) */
.server-line-resources {
    display: flex;
    gap: 30px;
    padding: 10px 0;
    margin-top: 8px;
}

.resource-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 300px;
}

.resource-label {
    font-size: 13px;
    min-width: 60px;
}

.resource-track {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.resource-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.resource-fill.disk-ok, .resource-fill.mem-ok {
    background: linear-gradient(90deg, var(--online), #2ecc71);
}

.resource-fill.disk-warning, .resource-fill.mem-warning {
    background: linear-gradient(90deg, var(--warning), #f39c12);
}

.resource-fill.disk-critical, .resource-fill.mem-critical {
    background: linear-gradient(90deg, var(--offline), #c0392b);
}

.resource-text {
    font-size: 12px;
    min-width: 120px;
    text-align: right;
}

/* === CLEAN SERVER LAYOUT === */
.server-line {
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.server-row-1, .server-row-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.server-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.server-row-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.server-hostname {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
    font-family: "Courier New", monospace;
}

.server-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.server-update {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.server-version {
    color: var(--text-dim);
    font-size: 13px;
}

.server-meta {
    color: var(--text-dim);
    font-size: 14px;
    min-width: 100px;
}

/* Row 2 */
.server-row-2 .server-row-left {
    gap: 8px;
}

.no-tags {
    color: var(--text-dim);
    font-size: 12px;
}

/* Resources */
.server-resources {
    gap: 25px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}

.resource-icon {
    font-size: 14px;
}

.resource-bar-track {
    width: 80px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.resource-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.resource-bar-fill.res-ok { background: var(--online); }
.resource-bar-fill.res-warning { background: var(--warning); }
.resource-bar-fill.res-critical { background: var(--offline); }

.resource-value {
    font-size: 12px;
    min-width: 90px;
}

.resource-value.res-ok { color: var(--online); }
.resource-value.res-warning { color: var(--warning); }
.resource-value.res-critical { color: var(--offline); }

/* Row 3 - Actions */
.server-row-3 {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
}

.server-row-3 button {
    padding: 8px 14px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.server-row-3 button:hover {
    background: rgba(0, 255, 136, 0.2);
    transform: translateY(-2px);
}

.server-row-3 .btn-delete {
    background: rgba(255, 68, 68, 0.1);
    border-color: rgba(255, 68, 68, 0.3);
}

.server-row-3 .btn-delete:hover {
    background: rgba(255, 68, 68, 0.2);
}

/* FIX: Kompakteres Layout */
.server-row-1, .server-row-2 {
    justify-content: flex-start !important;
    gap: 40px !important;
}

.server-row-right {
    margin-left: auto;
    max-width: 500px;
}

.server-row-2 .server-row-left {
    min-width: 200px;
}

.server-row-2 .server-row-right {
    margin-left: 0;
}

.server-resources {
    justify-content: flex-start !important;
}

.server-row-3 {
    margin-top: 10px;
}

/* OVERRIDE: Alles kompakt links */
.server-row-1 {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    gap: 30px !important;
}

.server-row-2 {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    gap: 30px !important;
}

.server-row-1 .server-row-left,
.server-row-2 .server-row-left {
    justify-self: start;
}

.server-row-1 .server-row-right,
.server-row-2 .server-row-right {
    justify-self: start;
    margin-left: 0 !important;
}

/* FIX: Zweite Zeile - mehr Abstand, RAM/Disk in die Mitte */
.server-row-2 {
    justify-content: flex-start !important;
}

.server-row-2 .server-row-left {
    min-width: 180px;
}

.server-row-2 .server-row-right {
    margin-left: 80px !important;
}

.server-resources {
    gap: 40px !important;
}

.resource-item {
    min-width: 200px !important;
}

/* FIX: RAM unter Agent-Version ausrichten */
.server-row-2 .server-row-right {
    margin-left: 120px !important;
    position: relative;
    left: 50px;
}

/* FIX: Mehr Abstand zwischen Zeile 1 und 2 */
.server-row-2 {
    margin-top: 15px !important;
}
