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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #333;
}

/* ---------- Header ---------- */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.header-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.header h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}
.btn-primary { background: white; color: #667eea; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn-secondary { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); }
.btn-secondary:hover { background: rgba(255,255,255,0.3); }
.btn-success { background: #10b981; color: white; }
.btn-danger { background: #ef4444; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Layout ---------- */
.container { margin: 30px auto; padding: 0 20px; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card { background: white; padding: 24px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.stat-card h3 { font-size: 13px; color: #666; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 30px; font-weight: 700; color: #667eea; }

.card { background: white; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); margin-bottom: 20px; overflow: hidden; }
.card-header { padding: 18px 22px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-header h2 { font-size: 16px; }
.card-body { padding: 22px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid #e5e7eb; }
.tab { padding: 10px 18px; cursor: pointer; font-size: 14px; font-weight: 500; color: #666; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: #667eea; border-bottom-color: #667eea; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 20px; text-align: left; border-bottom: 1px solid #f0f2f5; font-size: 13.5px; }
.table th { background: #fafbfc; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: #888; }
.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-muted { background: #eee; color: #666; }

/* ---------- Alerts ---------- */
.alert { padding: 14px 18px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ---------- Empty state ---------- */
.empty-state { padding: 60px 20px; text-align: center; color: #999; }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { color: #666; margin-bottom: 6px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 7px; color: #444; font-weight: 500; font-size: 13.5px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 2px solid #e1e8ed; border-radius: 6px; font-size: 13.5px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #667eea; }
.form-group small { display: block; margin-top: 6px; color: #888; font-size: 11.5px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; }

/* ---------- Modal ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: white; border-radius: 12px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; }
.modal-content.wide { max-width: 780px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 17px; }
.modal-header .close { cursor: pointer; font-size: 22px; color: #999; line-height: 1; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Log entries ---------- */
.log-entry { padding: 10px 14px; margin-bottom: 6px; border-left: 3px solid #d1d5db; background: #fafbfc; border-radius: 4px; font-family: 'Monaco', 'Courier New', monospace; font-size: 12.5px; }
.log-entry.info { border-left-color: #3b82f6; }
.log-entry.warning { border-left-color: #f59e0b; }
.log-entry.error { border-left-color: #ef4444; }
.log-time { color: #9ca3af; font-size: 11px; }

/* ---------- Backend / VM badges on service rows ---------- */
.backend-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 12px; }
.backend-pill.local { background: #eef1ff; color: #4338ca; }
.backend-pill.remote { background: #ecfdf5; color: #065f46; }
.backend-pill.remote.offline { background: #fef2f2; color: #991b1b; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.online { background: #10b981; }
.dot.offline { background: #ef4444; }
.dot.unknown { background: #9ca3af; }

/* ---------- Nginx / file browser shared layout ---------- */
.split-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.file-list { max-height: 65vh; overflow-y: auto; }
.file-item { padding: 12px 20px; border-bottom: 1px solid #f0f2f5; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: background 0.15s; }
.file-item:hover { background: #f8f9fb; }
.file-item.active { background: #eef1ff; border-left: 3px solid #667eea; }
.file-name { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.file-meta { font-size: 11px; color: #888; display: flex; gap: 6px; flex-wrap: wrap; }
.new-file-row { padding: 12px 20px; border-top: 1px solid #e5e7eb; display: flex; gap: 8px; }
.new-file-row input { flex: 1; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 12.5px; }

.editor-toolbar { padding: 12px 20px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-toolbar .path { font-family: monospace; font-size: 13px; color: #555; word-break: break-all; }
.editor-actions { display: flex; gap: 8px; }
.editor-actions .btn-save { background: #667eea; color: white; }
.editor-actions .btn-test { background: #10b981; color: white; }
.editor-actions .btn-reload { background: #f59e0b; color: white; }

textarea#editor {
    width: 100%; min-height: 62vh; border: none; outline: none; resize: vertical;
    padding: 20px; font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 13.5px; line-height: 1.6; tab-size: 4; color: #1f2937;
}

.status-bar { padding: 10px 20px; font-size: 12.5px; border-top: 1px solid #e5e7eb; display: none; }
.status-bar.show { display: block; }
.status-ok { background: #ecfdf5; color: #065f46; }
.status-err { background: #fef2f2; color: #991b1b; }
.status-info { background: #eff6ff; color: #1e40af; }

/* ---------- Browse modal (folder picker) ---------- */
.browse-toolbar { padding: 10px 22px; border-bottom: 1px solid #eee; display: flex; align-items: center; gap: 10px; }
.browse-toolbar .current-path { font-family: monospace; font-size: 12.5px; color: #555; flex: 1; word-break: break-all; }
.browse-list { max-height: 40vh; overflow-y: auto; padding: 6px 0; }
.browse-row { padding: 9px 22px; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.browse-row:hover { background: #f8f9fb; }
.browse-row .icon { width: 16px; text-align: center; opacity: 0.7; }

/* ---------- Login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-box { background: white; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); padding: 40px; width: 100%; max-width: 400px; }
.login-box h1 { color: #333; margin-bottom: 10px; font-size: 26px; }
.login-box .subtitle { color: #666; margin-bottom: 26px; font-size: 14px; }
.login-box button[type="submit"] {
    width: 100%; padding: 12px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer;
}
